From fddf11c498ee9500fc522d1b5dcaaccf00167104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=93=E5=B9=B3=E8=89=BA?= <52643018@qq.com> Date: Thu, 24 Jun 2021 15:50:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=B7=E6=B1=82=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/http.js | 9 +++++++++ pages/login/index.vue | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/common/http.js b/common/http.js index 69800b2..50b0f44 100644 --- a/common/http.js +++ b/common/http.js @@ -62,6 +62,15 @@ function $http(url, data = {}, options = {}){ if (sysInfo) { data.device_info = JSON.stringify(sysInfo); } + // 判断传入用户token和id + let userinfo = uni.getStorageSync('userinfo') || {}; + if(userinfo && userinfo.token && !data.token){ + data.token = userinfo.token; + } + if(userinfo && userinfo.id && !data.user_id){ + data.user_id = userinfo.id; + } + // 获取页面options参数 let _mergeParam = that._mergeParam; for (let _keyVar in _mergeParam) { diff --git a/pages/login/index.vue b/pages/login/index.vue index 24362fb..bb5739b 100644 --- a/pages/login/index.vue +++ b/pages/login/index.vue @@ -47,7 +47,7 @@ }, onLoad(options){ this.type = options.type || this.type; - getApp().globalData.wxlogin(); + getApp().globalData.wxlogin(); // 重新登录 }, methods: { // 进入查看协议 @@ -71,6 +71,9 @@ token: userInfo.token }).then(res => { console.log("更新手机号", res); + this.$msg('更新成功', {icon: 'success'}); + uni.setStorageSync('userinfo', res.data); + this.$toBack(); }) } },