qingyiay
2023-03-28 e7b0b34176549cfec809c6b89c4cab0999e488b9
pages/login/userPassword.vue
@@ -31,7 +31,7 @@
<script>
import { apiLoginPassword } from '@/api/publicInterface.js';
import { mapMutations } from 'vuex';
import { setToken, setRefreshToken, setUsernameKey, setCustomerId, redirectHome } from '@/utils/status.js';
import { setName, setToken, setRefreshToken, setUsernameKey, setCustomerId, redirectHome } from '@/utils/status.js';
export default {
   name: 'userPassword',
   props: {
@@ -43,8 +43,9 @@
   },
   data() {
      return {
         username: '18804050607',//客户
         // username: '18805080506',//王楠(司机)
         username: '12222222222', // 客户
         // username:'13333333331',//货代
         // username: '13333333332',// 司机
         password: '123456',
         remember: true,
         baseUrl: ''
@@ -79,39 +80,43 @@
               setRefreshToken(res.refresh_token);
               if (this.btnText == 0) {
                  if (res.code != 1) {
                     this.$u.toast('恭喜您,登录成功!');
                     // 登陆成功,存储相关信息
                     setToken(res.access_token);
                     setRefreshToken(res.refresh_token);
                     setUsernameKey(res.username);
                     //查询用户详细信息并储存
                     this.$reqGet('getUserEntity').then(res => {
                        this.setUserTabbar(res.data.type);
                        uni.setStorageSync('roleType', res.data.type);
                        setCustomerId(res.data.customerid);
                        uni.hideLoading();
                        //跳转页面
                        this.$nextTick(() => {
                           redirectHome();
                     this.$reqGet('getUserEntity')
                        .then(res => {
                           this.$u.toast('登录成功');
                           this.setUserTabbar(res.data.type);
                           uni.setStorageSync('roleType', res.data.type);
                           setCustomerId(res.data.customerid);
                           setName(res.name);
                           uni.hideLoading();
                           //跳转页面
                           this.$nextTick(() => {
                              redirectHome();
                           });
                        })
                        .catch(err => {
                           this.$u.toast('登录异常!');
                           console.log(err);
                        });
                     });
                  } else {
                     uni.hideLoading();
                     this.$u.toast(res.msg);
                  }
               } else {
                  this.$nextTick(() => {
                     this.$reqPost('wxBind', { state: 'MINI', code: uni.getStorageSync('code') }, 'params').then(res => {
                        uni.hideLoading();
                        if (res.code == 0) {
                           this.$u.toast('绑定成功!即将回到登录页!');
                           setTimeout(() => {
                              uni.navigateBack();
                           }, 1000);
                        } else {
                           this.$u.toast(res.msg ? res.msg : '绑定失败');
                        }
                     });
                  this.$reqPost('wxBind', { state: 'MINI', code: uni.getStorageSync('code') }, 'params').then(res => {
                     uni.hideLoading();
                     if (res.code == 0) {
                        this.$u.toast('绑定成功!即将回到登录页!');
                        setTimeout(() => {
                           uni.navigateBack();
                        }, 1000);
                     } else {
                        this.$u.toast(res.msg ? res.msg : '绑定失败');
                     }
                  });
               }
            })