From 8ebe968b1b3458da98a9436df4c4e8d362b19980 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=96=B9=E6=88=90?= Date: Wed, 22 Oct 2025 03:57:38 +0800 Subject: [PATCH] =?UTF-8?q?fix(contact):=20=E6=9B=BF=E6=8D=A2=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=8E=88=E6=9D=83=E5=BC=B9=E7=AA=97=E4=B8=BA=E9=9D=99?= =?UTF-8?q?=E9=BB=98=E7=99=BB=E5=BD=95=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将用户授权弹窗改为静默登录提示,优化登录流程。同时更新API基础URL配置,移除废弃代码。 --- .DS_Store | Bin 0 -> 6148 bytes api/request.js | 4 ++-- pages/.DS_Store | Bin 0 -> 6148 bytes pages/contact/index.js | 47 +++++++++++++++------------------------ pages/contact/index.wxml | 11 +++------ 5 files changed, 23 insertions(+), 39 deletions(-) create mode 100644 .DS_Store create mode 100644 pages/.DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..802ccbe6105a1588c0055e3f69f7ce80c9bc6700 GIT binary patch literal 6148 zcmeHKL2uJA6n<{IE@c8$0;EX@DH7MJlre3ZxMZa}aNx2cH~=b1TSi6}S53MiRh4pv z|G;11$}i!+aDwmIW=fMz;(!oCe$n&i*zY~tpB+0UBGH|V9uPH&$bmA}t|3_?T+dpP ziYd7P6e`A;q9>6Y29XR(*0#VhU>W$=7~pTWP96p1Ls!3F-V_d@?H@{1*Q>CbP?-D5 z+3L%BtMmRej%0j-TI>&KhkYm1rc+8*BZ#|&2u|LXB*g{$PnX)y=>sLD_}>fmbs8e- z8J<$?3imfZ<_+}OrxUPK=(S?!bB>*yWiU@BW*__-OrkJJJDqQ$Qmt*&Hyy{>a$fh} z$$3BZ(^=B>r!V>KnUqoREAI!-!|{C3y!BYdsUODUsd5NMW0<^p5ym4q@5)&`N|bM3 zS2&GEW6<1QEOrj|TJFRB{bkEt9PD&j?(W|1a@lZh-@E_lcMm!NatWYMdaU#s#Z@v zYJ-mH2(#0pr@%I5d9-Hzd1Am?Y z-XB~jqh~PFsJ0Fy>Iwj?p;!s>{6oM#u0hXWrV%v|p@Nlh6O7%kTfIPWH_*U>W$Y7!b8yzt_c( z%-LER9G|r=^bM4S?J|wZ1&KM1Rfdn^ZKx8|xtsxd1~ZK)f!H4bMT1Q&1Amo)pG<4# A9{>OV literal 0 HcmV?d00001 diff --git a/api/request.js b/api/request.js index 6106bf7..44820f7 100644 --- a/api/request.js +++ b/api/request.js @@ -1,5 +1,5 @@ -// const baseUrl = 'https://mini-chat.1024tool.vip/api/'; -const baseUrl = 'https://dsjhd9s.tbmw.cn/api/' +const baseUrl = 'https://mini-chat.1024tool.vip/api/'; +// const baseUrl = 'https://dsjhd9s.tbmw.cn/api/' function request(url, method = 'GET', data = {}) { const header = { diff --git a/pages/.DS_Store b/pages/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..f2dbd2e554a2279f4e5a6d204b9ad66470fd0af9 GIT binary patch literal 6148 zcmeHKOG-mQ5UkdS0XJE?oGW;PA;c5p0*Vn4HA(>~AO#Kz`1hgF9ed%J z7@rOf(E<=>42N+Zy#%p&fY=MiL`G~;h30oSlrBW>Sn7B#o~6x zTcpE!qDCno1&$Rs&*j4F|1JH8{{NVyl@yQy|4IRyt=6k0pH#JV@;I-xjebY>oKLzN p=Rx5R<(L@dm { wx.setStorageSync('user_info', resp); - // wx.setStorageSync('open_id', resp.openid); that.setData({ showGetUser: false, userInfo: resp }); request('app/user/create', 'post', { "app_id": accountInfo.miniProgram.appId, - "user_avatar": resp.user_avatar, + "user_avatar": resp.user_avatar || '/static/user.png', "user_id": resp.openid, - "user_name": resp.user_name + "user_name": resp.user_name || '微信用户' }).then(resp => { that.getMessages() // start polling once user info exists that.startPolling(); - + }); + }).catch(err => { + console.error('静默登录失败:', err); + // 如果静默登录失败,可以选择显示授权弹窗或其他处理 + that.setData({ + showGetUser: true }); }); }, + fail: function(err) { + console.error('wx.login失败:', err); + } }); - }, // Start polling messages every 1 second. Ensures only one interval exists. @@ -234,11 +227,7 @@ Page({ } }, - dismissGetUser() { - this.setData({ - showGetUser: false - }); - }, + onReady() { // 初始化欢迎消息,带时间分割线 diff --git a/pages/contact/index.wxml b/pages/contact/index.wxml index 738b28a..8a4d1d1 100644 --- a/pages/contact/index.wxml +++ b/pages/contact/index.wxml @@ -39,17 +39,12 @@ - + - 授权获取您的用户信息 - 授权后可用于显示头像、昵称等,提升聊天体验。 - - - - - + 正在登录... + 请稍候,正在为您自动登录。