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/note/note.js | 144 ++++++++++++++++++++++++++++------------------- 1 files changed, 85 insertions(+), 59 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 -- Gitblit v1.9.1