From 38cd76c5f05fd55855038e2d393074e27909c63d Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期五, 28 三月 2025 15:28:01 +0800 Subject: [PATCH] 剩余页面登录迁移 --- pages/digitalCourses/digitalCoursesDetails/components/testTree/index.js | 115 ++++---- pages/digitalCourses/digitalCoursesDetails/components/note/note.js | 144 ++++++---- pages/digitalCourses/digitalCoursesDetails/index.js | 45 +- pages/digitalCourses/digitalCoursesDetails/components/tree/index.js | 7 pages/digitalTextbooks/digitalTextbooksDetails/index.js | 345 +++++++++++------------- pages/digitalCourses/digitalCoursesDetails/components/question/question.js | 16 pages/digitalCourses/digitalCoursesDetails/components/tree/index.wxml | 135 ++++++++- 7 files changed, 458 insertions(+), 349 deletions(-) diff --git a/pages/digitalCourses/digitalCoursesDetails/components/note/note.js b/pages/digitalCourses/digitalCoursesDetails/components/note/note.js index f09f7d7..fc92680 100644 --- a/pages/digitalCourses/digitalCoursesDetails/components/note/note.js +++ b/pages/digitalCourses/digitalCoursesDetails/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({ /** * 缁勪欢鐨勫睘鎬у垪琛� @@ -15,8 +18,7 @@ * 缁勪欢鐨勫垵濮嬫暟鎹� */ data: { - inputStyle: - "border: 2rpx solid rgba(220,220,220,1);border-radius: 12rpx; padding:16rpx", + inputStyle: "border: 2rpx solid rgba(220,220,220,1);border-radius: 12rpx; padding:16rpx", placeholderstyle: "font-size:28rpx", flag: false, // 杈撳叆妗嗘槸鍚︽樉绀� submitType: "new", // 鏂板缓 or 缂栬緫 @@ -64,10 +66,15 @@ }); }, openDialog() { - this.setData({ - submitTitle: this.properties.bookInfo.name, - showNoteDialog: true, - }); + const token = wx.getStorageSync(app.config.tokenKey) + if (token) { + this.setData({ + submitTitle: this.properties.bookInfo.name, + showNoteDialog: true, + }); + } else { + loginInfo(app, (data) => {}) + } }, closeDialog() { this.setData({ @@ -144,63 +151,82 @@ }, // 鑾峰彇绗旇鍒楄〃 async getNoteList() { - if (!this.data.isMore) { - this.setData({ - loading: true, - }); - } - this.setData({ - noList: false, - }); - let topicId; - await app.MG.ugc - .getProductUserSubmitTopic({ - productId: this.properties.bookInfo.id, - appRefCode: app.config.appRefCode, - }) - .then((res) => { - if (res) { - topicId = res.id; - } else { - return wx.showToast({ - icon: "error", - title: "鏌ヨ澶辫触", - }); - } - }); - // loadings.value.bookResource = true - let query = { - start: 0, - size: this.data.pageCount.page * 5, - messageType: "note", - sort: { - type: "Desc", - field: "CreateDate", - }, - appRefCode: app.config.appRefCode, - topicIdOrRefCode: topicId + "", - }; - await app.MG.ugc.getTopicMessageList(query).then((res) => { - if (!res.datas.length) { - return this.setData({ - loading: false, - noList: true, - noteList: res.datas, + const getFun = async () => { + if (!this.data.isMore) { + this.setData({ + loading: true, }); } - // notePage.value.total = res.totalSize - res.datas.forEach((item) => { - item.compliceHover = false; - item.deleteHover = false; - item.createDate = this.convertTimestamp(item.createDate); - }); this.setData({ - "pageCount.total": res.totalSize, - noteList: res.datas, - loading: false, noList: false, }); - }); + let topicId; + await app.MG.ugc + .getProductUserSubmitTopic({ + productId: this.properties.bookInfo.id, + appRefCode: app.config.appRefCode, + }) + .then((res) => { + if (res) { + topicId = res.id; + } else { + return wx.showToast({ + icon: "error", + title: "鏌ヨ澶辫触", + }); + } + }); + let query = { + start: 0, + size: this.data.pageCount.page * 5, + messageType: "note", + sort: { + type: "Desc", + field: "CreateDate", + }, + appRefCode: app.config.appRefCode, + topicIdOrRefCode: topicId + "", + }; + await app.MG.ugc.getTopicMessageList(query).then((res) => { + if (!res.datas.length) { + return this.setData({ + loading: false, + noList: true, + noteList: res.datas, + }); + } + // notePage.value.total = res.totalSize + res.datas.forEach((item) => { + item.compliceHover = false; + item.deleteHover = false; + item.createDate = this.convertTimestamp(item.createDate); + }); + this.setData({ + "pageCount.total": res.totalSize, + noteList: res.datas, + loading: false, + noList: false, + }); + }); + } + const token = wx.getStorageSync(app.config.tokenKey) + if (!token) { + loginInfo(app, (data) => { + if (data) { + getFun() + } else { + this.setData({ + loading: false, + noList: true, + noteList: [], + }); + } + + }) + } else { + getFun() + } + }, // 鏂板缓绗旇鎺ュ彛 async makeNote() { @@ -342,4 +368,4 @@ }); }, }, -}); +}); \ No newline at end of file diff --git a/pages/digitalCourses/digitalCoursesDetails/components/question/question.js b/pages/digitalCourses/digitalCoursesDetails/components/question/question.js index c8a3132..8228695 100644 --- a/pages/digitalCourses/digitalCoursesDetails/components/question/question.js +++ b/pages/digitalCourses/digitalCoursesDetails/components/question/question.js @@ -1,5 +1,8 @@ // pages/bookServices/detail/components/note/note.js const app = getApp(); +import { + loginInfo +} from '../../../../../assets/js/login'; import moment from 'moment' Component({ /** @@ -67,10 +70,15 @@ }); }, openDialog() { - this.setData({ - submitTitle: this.properties.bookInfo.name, - showNoteDialog: true, - }); + const token = wx.getStorageSync(app.config.tokenKey) + if (token) { + this.setData({ + submitTitle: this.properties.bookInfo.name, + showNoteDialog: true, + }); + } else { + loginInfo(app, (data) => {}) + } }, closeDialog() { this.setData({ diff --git a/pages/digitalCourses/digitalCoursesDetails/components/testTree/index.js b/pages/digitalCourses/digitalCoursesDetails/components/testTree/index.js index dbc1439..d9c0210 100644 --- a/pages/digitalCourses/digitalCoursesDetails/components/testTree/index.js +++ b/pages/digitalCourses/digitalCoursesDetails/components/testTree/index.js @@ -1,4 +1,7 @@ const app = getApp(); +import { + loginInfo +} from '../../../../../assets/js/login'; Component({ properties: { treeList: { @@ -43,66 +46,66 @@ openIds: e.detail.value, }); }, - async goTest(e) { - console.log(e, 666) - const value = e.currentTarget.dataset.item; - const parent = e.currentTarget.dataset.parent; - const isTry = e.currentTarget.dataset.istry; - const token = wx.getStorageSync("jsek-token"); - if (!token) { - return wx.getUserProfile({ - desc: "鐢ㄦ埛鐧诲綍", - success: (res) => { - console.log(res); + goTest(e) { + const gotoPageFun = async () => { + const value = e.currentTarget.dataset.item; + const parent = e.currentTarget.dataset.parent; + const isTry = e.currentTarget.dataset.istry; + const token = wx.getStorageSync("jsek-token"); + if (!isTry && !this.data.isBuy) { + return wx.showToast({ + icon: 'error', + title: '璇峰厛璐拱璇ヨ绋�', + }) + } + // 鑾峰彇绔犺妭涓嬫槸鍚︽湁棰樼洰 + let idPathList = []; + let query = { + storeInfo: app.config.digitalCourses, + path: "*", + queryType: "*", + productId: this.properties.bookInfo.id, + cmsPath: value.productLinkPath, + pading: { + start: 0, + size: 999, }, - }); - } - if (!isTry && !this.data.isBuy) { - return wx.showToast({ - icon: 'error', - title: '璇峰厛璐拱璇ヨ绋�', - }) - } - // 鑾峰彇绔犺妭涓嬫槸鍚︽湁棰樼洰 - let idPathList = []; - let query = { - storeInfo: app.config.digitalCourses, - path: "*", - queryType: "*", - productId: this.properties.bookInfo.id, - cmsPath: value.productLinkPath, - pading: { - start: 0, - size: 999, - }, - }; - if (value.childrenFolderCount == 0) { - wx.hideLoading(); - return wx.showToast({ - icon: "error", - title: "鏆傛棤鏁版嵁", - }); - } else { - const res = await app.MG.store.getProductDetail(query); - res.datas.cmsDatas[0].datas.forEach((item) => { - idPathList.push({ - id: item.id, - name: item.name, - productLinkPath: item.productLinkPath, - type: item.type, + }; + if (value.childrenFolderCount == 0) { + wx.hideLoading(); + return wx.showToast({ + icon: "error", + title: "鏆傛棤鏁版嵁", }); + } else { + const res = await app.MG.store.getProductDetail(query); + res.datas.cmsDatas[0].datas.forEach((item) => { + idPathList.push({ + id: item.id, + name: item.name, + productLinkPath: item.productLinkPath, + type: item.type, + }); + }); + } + wx.hideLoading(); + wx.navigateTo({ + url: `/packageBookService/pages/bookServices/examination/examination?bookId=${ + this.properties.bookInfo.id + }&productLinkPath=${value.productLinkPath}&rootCmsItemId=${ + this.properties.bookInfo.rootCmsItemId + }&idPathList=${JSON.stringify(idPathList)}&answerTitle=${ + value.name + }&answerType=${"option"}&storeInfo=${app.config.digitalCourses}`, }); } - wx.hideLoading(); - wx.navigateTo({ - url: `/packageBookService/pages/bookServices/examination/examination?bookId=${ - this.properties.bookInfo.id - }&productLinkPath=${value.productLinkPath}&rootCmsItemId=${ - this.properties.bookInfo.rootCmsItemId - }&idPathList=${JSON.stringify(idPathList)}&answerTitle=${ - value.name - }&answerType=${"option"}&storeInfo=${app.config.digitalCourses}`, - }); + const token = wx.getStorageSync(app.config.tokenKey) + if (!token) { + loginInfo(app, () => {}) + } else { + gotoPageFun() + } + }, }, }); \ No newline at end of file diff --git a/pages/digitalCourses/digitalCoursesDetails/components/tree/index.js b/pages/digitalCourses/digitalCoursesDetails/components/tree/index.js index c2eaecc..83ef878 100644 --- a/pages/digitalCourses/digitalCoursesDetails/components/tree/index.js +++ b/pages/digitalCourses/digitalCoursesDetails/components/tree/index.js @@ -1,4 +1,7 @@ const app = getApp(); +import { + loginInfo +} from '../../../../../assets/js/login'; Component({ properties: { treeList: { @@ -114,9 +117,9 @@ 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=jsek_cloudLearning&storeInfo=${app.config.digitalCourses}`, }); + } else { + loginInfo(app, (data) => {}) } }, - - }, }); \ No newline at end of file diff --git a/pages/digitalCourses/digitalCoursesDetails/components/tree/index.wxml b/pages/digitalCourses/digitalCoursesDetails/components/tree/index.wxml index 2ba7bc1..0d143e7 100644 --- a/pages/digitalCourses/digitalCoursesDetails/components/tree/index.wxml +++ b/pages/digitalCourses/digitalCoursesDetails/components/tree/index.wxml @@ -1,14 +1,37 @@ <view class="tree"> <t-collapse default-value="{{openIds}}" catchchange="handleChange"> - <view wx:for="{{treeList}}" wx:for-item="item" wx:for-index="index" wx:key="id" wx:if="{{item.sysType== 'CmsItem' }}"> - <view class="listItems" wx:if="{{item.childrenFolderCount <= 0 && item.sysType == 'CmsItem'}}"> + <view + wx:for="{{treeList}}" + wx:for-item="item" + wx:for-index="index" + wx:key="id" + wx:if="{{item.sysType== 'CmsItem' }}" + > + <view + class="listItems" + wx:if="{{item.childrenFolderCount <= 0 && item.sysType == 'CmsItem'}}" + > <view class="itemsInfo"> - <view class="contentBox" > + <view class="contentBox"> <!-- 浜戝涔� 鍥炬爣 --> - <view class="box-image fl-cn" style="width: 80%" bind:tap="goPlayer" data-item="{{item}}" data-parent="{{''}}"> + <view + class="box-image fl-cn" + style="width: 80%" + bind:tap="goPlayer" + data-item="{{item}}" + data-parent="{{''}}" + > <view class="teach-icon fl-cn"> - <image wx:if="{{item.selectType == 'audio' || item.learnSelectType == 'audio'}}" src="/static/images/bookService/detail/audioIcon.png" mode="aspectFill" /> - <image wx:elif="{{item.selectType == 'video' || item.learnSelectType == 'video'}}" src="/static/images/bookService/detail/video.png" mode="aspectFill" /> + <image + wx:if="{{item.selectType == 'audio' || item.learnSelectType == 'audio'}}" + src="/static/images/bookService/detail/audioIcon.png" + mode="aspectFill" + /> + <image + wx:elif="{{item.selectType == 'video' || item.learnSelectType == 'video'}}" + src="/static/images/bookService/detail/video.png" + mode="aspectFill" + /> <image wx:elif="{{item.selectType == 'pdf' || item.learnSelectType == 'pdf'}}" src="/static/images/bookService/detail/pdf.png" @@ -45,21 +68,43 @@ mode="aspectFill" /> <!-- 璧勬簮鏃犳枃浠跺唴瀹瑰浘鏍� --> - <image wx:else src="/static/images/bookService/detail/word.png" mode="" /> + <image + wx:else + src="/static/images/bookService/detail/word.png" + mode="" + /> </view> <!-- 鍚嶇О --> <text class="name" style="width: 100%">{{item.name || '-'}}</text> <text>{{item.progress ? item.progress : 0}}%</text> </view> - <view class="seeBox" wx:if="{{!isBuy && citem.freeFile ? true : false}}" bind:tap="goPlayer" data-item="{{citem}}" data-parent="" data-isTry="{{true}}"> + <view + class="seeBox" + wx:if="{{!isBuy && citem.freeFile ? true : false}}" + bind:tap="goPlayer" + data-item="{{citem}}" + data-parent="" + data-isTry="{{true}}" + > <!-- 浜戝涔犺瘯鐪嬪浘鏍� --> - <image src="/static/images/bookService/detail/shikan.png" class="testSee" wx:if="{{!isBuy && item.freeFile ? true : false}}"></image> + <image + src="/static/images/bookService/detail/shikan.png" + class="testSee" + wx:if="{{!isBuy && item.freeFile ? true : false}}" + ></image> </view> </view> </view> </view> </view> - <t-collapse-panel wx:for="{{treeList}}" wx:for-item="item" wx:for-index="index" wx:key="id" value="{{item.id}}" wx:if="{{item.sysType == 'CmsFolder' }}"> + <t-collapse-panel + wx:for="{{treeList}}" + wx:for-item="item" + wx:for-index="index" + wx:key="id" + value="{{item.id}}" + wx:if="{{item.sysType == 'CmsFolder' }}" + > <view slot="header" class="header-title"> <view class="title-checkBox" catchtap="catchTap"> <!-- 绔犺妭鍚� --> @@ -68,16 +113,38 @@ </view> </view> </view> - <view class="list" wx:for="{{item.children}}" wx:for-item="citem" wx:for-index="cindex" wx:key="cindex"> + <view + class="list" + wx:for="{{item.children}}" + wx:for-item="citem" + wx:for-index="cindex" + wx:key="cindex" + > <!-- // 鍒ゆ柇 鏃犲瓙椤� 涓斾负鍟嗗搧item 鐩存帴鏄剧ず --> - <view class="listItems" wx:if="{{citem.childrenFolderCount <= 0 && citem.sysType == 'CmsItem'}}"> + <view + class="listItems" + wx:if="{{citem.childrenFolderCount <= 0 && citem.sysType == 'CmsItem'}}" + > <view class="itemsInfo"> - <view class="contentBox" > + <view class="contentBox"> <!-- 浜戝涔� 鍥炬爣 --> - <view class="box-image fl-cn" bind:tap="goPlayer" data-item="{{citem}}" data-parent="{{item}}"> + <view + class="box-image fl-cn" + bind:tap="goPlayer" + data-item="{{citem}}" + data-parent="{{item}}" + > <view class="teach-icon fl-cn"> - <image wx:if="{{citem.selectType == 'audio' || citem.learnSelectType == 'audio'}}" src="/static/images/bookService/detail/audioIcon.png" mode="aspectFill" /> - <image wx:elif="{{citem.selectType == 'video' || citem.learnSelectType == 'video'}}" src="/static/images/bookService/detail/video.png" mode="aspectFill" /> + <image + wx:if="{{citem.selectType == 'audio' || citem.learnSelectType == 'audio'}}" + src="/static/images/bookService/detail/audioIcon.png" + mode="aspectFill" + /> + <image + wx:elif="{{citem.selectType == 'video' || citem.learnSelectType == 'video'}}" + src="/static/images/bookService/detail/video.png" + mode="aspectFill" + /> <image wx:elif="{{citem.selectType == 'pdf' || citem.learnSelectType == 'pdf'}}" src="/static/images/bookService/detail/pdf.png" @@ -114,21 +181,45 @@ mode="aspectFill" /> <!-- 璧勬簮鏃犳枃浠跺唴瀹瑰浘鏍� --> - <image wx:else src="/static/images/bookService/detail/word.png" mode="" /> - <text class="name" style="width:400rpx">{{citem.name || '-'}}</text> + <image + wx:else + src="/static/images/bookService/detail/word.png" + mode="" + /> + <text class="name" style="width: 400rpx" + >{{citem.name || '-'}}</text + > </view> <!-- 鍚嶇О --> <text>{{citem.progress ? citem.progress : 0}}%</text> </view> - <view class="seeBox" wx:if="{{!isBuy && citem.freeFile ? true : false}}" bind:tap="goPlayer" data-item="{{citem}}" data-parent="{{item}}" data-isTry="{{true}}"> + <view + class="seeBox" + wx:if="{{!isBuy && citem.freeFile ? true : false}}" + bind:tap="goPlayer" + data-item="{{citem}}" + data-parent="{{item}}" + data-isTry="{{true}}" + > <!-- 浜戝涔犺瘯鐪嬪浘鏍� --> - <image src="/static/images/bookService/detail/shikan.png" class="testSee" ></image> + <image + src="/static/images/bookService/detail/shikan.png" + class="testSee" + ></image> </view> </view> </view> </view> <!-- // 鍒ゆ柇 涓嶆槸鍟嗗搧 鏈夊瓙椤� 閫掑綊缁勪欢 --> - <tree wx:if="{{ citem.sysType == 'CmsFolder' }}" bookInfo="{{bookInfo}}" treeList="{{[citem]}}" learnList="{{learnList}}" itemId="{{itemId}}" openIds="{{openIds}}" isBuy="{{isBuy}}"></tree> + <tree + wx:if="{{ citem.sysType == 'CmsFolder' }}" + bookInfo="{{bookInfo}}" + treeList="{{[citem]}}" + learnList="{{learnList}}" + itemId="{{itemId}}" + openIds="{{openIds}}" + isBuy="{{isBuy}}" + ></tree> </view> <!-- 鏆傛棤鏁版嵁 --> <view wx:if="{{!item.children || !item.children.length}}" class="noData"> @@ -143,4 +234,4 @@ </view> </t-collapse-panel> </t-collapse> -</view> \ No newline at end of file +</view> diff --git a/pages/digitalCourses/digitalCoursesDetails/index.js b/pages/digitalCourses/digitalCoursesDetails/index.js index 36a5698..1212ec1 100644 --- a/pages/digitalCourses/digitalCoursesDetails/index.js +++ b/pages/digitalCourses/digitalCoursesDetails/index.js @@ -167,8 +167,9 @@ bookId: options.id, bookPath: parentPath.join('\\') }) + const token = wx.getStorageSync(app.config.tokenKey) this.digitalCoursesDetailsGet(options.id) - this.getPlayerList() + if (token) this.getPlayerList() this.getType() }, logInFun(callback) { @@ -193,7 +194,8 @@ */ onShow() { if (this.data.tabValue == 2 && this.data.selectActive == 'learn') { - this.getPlayerList() + const token = wx.getStorageSync(app.config.tokenKey) + if (token) this.getPlayerList() this.getResource() this.getRelationBook() } @@ -506,7 +508,8 @@ pading: { start: 99, size: 0 - } + }, + } app.MG.store.getProductDetail(query).then((res) => { let test = [] @@ -742,30 +745,32 @@ }, readTextBook() { - wx.navigateTo({ - url: '/pages/digitalCourses/digitalCoursesDetails/components/digitalRead/index?refCode=' + this.data.relationTextBook.refCode + '&tryPageCount=' + this.data.relationTextBook.probationPage + '&isTextBookBuy=' + this.data.isTextBookBuy - }) + const token = wx.getStorageSync(app.config.tokenKey) + if (!token) { + this.logInFun(() => {}) + } else { + wx.navigateTo({ + url: '/pages/digitalCourses/digitalCoursesDetails/components/digitalRead/index?refCode=' + this.data.relationTextBook.refCode + '&tryPageCount=' + this.data.relationTextBook.probationPage + '&isTextBookBuy=' + this.data.isTextBookBuy + }) + } }, //鍦ㄧ嚎娴嬭瘯鎴戠殑鏀惰棌銆佹垜鐨勯敊棰� goMycollect(e) { - const answertype = e.currentTarget.dataset.answertype; - const token = wx.getStorageSync("jsek-token"); + const token = wx.getStorageSync(app.config.tokenKey) if (!token) { - return wx.getUserProfile({ - desc: "鐢ㄦ埛鐧诲綍", - success: (res) => { - console.log(res); - }, + this.logInFun(() => {}) + } else { + const answertype = e.currentTarget.dataset.answertype; + wx.navigateTo({ + url: `/packageBookService/pages/bookServices/examination/examination?bookId=${ + this.data.digitalsData.id + }&rootCmsItemId=${this.data.digitalsData.rootCmsItemId}&answerTitle=${ + answertype == "collectQuestion" ? "鎴戠殑鏀惰棌" : "鎴戠殑閿欓" + }&answerType=${answertype}&storeInfo=${app.config.digitalCourses}`, }); } - wx.navigateTo({ - url: `/packageBookService/pages/bookServices/examination/examination?bookId=${ - this.data.digitalsData.id - }&rootCmsItemId=${this.data.digitalsData.rootCmsItemId}&answerTitle=${ - answertype == "collectQuestion" ? "鎴戠殑鏀惰棌" : "鎴戠殑閿欓" - }&answerType=${answertype}&storeInfo=${app.config.digitalCourses}`, - }); + }, onCorrelationBook(e) { diff --git a/pages/digitalTextbooks/digitalTextbooksDetails/index.js b/pages/digitalTextbooks/digitalTextbooksDetails/index.js index b401c58..3dd83b4 100644 --- a/pages/digitalTextbooks/digitalTextbooksDetails/index.js +++ b/pages/digitalTextbooks/digitalTextbooksDetails/index.js @@ -88,21 +88,19 @@ this.setData({ digitalTextId: options.id }) - const token = wx.getStorageSync(app.config.tokenKey) - if (!token) { - loginInfo(app, (data) => { - if (data) { - this.digitalTextbooksDetailsGet(this.data.digitalTextId) - this.getType() - this.getCertificateList() - } else { - - } - }) - } this.digitalTextbooksDetailsGet(this.data.digitalTextId) this.getType() this.getCertificateList() + }, + logInFun(callback) { + loginInfo(app, (data) => { + if (data) { + this.digitalTextbooksDetailsGet(this.data.digitalTextId) + this.getType() + this.getCertificateList() + callback() + } + }) }, // 鏍煎紡鍖栨棩鏈� // 鏍煎紡鍖栨棩鏈� @@ -377,47 +375,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.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, }); } + } + const token = wx.getStorageSync(app.config.tokenKey) + if (!token) { + this.logInFun(() => {}) } else { - wx.showToast({ - title: "鍟嗗搧涓嶅湪鏈夋晥鏈�", - icon: "none", - duration: 1000, - }); + addFun() } }, showSuccessToast() { @@ -432,91 +438,78 @@ //璐拱鎸夐挳 - 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) => { - this.digitalTextbooksDetailsGet(this.data.digitalTextId) - if (res) { - wx.showToast({ - title: "棰嗗彇鎴愬姛", - icon: "none", - duration: 1000, - }); - this.getBookInfo(this.data.bookDetail.id); - } + buyBtn() { + 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) => { + this.digitalTextbooksDetailsGet(this.data.digitalTextId) + if (res) { + wx.showToast({ + title: "棰嗗彇鎴愬姛", + icon: "none", + duration: 1000, + }); + this.getBookInfo(this.data.bookDetail.id); + } + }); + } 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 {} + } else { + wx.showToast({ + title: "鍟嗗搧涓嶅湪鏈夋晥鏈�", + icon: "none", + duration: 1000, + }); + } + } + const token = wx.getStorageSync(app.config.tokenKey) + if (!token) { + this.logInFun(() => {}) } else { - wx.showToast({ - title: "鍟嗗搧涓嶅湪鏈夋晥鏈�", - icon: "none", - duration: 1000, - }); + buyFun() } }, goRead() { - // 棣栭〉娴嬭瘯鐧诲綍鍔熻兘锛屽悗缁敞閲� - // 妫�鏌ョ櫥褰曠姸鎬� - const token = wx.getStorageSync(app.config.tokenKey) - if (!token) { - loginInfo(app, (data) => { - // 濡傛灉涓嶆槸绗竴娆$櫥褰曪紝浼氭墽琛屽洖璋� - if (data) { - // 鐧诲綍鎴愬姛锛岃嚜鍔ㄨ褰晅oken鍜岀敤鎴蜂俊鎭紝骞惰繑鍥瀟rue - const item = this.data.digitalsData - wx.navigateTo({ - url: '/pages/digitalTextbooks/digitalTextbooksDetails/components/webView/index?refCode=' + item.refCode + "&tryPageCount=" + item.probationPage - }); - } else { - // 鍑虹幇閿欒锛岃繑鍥瀎alse - } - }) - } else { - // 濡傛灉鏄涓�娆$櫥褰曪紝浼氳烦杞嚦缁戝畾鐢ㄦ埛淇℃伅椤甸潰锛屽~鍐欏畬鐢ㄦ埛淇℃伅鍚庤繘琛岀櫥褰曞苟鍌ㄥ瓨token鍜岀敤鎴蜂俊鎭紝缁撴潫鍚庤烦杞洖褰撳墠椤甸潰锛堟惡甯﹂〉闈㈠弬鏁帮級 + const gotoPageFun = () => { const item = this.data.digitalsData wx.navigateTo({ url: '/pages/digitalTextbooks/digitalTextbooksDetails/components/webView/index?refCode=' + item.refCode + "&tryPageCount=" + item.probationPage }); } - // let token = wx.getStorageSync(app.config.tokenKey) - // if (token) { - - - - - // } - - + const token = wx.getStorageSync(app.config.tokenKey) + if (!token) { + this.logInFun(() => {}) + } else { + gotoPageFun() + } }, onTabClick(e) { let tab = e.currentTarget.dataset.tab; - this.setData({ type: tab, @@ -606,41 +599,7 @@ }).exec() }, 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: 'FavoriteTextBooks' - }) - .then(() => { - this.setData({ - "digitalsData.isFavourite": false - }) - }) - } else { - let params = { - productIds: [this.data.digitalsData.id], - linkType: 'FavoriteTextBooks' - } - 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({ @@ -663,6 +622,12 @@ }) }) } + } + const token = wx.getStorageSync(app.config.tokenKey) + if (!token) { + this.logInFun(() => {}) + } else { + collectFun() } }, // 鎴戣寤鸿 @@ -712,40 +677,48 @@ }, onCertificate() { - 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: this.data.isCertificate.state == 'WaitAudit' ? "鎮ㄧ敵璇风殑璇佷功姝e湪瀹℃牳涓�" : this.data.isCertificate.state == 'Normal' ? '鎮ㄥ凡鐢宠璇佷功' : '', - icon: "none", - duration: 1000, - }); - return false - } + 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: this.data.isCertificate.state == 'WaitAudit' ? "鎮ㄧ敵璇风殑璇佷功姝e湪瀹℃牳涓�" : this.data.isCertificate.state == 'Normal' ? '鎮ㄥ凡鐢宠璇佷功' : '', + icon: "none", + duration: 1000, + }); + return false + } - var page = getCurrentPages().pop(); // 鑾峰彇褰撳墠椤甸潰瀹炰緥 - page.setData({ - // 鍔ㄦ�佽缃姝㈡粴鍔ㄧ殑鏍峰紡 - disableScrollStyle: 'overflow: hidden;' - }); - this.setData({ - dialogBox: true, - scrollJudge: '' - }) + var page = getCurrentPages().pop(); // 鑾峰彇褰撳墠椤甸潰瀹炰緥 + page.setData({ + // 鍔ㄦ�佽缃姝㈡粴鍔ㄧ殑鏍峰紡 + disableScrollStyle: 'overflow: hidden;' + }); + this.setData({ + dialogBox: true, + scrollJudge: '' + }) + } + const token = wx.getStorageSync(app.config.tokenKey) + if (!token) { + this.logInFun(() => {}) + } else { + cateFun() + } }, closeDialog() { this.setData({ -- Gitblit v1.9.1