From b97bfcb85b2ded3b1f380e9a98b54b836faabba5 Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期五, 28 三月 2025 14:26:35 +0800 Subject: [PATCH] 除过数字教材外的页面的登录迁移 --- pages/home/home.js | 27 packageBookService/pages/bookServices/detail/components/learnResource/learnResource.wxml | 33 pages/digitalCourses/digitalCoursesDetails/index.js | 310 +++--- packageBookService/pages/bookServices/detail/index.wxml | 413 ++++++++- pages/bookExhibitionDetails/index.js | 19 pages/digitalCourses/index.js | 101 +- packageBookService/pages/bookServices/detail/components/learnResource/learnResource.js | 42 packageBookService/pages/bookServices/detail/components/note/note.js | 4 packageBookService/pages/bookServices/detail/components/testResource/testResource.js | 30 packageBookService/pages/bookServices/detail/components/tree/index.js | 183 ++-- packageBookService/pages/bookServices/detail/index.js | 943 +++++++++++---------- pages/home/home.wxml | 326 ++++++- pages/retrievalPage/index.js | 51 packageBookService/pages/bookServices/detail/components/testResource/testResource.wxml | 32 14 files changed, 1,557 insertions(+), 957 deletions(-) diff --git a/packageBookService/pages/bookServices/detail/components/learnResource/learnResource.js b/packageBookService/pages/bookServices/detail/components/learnResource/learnResource.js index 8c64c1b..5ee8695 100644 --- a/packageBookService/pages/bookServices/detail/components/learnResource/learnResource.js +++ b/packageBookService/pages/bookServices/detail/components/learnResource/learnResource.js @@ -1,4 +1,7 @@ // pages/bookServices/detail/components/learnResource/learnResource.js +import { + loginInfo +} from "../../../../../../assets/js/login"; Component({ /** * 缁勪欢鐨勫睘鎬у垪琛� @@ -54,15 +57,24 @@ }, // 璺宠浆璧勬簮璐拱椤� goBuyResource() { - if (!this.properties.isGoBuyResource) { - return wx.showToast({ - icon: 'error', - title: '鏆傛棤鍙喘涔拌祫婧�', + const token = wx.getStorageSync(app.config.tokenKey); + if (token) { + gotoPageFun() + } else { + loginInfo(app, (data) => { }) } - wx.navigateTo({ - url: `/packageBookService/pages/bookServices/detail/buyResource/index?productLinkPath=${this.properties.buyResourceData.productLinkPath}&refCode=${this.properties.buyResourceData.refCode}&bookId=${this.properties.bookId}`, - }) + const gotoPageFun = () => { + if (!this.properties.isGoBuyResource) { + return wx.showToast({ + icon: 'error', + title: '鏆傛棤鍙喘涔拌祫婧�', + }) + } + wx.navigateTo({ + url: `/packageBookService/pages/bookServices/detail/buyResource/index?productLinkPath=${this.properties.buyResourceData.productLinkPath}&refCode=${this.properties.buyResourceData.refCode}&bookId=${this.properties.bookId}`, + }) + } }, changeReceive(type) { @@ -76,9 +88,19 @@ }) }, goLearnTask() { - wx.navigateTo({ - url: `/packageBookService/pages/bookServices/detail/components/learnTask/index?bookId=${this.properties.bookId}&cmsPath=${this.properties.learnTaskData?.productLinkPath}`, - }) + const token = wx.getStorageSync(app.config.tokenKey); + if (token) { + gotoPageFun() + } else { + loginInfo(app, (data) => { + if (data) gotoPageFun() + }) + } + const gotoPageFun = () => { + wx.navigateTo({ + url: `/packageBookService/pages/bookServices/detail/components/learnTask/index?bookId=${this.properties.bookId}&cmsPath=${this.properties.learnTaskData?.productLinkPath}`, + }) + } }, buyCloudLearnClass() { var myEventDetail = {} // detail瀵硅薄锛屾彁渚涚粰浜嬩欢鐩戝惉鍑芥暟 diff --git a/packageBookService/pages/bookServices/detail/components/learnResource/learnResource.wxml b/packageBookService/pages/bookServices/detail/components/learnResource/learnResource.wxml index 9337036..bcff036 100644 --- a/packageBookService/pages/bookServices/detail/components/learnResource/learnResource.wxml +++ b/packageBookService/pages/bookServices/detail/components/learnResource/learnResource.wxml @@ -1,5 +1,9 @@ <!--pages/bookServices/detail/components/learnResource/learnResource.wxml--> -<view class="learnResource" theme="primary" style="justify-content: {{!isshowDrawBtn ? 'flex-end' : ''}};"> +<view + class="learnResource" + theme="primary" + style="justify-content: {{!isshowDrawBtn ? 'flex-end' : ''}};" +> <!-- <t-button wx:if="{{isshowDrawBtn}}" loading="{{receive}}" @@ -14,22 +18,41 @@ <text>棰嗗彇鏌ョ湅</text> </view> </t-button> --> - <t-button wx:if="{{isShowBuyCloundBtn}}" loading="{{buy}}" class="btn" theme="primary" bind:tap="goBuyResource" style="height: 72rpx; font-size: 28rpx;margin: {{!isshowDrawBtn ? '0 20rpx' : ''}}"> + <t-button + wx:if="{{isShowBuyCloundBtn}}" + loading="{{buy}}" + class="btn" + theme="primary" + bind:tap="goBuyResource" + style="height: 72rpx; font-size: 28rpx;margin: {{!isshowDrawBtn ? '0 20rpx' : ''}}" + > <view slot="content" class="btn-content"> <image src="/static/images/bookService/detail/yijiangoumai.png" /> <text>璧勬簮璐拱</text> </view> </t-button> - <t-button theme="primary" class="btn" style="height: 72rpx; font-size: 28rpx" bind:tap="buyCloudLearnClass" wx:if="{{isShowBuyCloundMenu}}"> + <t-button + theme="primary" + class="btn" + style="height: 72rpx; font-size: 28rpx" + bind:tap="buyCloudLearnClass" + wx:if="{{isShowBuyCloundMenu}}" + > <view slot="content" class="btn-content"> <image src="/static/images/bookService/detail/yijiangoumai.png" /> <text>鍏ㄩ儴璐拱</text> </view> </t-button> - <t-button class="btn" theme="primary" style="height: 72rpx; font-size: 28rpx; margin: 0 20rpx" bind:tap="goLearnTask" wx:if="{{learnTaskData.name}}"> + <t-button + class="btn" + theme="primary" + style="height: 72rpx; font-size: 28rpx; margin: 0 20rpx" + bind:tap="goLearnTask" + wx:if="{{learnTaskData.name}}" + > <view slot="content" class="btn-content"> <image src="/static/images/bookService/detail/renwudan锛廼con.png" /> <text>瀛︿範浠诲姟鍗�</text> </view> </t-button> -</view> \ No newline at end of file +</view> diff --git a/packageBookService/pages/bookServices/detail/components/note/note.js b/packageBookService/pages/bookServices/detail/components/note/note.js index f09f7d7..8a94230 100644 --- a/packageBookService/pages/bookServices/detail/components/note/note.js +++ b/packageBookService/pages/bookServices/detail/components/note/note.js @@ -1,5 +1,8 @@ // pages/bookServices/detail/components/note/note.js const app = getApp(); +import { + loginInfo +} from "../../../../../../assets/js/login"; Component({ /** * 缁勪欢鐨勫睘鎬у垪琛� @@ -64,6 +67,7 @@ }); }, openDialog() { + loginInfo(app, (data) => {}) this.setData({ submitTitle: this.properties.bookInfo.name, showNoteDialog: true, diff --git a/packageBookService/pages/bookServices/detail/components/testResource/testResource.js b/packageBookService/pages/bookServices/detail/components/testResource/testResource.js index 3d4be10..f4170f5 100644 --- a/packageBookService/pages/bookServices/detail/components/testResource/testResource.js +++ b/packageBookService/pages/bookServices/detail/components/testResource/testResource.js @@ -1,4 +1,7 @@ // pages/bookServices/detail/components/testResource/testResource.js +import { + loginInfo +} from "../../../../../../assets/js/login"; const app = getApp(); Component({ /** @@ -147,21 +150,22 @@ goMycollect(e) { const answertype = e.currentTarget.dataset.answertype; const token = wx.getStorageSync("jsek-token"); - if (!token) { - return wx.getUserProfile({ - desc: "鐢ㄦ埛鐧诲綍", - success: (res) => { - console.log(res); - }, + if (token) { + gotoPage() + } else { + loginInfo(app, (data) => { + if (data) gotoPage() + }) + } + const gotoPage = () => { + wx.navigateTo({ + url: `/packageBookService/pages/bookServices/examination/examination?bookId=${ + this.properties.bookInfo.id + }&rootCmsItemId=${this.properties.bookInfo.rootCmsItemId}&answerTitle=${ + answertype == "collectQuestion" ? "鎴戠殑鏀惰棌" : "鎴戠殑閿欓" + }&answerType=${answertype}`, }); } - wx.navigateTo({ - url: `/packageBookService/pages/bookServices/examination/examination?bookId=${ - this.properties.bookInfo.id - }&rootCmsItemId=${this.properties.bookInfo.rootCmsItemId}&answerTitle=${ - answertype == "collectQuestion" ? "鎴戠殑鏀惰棌" : "鎴戠殑閿欓" - }&answerType=${answertype}`, - }); }, // 缁冧範 缁勪欢鍒囨崲 onRadioChange(e) { diff --git a/packageBookService/pages/bookServices/detail/components/testResource/testResource.wxml b/packageBookService/pages/bookServices/detail/components/testResource/testResource.wxml index 8ead846..e5a19ee 100644 --- a/packageBookService/pages/bookServices/detail/components/testResource/testResource.wxml +++ b/packageBookService/pages/bookServices/detail/components/testResource/testResource.wxml @@ -27,38 +27,6 @@ <view class="btn-content-text">缁勫嵎</view> </view> </view> - <!-- <t-radio-group - class="test-radio" - t-class="horizontal-box" - value="{{radioItem}}" - bind:change="onRadioChange" - style="margin: 0" - > - <view class="card {{radioItem == 'test' ? 'card--active' : ''}}"> - <t-radio value="test" icon="none" borderless style="height: 80rpx"> - <view class="radio-content" slot="content"> - <image - src="{{ radioItem == 'test' ? '/static/images/bookService/detail/practice-icon.png' : '/static/images/bookService/detail/notest.png'}}" - ></image> - <text style="color: {{radioItem == 'test' ? '#fff':'#ff6c00'}};" - >缁冧範</text - > - </view> - </t-radio> - </view> - <view class="card {{radioItem == 'mock' ? 'card--active' : ''}}"> - <t-radio value="mock" icon="none" borderless style="height: 80rpx"> - <view class="radio-content" slot="content"> - <image - src="{{ radioItem == 'mock' ? '/static/images/bookService/detail/checkpaper.png' : '/static/images/bookService/detail/zujuan.png'}}" - ></image> - <text style="color: {{radioItem == 'mock' ? '#fff':'#ff6c00'}};" - >缁勫嵎</text - > - </view> - </t-radio> - </view> - </t-radio-group> --> <view class="btn-box"> <t-button class="error-btn" diff --git a/packageBookService/pages/bookServices/detail/components/tree/index.js b/packageBookService/pages/bookServices/detail/components/tree/index.js index cf3f46c..8a0515a 100644 --- a/packageBookService/pages/bookServices/detail/components/tree/index.js +++ b/packageBookService/pages/bookServices/detail/components/tree/index.js @@ -165,109 +165,108 @@ // 璺宠浆闊宠棰戞挱鏀惧櫒 goPlayer(e) { // 妫�鏌ョ櫥褰曠姸鎬� - console.log(e.currentTarget.dataset.item) - const token = wx.getStorageSync(app.config.tokenKey); - if (!token) return false - const item = e.currentTarget.dataset.item; - const parent = e.currentTarget.dataset.parent; - const parentProductLinkPath = parent ? - parent.productLinkPath : - wx.getStorageSync("teachResourcesPath"); - const parentName = parent ? parent.name : "鏁欏璧勬簮"; - // 璧勬簮璐拱椤甸潰(鍙睍绀烘湭璐拱璧勬簮) 鐐瑰嚮涓嶈烦杞� - if (this.properties.isShowCheck) return false; - if (item.selectType == "webpage" || item.learnSelectType == "webpage") { - // 缃戦〉绫诲瀷璺宠浆鍒扮綉鍧�澶嶅埗椤碉紝鍥犱负url浼犲弬涓嶈兘浼� 甯﹀弬鏁扮殑缃戠粶鍦板潃锛屾墍浠ユ澶勮鎶婄綉缁滃湴鍧�閲岀殑浼犲弬鎽樺嚭鏉ワ紝鏀惧埌url閲� - let urlData = '' - const flags = item.jsek_link.indexOf("?") - if (flags > -1) { - urlData = item.jsek_link.slice(flags + 1, item.jsek_link.length) + const goPlayerFun = () => { + const item = e.currentTarget.dataset.item; + const parent = e.currentTarget.dataset.parent; + const parentProductLinkPath = parent ? + parent.productLinkPath : + wx.getStorageSync("teachResourcesPath"); + const parentName = parent ? parent.name : "鏁欏璧勬簮"; + // 璧勬簮璐拱椤甸潰(鍙睍绀烘湭璐拱璧勬簮) 鐐瑰嚮涓嶈烦杞� + if (this.properties.isShowCheck) return false; + if (item.selectType == "webpage" || item.learnSelectType == "webpage") { + // 缃戦〉绫诲瀷璺宠浆鍒扮綉鍧�澶嶅埗椤碉紝鍥犱负url浼犲弬涓嶈兘浼� 甯﹀弬鏁扮殑缃戠粶鍦板潃锛屾墍浠ユ澶勮鎶婄綉缁滃湴鍧�閲岀殑浼犲弬鎽樺嚭鏉ワ紝鏀惧埌url閲� + let urlData = '' + const flags = item.jsek_link.indexOf("?") + if (flags > -1) { + urlData = item.jsek_link.slice(flags + 1, item.jsek_link.length) + } + url = '/packageBookService/pages/bookServices/linkPage/index' + return wx.navigateTo({ + url: urlData ? url + `?path=${item.jsek_link.slice(0,flags)}` + '&' + urlData : url + `?path=${item.jsek_link}` + }) } - url = '/packageBookService/pages/bookServices/linkPage/index' - return wx.navigateTo({ - url: urlData ? url + `?path=${item.jsek_link.slice(0,flags)}` + '&' + urlData : url + `?path=${item.jsek_link}` - }) - } - if (!item.file && !item.freeFile && !item.protectedFile) { - return wx.showToast({ - icon: 'error', - title: '鏆傛棤璧勬簮', - }) - } - if (item.selectType == 'zip' || item.learnSelectType == 'zip') { - // if (this.properties.applyState == 'Normal') { - return wx.showToast({ - icon: 'error', - title: '璇峰墠寰�PC绔笅杞�', - }) - // } else { - // return wx.showToast({ - // icon: 'error', - // title: '璇峰厛鐢宠涓嬭浇', - // }) - // } - } - if (this.properties.tab == "jsek_teachingResources" && (item.file || item.freeFile)) { - let file = item.fileMap[item.file] ? item.fileMap[item.file] : item.fileMap[item.freeFile] - if (file && file.protectType !== "Public") { + if (!item.file && !item.freeFile && !item.protectedFile) { return wx.showToast({ - icon: "none", - title: "璧勬簮涓嶅彲鐢紝璇疯仈绯荤鐞嗗憳", - }); + icon: 'error', + title: '鏆傛棤璧勬簮', + }) } - } - if (this.properties.tab == "jsek_cloudLearning") { - - // 1.鎵惧嚭鎵�鏈夌埗绾х洰褰曞拰鏈韩(鏈夐攢鍞柟寮�) 鍜� 浜戝涔犳湰韬�(鏈夐攢鍞柟寮�) 鏀惧埌涓�涓暟缁� 涓虹┖鍒欐殏鏈紑鏀鹃攢鍞� - let learn = [] - if (this.properties.isCloundHaveSaleMethod) { - // 1.1 浜戝涔犳湁閿�鍞柟寮忥紝鍔犲叆鐖剁骇鏁扮粍 - learn.push(this.properties.learnMenu) - } else { - // 1.2 浜戝涔犳棤閿�鍞柟寮忥紝灏嗙埗绾х洰褰曞拰鏈韩鍔犲叆鏁扮粍 - learn = this.handleTreeData(this.properties.learnList).filter( - (citem) => citem.saleMethod && - citem.saleMethod.find((ditem) => ditem.SaleType == 'Normal' && ditem.Price > 0) && - new Date(citem.saleMethod.find((ditem) => ditem.SaleType == 'Normal').EndDate).getTime() >= new Date().getTime() && - new Date(citem.saleMethod.find((ditem) => ditem.SaleType == 'Normal').BeginDate).getTime() <= new Date().getTime() && - item.productLinkPath.includes(citem.productLinkPath) - ) + if (item.selectType == 'zip' || item.learnSelectType == 'zip') { + return wx.showToast({ + icon: 'error', + title: '璇峰墠寰�PC绔笅杞�', + }) } - // 2.鎵惧嚭杩欎釜鏁扮粍閲屽凡璐拱鐨� 褰㈡垚鏂版暟缁� 涓虹┖鍒欐湭璐拱 - let buyList = [] - if (learn.length) buyList = learn.filter((item) => this.properties.buyIds.includes(item.saleMethod.find((citem) => citem.SaleType == 'Normal').Id)) - // 鏈夌埗绾�(鍖呭惈閿�鍞柟寮�)锛屼笖鏈喘涔� - if (learn.length && !buyList.length) return wx.showToast({ - icon: 'error', - title: '璇峰厛璐拱璇ヨ祫婧�', - }) - if (item.protectedFile || item.freeFile) { - let file = item.fileMap[item.protectedFile] ? item.fileMap[item.protectedFile] : item.fileMap[item.freeFile] + if (this.properties.tab == "jsek_teachingResources" && (item.file || item.freeFile)) { + let file = item.fileMap[item.file] ? item.fileMap[item.file] : item.fileMap[item.freeFile] if (file && file.protectType !== "Public") { return wx.showToast({ - icon: 'none', + icon: "none", title: "璧勬簮涓嶅彲鐢紝璇疯仈绯荤鐞嗗憳", }); } } + if (this.properties.tab == "jsek_cloudLearning") { + // 1.鎵惧嚭鎵�鏈夌埗绾х洰褰曞拰鏈韩(鏈夐攢鍞柟寮�) 鍜� 浜戝涔犳湰韬�(鏈夐攢鍞柟寮�) 鏀惧埌涓�涓暟缁� 涓虹┖鍒欐殏鏈紑鏀鹃攢鍞� + let learn = [] + if (this.properties.isCloundHaveSaleMethod) { + // 1.1 浜戝涔犳湁閿�鍞柟寮忥紝鍔犲叆鐖剁骇鏁扮粍 + learn.push(this.properties.learnMenu) + } else { + // 1.2 浜戝涔犳棤閿�鍞柟寮忥紝灏嗙埗绾х洰褰曞拰鏈韩鍔犲叆鏁扮粍 + learn = this.handleTreeData(this.properties.learnList).filter( + (citem) => citem.saleMethod && + citem.saleMethod.find((ditem) => ditem.SaleType == 'Normal' && ditem.Price > 0) && + new Date(citem.saleMethod.find((ditem) => ditem.SaleType == 'Normal').EndDate).getTime() >= new Date().getTime() && + new Date(citem.saleMethod.find((ditem) => ditem.SaleType == 'Normal').BeginDate).getTime() <= new Date().getTime() && + item.productLinkPath.includes(citem.productLinkPath) + ) + } + // 2.鎵惧嚭杩欎釜鏁扮粍閲屽凡璐拱鐨� 褰㈡垚鏂版暟缁� 涓虹┖鍒欐湭璐拱 + let buyList = [] + if (learn.length) buyList = learn.filter((item) => this.properties.buyIds.includes(item.saleMethod.find((citem) => citem.SaleType == 'Normal').Id)) + // 鏈夌埗绾�(鍖呭惈閿�鍞柟寮�)锛屼笖鏈喘涔� + if (learn.length && !buyList.length) return wx.showToast({ + icon: 'error', + title: '璇峰厛璐拱璇ヨ祫婧�', + }) + if (item.protectedFile || item.freeFile) { + let file = item.fileMap[item.protectedFile] ? item.fileMap[item.protectedFile] : item.fileMap[item.freeFile] + if (file && file.protectType !== "Public") { + return wx.showToast({ + icon: 'none', + title: "璧勬簮涓嶅彲鐢紝璇疯仈绯荤鐞嗗憳", + }); + } + } + } + let url; + if (item.selectType == "video" || item.learnSelectType == "video") { + url = "/packageDomain/pages/resourceDetails/myVideo/index"; + } + if ( + item.selectType == "audio" || + item.learnSelectType == "audio" + ) { + url = "/packageDomain/pages/resourceDetails/myAudio/index"; + } + if (item.selectType == "picture" || item.selectType == 'document' || item.selectType == 'pdf' || item.learnSelectType == "picture" || item.learnSelectType == 'document' || item.learnSelectType == 'pdf') { + url = "/packageDomain/pages/resourceDetails/document/index"; + } + wx.navigateTo({ + url: `${url}?productLinkPath=${item.productLinkPath}&parentProductLinkPath=${parentProductLinkPath}&parentName=${parentName}&activeId=${item.id}&bookId=${this.properties.bookInfo.id}&bookName=${this.properties.bookInfo.name}&cmsId=${this.properties.bookInfo.rootCmsItemId}&formPath=${this.properties.tab}&applyState=${this.properties.applyState}&deadline=${this.properties.deadline}`, + }); + } + const token = wx.getStorageSync(app.config.tokenKey); + if (!token && this.data.tab != 'jsek_teachingResources') { + loginInfo(app, (data) => { + if (data) goPlayerFun() + }) + } else { + goPlayerFun() + } - } - let url; - if (item.selectType == "video" || item.learnSelectType == "video") { - url = "/packageDomain/pages/resourceDetails/myVideo/index"; - } - if ( - item.selectType == "audio" || - item.learnSelectType == "audio" - ) { - url = "/packageDomain/pages/resourceDetails/myAudio/index"; - } - if (item.selectType == "picture" || item.selectType == 'document' || item.selectType == 'pdf' || item.learnSelectType == "picture" || item.learnSelectType == 'document' || item.learnSelectType == 'pdf') { - url = "/packageDomain/pages/resourceDetails/document/index"; - } - wx.navigateTo({ - url: `${url}?productLinkPath=${item.productLinkPath}&parentProductLinkPath=${parentProductLinkPath}&parentName=${parentName}&activeId=${item.id}&bookId=${this.properties.bookInfo.id}&bookName=${this.properties.bookInfo.name}&cmsId=${this.properties.bookInfo.rootCmsItemId}&formPath=${this.properties.tab}&applyState=${this.properties.applyState}&deadline=${this.properties.deadline}`, - }); }, // 鎷垮埌鎵�鏈夐」 diff --git a/packageBookService/pages/bookServices/detail/index.js b/packageBookService/pages/bookServices/detail/index.js index 212bf12..72cd1ec 100644 --- a/packageBookService/pages/bookServices/detail/index.js +++ b/packageBookService/pages/bookServices/detail/index.js @@ -13,9 +13,6 @@ * 椤甸潰鐨勫垵濮嬫暟鎹� */ data: { - // 杩涢〉闈㈤粯璁ゅ垏鎹� 灞曞紑鐨刬d - // defaultactiveTeachid 鏁欏璧勬簮 - // defaultactiveLearnid 浜戝涔� bookId: "", barHeight: "", navBarHeight: "", @@ -49,7 +46,7 @@ learnPath: '', applyResourceState: false, // 鐢宠鏁欏璧勬簮鎸夐挳闃叉姈 resourceClassList: [], // 璧勬簮鎵�灞炲垎绫� - applyState: "", // 鏁欏璧勬簮鐢宠鐘舵�� + applyState: "1", // 鏁欏璧勬簮鐢宠鐘舵�� deadline: "", // 鏁欏璧勬簮鐢宠鏈夋晥鏃ユ湡, isShowBuyCloundBtn: false, isshowDrawBtn: true, // 浜戝涔犻鍙栨煡鐪嬫寜閽槸鍚︽樉绀� @@ -224,6 +221,26 @@ list: e.detail.changeList, }); }, + + logInFun(callback) { + loginInfo(app, (data) => { + if (data) { + this.getShoppingCartProductGet(); + this.getApplyInfo(this.data.options.id); + this.getAlreadyPBookList(); + this.getAlreadyEBookList(); + if (wx.getStorageSync(app.config.userInfoKey)) { + this.setData({ + userInfo: JSON.parse(wx.getStorageSync(app.config.userInfoKey)), + }); + // 鑾峰彇鐢宠娆℃暟 + this.getSelectPaperBookCount(); + this.getSelectBookCount(); + } + callback() + } + }) + }, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇 */ @@ -245,33 +262,26 @@ wx.setNavigationBarTitle({ title: decodeURI(options.name), }) - let token = wx.getStorageSync(app.config.tokenKey) - if (!token) { - loginInfo(app, (data) => { - if (data) {} else {} - }) - } this.getBookInfo(options.id); - // this.getResourceClass(); // 鑾峰彇璧勬簮鎵�灞炲垎绫� - token = wx.getStorageSync(app.config.tokenKey) - if (token) { - this.getShoppingCartProductGet(); - this.getApplyInfo(options.id); - this.getAlreadyPBookList(); - this.getAlreadyEBookList(); - } - if (wx.getStorageSync(app.config.userInfoKey)) { - this.setData({ - userInfo: JSON.parse(wx.getStorageSync(app.config.userInfoKey)), - }); - // 鑾峰彇鐢宠娆℃暟 - this.getSelectPaperBookCount(); - this.getSelectBookCount(); - } if (options.tabValue) { this.setData({ tabValue: options.tabValue, }); + } + const token = wx.getStorageSync(app.config.tokenKey); + if (token) { + this.getShoppingCartProductGet(); + this.getApplyInfo(this.data.options.id); + this.getAlreadyPBookList(); + this.getAlreadyEBookList(); + if (wx.getStorageSync(app.config.userInfoKey)) { + this.setData({ + userInfo: JSON.parse(wx.getStorageSync(app.config.userInfoKey)), + }); + // 鑾峰彇鐢宠娆℃暟 + this.getSelectPaperBookCount(); + this.getSelectBookCount(); + } } }, @@ -724,42 +734,37 @@ setCollect() { const token = wx.getStorageSync(app.config.tokenKey); if (!token) { - // 妫�鏌ョ櫥褰曠姸鎬� - loginInfo(app, (data) => { - // 濡傛灉涓嶆槸绗竴娆$櫥褰曪紝浼氭墽琛屽洖璋� - if (data) { - // 鐧诲綍鎴愬姛锛岃嚜鍔ㄨ褰晅oken鍜岀敤鎴蜂俊鎭紝骞惰繑鍥瀟rue - this.getBookInfo(this.data.bookId); - } else { - // 鍑虹幇閿欒锛岃繑鍥瀎alse - } - }); + this.logInFun(() => { + this.getBookInfo(this.data.bookId); + }) } else { - if (this.data.bookDetail.isFavourite) { - app.MG.store - .delProductLink({ - productIds: [this.data.bookDetail.id], - linkType: "FavoriteBookCity", - }) - .then(() => { - this.setData({ - "bookDetail.isFavourite": false, - }); - }); - } else { - const params = { - productIds: [this.data.bookDetail.id], - linkType: "FavoriteBookCity", - }; - app.MG.store.addProductLink(params).then((res) => { - this.setData({ - "bookDetail.isFavourite": true, - }); - }); - } + this.collectFun() } }, - + collectFun() { + if (this.data.bookDetail.isFavourite) { + app.MG.store + .delProductLink({ + productIds: [this.data.bookDetail.id], + linkType: "FavoriteBookCity", + }) + .then(() => { + this.setData({ + "bookDetail.isFavourite": false, + }); + }); + } else { + const params = { + productIds: [this.data.bookDetail.id], + linkType: "FavoriteBookCity", + }; + app.MG.store.addProductLink(params).then((res) => { + this.setData({ + "bookDetail.isFavourite": true, + }); + }); + } + }, // 鑱旂郴 editPhone() { this.setData({ @@ -771,12 +776,18 @@ suggestBtn() { // 妫�鏌ョ櫥褰曠姸鎬� const token = wx.getStorageSync(app.config.tokenKey); - const child = this.selectComponent("#suggest-component"); - if (token) - // child.showDialog(); + if (token) { this.setData({ showIndex: '1' }) + } else { + this.logInFun(() => { + this.setData({ + showIndex: '1' + }) + }) + } + }, // 璺宠浆缃戝簵 goShop(e) { @@ -810,17 +821,6 @@ "buyResourceData.refCode": checkData.refCode, }); } - // if ( - // (e.detail.value == "jsek_teachingResources" && - // !this.data.teach.length) || - // (e.detail.value == "jsek_cloudLearning" && !this.data.learn.length) || - // (e.detail.value == "questionBank" && !this.data.test.length) - // ) { - // if (e.detail.value == "jsek_teachingResources") { - // wx.setStorageSync('teachResourcesPath', checkData.productLinkPath) - // } - // this.getResourceData(checkData); - // } if ((e.detail.value == "jsek_teachingResources" && !this.data.teach.length) || (e.detail.value == "jsek_cloudLearning" && !this.data.learn.length)) { wx.setStorageSync('teachResourcesPath', checkData.productLinkPath) this.getResourceDataList(checkData) @@ -1028,7 +1028,6 @@ loading: false, }); } - let list = [] // 鍒ゆ柇浜戝涔犳湁鏃犻攢鍞柟寮忓拰鏈夋晥鏈� const cloundSaleMethod = @@ -1120,6 +1119,7 @@ learnPath: type.productLinkPath }); } + console.log('1', this.data.teach); }) }, // 鑾峰彇 浜戞祴璇� @@ -1271,47 +1271,55 @@ }, // 鍥句功娣诲姞璐墿杞� - async addBookShopcCar() { - if (!this.data.expire) { - const shoppingCartGetId = []; - let query = { - start: 0, - size: 9999, - filterList: [], - searchList: [], - }; - const res = await app.MG.store.getShoppingCartProductList(query); - res.datas.forEach((item) => { - shoppingCartGetId.push(item.saleMethod.id); - }); - const determine = shoppingCartGetId.some( - (item) => item == this.data.selectedIds - ); - if (!determine) { + addBookShopcCar() { + const token = wx.getStorageSync(app.config.tokenKey); + if (token) { + addFun() + } else { + this.logInFun(() => {}) + } + const addFun = async () => { + if (!this.data.expire) { + const shoppingCartGetId = []; let query = { - requests: [{ - saleMethodId: this.data.selectedIds, - storeEventId: null, - agentCode: "鐢靛瓙涔�", - }, ], + start: 0, + size: 9999, + filterList: [], + searchList: [], }; - const addRes = app.MG.store.addShoppingCart(query); - this.showSuccessToast(); + const res = await app.MG.store.getShoppingCartProductList(query); + res.datas.forEach((item) => { + shoppingCartGetId.push(item.saleMethod.id); + }); + const determine = shoppingCartGetId.some( + (item) => item == this.data.selectedIds + ); + if (!determine) { + let query = { + requests: [{ + saleMethodId: this.data.selectedIds, + storeEventId: null, + agentCode: "鐢靛瓙涔�", + }, ], + }; + const addRes = app.MG.store.addShoppingCart(query); + this.showSuccessToast(); + } else { + Toast({ + context: this, + selector: "#t-toast", + message: "璇ヤ功宸插湪璐墿杞︼紝璇峰嬁閲嶅娣诲姞", + theme: "warning", + direction: "column", + }); + } } else { - Toast({ - context: this, - selector: "#t-toast", - message: "璇ヤ功宸插湪璐墿杞︼紝璇峰嬁閲嶅娣诲姞", - theme: "warning", - direction: "column", + wx.showToast({ + title: "鍟嗗搧涓嶅湪鏈夋晥鏈�", + icon: "none", + duration: 1000, }); } - } else { - wx.showToast({ - title: "鍟嗗搧涓嶅湪鏈夋晥鏈�", - icon: "none", - duration: 1000, - }); } }, @@ -1787,84 +1795,81 @@ return flattenedArray; }, // 浜戝涔犱竴閿鍙� - async getFreeResource() { + getFreeResource() { const child = this.selectComponent("#learn-resource"); const token = wx.getStorageSync(app.config.tokenKey); if (!token) { - loginInfo(app, (data) => { - // 濡傛灉涓嶆槸绗竴娆$櫥褰曪紝浼氭墽琛屽洖璋� - if (data) { - // 鐧诲綍鎴愬姛锛岃嚜鍔ㄨ褰晅oken鍜岀敤鎴蜂俊鎭紝骞惰繑鍥瀟rue - } else { - // 鍑虹幇閿欒锛岃繑鍥瀎alse - } - }); - } - // 棰嗗彇鏌ョ湅 锛屽厛鐪嬩簯瀛︿範涓婄殑 鍐嶇湅璧勬簮涓婄殑 - const cloundMenu = this.data.resourceCodeList.find((item) => item.refCode == 'jsek_cloudLearning') - const cloundMenuSaleMethod = - cloundMenu.saleMethod && cloundMenu.saleMethod.length ? - cloundMenu.saleMethod.find((ditem) => ditem.SaleType == 'Normal') : - undefined - let query = {} - if (this.data.isCloundHaveSaleMethod && !cloundMenuSaleMethod.Price) { - // 浜戝涔犱笂鏈夐攢鍞柟寮忥紝涓斾负0鍏冿紝鐩存帴棰嗗彇浜戝涔� - query = { - remarks: '浜戝涔�', - requests: [{ - saleMethodId: cloundMenuSaleMethod.Id, - count: 1 - }] - } + this.logInFun(() => {}); } else { - // 棰嗗彇璧勬簮 - let arr = this.handleTreeData(this.data.learn).filter(item => this.resourceIsBuy(item)) - let freeIds = arr.filter((item) => { - return item.saleMethod.find((citem) => citem.SaleType == 'Normal').Price == 0 - }) - if (!freeIds.length) - return wx.showToast({ - icon: "error", - title: "鏆傛棤鍏嶈垂璧勬簮", - }); - let requests = []; - freeIds.forEach((item, index) => { - if (this.resourceIsBuy(item)) { - requests.push({ - saleMethodId: item.saleMethod[0].Id, - count: 1, - }); - } - }); - query = { - remarks: "浜戝涔�", - requests, - }; + getFreeFun() } - child.changeReceive(true); - try { - const initOrderRes = await app.MG.store.initOrder(query); - let parameter = { - orderNum: initOrderRes.orderNumber, - }; - // 纭璁㈠崟 - const confirmOrderRes = await app.MG.store.confirmOrder(parameter); - if (confirmOrderRes.orderNumber) { - child.changeReceive(false); - wx.showToast({ - title: "棰嗗彇鎴愬姛", + const getFreeFun = async () => { + // 棰嗗彇鏌ョ湅 锛屽厛鐪嬩簯瀛︿範涓婄殑 鍐嶇湅璧勬簮涓婄殑 + const cloundMenu = this.data.resourceCodeList.find((item) => item.refCode == 'jsek_cloudLearning') + const cloundMenuSaleMethod = + cloundMenu.saleMethod && cloundMenu.saleMethod.length ? + cloundMenu.saleMethod.find((ditem) => ditem.SaleType == 'Normal') : + undefined + let query = {} + if (this.data.isCloundHaveSaleMethod && !cloundMenuSaleMethod.Price) { + // 浜戝涔犱笂鏈夐攢鍞柟寮忥紝涓斾负0鍏冿紝鐩存帴棰嗗彇浜戝涔� + query = { + remarks: '浜戝涔�', + requests: [{ + saleMethodId: cloundMenuSaleMethod.Id, + count: 1 + }] + } + } else { + // 棰嗗彇璧勬簮 + let arr = this.handleTreeData(this.data.learn).filter(item => this.resourceIsBuy(item)) + let freeIds = arr.filter((item) => { + return item.saleMethod.find((citem) => citem.SaleType == 'Normal').Price == 0 + }) + if (!freeIds.length) + return wx.showToast({ + icon: "error", + title: "鏆傛棤鍏嶈垂璧勬簮", + }); + let requests = []; + freeIds.forEach((item, index) => { + if (this.resourceIsBuy(item)) { + requests.push({ + saleMethodId: item.saleMethod[0].Id, + count: 1, + }); + } }); - this.getBookInfo(this.data.bookId); - this.getResourceDataList({ - refCode: 'jsek_cloudLearning', - productLinkPath: this.data.learnPath - }) - this.setData({ - successOrderNumber: confirmOrderRes.orderNumber - }) + query = { + remarks: "浜戝涔�", + requests, + }; } - } catch (error) { - console.log(error); + child.changeReceive(true); + try { + const initOrderRes = await app.MG.store.initOrder(query); + let parameter = { + orderNum: initOrderRes.orderNumber, + }; + // 纭璁㈠崟 + const confirmOrderRes = await app.MG.store.confirmOrder(parameter); + if (confirmOrderRes.orderNumber) { + child.changeReceive(false); + wx.showToast({ + title: "棰嗗彇鎴愬姛", + }); + this.getBookInfo(this.data.bookId); + this.getResourceDataList({ + refCode: 'jsek_cloudLearning', + productLinkPath: this.data.learnPath + }) + this.setData({ + successOrderNumber: confirmOrderRes.orderNumber + }) + } + } catch (error) { + console.log(error); + } } }, // 浜戝涔犱竴閿喘涔� @@ -1918,34 +1923,37 @@ } }, // 浜戝涔犲叏閮ㄨ喘涔� - async buyCloudLearnClass() { - const cloundMenu = this.data.resourceCodeList.find((item) => item.refCode == 'jsek_cloudLearning') - let query = { - remarks: '浜戝涔�', - requests: [{ - saleMethodId: cloundMenu.saleMethod.find((eitem) => eitem.SaleType == 'Normal').Id, - count: 1 - }] - } - const initOrderRes = await app.MG.store.initOrder(query) - // 妫�鏌ヨ鍗曞彿鏄惁瀛樺湪 - if (initOrderRes.orderNumber) { - // bookService: orderNumber.value, 灏戜紶杩欎釜 锛屾殏鏃朵笉鐭ラ亾鏈変粈涔堢敤 - wx.navigateTo({ - url: `/pages/cart/paymentPage/index?&bookId=${this.data.bookDetail.id}&bookName=${this.data.bookDetail.name}&orderNumber=${initOrderRes.orderNumber}`, - }); + buyCloudLearnClass() { + const token = wx.getStorageSync(app.config.tokenKey); + if (token) { + buyClass() } else { - // 璁㈠崟鍙蜂笉瀛樺湪锛屾樉绀鸿鍛婃秷鎭� - wx.showToast({ - icon: "error", - title: "璇烽噸璇�", - }); + this.logInFun(() => {}) } - }, - // 浜戝涔犲瓧娈佃喘涔� - async buyCloundMenu() { - const cloundData = this.data.resourceCodeList.find(item => item.refCode == 'jsek_cloudLearning') - + const buyClass = async () => { + const cloundMenu = this.data.resourceCodeList.find((item) => item.refCode == 'jsek_cloudLearning') + let query = { + remarks: '浜戝涔�', + requests: [{ + saleMethodId: cloundMenu.saleMethod.find((eitem) => eitem.SaleType == 'Normal').Id, + count: 1 + }] + } + const initOrderRes = await app.MG.store.initOrder(query) + // 妫�鏌ヨ鍗曞彿鏄惁瀛樺湪 + if (initOrderRes.orderNumber) { + // bookService: orderNumber.value, 灏戜紶杩欎釜 锛屾殏鏃朵笉鐭ラ亾鏈変粈涔堢敤 + wx.navigateTo({ + url: `/pages/cart/paymentPage/index?&bookId=${this.data.bookDetail.id}&bookName=${this.data.bookDetail.name}&orderNumber=${initOrderRes.orderNumber}`, + }); + } else { + // 璁㈠崟鍙蜂笉瀛樺湪锛屾樉绀鸿鍛婃秷鎭� + wx.showToast({ + icon: "error", + title: "璇烽噸璇�", + }); + } + } }, // 鍙樹负鎵�鏈塩heck true findAndUpdateItemsByIds(tree, ids) { @@ -1964,9 +1972,6 @@ findAndUpdate(node); // 瀵规瘡涓《灞傝妭鐐规墽琛屾煡鎵惧拰鏇存柊鎿嶄綔 } return tree; // 杩斿洖淇敼鍚庣殑瀹屾暣鏁扮粍 - }, - handleTrue() { - // findAndUpdateItemsByIds(this.date.) }, // 棰樺簱璐拱 @@ -2090,52 +2095,60 @@ }); }, // 璐拱缁勫嵎 - async buyMock() { - let res; - if (!this.data.mockData.id) - return wx.showToast({ - icon: "error", - title: "鏆傛棤缁勫嵎", - mask: true, - }); - // 鏋勫缓璁㈠崟鏌ヨ瀵硅薄 - try { - let query = { - remarks: "缁勫嵎", - requests: [{ - saleMethodId: this.data.mockData.id, - count: 1, - }, ], - }; - if (this.data.flag) { - this.setData({ - flag: false, + buyMock() { + const token = wx.getStorageSync(app.config.tokenKey); + if (token) { + buyMockFun() + } else { + this.logInFun(() => {}) + } + const buyMockFun = async () => { + let res; + if (!this.data.mockData.id) + return wx.showToast({ + icon: "error", + title: "鏆傛棤缁勫嵎", + mask: true, }); - res = await app.MG.store.initOrder(query); - } - if (res.orderNumber && this.data.mockData.price) { - wx.navigateTo({ - url: `/pages/cart/paymentPage/index?orderNumber=${res.orderNumber}`, - }); - } else { - // 0鍏冪洿鎺ラ鍙� - // 纭璁㈠崟 - const confirmOrderRes = await app.MG.store.confirmOrder({ - orderNum: res.orderNumber, - }); - if (confirmOrderRes) { - wx.showToast({ - icon: "success", - title: "棰嗗彇鎴愬姛", - }); + // 鏋勫缓璁㈠崟鏌ヨ瀵硅薄 + try { + let query = { + remarks: "缁勫嵎", + requests: [{ + saleMethodId: this.data.mockData.id, + count: 1, + }, ], + }; + if (this.data.flag) { this.setData({ - flag: true, + flag: false, }); - await this.recordBuyMock(); // 璁板綍璐拱鏃堕棿 + res = await app.MG.store.initOrder(query); } + if (res.orderNumber && this.data.mockData.price) { + wx.navigateTo({ + url: `/pages/cart/paymentPage/index?orderNumber=${res.orderNumber}`, + }); + } else { + // 0鍏冪洿鎺ラ鍙� + // 纭璁㈠崟 + const confirmOrderRes = await app.MG.store.confirmOrder({ + orderNum: res.orderNumber, + }); + if (confirmOrderRes) { + wx.showToast({ + icon: "success", + title: "棰嗗彇鎴愬姛", + }); + this.setData({ + flag: true, + }); + await this.recordBuyMock(); // 璁板綍璐拱鏃堕棿 + } + } + } catch (error) { + console.log(error); } - } catch (error) { - console.log(error); } }, // 璁板綍璐拱缁勫嵎鏃堕棿 @@ -2238,40 +2251,64 @@ }, // 搴曢儴璐拱鎸夐挳 buyBtn() { - if (this.data.tabValue == "brief" && !this.data.bookBuy) { - this.buyBook(); - } else if (this.data.tabValue == "jsek_cloudLearning") { - const tree = this.selectComponent("#tree"); - tree.onCloudShoppingCart(); + const token = wx.getStorageSync(app.config.tokenKey); + if (token) { + buyFun() } else { - console.log(this.data.tabValue); + this.logInFun(() => {}) + } + const buyFun = () => { + if (this.data.tabValue == "brief" && !this.data.bookBuy) { + this.buyBook(); + } else if (this.data.tabValue == "jsek_cloudLearning") { + const tree = this.selectComponent("#tree"); + tree.onCloudShoppingCart(); + } else { + console.log(this.data.tabValue); + } } }, - goRead() { - if (!this.data.noFile) { - wx.showToast({ - title: "鏆傛棤闃呰鏂囦欢", - icon: "none", - duration: 2000, + goRead(e) { + const readFun = (bookBuy) => { + if (!this.data.noFile) { + wx.showToast({ + title: "鏆傛棤闃呰鏂囦欢", + icon: "none", + duration: 2000, + }); + return false; + } + wx.navigateTo({ + url: "/packageBookService/pages/components/webView/index?md5=" + + this.data.fileInfo.md5 + + "&fileName=" + + this.data.fileInfo.bookName + + "&fileType=" + + this.data.fileInfo.fileType + + "&freePage=" + + this.data.fileInfo.freePage + + "&bookBuy=" + + bookBuy + + "&bookId=" + + this.data.bookDetail.id, }); - return false; } - wx.navigateTo({ - url: "/packageBookService/pages/components/webView/index?md5=" + - this.data.fileInfo.md5 + - "&fileName=" + - this.data.fileInfo.bookName + - "&fileType=" + - this.data.fileInfo.fileType + - "&freePage=" + - this.data.fileInfo.freePage + - "&bookBuy=" + - this.data.bookBuy + - "&bookId=" + - this.data.bookDetail.id, + const { + type + } = e.currentTarget.dataset + if (type == 'freeFile') return readFun(this.data.bookBuy) + if (this.data.bookDetail.price == '0.00') + return readFun(true) + const token = wx.getStorageSync(app.config.tokenKey); + if (token) { + readFun(this.data.bookBuy) + } else { + this.logInFun(() => { + readFun(this.data.bookBuy) + }) + } - }); }, //鏍蜂功鐢宠 @@ -2384,179 +2421,132 @@ //鐢宠鐢靛瓙鏍蜂功 appplyElectronicBook() { - // 鍏堝垽鏂笅鏁欏笀璁よ瘉锛屾湭瀵瑰師鏈夐�昏緫淇敼 - let role = this.data.userInfo != null ? this.data.userInfo.role : null; - if (role && role == "Teacher") {} else { - return wx.showModal({ - title: "灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�", //鎻愮ず鐨勬爣棰� - content: "璇峰厛杩涜鏁欏笀璁よ瘉锛�", //鎻愮ず鐨勫唴瀹� - confirmColor: "#ff6c00", - cancelColor: "#949494", - success: function (res) { - if (res.confirm) { - wx.navigateTo({ - url: "/packageDomain/pages/teacherCertification/index", - }); - } else if (res.cancel) {} - }, - }); + const token = wx.getStorageSync(app.config.tokenKey); + if (token) { + applyFun() + } else { + this.logInFun(() => {}) } - if ( - this.data.bookDetail.isApplyBook == 2 || - this.data.bookDetail.isApplyBook == 4 - ) { + const applyFun = () => { + // 鍏堝垽鏂笅鏁欏笀璁よ瘉锛屾湭瀵瑰師鏈夐�昏緫淇敼 let role = this.data.userInfo != null ? this.data.userInfo.role : null; - if (role && role == "Teacher") { - if (!this.data.noFile) { - wx.showToast({ - title: "鏆傛棤鐢靛瓙涔︽枃浠�,璇疯仈绯荤鐞嗗憳!", - icon: "none", - duration: 1000, - }); - return; - } - if (this.data.ebookCount == 0) { - wx.showToast({ - title: "鎮ㄧ殑鐢靛瓙鏍蜂功鐢宠娆℃暟宸茬敤灏斤紝鑻ヨ缁х画锛岃鑱旂郴绠$悊鍛橈紒", - icon: "none", - duration: 1000, - }); - return false; - } - - let isHas = this.data.electronicBookList.find( - (eitem) => eitem.id == this.data.bookDetail.id - ); - if (isHas) { - wx.showToast({ - title: "璇ヤ功宸插湪娓呭崟鍒楄〃涓�", - icon: "none", - duration: 1000, - }); - return false; - } - let isApply = this.data.alreadyElectronicBookList.find( - (eitem) => eitem.content[0].id == this.data.bookDetail.id - ); - if (isApply) { - if (isApply.state == 'WaitAudit') { + if (role && role == "Teacher") {} else { + return wx.showModal({ + title: "灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�", //鎻愮ず鐨勬爣棰� + content: "璇峰厛杩涜鏁欏笀璁よ瘉锛�", //鎻愮ず鐨勫唴瀹� + confirmColor: "#ff6c00", + cancelColor: "#949494", + success: function (res) { + if (res.confirm) { + wx.navigateTo({ + url: "/packageDomain/pages/teacherCertification/index", + }); + } else if (res.cancel) {} + }, + }); + } + if ( + this.data.bookDetail.isApplyBook == 2 || + this.data.bookDetail.isApplyBook == 4 + ) { + let role = this.data.userInfo != null ? this.data.userInfo.role : null; + if (role && role == "Teacher") { + if (!this.data.noFile) { wx.showToast({ - title: "璇ヤ功宸茬敵璇凤紒", + title: "鏆傛棤鐢靛瓙涔︽枃浠�,璇疯仈绯荤鐞嗗憳!", + icon: "none", + duration: 1000, + }); + return; + } + if (this.data.ebookCount == 0) { + wx.showToast({ + title: "鎮ㄧ殑鐢靛瓙鏍蜂功鐢宠娆℃暟宸茬敤灏斤紝鑻ヨ缁х画锛岃鑱旂郴绠$悊鍛橈紒", icon: "none", duration: 1000, }); return false; - } else if (isApply.state == 'Normal') { - const flag = new Date(isApply.feedBack.endDate + ' 23:59:59').getTime() > new Date().getTime() - if (flag) { + } + + let isHas = this.data.electronicBookList.find( + (eitem) => eitem.id == this.data.bookDetail.id + ); + if (isHas) { + wx.showToast({ + title: "璇ヤ功宸插湪娓呭崟鍒楄〃涓�", + icon: "none", + duration: 1000, + }); + return false; + } + let isApply = this.data.alreadyElectronicBookList.find( + (eitem) => eitem.content[0].id == this.data.bookDetail.id + ); + if (isApply) { + if (isApply.state == 'WaitAudit') { wx.showToast({ title: "璇ヤ功宸茬敵璇凤紒", icon: "none", duration: 1000, }); return false; + } else if (isApply.state == 'Normal') { + const flag = new Date(isApply.feedBack.endDate + ' 23:59:59').getTime() > new Date().getTime() + if (flag) { + wx.showToast({ + title: "璇ヤ功宸茬敵璇凤紒", + icon: "none", + duration: 1000, + }); + return false; + } } } - } - if (this.data.electronicBookList.length >= 2) { - wx.showToast({ - title: "姣忔鏈�澶氬彧鍙敵璇�2鏈牱涔�", - icon: "none", - duration: 1000, + if (this.data.electronicBookList.length >= 2) { + wx.showToast({ + title: "姣忔鏈�澶氬彧鍙敵璇�2鏈牱涔�", + icon: "none", + duration: 1000, + }); + return false; + } + this.addBookFun(this.data.bookDetail, "eBook"); + } else { + wx.showModal({ + title: "灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�", //鎻愮ず鐨勬爣棰� + content: "璇峰厛杩涜鏁欏笀璁よ瘉锛�", //鎻愮ず鐨勫唴瀹� + confirmColor: "#ff6c00", + cancelColor: "#949494", + success: function (res) { + if (res.confirm) { + wx.navigateTo({ + url: "/packageDomain/pages/teacherCertification/index", + }); + } else if (res.cancel) {} + }, }); - return false; } - this.addBookFun(this.data.bookDetail, "eBook"); } else { - wx.showModal({ - title: "灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�", //鎻愮ず鐨勬爣棰� - content: "璇峰厛杩涜鏁欏笀璁よ瘉锛�", //鎻愮ず鐨勫唴瀹� - confirmColor: "#ff6c00", - cancelColor: "#949494", - success: function (res) { - if (res.confirm) { - wx.navigateTo({ - url: "/packageDomain/pages/teacherCertification/index", - }); - } else if (res.cancel) {} - }, + wx.showToast({ + title: "璇ヤ功涓嶈兘鐢宠鐢靛瓙鏍蜂功", + icon: "none", + duration: 1000, }); } - } else { - wx.showToast({ - title: "璇ヤ功涓嶈兘鐢宠鐢靛瓙鏍蜂功", - icon: "none", - duration: 1000, - }); } }, //鐢宠绾歌川鏍蜂功 appplyPaperBook() { - let role = this.data.userInfo != null ? this.data.userInfo.role : null; - if (role && role == "Teacher") {} else { - return wx.showModal({ - title: "灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�", //鎻愮ず鐨勬爣棰� - content: "璇峰厛杩涜鏁欏笀璁よ瘉锛�", //鎻愮ず鐨勫唴瀹� - confirmColor: "#ff6c00", - cancelColor: "#949494", - success: function (res) { - if (res.confirm) { - wx.navigateTo({ - url: "/packageDomain/pages/teacherCertification/index", - }); - } else if (res.cancel) {} - }, - }); + const token = wx.getStorageSync(app.config.tokenKey); + if (token) { + applyFun() + } else { + this.logInFun(() => {}) } - if ( - this.data.bookDetail.isApplyBook == 3 || - this.data.bookDetail.isApplyBook == 4 - ) { + const applyFun = () => { let role = this.data.userInfo != null ? this.data.userInfo.role : null; - if (role && role == "Teacher") { - // 鐐瑰嚮閫変腑 - if (this.data.paperBookCount == 0) { - wx.showToast({ - title: "鎮ㄧ殑绾歌川鏍蜂功鐢宠娆℃暟宸茬敤灏斤紝鑻ヨ缁х画锛岃鑱旂郴绠$悊鍛橈紒", - icon: "none", - duration: 1000, - }); - return false; - } - let isApply = this.data.alreadyPaperBookList.find( - (pitem) => pitem.content[0].id == this.data.bookDetail.id - ); - if (isApply) { - wx.showToast({ - title: "璇ヤ功宸茬敵璇凤紒", - icon: "none", - duration: 1000, - }); - return false; - } - - let isHas = this.data.paperBookList.find( - (pitem) => pitem.id == this.data.bookDetail.id - ); - if (isHas) { - wx.showToast({ - title: "璇ヤ功宸插湪娓呭崟鍒楄〃涓�", - icon: "none", - duration: 1000, - }); - return false; - } - if (this.data.paperBookList.length >= 2) { - wx.showToast({ - title: "姣忔鏈�澶氬彧鍙敵璇�2鏈牱涔�", - icon: "none", - duration: 1000, - }); - return false; - } - this.addBookFun(this.data.bookDetail, "pBook"); - } else { - wx.showModal({ + if (role && role == "Teacher") {} else { + return wx.showModal({ title: "灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�", //鎻愮ず鐨勬爣棰� content: "璇峰厛杩涜鏁欏笀璁よ瘉锛�", //鎻愮ず鐨勫唴瀹� confirmColor: "#ff6c00", @@ -2570,12 +2560,75 @@ }, }); } - } else { - wx.showToast({ - title: "璇ヤ功涓嶈兘鐢宠绾歌川鏍蜂功", - icon: "none", - duration: 1000, - }); + if ( + this.data.bookDetail.isApplyBook == 3 || + this.data.bookDetail.isApplyBook == 4 + ) { + let role = this.data.userInfo != null ? this.data.userInfo.role : null; + if (role && role == "Teacher") { + // 鐐瑰嚮閫変腑 + if (this.data.paperBookCount == 0) { + wx.showToast({ + title: "鎮ㄧ殑绾歌川鏍蜂功鐢宠娆℃暟宸茬敤灏斤紝鑻ヨ缁х画锛岃鑱旂郴绠$悊鍛橈紒", + icon: "none", + duration: 1000, + }); + return false; + } + let isApply = this.data.alreadyPaperBookList.find( + (pitem) => pitem.content[0].id == this.data.bookDetail.id + ); + if (isApply) { + wx.showToast({ + title: "璇ヤ功宸茬敵璇凤紒", + icon: "none", + duration: 1000, + }); + return false; + } + + let isHas = this.data.paperBookList.find( + (pitem) => pitem.id == this.data.bookDetail.id + ); + if (isHas) { + wx.showToast({ + title: "璇ヤ功宸插湪娓呭崟鍒楄〃涓�", + icon: "none", + duration: 1000, + }); + return false; + } + if (this.data.paperBookList.length >= 2) { + wx.showToast({ + title: "姣忔鏈�澶氬彧鍙敵璇�2鏈牱涔�", + icon: "none", + duration: 1000, + }); + return false; + } + this.addBookFun(this.data.bookDetail, "pBook"); + } else { + wx.showModal({ + title: "灏婃暚鐨勭敤鎴凤紝鎮ㄥソ锛�", //鎻愮ず鐨勬爣棰� + content: "璇峰厛杩涜鏁欏笀璁よ瘉锛�", //鎻愮ず鐨勫唴瀹� + confirmColor: "#ff6c00", + cancelColor: "#949494", + success: function (res) { + if (res.confirm) { + wx.navigateTo({ + url: "/packageDomain/pages/teacherCertification/index", + }); + } else if (res.cancel) {} + }, + }); + } + } else { + wx.showToast({ + title: "璇ヤ功涓嶈兘鐢宠绾歌川鏍蜂功", + icon: "none", + duration: 1000, + }); + } } }, // 娣诲姞鏍蜂功 @@ -2703,15 +2756,25 @@ return childrenList }, uploadFile(e) { - const userInfo = JSON.parse(wx.getStorageSync(app.config.userInfoKey)) - if (userInfo.role != 'Teacher') return wx.showToast({ - icon: 'error', - title: '璇峰厛杩涜鏁欏笀璁よ瘉', - }) - this.setData({ - dialogBox: true, - isShowUp: true - }); + const token = wx.getStorageSync(app.config.tokenKey); + if (token) { + uploadFun() + } else { + this.logInFun(() => { + uploadFun() + }) + } + const uploadFun = () => { + const userInfo = JSON.parse(wx.getStorageSync(app.config.userInfoKey)) + if (userInfo.role != 'Teacher') return wx.showToast({ + icon: 'error', + title: '璇峰厛杩涜鏁欏笀璁よ瘉', + }) + this.setData({ + dialogBox: true, + isShowUp: true + }); + } }, closeDialog() { this.setData({ diff --git a/packageBookService/pages/bookServices/detail/index.wxml b/packageBookService/pages/bookServices/detail/index.wxml index 6121d79..6240741 100644 --- a/packageBookService/pages/bookServices/detail/index.wxml +++ b/packageBookService/pages/bookServices/detail/index.wxml @@ -2,35 +2,65 @@ <import src="index.skeleton.wxml" /> <template is="skeleton" wx:if="{{pageLoading}}" /> -<suggest-dialog class="suggest-dialog" showIndex="{{showIndex}}" bookIcon="{{bookDetail.icon}}" bookName="{{bookDetail.name}}"></suggest-dialog> +<suggest-dialog + class="suggest-dialog" + showIndex="{{showIndex}}" + bookIcon="{{bookDetail.icon}}" + bookName="{{bookDetail.name}}" +></suggest-dialog> <!-- <popup showIndex="{{showIndex}}"></popup> --> <view class="page-bookService" wx:if="{{!pageLoading}}"> <t-toast id="t-toast" /> <movable-area class="movable-area"> - <scroll-view scroll-y="{{true}}" class="book" bindscrolltolower="onReachBottom"> + <scroll-view + scroll-y="{{true}}" + class="book" + bindscrolltolower="onReachBottom" + > <!-- 鍥句功璇︽儏 --> <view class="book-box"> <view class="book-detail" id="book-detail"> <view class="detail-left"> <view class="book-img"> - <image loading="" src="{{bookDetail.icon ? bookDetail.icon : '/static/images/default-book-img.png'}}" mode="aspectFit" aria-label="{{bookDetail.name}}" /> + <image + loading="" + src="{{bookDetail.icon ? bookDetail.icon : '/static/images/default-book-img.png'}}" + mode="aspectFit" + aria-label="{{bookDetail.name}}" + /> </view> <view class="book-use"> <view class="collect" bind:tap="setCollect"> <view> - <image loading="" src="/static/images/bookService/detail/collect.png" wx:if="{{!bookDetail.isFavourite}}" /> - <image loading="" src="/static/images/bookService/detail/collecting.png" wx:if="{{bookDetail.isFavourite}}" /> + <image + loading="" + src="/static/images/bookService/detail/collect.png" + wx:if="{{!bookDetail.isFavourite}}" + /> + <image + loading="" + src="/static/images/bookService/detail/collecting.png" + wx:if="{{bookDetail.isFavourite}}" + /> </view> <view class="use-title">鏀惰棌</view> </view> <view class="suggest" bind:tap="suggestBtn"> <view> - <image loading="" src="/static/images/bookService/detail/suggest.png" /> + <image + loading="" + src="/static/images/bookService/detail/suggest.png" + /> </view> <view class="use-title">寤鸿</view> </view> <view class="suggest" bindtap="editPhone"> - <t-icon class="editIcon" style="color: rgb(194, 194, 194);" name="calendar-edit" size="40rpx" /> + <t-icon + class="editIcon" + style="color: rgb(194, 194, 194)" + name="calendar-edit" + size="40rpx" + /> <view class="use-title">鑱旂郴</view> </view> </view> @@ -54,12 +84,19 @@ <view class="li-title">鍑虹増鏃堕棿锛�</view> <view class="li-content">{{bookDetail.publicationDate}}</view> </view> - <view class="message-li" wx:if="{{bookClass.length}}" style="height: 80rpx"> + <view + class="message-li" + wx:if="{{bookClass.length}}" + style="height: 80rpx" + > <view class="li-title">鍥句功鍒嗙被锛�</view> <view class="class-name showTow">{{bookClass}}</view> </view> </view> - <image src="/static/images/bookService/detail/square.png" class="right-background" /> + <image + src="/static/images/bookService/detail/square.png" + class="right-background" + /> </view> </view> <!-- 閿�鍞俊鎭� --> @@ -68,12 +105,19 @@ <!-- 鐢靛瓙涔﹀敭浠� --> <view class="electron-price" wx:if="{{bookDetail.price}}"> <view> - <image src="/static/images/bookService/detail/electon-price.png" /> + <image + src="/static/images/bookService/detail/electon-price.png" + /> </view> <view class="price"> - <view class="price-text">{{bookDetail.price == '0.00' ? '鍏嶈垂' : '楼'+ - bookDetail.price}}</view> - <view class="price-old" wx:if="{{bookDetail.oldPrice != '0.00'}}">楼{{bookDetail.oldPrice}} + <view class="price-text" + >{{bookDetail.price == '0.00' ? '鍏嶈垂' : '楼'+ + bookDetail.price}}</view + > + <view + class="price-old" + wx:if="{{bookDetail.oldPrice != '0.00'}}" + >楼{{bookDetail.oldPrice}} </view> </view> <view> </view> @@ -81,27 +125,72 @@ <!-- 绾歌川涔﹀敭浠� --> <view class="paper-price" wx:if="{{bookDetail.paperPrice}}"> <view> - <image src="/static/images/bookService/detail/paper-price.png" /> + <image + src="/static/images/bookService/detail/paper-price.png" + /> </view> - <view class="price">{{bookDetail.paperPrice == '0.00' ? '鍏嶈垂' : - '楼'+bookDetail.paperPrice}}</view> + <view class="price" + >{{bookDetail.paperPrice == '0.00' ? '鍏嶈垂' : + '楼'+bookDetail.paperPrice}}</view + > </view> </view> <!-- 缃戝簵 --> <view class="book-web"> - <image src="/static/images/bookService/detail/jd.png" wx:if="{{bookDetail.JDLink}}" bind:tap="goShop" data-link="{{bookDetail.JDLink}}" data-type="jd" /> - <image class="tmall-image" src="/static/images/bookService/detail/tmall.png" bind:tap="goShop" data-link="{{bookDetail.tmallLink}}" wx:if="{{bookDetail.tmallLink}}" /> - <image src="/static/images/bookService/detail/dangdang.png" bind:tap="goShop" data-link="{{bookDetail.dangdangLink}}" wx:if="{{bookDetail.dangdangLink}}" /> - <image src="/static/images/bookService/detail/weidian.png" bind:tap="goShop" data-link="{{bookDetail.weidianLink}}" wx:if="{{bookDetail.weidianLink}}" /> + <image + src="/static/images/bookService/detail/jd.png" + wx:if="{{bookDetail.JDLink}}" + bind:tap="goShop" + data-link="{{bookDetail.JDLink}}" + data-type="jd" + /> + <image + class="tmall-image" + src="/static/images/bookService/detail/tmall.png" + bind:tap="goShop" + data-link="{{bookDetail.tmallLink}}" + wx:if="{{bookDetail.tmallLink}}" + /> + <image + src="/static/images/bookService/detail/dangdang.png" + bind:tap="goShop" + data-link="{{bookDetail.dangdangLink}}" + wx:if="{{bookDetail.dangdangLink}}" + /> + <image + src="/static/images/bookService/detail/weidian.png" + bind:tap="goShop" + data-link="{{bookDetail.weidianLink}}" + wx:if="{{bookDetail.weidianLink}}" + /> </view> </view> </view> <view class="book-resource"> - <t-tabs value="{{tabValue}}" bind:change="onTabsChange" t-class="custom-tabs" t-class-content="custom-panel" class="tab-class"> - <t-tab-panel label="鍥句功淇℃伅" icon="{{ tabValue == 'brief' ? briefIconClick : briefIcon}}" value="brief" style="{{tabPanelstyle}}"> - <book-brief content="{{bookDetail.content}}" catalogue="{{bookDetail.catalogue}}" authorIntroduction="{{bookDetail.authorIntroduction}}" wx:if="{{bookDetail.content || bookDetail.authorIntroduction}}"></book-brief> - <view wx:if="{{!bookDetail.content && !bookDetail.authorIntroduction && !loading}}" class="noData"> + <t-tabs + value="{{tabValue}}" + bind:change="onTabsChange" + t-class="custom-tabs" + t-class-content="custom-panel" + class="tab-class" + > + <t-tab-panel + label="鍥句功淇℃伅" + icon="{{ tabValue == 'brief' ? briefIconClick : briefIcon}}" + value="brief" + style="{{tabPanelstyle}}" + > + <book-brief + content="{{bookDetail.content}}" + catalogue="{{bookDetail.catalogue}}" + authorIntroduction="{{bookDetail.authorIntroduction}}" + wx:if="{{bookDetail.content || bookDetail.authorIntroduction}}" + ></book-brief> + <view + wx:if="{{!bookDetail.content && !bookDetail.authorIntroduction && !loading}}" + class="noData" + > <!-- <t-empty icon="folder-open" description="鏆傛棤鏁版嵁" /> --> <empty /> </view> @@ -113,38 +202,138 @@ style="{{tabPanelstyle}}" > </t-tab-panel> --> - <t-tab-panel label="鏁欏璧勬簮" icon="{{tabValue == 'jsek_teachingResources' ? teachResourcesClickIcon : teachResourcesIcon}}" value="jsek_teachingResources" class="{{loading ? 'loading': ''}}"> + <t-tab-panel + label="鏁欏璧勬簮" + icon="{{tabValue == 'jsek_teachingResources' ? teachResourcesClickIcon : teachResourcesIcon}}" + value="jsek_teachingResources" + class="{{loading ? 'loading': ''}}" + > <view wx:if="{{!loading && applyState}}"> - <teach-resource applyState="{{applyState}}" rejectCause="{{rejectCause}}" deadline="{{deadline}}" bind:applyResource="applyResource" md5List="{{md5List}}" applyResourceLoading="{{applyResourceLoading}}" bind:uploadFile="uploadFile"></teach-resource> - <tree id="teach-tree" openIds="{{openTeachids}}" bookInfo="{{bookDetail}}" treeList="{{teach}}" tab="{{tabValue}}" applyState="{{applyState}}" deadline="{{deadline}}" bind:downloadTeach="downloadTeach" bind:handleTree="handleTree" openTeachids="{{openTeachids}}" wx:if="{{teach.length}}" isShoppingCart="isShoppingCart" bind:updateCloudLearning="updateCloudLearning"></tree> + <teach-resource + applyState="{{applyState}}" + rejectCause="{{rejectCause}}" + deadline="{{deadline}}" + bind:applyResource="applyResource" + md5List="{{md5List}}" + applyResourceLoading="{{applyResourceLoading}}" + bind:uploadFile="uploadFile" + ></teach-resource> + <tree + id="teach-tree" + openIds="{{openTeachids}}" + bookInfo="{{bookDetail}}" + treeList="{{teach}}" + tab="{{tabValue}}" + applyState="{{applyState}}" + deadline="{{deadline}}" + bind:downloadTeach="downloadTeach" + bind:handleTree="handleTree" + openTeachids="{{openTeachids}}" + wx:if="{{teach.length}}" + isShoppingCart="isShoppingCart" + bind:updateCloudLearning="updateCloudLearning" + ></tree> </view> <view wx:if="{{loading}}" style="width: 100%; height: min-content"> - <t-skeleton row-col="{{rowCol}}" theme="paragraph" animation="gradient" loading="{{loading}}"></t-skeleton> + <t-skeleton + row-col="{{rowCol}}" + theme="paragraph" + animation="gradient" + loading="{{loading}}" + ></t-skeleton> </view> <view wx:if="{{noResources && !loading}}" class="noData"> <empty /> </view> </t-tab-panel> - <t-tab-panel label="浜戝涔�" icon="{{tabValue == 'jsek_cloudLearning' ? learnResourceClickIcon : learnResourceIcon}}" value="jsek_cloudLearning" style="{{tabPanelstyle}}"> + <t-tab-panel + label="浜戝涔�" + icon="{{tabValue == 'jsek_cloudLearning' ? learnResourceClickIcon : learnResourceIcon}}" + value="jsek_cloudLearning" + style="{{tabPanelstyle}}" + > <view wx:if="{{!loading && learn.length}}"> - <learn-resource bind:getFreeResource="getFreeResource" bind:allAddShoppiingCar="allAddShoppiingCar" id="learn-resource" buyResourceData="{{buyResourceData}}" bookId="{{bookDetail.id}}" isshowDrawBtn="{{isshowDrawBtn}}" successOrderNumber="{{successOrderNumber}}" isGoBuyResource="{{isGoBuyResource}}" isShowBuyCloundMenu="{{isShowBuyCloundMenu}}" isShowBuyCloundBtn="{{isShowBuyCloundBtn}}" bind:buyCloudLearnClass="buyCloudLearnClass" learnTaskData="{{learnTaskData}}"></learn-resource> + <learn-resource + bind:getFreeResource="getFreeResource" + bind:allAddShoppiingCar="allAddShoppiingCar" + id="learn-resource" + buyResourceData="{{buyResourceData}}" + bookId="{{bookDetail.id}}" + isshowDrawBtn="{{isshowDrawBtn}}" + successOrderNumber="{{successOrderNumber}}" + isGoBuyResource="{{isGoBuyResource}}" + isShowBuyCloundMenu="{{isShowBuyCloundMenu}}" + isShowBuyCloundBtn="{{isShowBuyCloundBtn}}" + bind:buyCloudLearnClass="buyCloudLearnClass" + learnTaskData="{{learnTaskData}}" + ></learn-resource> - <tree id="tree" openIds="{{openLearnids}}" bookInfo="{{bookDetail}}" tab="{{tabValue}}" treeList="{{learn}}" learnList="{{learn}}" buyIds="{{buyIdList}}" openLearnids="{{openLearnids}}" cloundMenuIsBuy="{{cloundMenuIsBuy}}" learnMenu="{{learnMenu}}" isCloundHaveSaleMethod="{{isCloundHaveSaleMethod}}" bind:updateShoppingCartHidden="updateShoppingCartHidden" bind:updateCloudLearning="updateCloudLearning" bind:getCloundIsBuy="getCloundIsBuy"></tree> + <tree + id="tree" + openIds="{{openLearnids}}" + bookInfo="{{bookDetail}}" + tab="{{tabValue}}" + treeList="{{learn}}" + learnList="{{learn}}" + buyIds="{{buyIdList}}" + openLearnids="{{openLearnids}}" + cloundMenuIsBuy="{{cloundMenuIsBuy}}" + learnMenu="{{learnMenu}}" + isCloundHaveSaleMethod="{{isCloundHaveSaleMethod}}" + bind:updateShoppingCartHidden="updateShoppingCartHidden" + bind:updateCloudLearning="updateCloudLearning" + bind:getCloundIsBuy="getCloundIsBuy" + ></tree> </view> <view wx:if="{{noResources && !loading}}" class="noData"> <empty /> </view> </t-tab-panel> - <t-tab-panel label="浜戞祴璇�" icon="{{tabValue == 'questionBank' ? testResourceClickIocn : testResourceIocn}}" value="questionBank" style="{{tabPanelstyle}}"> + <t-tab-panel + label="浜戞祴璇�" + icon="{{tabValue == 'questionBank' ? testResourceClickIocn : testResourceIocn}}" + value="questionBank" + style="{{tabPanelstyle}}" + > <view wx:if="{{!loading}}"> - <test-resource id="test-resource" list="{{test}}" bankSaleData="{{bankSaleData}}" isBuyBank="{{isBuyBank}}" isShoppingBank="{{isShoppingBank}}" bookInfo="{{bookDetail}}" openIds="{{openLearnids}}" mockData="{{mockData}}" tab="{{tabValue}}" storeInfo="{{options.storeInfo}}" jslx="{{jslx}}" bind:buyMock="buyMock" bind:buyBank="buyBank" bind:handleShoppingBank="handleShoppingBank"></test-resource> + <test-resource + id="test-resource" + list="{{test}}" + bankSaleData="{{bankSaleData}}" + isBuyBank="{{isBuyBank}}" + isShoppingBank="{{isShoppingBank}}" + bookInfo="{{bookDetail}}" + openIds="{{openLearnids}}" + mockData="{{mockData}}" + tab="{{tabValue}}" + storeInfo="{{options.storeInfo}}" + jslx="{{jslx}}" + bind:buyMock="buyMock" + bind:buyBank="buyBank" + bind:handleShoppingBank="handleShoppingBank" + ></test-resource> </view> </t-tab-panel> - <t-tab-panel label="浜戠瑪璁�" icon="{{tabValue == 'jsek_note' ? noteClickIcon: noteIcon}}" value="jsek_note" style="{{tabPanelstyle}}"> + <t-tab-panel + label="浜戠瑪璁�" + icon="{{tabValue == 'jsek_note' ? noteClickIcon: noteIcon}}" + value="jsek_note" + style="{{tabPanelstyle}}" + > <note bookInfo="{{bookDetail}}" id="note" class="note-list"></note> </t-tab-panel> - <t-tab-panel label="鐩稿叧鍥句功" icon="{{tabValue == 'related_books' ? linkClickIcon: linkIcon}}" value="related_books" style="{{tabPanelstyle}}"> - <related-books relatedBookData="{{relatedBookData}}" relatedBookLoading="{{relatedBookLoading}}" noRelatedBookData="{{noRelatedBookData}}" bind:goBookDetails="goBookDetails"></related-books> + <t-tab-panel + label="鐩稿叧鍥句功" + icon="{{tabValue == 'related_books' ? linkClickIcon: linkIcon}}" + value="related_books" + style="{{tabPanelstyle}}" + > + <related-books + relatedBookData="{{relatedBookData}}" + relatedBookLoading="{{relatedBookLoading}}" + noRelatedBookData="{{noRelatedBookData}}" + bind:goBookDetails="goBookDetails" + ></related-books> </t-tab-panel> </t-tabs> </view> @@ -152,7 +341,11 @@ <movable-view class="movable-view" :x="{{x}}" :y="{{y}}" direction="all"> <view class="applyBox" bindtap="goApply"> <view class="box"> - <t-image src="/static/images/home/yangshuForm1.png" mode="heightFix" class="img" /> + <t-image + src="/static/images/home/yangshuForm1.png" + mode="heightFix" + class="img" + /> <view class="num" wx:if="{{num > 0}}">{{num}}</view> </view> </view> @@ -166,34 +359,77 @@ </view> </t-dialog> <!-- 鎴戣寤鸿寮圭獥 --> - <suggest class="suggest-component" id="suggest-component" bookIcon="{{bookDetail.icon}}" bookName="{{bookDetail.name}}"></suggest> + <suggest + class="suggest-component" + id="suggest-component" + bookIcon="{{bookDetail.icon}}" + bookName="{{bookDetail.name}}" + ></suggest> <!-- 鏁欏璧勬簮涓嬭浇鎻愮ず寮圭獥 --> - <t-dialog class="teachDownloadDialog" visible="{{isShowTeachDownload}}" title="鎻愮ず" content="璇峰墠寰�PC绔笅杞�" confirm-btn="{{ confirmBtn }}" bind:confirm="closeTeachDownload" /> + <t-dialog + class="teachDownloadDialog" + visible="{{isShowTeachDownload}}" + title="鎻愮ず" + content="璇峰墠寰�PC绔笅杞�" + confirm-btn="{{ confirmBtn }}" + bind:confirm="closeTeachDownload" + /> <!-- 璐拱鎸夐挳 --> <view class="box-bottom"> <view class="bottom-btn" bind:tap="appplyElectronicBook"> <view> - <t-image loading="" src="/static/images/bookService/detail/ebook.png"></t-image> + <t-image + loading="" + src="/static/images/bookService/detail/ebook.png" + ></t-image> </view> <view class="btn-text">鐢靛瓙鏍蜂功鐢宠</view> </view> <view class="bottom-btn" bind:tap="appplyPaperBook"> <view> - <t-image src="/static/images/bookService/detail/paper-book.png"></t-image> + <t-image + src="/static/images/bookService/detail/paper-book.png" + ></t-image> </view> <view class="btn-text">绾歌川鏍蜂功鐢宠</view> </view> - <view class="{{!bookBuy && bookDetail.isSell ? 'bottom-btn tryRead' : 'bottom-btn try'}}" bind:tap="goRead" wx:if="{{!bookBuy || applicationState == 'overdue'}}"> + <view + class="{{!bookBuy && bookDetail.isSell ? 'bottom-btn tryRead' : 'bottom-btn try'}}" + bind:tap="goRead" + data-type="freeFile" + wx:if="{{!bookBuy || applicationState == 'overdue'}}" + > <view> <t-image src="/static/images/bookService/detail/shidu.png"></t-image> </view> <view class="btn-text">璇曡</view> </view> - <view class="shopCar shopCarColor" bind:tap="addBookShopcCar" wx:if="{{!bookBuy && bookDetail.price !== '0.00' && bookDetail.isSell == '1'}}">鍔犲叆璐墿杞�</view> - <view class="buy buyColor" bind:tap="buyBtn" wx:if="{{!bookBuy && bookDetail.price !== '0.00' && bookDetail.isSell == '1'}}">绔嬪嵆璐拱</view> - <view class="buy receiveColor" bind:tap="buyBtn" wx:if="{{!bookBuy && bookDetail.price == '0.00' && bookDetail.isSell == '1'}}">鍏嶈垂棰嗗彇</view> - <view class="buy read" bind:tap="goRead" wx:if="{{bookBuy || applicationState == 'Normal'}}">绔嬪嵆鏌ョ湅</view> + <view + class="shopCar shopCarColor" + bind:tap="addBookShopcCar" + wx:if="{{!bookBuy && bookDetail.price !== '0.00' && bookDetail.isSell == '1'}}" + >鍔犲叆璐墿杞�</view + > + <view + class="buy buyColor" + bind:tap="buyBtn" + wx:if="{{!bookBuy && bookDetail.price !== '0.00' && bookDetail.isSell == '1'}}" + >绔嬪嵆璐拱</view + > + <view + class="buy receiveColor" + bind:tap="buyBtn" + wx:if="{{!bookBuy && bookDetail.price == '0.00' && bookDetail.isSell == '1'}}" + >鍏嶈垂棰嗗彇</view + > + <view + class="buy read" + bind:tap="goRead" + data-type="file" + wx:if="{{bookBuy || applicationState == 'Normal'}}" + >绔嬪嵆鏌ョ湅</view + > </view> </view> <view wx:if="{{dialogBox}}"> @@ -203,12 +439,19 @@ <view class="row-info"> <view class="body"> <view class="dialog-title">鏂囦欢涓婁紶</view> - <view style="width: 100%; height: 2rpx; background-color: #f4f4f4"></view> + <view + style="width: 100%; height: 2rpx; background-color: #f4f4f4" + ></view> <view class="from-item"> <view class="label"> <text class="icon">*</text>璧勬簮鍚嶇О: </view> <view class="item-content"> <view class="inputBox1"> - <t-input placeholder="杈撳叆璧勬簮鍚嶇О" borderless value="{{resourceInfo.resourceName}}" bindchange="onNameInput" /> + <t-input + placeholder="杈撳叆璧勬簮鍚嶇О" + borderless + value="{{resourceInfo.resourceName}}" + bindchange="onNameInput" + /> </view> </view> </view> @@ -218,8 +461,25 @@ <!-- <view class="inputBox1"> <t-input placeholder="杈撳叆璧勬簮绫诲瀷" borderless value="{{resourceInfo.fileType}}" bindchange="onFileTypeInput" /> </view> --> - <t-cell class="mb-16" title="" arrow hover note="{{resourceInfo.fileType}}" bind:click="onResourcePicker" /> - <t-picker visible="{{resourceVisible}}" value="{{resourceValue}}" data-key="resource" title="閫夋嫨璧勬簮绫诲瀷" cancelBtn="鍙栨秷" confirmBtn="纭" usingCustomNavbar bindchange="onPickerChange" bindcancel="onPickerCancel"> + <t-cell + class="mb-16" + title="" + arrow + hover + note="{{resourceInfo.fileType}}" + bind:click="onResourcePicker" + /> + <t-picker + visible="{{resourceVisible}}" + value="{{resourceValue}}" + data-key="resource" + title="閫夋嫨璧勬簮绫诲瀷" + cancelBtn="鍙栨秷" + confirmBtn="纭" + usingCustomNavbar + bindchange="onPickerChange" + bindcancel="onPickerCancel" + > <t-picker-item options="{{fileTypeList}}" /> </t-picker> </view> @@ -228,24 +488,51 @@ <view class="label">鏂囦欢鎻忚堪:</view> <view class="item-content"> <view class="inputBox1"> - <t-textarea placeholder="璇疯緭鍏ユ枃浠舵弿杩�" value="{{resourceInfo.description}}" disableDefaultPadding="{{true}}" autosize="{{true}}" maxlength="300" indicator bind:change="textareaChange" /> + <t-textarea + placeholder="璇疯緭鍏ユ枃浠舵弿杩�" + value="{{resourceInfo.description}}" + disableDefaultPadding="{{true}}" + autosize="{{true}}" + maxlength="300" + indicator + bind:change="textareaChange" + /> </view> </view> </view> <view class="from-item"> <view class="label"> <text class="icon">*</text>涓婁紶鏂囦欢: </view> <view class="item-content"> - <t-button size="small" class="right-btn" bind:tap="uploadPicture" wx:if="{{isShowUp}}">鐐瑰嚮涓婁紶</t-button> - <view wx:if="{{!isShowUp && fileList.length > 0}}" class="fileList"> + <t-button + size="small" + class="right-btn" + bind:tap="uploadPicture" + wx:if="{{isShowUp}}" + >鐐瑰嚮涓婁紶</t-button + > + <view + wx:if="{{!isShowUp && fileList.length > 0}}" + class="fileList" + > <text class="fileName">{{fileList[0].name}}</text> - <image src="/static/images/bookService/detail/deleteHover.png" class="deleteBtn" data-md5="{{fileList[0].md5}}" bind:tap="handleRemove" /> + <image + src="/static/images/bookService/detail/deleteHover.png" + class="deleteBtn" + data-md5="{{fileList[0].md5}}" + bind:tap="handleRemove" + /> </view> </view> <view class="tip">娉細鏂囦欢澶у皬涓嶅緱瓒呰繃50MB</view> </view> <view class="from-item"> <view class="protocolBox"> - <t-checkbox label="鍚屾剰" icon="rectangle" checked="{{resourceInfo.agree}}" bind:change="onChange" /> + <t-checkbox + label="鍚屾剰" + icon="rectangle" + checked="{{resourceInfo.agree}}" + bind:change="onChange" + /> <text class="wait" bind:tap="getAgreement">銆婃巿鏉冨悓鎰忎功銆�</text> </view> </view> @@ -260,15 +547,25 @@ </view> <view class="popupBox"> - <t-popup visible="{{protocolShow}}" bind:visible-change="onVisibleChange" placement="center"> + <t-popup + visible="{{protocolShow}}" + bind:visible-change="onVisibleChange" + placement="center" + > <view class="block"> <view class="protocol"> <rich-text space="emsp" nodes="{{protocolTxt}}" class="content" /> </view> - <t-icon t-class="close-btn" name="close-circle" size="32" color="#fff" bind:tap="onCloseProtocol" /> + <t-icon + t-class="close-btn" + name="close-circle" + size="32" + color="#fff" + bind:tap="onCloseProtocol" + /> </view> </t-popup> </view> <!-- <view class="loading" wx:if="{{pageLoading}}"> <t-loading loading="{{pageLoading}}" size="40"></t-loading> -</view> --> \ No newline at end of file +</view> --> diff --git a/pages/bookExhibitionDetails/index.js b/pages/bookExhibitionDetails/index.js index 0642cf8..8f4057a 100644 --- a/pages/bookExhibitionDetails/index.js +++ b/pages/bookExhibitionDetails/index.js @@ -39,23 +39,8 @@ this.setData({ passId: options.id }) - const token = wx.getStorageSync(app.config.tokenKey) - if (!token) { - loginInfo(app, (data) => { - if (data) { - this.bookExhibitionGet(this.data.passId) - this.getBookExhibitionDetails() - } else { - this.bookExhibitionGet(this.data.passId) - this.getBookExhibitionDetails() - } - }) - - } else { - this.bookExhibitionGet(this.data.passId) - this.getBookExhibitionDetails() - } - + this.bookExhibitionGet(this.data.passId) + this.getBookExhibitionDetails() }, /** diff --git a/pages/digitalCourses/digitalCoursesDetails/index.js b/pages/digitalCourses/digitalCoursesDetails/index.js index 942e574..36a5698 100644 --- a/pages/digitalCourses/digitalCoursesDetails/index.js +++ b/pages/digitalCourses/digitalCoursesDetails/index.js @@ -13,6 +13,7 @@ loginInfo } from '../../../assets/js/login'; import wxbarcode from 'wxbarcode' + Page({ /** @@ -166,24 +167,20 @@ bookId: options.id, bookPath: parentPath.join('\\') }) - const token = wx.getStorageSync(app.config.tokenKey) - if (!token) { - loginInfo(app, (data) => { - if (data) { - this.digitalCoursesDetailsGet(options.id) - this.getPlayerList() - this.getType() - } else {} - }) - } this.digitalCoursesDetailsGet(options.id) this.getPlayerList() this.getType() - // this.setData({ - // userName: JSON.parse(wx.getStorageSync(app.config.userInfoKey)).name, - // }) }, - + logInFun(callback) { + loginInfo(app, (data) => { + if (data) { + this.digitalCoursesDetailsGet(options.id) + this.getPlayerList() + this.getType() + callback() + } + }) + }, /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚 */ @@ -831,48 +828,57 @@ //瀛︿範绗旇 //鍦ㄧ嚎鎻愰棶 // 鍥句功娣诲姞璐墿杞� - async addBookShopcCar() { - if (!this.data.expire) { - const shoppingCartGetId = []; - let query = { - start: 0, - size: 9999, - filterList: [], - searchList: [], - }; - const res = await app.MG.store.getShoppingCartProductList(query); - res.datas.forEach((item) => { - shoppingCartGetId.push(item.saleMethod.id); - }); - const determine = shoppingCartGetId.some( - (item) => item == this.data.digitalsData.defaultSaleMethodId - ); - if (!determine) { + addBookShopcCar() { + const addFun = async () => { + if (!this.data.expire) { + const shoppingCartGetId = []; let query = { - requests: [{ - saleMethodId: this.data.digitalsData.defaultSaleMethodId, - storeEventId: null, - agentCode: "鐢靛瓙涔�", - }, ], + start: 0, + size: 9999, + filterList: [], + searchList: [], }; - const addRes = app.MG.store.addShoppingCart(query); - this.showSuccessToast(); + const res = await app.MG.store.getShoppingCartProductList(query); + res.datas.forEach((item) => { + shoppingCartGetId.push(item.saleMethod.id); + }); + const determine = shoppingCartGetId.some( + (item) => item == this.data.digitalsData.defaultSaleMethodId + ); + if (!determine) { + let query = { + requests: [{ + saleMethodId: this.data.digitalsData.defaultSaleMethodId, + storeEventId: null, + agentCode: "鐢靛瓙涔�", + }, ], + }; + const addRes = app.MG.store.addShoppingCart(query); + this.showSuccessToast(); + } else { + Toast({ + context: this, + selector: "#t-toast", + message: "璇ヨ绋嬪凡鍦ㄨ喘鐗╄溅锛岃鍕块噸澶嶆坊鍔�", + theme: "warning", + direction: "column", + }); + } } else { - Toast({ - context: this, - selector: "#t-toast", - message: "璇ヨ绋嬪凡鍦ㄨ喘鐗╄溅锛岃鍕块噸澶嶆坊鍔�", - theme: "warning", - direction: "column", + wx.showToast({ + title: "鍟嗗搧涓嶅湪鏈夋晥鏈�", + icon: "none", + duration: 1000, }); } - } else { - wx.showToast({ - title: "鍟嗗搧涓嶅湪鏈夋晥鏈�", - icon: "none", - duration: 1000, - }); } + const token = wx.getStorageSync(app.config.tokenKey) + if (!token) { + this.logInFun(() => {}) + } else { + addFun() + } + }, showSuccessToast() { Toast({ @@ -886,51 +892,60 @@ //璐拱鎸夐挳 async buyBtn() { - if (!this.data.expire) { - let bookOrdersId = ""; - let query = { - remarks: "鐢靛瓙涔�", - requests: [{ - saleMethodId: this.data.digitalsData.defaultSaleMethodId, - count: 1, - }, ], - }; - // 鍙戣捣璁㈠崟鍒濆鍖栬姹傚苟绛夊緟缁撴灉 - const res = await app.MG.store.initOrder(query); - // 鑾峰彇璁㈠崟鍙峰苟璧嬪�肩粰 orderNumber.value - bookOrdersId = res.orderNumber; - // 妫�鏌ヨ鍗曞彿鏄惁瀛樺湪 - if (bookOrdersId) { - if (this.data.digitalsData.price == "0.00") { - app.MG.store - .confirmOrder({ - orderNum: bookOrdersId, - }) - .then((res) => { - if (res) { - this.digitalCoursesDetailsGet(this.data.digitalsData.id); - wx.showToast({ - title: "棰嗗彇鎴愬姛", - icon: "none", - duration: 1000, - }); - this.digitalCoursesDetailsGet(this.data.bookId); - } + const buyFun = async () => { + if (!this.data.expire) { + let bookOrdersId = ""; + let query = { + remarks: "鐢靛瓙涔�", + requests: [{ + saleMethodId: this.data.digitalsData.defaultSaleMethodId, + count: 1, + }, ], + }; + // 鍙戣捣璁㈠崟鍒濆鍖栬姹傚苟绛夊緟缁撴灉 + const res = await app.MG.store.initOrder(query); + // 鑾峰彇璁㈠崟鍙峰苟璧嬪�肩粰 orderNumber.value + bookOrdersId = res.orderNumber; + // 妫�鏌ヨ鍗曞彿鏄惁瀛樺湪 + if (bookOrdersId) { + if (this.data.digitalsData.price == "0.00") { + app.MG.store + .confirmOrder({ + orderNum: bookOrdersId, + }) + .then((res) => { + if (res) { + this.digitalCoursesDetailsGet(this.data.digitalsData.id); + wx.showToast({ + title: "棰嗗彇鎴愬姛", + icon: "none", + duration: 1000, + }); + this.digitalCoursesDetailsGet(this.data.bookId); + } + }); + } else { + const url = "/pages/cart/paymentPage/index?orderNumber=" + bookOrdersId + '&onNorderSaleMethod=' + res.saleMethodLinks[0].orderSaleMethod.id; + wx.navigateTo({ + url, }); - } else { - const url = "/pages/cart/paymentPage/index?orderNumber=" + bookOrdersId + '&onNorderSaleMethod=' + res.saleMethodLinks[0].orderSaleMethod.id; - wx.navigateTo({ - url, - }); - } - } else {} - } else { - wx.showToast({ - title: "鍟嗗搧涓嶅湪鏈夋晥鏈�", - icon: "none", - duration: 1000, - }); + } + } else {} + } else { + wx.showToast({ + title: "鍟嗗搧涓嶅湪鏈夋晥鏈�", + icon: "none", + duration: 1000, + }); + } } + const token = wx.getStorageSync(app.config.tokenKey) + if (!token) { + this.logInFun(() => {}) + } else { + buyFun() + } + }, @@ -1097,40 +1112,48 @@ }, onCertificate() { - if (!this.data.isBuy) { - wx.showToast({ - title: "璇峰厛璐拱锛屼綋楠屽畬鏁存湇鍔�", - icon: "none", - duration: 1000, + const cateFun = () => { + if (!this.data.isBuy) { + wx.showToast({ + title: "璇峰厛璐拱锛屼綋楠屽畬鏁存湇鍔�", + icon: "none", + duration: 1000, + }); + return false + } + if (!this.data.isLearn) { + wx.showToast({ + title: "鎮ㄧ殑瀛︿範浠诲姟杩樻湭瀹屾垚锛屾殏涓嶈兘鐢宠璇佷功锛屽姞娌瑰摝锛�", + icon: "none", + duration: 1000, + }); + return false + } + if (this.data.isCertificate && this.data.isCertificate.state == 'WaitAudit') { + wx.showToast({ + title: "鎮ㄧ敵璇风殑璇佷功姝e湪瀹℃牳涓�", + icon: "none", + duration: 1000, + }); + return false + } + var page = getCurrentPages().pop(); // 鑾峰彇褰撳墠椤甸潰瀹炰緥 + page.setData({ + // 鍔ㄦ�佽缃姝㈡粴鍔ㄧ殑鏍峰紡 + disableScrollStyle: 'overflow: hidden;' }); - return false + this.setData({ + dialogBox: true, + scrollJudge: '' + }) } - if (!this.data.isLearn) { - wx.showToast({ - title: "鎮ㄧ殑瀛︿範浠诲姟杩樻湭瀹屾垚锛屾殏涓嶈兘鐢宠璇佷功锛屽姞娌瑰摝锛�", - icon: "none", - duration: 1000, - }); - return false - } - if (this.data.isCertificate && this.data.isCertificate.state == 'WaitAudit') { - wx.showToast({ - title: "鎮ㄧ敵璇风殑璇佷功姝e湪瀹℃牳涓�", - icon: "none", - duration: 1000, - }); - return false + const token = wx.getStorageSync(app.config.tokenKey) + if (!token) { + this.logInFun(() => {}) + } else { + cateFun() } - var page = getCurrentPages().pop(); // 鑾峰彇褰撳墠椤甸潰瀹炰緥 - page.setData({ - // 鍔ㄦ�佽缃姝㈡粴鍔ㄧ殑鏍峰紡 - disableScrollStyle: 'overflow: hidden;' - }); - this.setData({ - dialogBox: true, - scrollJudge: '' - }) }, closeDialog() { this.setData({ @@ -1317,40 +1340,7 @@ } }, setCoolect() { - // 棣栭〉娴嬭瘯鐧诲綍鍔熻兘锛屽悗缁敞閲� - // 妫�鏌ョ櫥褰曠姸鎬� - const token = wx.getStorageSync(app.config.tokenKey) - if (!token) { - loginInfo(app, (data) => { - // 濡傛灉涓嶆槸绗竴娆$櫥褰曪紝浼氭墽琛屽洖璋� - if (data) { - if (this.data.digitalsData.isFavourite) { - app.MG.store - .delProductLink({ - productIds: [this.data.digitalsData.id], - linkType: 'Favoriteclass' - }) - .then(() => { - this.setData({ - "digitalsData.isFavourite": false - }) - }) - } else { - let params = { - productIds: [this.data.digitalsData.id], - linkType: 'Favoriteclass' - } - app.MG.store.addProductLink(params).then((res) => { - this.setData({ - "digitalsData.isFavourite": true - }) - }) - } - } else { - // 鍑虹幇閿欒锛岃繑鍥瀎alse - } - }) - } else { + const collectFun = () => { if (this.data.digitalsData.isFavourite) { app.MG.store .delProductLink({ @@ -1374,6 +1364,12 @@ }) } } + const token = wx.getStorageSync(app.config.tokenKey) + if (!token) { + this.logInFun(() => {}) + } else { + collectFun() + } }, //璇佷功鏌ョ湅 diff --git a/pages/digitalCourses/index.js b/pages/digitalCourses/index.js index 10b6d06..204a643 100644 --- a/pages/digitalCourses/index.js +++ b/pages/digitalCourses/index.js @@ -1,4 +1,7 @@ // pages/digitalCourses/index.js +import { + loginInfo +} from '../../assets/js/login'; const app = getApp() import { setSessionGuid, @@ -68,7 +71,8 @@ }); } this.getCourseTypeListList() - this.getShoppingCartList() + const token = wx.getStorageSync(app.config.tokenKey) + if (token) this.getShoppingCartList() }, /** @@ -288,55 +292,66 @@ }) }, addCart(e) { - const { - item - } = e.currentTarget.dataset; - wx.showToast({ - title: "寤鸿涓�", - icon: 'none', - duration: 1000 - }) - if (wx.getStorageSync(app.config.tokenKey)) { - let query = { - start: 0, - size: 999, - filterList: [], - searchList: [] - } - try { - if ( - this.data.shoppingCartGetId.includes( - item.defaultSaleMethodId - ) - ) { - wx.showToast({ - title: "璇ヨ绋嬪凡鍦ㄨ喘鐗╄溅锛岃鍕块噸澶嶆坊鍔�", - icon: 'none', - duration: 1000 - }) - } else { - let query = { - requests: [{ - saleMethodId: item.defaultSaleMethodId, - storeEventId: null, - agentCode: '鏁板瓧璇剧▼' - }] - } - const addRes = app.MG.store.addShoppingCart(query) - if (addRes) { + const addFun = () => { + const { + item + } = e.currentTarget.dataset; + wx.showToast({ + title: "寤鸿涓�", + icon: 'none', + duration: 1000 + }) + if (wx.getStorageSync(app.config.tokenKey)) { + let query = { + start: 0, + size: 999, + filterList: [], + searchList: [] + } + try { + if ( + this.data.shoppingCartGetId.includes( + item.defaultSaleMethodId + ) + ) { wx.showToast({ - title: "娣诲姞鎴愬姛", - icon: 'success', + title: "璇ヨ绋嬪凡鍦ㄨ喘鐗╄溅锛岃鍕块噸澶嶆坊鍔�", + icon: 'none', duration: 1000 }) + } else { + let query = { + requests: [{ + saleMethodId: item.defaultSaleMethodId, + storeEventId: null, + agentCode: '鏁板瓧璇剧▼' + }] + } + const addRes = app.MG.store.addShoppingCart(query) + if (addRes) { + wx.showToast({ + title: "娣诲姞鎴愬姛", + icon: 'success', + duration: 1000 + }) + } + this.getShoppingCartList() } - this.getShoppingCartList() + } catch (error) { + console.error('鍑洪敊浜嗭細', error) } - } catch (error) { - console.error('鍑洪敊浜嗭細', error) } } - + const token = wx.getStorageSync(app.config.tokenKey) + if (token) { + addFun() + } else { + loginInfo(app, (data) => { + if (data) { + this.getShoppingCartList() + } + }) + } }, }) \ No newline at end of file diff --git a/pages/home/home.js b/pages/home/home.js index c8077fd..bdc8161 100644 --- a/pages/home/home.js +++ b/pages/home/home.js @@ -546,8 +546,6 @@ if (data) { this.addCartFun(info) this.registe() - } else { - this.addCartFun(info) } }) } @@ -711,28 +709,9 @@ }, onRetrievalPage() { - - // 棣栭〉娴嬭瘯鐧诲綍鍔熻兘锛屽悗缁敞閲� - // 妫�鏌ョ櫥褰曠姸鎬� - const token = wx.getStorageSync(app.config.tokenKey) - if (!token) { - loginInfo(app, (data) => { - // 濡傛灉涓嶆槸绗竴娆$櫥褰曪紝浼氭墽琛屽洖璋� - if (data) { - wx.navigateTo({ - url: '/pages/retrievalPage/index?searchVal=' + this.data.searchVal - }) - } else { - // 鍑虹幇閿欒锛岃繑鍥瀎alse - } - }) - } else { - wx.navigateTo({ - url: '/pages/retrievalPage/index?searchVal=' + this.data.searchVal - }) - } - - + wx.navigateTo({ + url: '/pages/retrievalPage/index?searchVal=' + this.data.searchVal + }) }, /** diff --git a/pages/home/home.wxml b/pages/home/home.wxml index 52ee429..6f4cbaa 100644 --- a/pages/home/home.wxml +++ b/pages/home/home.wxml @@ -1,22 +1,66 @@ <view class="container"> - <t-pull-down-refresh value="{{baseRefresh.value}}" loadingTexts="{{['涓嬫媺鍒锋柊', '鏉炬墜鍒锋柊', '姝e湪鍒锋柊', '鍒锋柊瀹屾垚']}}" bind:refresh="onPullDownRefresh" wx:if="{{!loading}}" bind:scroll="onScroll"> - <view class="background {{ isWhite ? 'white':''}}" style="padding-top: {{barHeight}}px"> + <t-pull-down-refresh + value="{{baseRefresh.value}}" + loadingTexts="{{['涓嬫媺鍒锋柊', '鏉炬墜鍒锋柊', '姝e湪鍒锋柊', '鍒锋柊瀹屾垚']}}" + bind:refresh="onPullDownRefresh" + wx:if="{{!loading}}" + bind:scroll="onScroll" + > + <view + class="background {{ isWhite ? 'white':''}}" + style="padding-top: {{barHeight}}px" + > <text class="text">浜笀鏅烘暀</text> </view> <view class="home-page-header"> <view class="bg"> - <image src="https://jsek.bnuic.com/home/image/home-bg.png" mode="heightFix" class="image" /> + <image + src="https://jsek.bnuic.com/home/image/home-bg.png" + mode="heightFix" + class="image" + /> </view> <view class="search"> - <image class="icon" src="/static/images/home/nav_icon_scan.png" bindtap="onIconScanTap" /> - <t-search t-class-input="t-search__input" t-class-input-container="t-search__input-container" placeholder="璇疯緭鍏ュ叧閿瘝/涔﹀悕/ISBN/浣滆��/椤圭洰璐熻矗浜�" leftIcon="" bind:submit="onRetrievalPage" model:value="{{searchVal}}"> - <t-icon slot="left-icon" prefix="wr" name="search" size="40rpx" color="#bbb" bind:tap="onRetrievalPage" /> + <image + class="icon" + src="/static/images/home/nav_icon_scan.png" + bindtap="onIconScanTap" + /> + <t-search + t-class-input="t-search__input" + t-class-input-container="t-search__input-container" + placeholder="璇疯緭鍏ュ叧閿瘝/涔﹀悕/ISBN/浣滆��/椤圭洰璐熻矗浜�" + leftIcon="" + bind:submit="onRetrievalPage" + model:value="{{searchVal}}" + > + <t-icon + slot="left-icon" + prefix="wr" + name="search" + size="40rpx" + color="#bbb" + bind:tap="onRetrievalPage" + /> </t-search> </view> <view class="swiper-wrap"> <!-- <t-swiper wx:if="{{bannerList.length > 0}}" list="{{bannerList}}" autoplay="{{autoplay}}" duration="{{duration}}" interval="{{interval}}" navigation="{{ { type: 'dots' } }}" height="380rpx" bind:click="navToActivityDetail" /> --> - <swiper interval="5000" indicator-dots="true" autoplay="true" circular="true" class="swiper"> - <swiper-item wx:for="{{bannerList}}" wx:for-index="index" wx:key="index" data-info="{{item}}" bindtap="navToActivityDetail" class="swiper-item"> + <swiper + interval="5000" + indicator-dots="true" + autoplay="true" + circular="true" + class="swiper" + > + <swiper-item + wx:for="{{bannerList}}" + wx:for-index="index" + wx:key="index" + data-info="{{item}}" + bindtap="navToActivityDetail" + class="swiper-item" + > <view class="swiperItem"> <image src="{{item.value}}" mode="widthFix" class="img" /> </view> @@ -25,37 +69,81 @@ </view> </view> <view class="home-page-menu"> - <t-grid class="t-grid-block" theme="card" border="{{border}}" column="{{5}}"> - <t-grid-item wx:for="{{tabList}}" wx:for-index="index" wx:key="index" text="{{item.text}}" image="{{item.icon}}" data-info="{{item}}" bindtap="toPages" /> + <t-grid + class="t-grid-block" + theme="card" + border="{{border}}" + column="{{5}}" + > + <t-grid-item + wx:for="{{tabList}}" + wx:for-index="index" + wx:key="index" + text="{{item.text}}" + image="{{item.icon}}" + data-info="{{item}}" + bindtap="toPages" + /> </t-grid> </view> <view class="home-page-container"> <view class="home-page-list"> <view class="tabCardPublic iconOne"> <view class="icon"> - <image src="/static/images/home/zhuantitaolun2.png" mode="aspectFit" class="iconImage" /> + <image + src="/static/images/home/zhuantitaolun2.png" + mode="aspectFit" + class="iconImage" + /> </view> - <view data-info="{{'zhuantitaolun'}}" bindtap="onMoreGuide" class="flex" style="align-items: center"> + <view + data-info="{{'zhuantitaolun'}}" + bindtap="onMoreGuide" + class="flex" + style="align-items: center" + > <text class="more">鏇村</text> <t-icon name="chevron-right" size="32rpx" color="#ff6d00" /> </view> </view> <view class="listBox"> <view wx:if="{{specialSubjectList.length > 0}}"> - <view wx:for="{{specialSubjectList}}" wx:for-item="item" wx:for-index="index" wx:key="index" class="listItemBox"> - <view class="listItem" bindtap="goSubjectDetail" data-book="{{item}}"> + <view + wx:for="{{specialSubjectList}}" + wx:for-item="item" + wx:for-index="index" + wx:key="index" + class="listItemBox" + > + <view + class="listItem" + bindtap="goSubjectDetail" + data-book="{{item}}" + > <view class="specialSubject-img"> <image src="{{item.icon}}" mode="aspectFill" class="img" /> </view> <view class="body-info"> <view class="name">{{item.name}}</view> - <view class="time" wx:if="{{item.liveTime}}">鐩存挱鏃堕棿锛歿{item.liveTime}}</view> - <view class="time" wx:if="{{item.startTime}}">寮�鎾椂闂达細{{ item.startTime }}</view> - <view class="time" wx:if="{{!item.liveTime && !item.startTime}}">寮�鎾椂闂达細<text class="grey">寰呭畾</text></view> + <view class="time" wx:if="{{item.liveTime}}" + >鐩存挱鏃堕棿锛歿{item.liveTime}}</view + > + <view class="time" wx:if="{{item.startTime}}" + >寮�鎾椂闂达細{{ item.startTime }}</view + > + <view + class="time" + wx:if="{{!item.liveTime && !item.startTime}}" + >寮�鎾椂闂达細<text class="grey">寰呭畾</text></view + > <view class="flex jc-sb"> - <text class="author">{{item.lecturer}} {{item.position}}</text> + <text class="author" + >{{item.lecturer}} {{item.position}}</text + > <text class="price" wx:if="{{item.price == 0}}">鍏嶈垂</text> - <text class="price" wx:if="{{item.price !== 0}}">锟{item.price}}</text> + <text class="price" wx:if="{{item.price !== 0}}" + >锟{item.price}}</text + > </view> </view> </view> @@ -67,7 +155,11 @@ </view> <view class="tabCardPublic iconTwo"> <view class="icon"> - <image src="/static/images/home/tushufuwu2.png" mode="aspectFit" class="iconImage" /> + <image + src="/static/images/home/tushufuwu2.png" + mode="aspectFit" + class="iconImage" + /> </view> <view data-info="{{'tushufuwu'}}" bindtap="onMoreGuide" class="flex"> <text class="more">鏇村</text> @@ -75,16 +167,39 @@ </view> </view> <view class="home-page-tabs"> - <t-tabs t-class="t-tabs" split="{{false}}" position="{{'home'}}" defaultValue="{{activeItem1}}" bind:change="tabBookClick"> - <t-tab-panel wx:for="{{bookTypeList}}" wx:for-index="index" wx:key="index" label="{{item.name}}" value="{{index}}" /> + <t-tabs + t-class="t-tabs" + split="{{false}}" + position="{{'home'}}" + defaultValue="{{activeItem1}}" + bind:change="tabBookClick" + > + <t-tab-panel + wx:for="{{bookTypeList}}" + wx:for-index="index" + wx:key="index" + label="{{item.name}}" + value="{{index}}" + /> </t-tabs> </view> <view class="listBox2"> <view wx:if="{{booksList.length > 0}}" class="flex"> - <view wx:for="{{booksList}}" wx:for-item="item" wx:for-index="index" wx:key="index" class="booksListItemBox"> + <view + wx:for="{{booksList}}" + wx:for-item="item" + wx:for-index="index" + wx:key="index" + class="booksListItemBox" + > <view class="listItem" bind:tap="goDetail" data-book="{{item}}"> <view class="specialSubject-img"> - <image src="{{item.icon ? item.icon : '/static/images/default-book-img.png'}}" mode="aspectFit" class="img" aria-label="{{item.name}}" /> + <image + src="{{item.icon ? item.icon : '/static/images/default-book-img.png'}}" + mode="aspectFit" + class="img" + aria-label="{{item.name}}" + /> </view> <view class="body-info"> <view class="name">{{item.name}}</view> @@ -100,35 +215,78 @@ </view> <view class="tabCardPublic iconTwo"> <view class="icon"> - <image src="/static/images/home/jingxuankecheng2.png" mode="aspectFit" class="iconImage" /> + <image + src="/static/images/home/jingxuankecheng2.png" + mode="aspectFit" + class="iconImage" + /> </view> - <view data-info="{{'jingxuankecheng'}}" bindtap="onMoreGuide" class="flex"> + <view + data-info="{{'jingxuankecheng'}}" + bindtap="onMoreGuide" + class="flex" + > <text class="more">鏇村</text> <t-icon name="chevron-right" size="32rpx" color="#ff6d00" /> </view> </view> <view class="home-page-tabs"> - <t-tabs t-class="t-tabs" split="{{false}}" defaultValue="{{activeItem}}" bind:change="tabChangeHandle"> - <t-tab-panel wx:for="{{courseTypeList}}" wx:for-index="index" wx:key="index" label="{{item.name}}" value="{{index}}" /> + <t-tabs + t-class="t-tabs" + split="{{false}}" + defaultValue="{{activeItem}}" + bind:change="tabChangeHandle" + > + <t-tab-panel + wx:for="{{courseTypeList}}" + wx:for-index="index" + wx:key="index" + label="{{item.name}}" + value="{{index}}" + /> </t-tabs> </view> <view class="listBox1"> <view wx:if="{{courseList.length>0}}"> - <view wx:for="{{courseList}}" wx:for-item="item" wx:for-index="index" wx:key="index" class="listItemBox"> + <view + wx:for="{{courseList}}" + wx:for-item="item" + wx:for-index="index" + wx:key="index" + class="listItemBox" + > <view class="listItem flex"> - <view class="specialSubject-img" data-book="{{item}}" bindtap="goCourseDetail"> + <view + class="specialSubject-img" + data-book="{{item}}" + bindtap="goCourseDetail" + > <image src="{{item.icon}}" mode="aspectFit" class="img" /> </view> <view class="body-info"> - <view class="name" data-book="{{item}}" bindtap="goCourseDetail">{{item.name}}</view> + <view + class="name" + data-book="{{item}}" + bindtap="goCourseDetail" + >{{item.name}}</view + > <view class="flex jc-sb"> <text class="author">{{item.courseLeader}}</text> <text class="classHours">{{item.classHours}}璇炬椂</text> </view> <view class="priceBox flex jc-sb"> <text class="price" wx:if="{{item.price == 0}}">鍏嶈垂</text> - <text class="price" wx:if="{{item.price !== 0}}">锟{item.price}}</text> - <image wx:if="{{item.price}}" src="/static/images/home/home-cart.png" mode="aspectFit" class="addCartImg" bind:tap="addCart" data-info="{{item}}" /> + <text class="price" wx:if="{{item.price !== 0}}" + >锟{item.price}}</text + > + <image + wx:if="{{item.price}}" + src="/static/images/home/home-cart.png" + mode="aspectFit" + class="addCartImg" + bind:tap="addCart" + data-info="{{item}}" + /> </view> </view> </view> @@ -142,7 +300,11 @@ <view class="tabCardPublic iconTwo"> <view class="icon"> - <image src="/static/images/home/shuziyuedu2.png" mode="aspectFit" class="iconImage" /> + <image + src="/static/images/home/shuziyuedu2.png" + mode="aspectFit" + class="iconImage" + /> </view> <view data-info="{{'shuziyuedu'}}" bindtap="onMoreGuide" class="flex"> <text class="more">鏇村</text> @@ -150,8 +312,18 @@ </view> </view> <view class="listBox2 flex"> - <view wx:for="{{readBookList}}" wx:for-item="item" wx:for-index="index" wx:key="index" class="booksListItemBox"> - <view class="listItem" bind:tap="goReadBookDetail" data-book="{{item}}"> + <view + wx:for="{{readBookList}}" + wx:for-item="item" + wx:for-index="index" + wx:key="index" + class="booksListItemBox" + > + <view + class="listItem" + bind:tap="goReadBookDetail" + data-book="{{item}}" + > <view class="specialSubject-img"> <image src="{{item.icon}}" mode="aspectFit" class="img" /> </view> @@ -164,28 +336,64 @@ </view> <view class="tabCardPublic iconTwo"> <view class="icon"> - <image src="/static/images/home/shuzijiaocai2.png" mode="aspectFit" class="iconImage" /> + <image + src="/static/images/home/shuzijiaocai2.png" + mode="aspectFit" + class="iconImage" + /> </view> - <view data-info="{{'shuzijiaocai'}}" bindtap="onMoreGuide" class="flex"> + <view + data-info="{{'shuzijiaocai'}}" + bindtap="onMoreGuide" + class="flex" + > <text class="more">鏇村</text> <t-icon name="chevron-right" size="32rpx" color="#ff6d00" /> </view> </view> <view class="listBox3"> <view wx:if="{{textbookList.length > 0}}"> - <view wx:for="{{textbookList}}" wx:for-item="item" wx:for-index="index" wx:key="index" class="textbooksItemBox"> + <view + wx:for="{{textbookList}}" + wx:for-item="item" + wx:for-index="index" + wx:key="index" + class="textbooksItemBox" + > <view class="listItem flex"> - <view class="specialSubject-img" bind:tap="goTextBookDetail" data-book="{{item}}"> + <view + class="specialSubject-img" + bind:tap="goTextBookDetail" + data-book="{{item}}" + > <image src="{{item.icon}}" mode="aspectFit" class="img" /> </view> <view class="body-info"> - <view class="name" bind:tap="goTextBookDetail" data-book="{{item}}">{{item.name}}</view> - <view class="introduction" bind:tap="goTextBookDetail" data-book="{{item}}">{{item.description}}</view> + <view + class="name" + bind:tap="goTextBookDetail" + data-book="{{item}}" + >{{item.name}}</view + > + <view + class="introduction" + bind:tap="goTextBookDetail" + data-book="{{item}}" + >{{item.description}}</view + > <view class="author">{{item.author}}</view> <view class="priceBox flex jc-sb"> <text class="price" wx:if="{{item.price == 0}}">鍏嶈垂</text> - <text class="price" wx:if="{{item.price !== 0}}">锟{item.price}}</text> - <image src="/static/images/home/home-cart.png" mode="aspectFit" class="addCartImg" bind:tap="addCart" data-info="{{item}}" /> + <text class="price" wx:if="{{item.price !== 0}}" + >锟{item.price}}</text + > + <image + src="/static/images/home/home-cart.png" + mode="aspectFit" + class="addCartImg" + bind:tap="addCart" + data-info="{{item}}" + /> </view> </view> </view> @@ -198,17 +406,37 @@ </view> <view class="tabCardPublic"> <view class="icon"> - <image src="/static/images/home/paihangbang2.png" mode="" class="iconImage" /> + <image + src="/static/images/home/paihangbang2.png" + mode="" + class="iconImage" + /> </view> </view> <view class="rankingList"> <scroll-view class="srcolbox" scroll-x scroll-with-animation="true"> <view class="booksListBox"> - <view wx:for="{{rankingList}}" wx:for-item="item" wx:for-index="index" wx:key="index" class="booksListItemBox"> + <view + wx:for="{{rankingList}}" + wx:for-item="item" + wx:for-index="index" + wx:key="index" + class="booksListItemBox" + > <view class="listItem" bind:tap="goDetail" data-book="{{item}}"> <view class="specialSubject-img"> - <image src="{{item.icon}}" mode="aspectFit" class="img" wx:if="{{item.icon}}" /> - <image src="/static/images/default-book-img.png" mode="aspectFit" class="img" wx:else /> + <image + src="{{item.icon}}" + mode="aspectFit" + class="img" + wx:if="{{item.icon}}" + /> + <image + src="/static/images/default-book-img.png" + mode="aspectFit" + class="img" + wx:else + /> </view> <view class="body-info"> <view class="name">{{item.name}}</view> @@ -252,4 +480,4 @@ </t-popup> --> </view> <import src="home.skeleton.wxml" /> -<template is="skeleton" wx:if="{{loading}}" /> \ No newline at end of file +<template is="skeleton" wx:if="{{loading}}" /> diff --git a/pages/retrievalPage/index.js b/pages/retrievalPage/index.js index 7c03f63..fc8fd6c 100644 --- a/pages/retrievalPage/index.js +++ b/pages/retrievalPage/index.js @@ -1,6 +1,8 @@ // pages/retrievalPage/index.js import request from '../../assets/request/index' - +import { + loginInfo +} from '../../assets/js/login'; import { handleQueryResourceListData } from '../../assets/js/middleGround/tool' @@ -97,16 +99,16 @@ } this.onTabsChange(e) // 妫�鏌ョ櫥褰曠姸鎬� - const token = wx.getStorageSync(app.config.tokenKey) - if (!token) { - loginInfo(app, (data) => { - if (data) { - this.getUserInfo() - } - }) - } else { - this.getUserInfo() - } + // const token = wx.getStorageSync(app.config.tokenKey) + // if (!token) { + // loginInfo(app, (data) => { + // if (data) { + // this.getUserInfo() + // } + // }) + // } else { + // this.getUserInfo() + // } var that = this; // 鍔ㄦ�佽幏鍙栧睆骞曢珮搴� wx.getSystemInfo({ @@ -233,7 +235,7 @@ } } - let url = '/store/api/ApiQueryProductByAppUser' + let url = '/store/api/ApiQueryProduct' //鍥句功 let queryBook = { AccessControl: { @@ -703,11 +705,26 @@ mailbox(e) { const key = e.currentTarget.dataset.key; const item = e.currentTarget.dataset.item; - this.setData({ - [key]: true, - dialogKey: key, - Md5: item.datas.freeFile.FileList[0].Md5 - }); + const token = wx.getStorageSync(app.config.tokenKey) + if (!token) { + loginInfo(app, (data) => { + if (data) { + this.getUserInfo() + this.setData({ + [key]: true, + dialogKey: key, + Md5: item.datas.freeFile.FileList[0].Md5 + }); + } + }) + } else { + this.getUserInfo() + this.setData({ + [key]: true, + dialogKey: key, + Md5: item.datas.freeFile.FileList[0].Md5 + }); + } }, //閭鐨勬牎楠� onEmailInput(e) { -- Gitblit v1.9.1