zjh
2025-04-26 18db0dbf100ff81ead99b1d6a3daa6c4c26e5d91
pages/BasePages/login.vue
@@ -9,29 +9,15 @@
      <form class="login-form" @submit.prevent="handleSubmit">
        <view class="form-group">
          <text class="form-label">账号</text>
          <input
            type="text"
            id="username"
            v-model="username"
            placeholder="请输入账号"
            class="form-input"
            autocapitalize="off"
            autocomplete="username"
         @keyup.enter="handleSubmit"
          />
               <input type="text" id="username" v-model="username" placeholder="请输入账号" class="form-input"
                  autocapitalize="off" autocomplete="username" @keyup.enter="handleSubmit" />
        </view>
        
        <view class="form-group">
          <text class="form-label">密码</text>
          <input
            :type="showPassword ? 'text' : 'password'"
            id="password"
            v-model="password"
            placeholder="请输入密码"
            class="form-input"
            autocomplete="current-password"
         @keyup.enter="handleSubmit"
          />
               <input :type="showPassword ? 'text' : 'password'" id="password" v-model="password"
                  placeholder="请输入密码" class="form-input" autocomplete="current-password"
                  @keyup.enter="handleSubmit" />
          <view class="password-toggles">
            <text class="show-password" @tap="toggleShowPassword">
              {{ showPassword ? '隐藏密码' : '显示密码' }}
@@ -77,6 +63,7 @@
      this.showPassword = !this.showPassword;
    },
    handleSubmit() {
      // uni.showToast({
      //   title: '登录功能仅为演示',
      //   icon: 'none'
@@ -86,7 +73,7 @@
      //   username: this.username,
      //   password: this.password
      // }).then(...)
     console.log(this.username)
     if (!this.username) {
        uni.showToast({
           icon: 'none',
@@ -149,6 +136,21 @@
            this.$loginInfo.chineseName = user.fname;
            this.$loginInfo.id = user.fid;
            this.$loginInfo.roleid=user.roleids;
            uni.setStorage({
               key: 'gs_mes_pad_userid',
               data: this.username,
               success: function() {
               }
            });
            uni.setStorage({
               key: 'gs_mes_pad_userkey',
               data: this.password,
               success: function() {
               }
            });
            this.$login();
            if (this.$loginInfo.forcedLogin) {
               uni.reLaunch({
@@ -157,6 +159,57 @@
            } else {
               uni.navigateBack();
            }
         }
      },
      onLoad(options) {
       try {
          const id = uni.getStorageSync('gs_mes_pad_userid');
         const pwd = uni.getStorageSync('gs_mes_pad_userkey');
         if(id){
            this.username=id;
         }
         if(pwd){
            this.password=pwd;
         }
          if (id&&pwd) {
             uni.showLoading({
                mask: true,
                title: "登录中..."
             });
             uni.request({
                url: this.$store.state.serverInfo.serverAPI + '/login/login',
                method: "POST",
                header: {
                   'content-type': "application/json"
                },
                data: {
                   userID: id,
                   userPass: pwd
                },
                success: res => {
                   if (res.data.status == 0) {
                      this.toMain(res.data.data.tbBillList[0]);
                   } else {
                      uni.showToast({
                         icon: 'none',
                         title: res.data.message
                      });
                   }
                },
                fail(err) {
                   uni.showToast({
                      icon: 'none',
                      title: "服务器断开"
                   });
                },
                complete: () => {
                   uni.hideLoading();
                }
             });
          }
       } catch (e) {
          // error
         }
  }
}
@@ -349,6 +402,7 @@
    font-size: 13px;
  }
}
/* 手机样式 */
@media (min-width: 300px) {
  .login-content {