#
zjj
2025-06-16 4c9525b77cb86da7c5b477dcafffc78360c5b850
pages/login/index.vue
@@ -55,7 +55,7 @@
            </view>
         </view>
         <view class="itemView">
            <button class="loadingButton"  :loading="loading">{{btnText}}</button>
            <button class="loadingButton" @click="onLogin()"  :loading="loading">{{btnText}}</button>
         </view>
      </view>
   </view>
@@ -119,6 +119,61 @@
      })
   },
   methods:{
      async onLogin() {
         const {
            code,
            data,
            msg
         } = await request('/login', {
            username: this.user.userName,
            password: this.user.password,
         })
         if (code === 200) {
            this.loading = true;
            this.loginButton = 'login.loging';
            uni.setStorageSync('token', data.accessToken);
            uni.setStorageSync('userData', data.user);
            if (this.remberPassword) {
               uni.setStorageSync('user', this.user);
            } else {
               uni.removeStorageSync('user');
            }
            this.goHome()
         } else {
            uni.showToast({
               title: msg
            })
         }
      },
      goHome() {
         setTimeout(() => {
            // this.getAuth2()
            this.getFields()
            uni.showToast({
               title: '登录成功'
            })
            setTimeout(() => {
               uni.reLaunch({
                  url: '../home/index'
               });
            }, 300)
         }, 700)
      },
      async getFields() {
         const {
            code,
            data,
            msg
         } = await request('/dynamic/fields', {}, 'get')
         if (code === 200) {
            this.$store.commit('user/setFields', data)
         } else {
            uni.showToast({
               title: msg
            })
         }
      },
      remberChange(e) {
         this.remberPassword = !this.remberPassword
      },