朱桂飞
2023-03-22 4434c41562f18959967a957f09c795f0c24f3b70
pages/login/login.vue
@@ -13,7 +13,8 @@
            </u-form-item>
            <u-form-item label="密码" prop="password" borderBottom ref="item1">
               <u-input v-model="model.password" placeholder="请输入密码" border="none" clearable></u-input>
               <u-input type="password" v-model="model.password" placeholder="请输入密码" border="none" clearable>
               </u-input>
            </u-form-item>
         </view>
@@ -54,36 +55,51 @@
         };
      },
      onLoad() {
         const account = uni.getStorageSync('account');
         if (account) {
            this.model = account
         }
      },
      methods: {
         forget() {
            uni.navigateTo({
               url: "/pages/tabBar/demo"
            })
         },
         submit() {
            
            this.$refs.form.validate().then(res => {
               uni.$u.toast('校验通过')
               //this.login()
               uni.switchTab({
                  url:'/pages/tabBar/general'
               })
               this.login()
            }).catch(errors => {
               uni.$u.toast('校验失败')
            })
         },
         login() {
            this.$api.test({
               id: 4
            }).then((res) => {
            this.$api.login(this.model).then((res) => {
               if (res.success) {
             
               console.log('request success', res)
               uni.showToast({
                  title: '请求成功',
                     title: '登录成功',
                  icon: 'success',
                  mask: true
               });
               
                  uni.setStorageSync('account', this.model);
                  uni.setStorageSync('userinfo', res.result.userInfo);
                  uni.setStorageSync('token', res.result.token);
               uni.switchTab({
                  url:'/pages/tabBar/general'
               })
               }
            }).catch((err) => {
          
               console.log('request fail', err);