qingyiay
2023-03-28 5c01be6370291febe52adfa74fad8101a197c388
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: ''
@@ -84,27 +85,37 @@
                     setRefreshToken(res.refresh_token);
                     setUsernameKey(res.username);
                     //查询用户详细信息并储存
                     this.$reqGet('getUserEntity').then(res => {
                        this.$u.toast('恭喜您,登录成功!');
                        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);
                        });
                     }).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.login({
                     success: res => {
                        if (res.code) {
                           uni.setStorageSync('bindcode', res.code);
                        }
                     }
                  });
                  if (uni.getStorageSync('bindcode')) {
                     this.$reqPost('wxBind', { state: 'MINI', code: uni.getStorageSync('bindcode') }, 'params').then(res => {
                        uni.hideLoading();
                        if (res.code == 0) {
                           this.$u.toast('绑定成功!即将回到登录页!');
@@ -115,7 +126,7 @@
                           this.$u.toast(res.msg ? res.msg : '绑定失败');
                        }
                     });
                  });
                  }
               }
            })
            .catch(e => {