diff --git a/pages/user/PersonalData/index.vue b/pages/user/PersonalData/index.vue index ba56aab..3a1e92d 100644 --- a/pages/user/PersonalData/index.vue +++ b/pages/user/PersonalData/index.vue @@ -171,17 +171,17 @@ export default { getUserInfo: function() { let that = this; getUser().then(res => { - let switchUserInfo = res.data.switchUserInfo; - for (let i = 0; i < switchUserInfo.length; i++) { - if (switchUserInfo[i].uid == that.userInfo.uid) that.userIndex = i; - if ( - !that.isWeixin && - switchUserInfo[i].user_type != "h5" && - switchUserInfo[i].phone === "" - ) - switchUserInfo.splice(i, 1); - } - that.$set(this, "switchUserInfo", switchUserInfo); + // let switchUserInfo = res.data.switchUserInfo; + // for (let i = 0; i < switchUserInfo.length; i++) { + // if (switchUserInfo[i].uid == that.userInfo.uid) that.userIndex = i; + // if ( + // !that.isWeixin && + // switchUserInfo[i].user_type != "h5" && + // switchUserInfo[i].phone === "" + // ) + // switchUserInfo.splice(i, 1); + // } + // that.$set(this, "switchUserInfo", switchUserInfo); }); }, imageuploaded(res) { diff --git a/pages/user/User/index.vue b/pages/user/User/index.vue index 2d0363a..ffed25d 100644 --- a/pages/user/User/index.vue +++ b/pages/user/User/index.vue @@ -220,6 +220,7 @@ export default { this.$yrouter.push("/pages/user/PersonalData/index"); }, getPhoneNumber: function(e) { + let thit=this // 判断一下这里是不是小程序 如果是小程序,走获取微信手机号进行绑定 if (e.mp.detail.errMsg == "getPhoneNumber:ok") { uni.showLoading({ @@ -239,7 +240,9 @@ export default { iv: e.mp.detail.iv }) .then(res => { - this.User(); + console.log(res); + // this.User(); + thit.$store.dispatch("USERINFO", true); uni.hideLoading(); uni.showToast({ title: res.msg, @@ -248,15 +251,27 @@ export default { }); }) .catch(error => { + uni.hideLoading(); + thit.$store.dispatch("USERINFO", true); + console.log(error); uni.showToast({ - title: error.msg || error.response.data.msg, + title: + error.msg || + error.response.data.msg || + error.response.data.message, icon: "none", duration: 2000 }); }); + }, + fail() { + reject("绑定失败"); } }); } + }, + fail() { + reject("获取环境服务商失败"); } }); } else { diff --git a/utils/index.js b/utils/index.js index 255946c..8dc944d 100644 --- a/utils/index.js +++ b/utils/index.js @@ -208,6 +208,7 @@ export const login = (option) => { resolve(data) uni.hideLoading(); store.commit("LOGIN", data.token, dayjs(data.expires_time)); + store.dispatch('USERINFO', true) console.log(store) handleGetUserInfo() diff --git a/utils/request.js b/utils/request.js index 68974c4..71ee8f1 100644 --- a/utils/request.js +++ b/utils/request.js @@ -57,6 +57,7 @@ function baseRequest(options) { }).then(res => { const data = res.data || {}; if (res.status !== 200) { + return Promise.reject({ msg: "请求失败", res, data }); } if ([410000, 410001, 410002].indexOf(data.status) !== -1) {