From ab5a7dda97a66053260563fd453dc25743fd4991 Mon Sep 17 00:00:00 2001 From: XiaoXinPro 14 IAH5R <568170040@qq.com> Date: Thu, 11 May 2023 17:55:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E4=BA=ABbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- miniprogram/app.js | 1 + miniprogram/pages/ContactUs/ContactUs.js | 30 +++++++++++--- miniprogram/pages/chat/chat.js | 30 +++++++++++--- miniprogram/pages/index/index.js | 52 +++++++++++++++++++----- miniprogram/utils/request.js | 4 +- project.config.json | 2 +- 6 files changed, 96 insertions(+), 23 deletions(-) diff --git a/miniprogram/app.js b/miniprogram/app.js index 6a254a6..0bd5e12 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -82,6 +82,7 @@ App({ wx.setStorageSync('completionContentCount', res.data.completionContentCount) that.globalData.completionContentCount = res.data.completionContentCount + }).catch(err => { console.log(err, 'err'); }) diff --git a/miniprogram/pages/ContactUs/ContactUs.js b/miniprogram/pages/ContactUs/ContactUs.js index e837f5b..324dca4 100644 --- a/miniprogram/pages/ContactUs/ContactUs.js +++ b/miniprogram/pages/ContactUs/ContactUs.js @@ -48,7 +48,7 @@ Page({ }) }, - makePhoneCall(e){ + makePhoneCall(e) { wx.makePhoneCall({ phoneNumber: e.currentTarget.dataset.phone }) @@ -97,10 +97,30 @@ Page({ }, - /** - * 用户点击右上角分享 - */ onShareAppMessage() { - + const promise = new Promise(resolve => { + setTimeout(() => { + resolve({ + title: '小闲聊' + }) + }, 500) + }) + return { + title: '小闲聊', + promise + } + }, + onShareTimeline() { + const promise = new Promise(resolve => { + setTimeout(() => { + resolve({ + title: '小闲聊' + }) + }, 500) + }) + return { + title: '小闲聊', + promise + } } }) \ No newline at end of file diff --git a/miniprogram/pages/chat/chat.js b/miniprogram/pages/chat/chat.js index 4ff4a2a..fe71171 100644 --- a/miniprogram/pages/chat/chat.js +++ b/miniprogram/pages/chat/chat.js @@ -43,7 +43,7 @@ Page({ const that = this return new Promise((resolve, reject) => { const data = { - appId: 'wxf288a9b8167ff2ca', + appId: 'wxedb9fb309728a9f1', message } request.post({ @@ -440,10 +440,30 @@ Page({ }, - /** - * 用户点击右上角分享 - */ onShareAppMessage() { - + const promise = new Promise(resolve => { + setTimeout(() => { + resolve({ + title: '小闲聊' + }) + }, 500) + }) + return { + title: '小闲聊', + promise + } + }, + onShareTimeline() { + const promise = new Promise(resolve => { + setTimeout(() => { + resolve({ + title: '小闲聊' + }) + }, 500) + }) + return { + title: '小闲聊', + promise + } } }) \ No newline at end of file diff --git a/miniprogram/pages/index/index.js b/miniprogram/pages/index/index.js index ba0b5f7..bded52f 100644 --- a/miniprogram/pages/index/index.js +++ b/miniprogram/pages/index/index.js @@ -29,19 +29,28 @@ Page({ this.checkUserInfo() } const that = this - app.userInfoCallback = res => { - console.log(res, 'userInfoCallback') - that.setData({ - userInfo: res.data, - isPhone: that.data.userInfo.phone ? true : false - }) - if (app.globalData.noticeText) { + if (!this.data.checkUserInfo) { + app.userInfoCallback = res => { + console.log(res, 'userInfoCallback') that.setData({ - noticeText: app.globalData.noticeText + userInfo: res.data, + isPhone: that.data.userInfo.phone ? true : false }) + if (app.globalData.noticeText) { + that.setData({ + noticeText: app.globalData.noticeText + }) + } } } }, + + onShow() { + if (!this.data.checkUserInfo) { + this.getNoticeText() + } + }, + getUserProfile() { // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗 wx.getUserProfile({ @@ -226,6 +235,31 @@ Page({ }) }, + /** + * @description 获取通知栏信息文本 + * @returns list + */ + getNoticeText() { + const that = this + request.get({ + url: '/api/notice/list' + }).then(res => { + console.log(res, 'getNoticeText'); + let noticeText = '' + res.data.forEach((item, index) => { + noticeText += index + 1 + '、' + item.content + ' ' + }) + app.globalData.noticeText = noticeText + that.setData({ + noticeText: noticeText + }) + // 检查用户信息 + that.checkUserInfo() + }).catch(err => { + console.log(err, 'err'); + }) + }, + onShareAppMessage() { const promise = new Promise(resolve => { setTimeout(() => { @@ -236,7 +270,6 @@ Page({ }) return { title: '小闲聊', - path: '/pages/index/index', promise } }, @@ -250,7 +283,6 @@ Page({ }) return { title: '小闲聊', - path: '/pages/index/index', promise } } diff --git a/miniprogram/utils/request.js b/miniprogram/utils/request.js index eabe224..473607b 100644 --- a/miniprogram/utils/request.js +++ b/miniprogram/utils/request.js @@ -33,9 +33,9 @@ class request { /** * @description 小程序appId - * @returns {string} wxf288a9b8167ff2ca + * @returns {string} wxedb9fb309728a9f1 */ - appId = 'wxf288a9b8167ff2ca'; + appId = 'wxedb9fb309728a9f1'; /** * @description get diff --git a/project.config.json b/project.config.json index dfabc4b..1cd93cb 100644 --- a/project.config.json +++ b/project.config.json @@ -31,7 +31,7 @@ "simulatorPluginLibVersion": {}, "condition": {}, "srcMiniprogramRoot": "miniprogram/", - "appid": "wxf288a9b8167ff2ca", + "appid": "wxedb9fb309728a9f1", "libVersion": "2.31.0", "editorSetting": { "tabIndent": "insertSpaces",