qingyiay
2023-05-17 af436aa050f76584cd5cb88e413e45cd08c15d50
pages/login/login.vue
@@ -61,6 +61,7 @@
         uni.login({
            success: res => {
               if (res.code) {
                  uni.setStorageSync('code', res.code);
                  this.apiLogin(res.code);
               } else {
                  uni.showToast({
@@ -80,21 +81,20 @@
         uni.showLoading({
            title: '加载中...'
         });
         wx.request({
            url: `https://api.weixin.qq.com/sns/jscode2session?appid=wx4a62fc1684c429a9&secret=ee90afe376cdcec2fdd947c0a4db961a&js_code=${code}&grant_type=authorization_code`,
            success(res) {
               uni.setStorageSync('openid', res.data.openid);
               uni.showToast({
                  title: '成功获取测试openid',
                  icon: 'none'
               });
            }
         });
         // wx.request({
         //    url: `https://api.weixin.qq.com/sns/jscode2session?appid=wx4a62fc1684c429a9&secret=ee90afe376cdcec2fdd947c0a4db961a&js_code=${code}&grant_type=authorization_code`,
         //    success(res) {
         //       uni.setStorageSync('openid', res.data.openid);
         //       uni.showToast({
         //          title: '成功获取测试openid',
         //          icon: 'none'
         //       });
         //    }
         // });
         this.$nextTick(() => {
            apiLoginWx({ code: uni.getStorageSync('openid') }).then(res => {
               uni.hideLoading();
            apiLoginWx({ code: code }).then(res => {
               if (res.code != 1) {
                  this.$u.toast('恭喜您,登录成功!');
                  this.$u.toast('登录成功');
                  // 登陆成功,存储相关信息
                  setToken(res.access_token);
                  setRefreshToken(res.refresh_token);
@@ -104,6 +104,7 @@
                     this.setUserTabbar(res.data.type);
                     uni.setStorageSync('roleType', res.data.type);
                     setCustomerId(res.data.customerid);
                     uni.hideLoading();
                     //跳转页面
                     this.$nextTick(() => {
                        redirectHome();
@@ -119,7 +120,7 @@
      },
      bindWxConfirm() {
         uni.navigateTo({
            url: `/pages/login/wxLogin?code=${uni.getStorageSync('openid')}`
            url: `/pages/login/wxLogin?code=${uni.getStorageSync('code')}`
         });
         this.bindWxModelShow = false;
      },