付延余
2023-03-24 eb9ae89c3e9f66fe5d0f39092a41e5c09bd86fc6
pages/login/login.vue
@@ -2,7 +2,7 @@
   <view class="login">
      <view class="logo">无人值守</view>
      <!--用户名密码登录-->
      <user-password :btnText='0'/>
      <user-password :btnText="0" />
      <!-- 微信openid登录 -->
      <view class="loginBtn">
         <u-button class="button" @click.stop="beforeLoginEvent" :disabled="btnLoading" :loading="btnLoading" type="primary" text="微信一键登录"></u-button>
@@ -39,7 +39,6 @@
export default {
   data() {
      return {
         wxcode: '', // 司机1
         btnLoading: false,
         loginPopupShow: false,
         // 绑定微信模态框
@@ -62,8 +61,7 @@
         uni.login({
            success: res => {
               if (res.code) {
                  this.wxcode = res.code;
                  this.apiLogin();
                  this.apiLogin(res.code);
               } else {
                  uni.showToast({
                     title: '微信登录失败!',
@@ -74,37 +72,18 @@
         });
      },
      // 登录接口
      apiLogin() {
         // apiLoginWx({ code: this.wxcode })
         //    .then(res => {
         //       console.log('请求登录', res);
         //       if (res.msg == '需绑定') {
         //          uni.navigateTo({
         //             url: `/pages/register/register?code=${res.data}`
         //          });
         //       }
         //       if (res.msg == '登录成功') {
         //          uni.setStorageSync('userInfo', res.data);
         //          this.setUserTabbar(res.data.type);
         //          uni.switchTab({
         //             url: '/pages/tabbar-page/index-tabbar/index-tabbar'
         //          });
         //       }
         //    })
         //    .catch(err => {
         //       console.log('错误', err);
         //    });
      apiLogin(code) {
         /**
          * @openid
          * 获取微信用户openid,微信一键登录暂无相关接口,用于测试呼叫客服功能
          */
         uni.showLoading({
            title: '加载中...'
         });
         wx.request({
            url: `https://api.weixin.qq.com/sns/jscode2session?appid=wx4a62fc1684c429a9&secret=ee90afe376cdcec2fdd947c0a4db961a&js_code=${this.wxcode}&grant_type=authorization_code`,
            url: `https://api.weixin.qq.com/sns/jscode2session?appid=wx4a62fc1684c429a9&secret=ee90afe376cdcec2fdd947c0a4db961a&js_code=${code}&grant_type=authorization_code`,
            success(res) {
               let id = res.data.openid;
               uni.setStorageSync('openid', id);
               uni.setStorageSync('openid', res.data.openid);
               uni.showToast({
                  title: '成功获取测试openid',
                  icon: 'none'
@@ -124,6 +103,7 @@
                     this.setUserTabbar(res.data.type);
                     uni.setStorageSync('roleType', res.data.type);
                     setCustomerId(res.data.customerid);
                     uni.hideLoading();
                     //跳转页面
                     this.$nextTick(() => {
                        redirectHome();
@@ -135,7 +115,6 @@
               }
            });
         });
         this.loginPopupShow = false;
      },
      bindWxConfirm() {