宋飞扬 1 年之前
父节点
当前提交
cd6cc330b8
共有 3 个文件被更改,包括 63 次插入164 次删除
  1. 2 2
      src/pages/login/index.vue
  2. 56 150
      src/pages/login/phoneLogin.vue
  3. 5 12
      src/pages/login/register.vue

+ 2 - 2
src/pages/login/index.vue

@@ -18,6 +18,7 @@
         手机号登录/注册
       </u-button>
     </view>
+    <br />
 
     <!-- 底部协议 -->
     <view class="agree">
@@ -156,9 +157,8 @@ export default {
 
 .agree {
   display: flex;
-  flex-wrap: wrap;
-  margin-top: 20rpx;
   justify-content: center;
   align-items: center;
+  font-size: 27rpx;
 }
 </style>

+ 56 - 150
src/pages/login/phoneLogin.vue

@@ -1,6 +1,11 @@
 <template>
   <view class="container">
-    <u-image src="@/static/logo.png"></u-image>
+    <!-- 顶部logo -->
+    <div class="image">
+      <u-image src="@/static/logo.png"></u-image>
+    </div>
+
+    <!-- 中间登录注册 -->
     <view class="login-form-wrap">
       <u--form labelPosition="left" :model="loginForm" :rules="rules" ref="loginForm">
         <u-form-item prop="mobile" borderBottom label="账号">
@@ -18,10 +23,16 @@
             v-model="loginForm.password"
             maxlength="6"
             border="none"
+            :type="type"
             placeholder="请输入密码"
           >
+            <template slot="suffix">
+              <u-icon v-if="type == 'password'" name="eye-off" @click="onClickPW('text')"></u-icon>
+              <u-icon v-else name="eye-fill" @click="onClickPW('password')"></u-icon>
+            </template>
           </u-input>
         </u-form-item>
+
         <view style="display: flex; justify-content: space-between">
           <view style="display: flex">
             <u-checkbox-group>
@@ -51,40 +62,23 @@
           <u-button :loading="loading" shape="circle" @click="register">注册</u-button>
         </u-form-item>
       </u--form>
-      <view class="user-agreement">
-        <u-checkbox-group>
-          <u-checkbox
-            shape="circle"
-            @change="checkboxChange"
-            v-model="isChecked"
-            :checked="isChecked"
-          ></u-checkbox>
-        </u-checkbox-group>
-        <view>我已阅读并同意</view>
-        <view @click="click('用户协议')">《用户协议》</view>
-        <view @click="click('隐私政策')">《隐私政策》</view>
-        <!-- <text class="terms">《商家/车主个人信息保护规则》</text> -->
-      </view>
+      <br />
     </view>
 
-    <!-- <view>
-      <u-popup :show="show" @close="close" mode="center">
-        <view
-          style="
-            height: 100rpx;
-            width: 700rpx;
-            align-items: center;
-            display: flex;
-            justify-content: center;
-          "
-        >
-          <text style="color: gray; font-size: 14px">我已阅读并同意</text>
-          <text style="font-weight: bold">《用户协议》</text>
-          <text style="font-weight: bold">《隐私政策》</text>
-        </view>
-        <u-button @click="confirmShow" type="primary" :loading="loading">确认</u-button>
-      </u-popup>
-    </view> -->
+    <!-- 底部协议 -->
+    <view class="user-agreement">
+      <u-checkbox-group>
+        <u-checkbox
+          shape="circle"
+          @change="checkboxChange"
+          v-model="isChecked"
+          :checked="isChecked"
+        ></u-checkbox>
+      </u-checkbox-group>
+      <view>我已阅读并同意</view>
+      <view @click="click('用户协议')">《用户协议》</view>
+      <view @click="click('隐私政策')">《隐私政策》</view>
+    </view>
 
     <!-- 用户协议弹框 -->
     <userAgreement v-if="show" :title="title" :show="show" @handleConfirm="handleConfirm" />
@@ -93,7 +87,7 @@
 
 <script>
 import userAgreement from '@/components/userAgreement/userAgreement.vue';
-import { getSmsCodeByPhone, loginByPhoneAndSmsCode, maintainSmsCaptcha } from '@/api/login';
+import { maintainSmsCaptcha } from '@/api/login';
 export default {
   components: {
     userAgreement,
@@ -105,9 +99,8 @@ export default {
         client_secret: 'qWBe6jD%GCuPPTkP',
         grant_type: 'sms',
         token: '',
-        mobile: '18380313545', //手机号
-        captcha: '363636', //验证码
-        password: '1', //密码
+        mobile: '', //手机号
+        password: '', //密码
       },
       rules: {
         mobile: [
@@ -124,17 +117,9 @@ export default {
             trigger: ['change', 'blur'],
           },
         ],
-        captcha: [
-          {
-            required: true,
-            trigger: ['change', 'blur'],
-            message: '请输入六位数验证码',
-          },
-        ],
       },
-      seconds: 120,
-      tips: '',
       title: '',
+      type: 'password',
       isChecked: true,
       show: false,
       loading: false,
@@ -147,31 +132,11 @@ export default {
 
   computed: {
     isDisabled() {
-      return !(this.loginForm.mobile && this.loginForm.captcha.length === 6);
+      return !this.loginForm.mobile;
     },
   },
 
   methods: {
-    getCode() {
-      if (!this.loginForm.mobile) return uni.$u.toast('请输入您的手机号!');
-      if (!uni.$u.test.mobile(this.loginForm.mobile)) return uni.$u.toast('手机号码格式不正确!');
-      // TODO: 处理验证码倒计时
-      if (this.$refs.uCode.canGetCode) {
-        getSmsCodeByPhone(this.loginForm.mobile)
-          .then(res => {
-            if (res.code === 200) {
-              uni.$u.toast('验证码已发送');
-              this.loginForm.token = res.data.token;
-              this.$refs.uCode.start();
-            }
-          })
-          .catch(err => {
-            uni.$u.toast('无法发送验证码');
-            this.$refs.uCode.start();
-          });
-      }
-    },
-
     //点击用户协议
     click(title) {
       this.show = true; //打开弹框
@@ -189,41 +154,16 @@ export default {
         this.show = true;
         return;
       }
+      const params = {
+        ...this.loginForm,
+      };
       this.loading = true;
-      let mobile = '18380313545';
-      maintainSmsCaptcha({
-        mobile: mobile,
-      })
-        .then(res => {
-          //   this.loading = false;
-          //   if (res.access_token) {
-          //     uni.$u.toast('登录成功');
-          //     this.$store.commit('SET_ACCESS_TOKEN', res.access_token);
-          //     this.$store.commit('SET_REFRESH_TOKEN', res.refresh_token);
-          //     setTimeout(() => {
-          //       this.$Router.pushTab('/pages/client/tabBar/home');
-          //     }, 1500);
-          //   }
-          // })
-          // .catch(err => {
-          //   this.loading = false;
-          //   uni.$u.toast('登录失败-' + err.data.error_description);
-          //   this.loading = false;
-
-          // 下方登陆代码调通 token不知道放哪 不知道为什么要存两个token  上方代码没动 loginByPhoneAndSmsCode 这个是之前的接口
-          if (res.code == 200) {
-            uni.$u.toast('登录成功');
-            // this.$store.commit('SET_ACCESS_TOKEN', res.data.token);
-            // this.$store.commit('SET_REFRESH_TOKEN', res.data.token);
-            setTimeout(() => {
-              this.$Router.pushTab('/pages/client/tabBar/home');
-            }, 1500);
-          }
-        })
-        .catch(err => {
-          this.loading = false;
-          uni.$u.toast('登录失败-' + err.data.error_description);
-        });
+      const res = await maintainSmsCaptcha(params).catch(err => err);
+      this.loading = false;
+      if (res.code == 200) {
+        this.$Router.pushTab('/pages/client/tabBar/home');
+        uni.$u.toast('登录成功');
+      }
     },
 
     //点击注册
@@ -231,28 +171,9 @@ export default {
       this.$Router.pushTab('/pages/login/register');
     },
 
-    //点击我已阅读
-    // checkboxChange(v) {
-    //   this.isChecked = v;
-    // },
-
-    //点击手机号无法使用?
-    noPhone() {
-      this.$message('要跳转到解决方案哦 还没写');
-    },
-
-    //点击弹框确认
-    confirmShow() {
-      this.isChecked = true;
-      this.show = false;
-      setTimeout(() => {
-        this.login();
-      }, 250);
-    },
-
-    //关闭弹框f
-    close() {
-      this.show = false;
+    //点击密码后的icon
+    onClickPW(type) {
+      this.type = type; //切换icon 和密码显示与否
     },
   },
 };
@@ -261,45 +182,30 @@ export default {
 <style scoped lang="scss">
 .container {
   padding: 0 40rpx;
-  margin: 0 auto;
   display: flex;
   justify-content: center;
   align-items: center;
   flex-direction: column;
 }
 
-.login-form-wrap {
-  margin-top: 200rpx;
+.image {
+  margin-top: 50rpx;
+}
 
-  .phone-prefix {
-    display: flex;
-    align-items: center;
-    padding-right: 20rpx;
-    border-right: 2rpx solid $uni-text-color-grey;
-    margin-right: 20rpx;
-  }
+.login-form-wrap {
+  width: 90%;
+  margin-top: 50rpx;
 
   .phone-question {
     text-align: right;
     font-size: 24rpx;
     padding: 20rpx 0 20rpx 0;
   }
-
-  .user-agreement {
-    display: flex;
-    padding: 0 10rpx;
-
-    .user-agreement-text {
-      font-size: 24rpx;
-      color: $uni-text-color-grey;
-      margin-top: 20rpx;
-      margin-left: 20rpx;
-
-      .terms {
-        color: $uni-text-color;
-        font-weight: 400;
-      }
-    }
-  }
+}
+.user-agreement {
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  font-size: 27rpx;
 }
 </style>

+ 5 - 12
src/pages/login/register.vue

@@ -59,8 +59,9 @@
           >
         </u-form-item>
       </u--form>
+      <br />
       <view class="user-agreement">
-        <u-checkbox-group style="margin-top: 17rpx">
+        <u-checkbox-group>
           <u-checkbox shape="circle" @change="checkboxChange" :checked="isChecked"></u-checkbox>
         </u-checkbox-group>
         <view>我已阅读并同意</view>
@@ -274,17 +275,9 @@ export default {
   }
   .user-agreement {
     display: flex;
-    padding: 0 10rpx;
-    .user-agreement-text {
-      font-size: 26rpx;
-      color: $uni-text-color-grey;
-      margin-top: 20rpx;
-      margin-left: 20rpx;
-      .terms {
-        color: $uni-text-color;
-        font-weight: 400;
-      }
-    }
+    justify-content: center;
+    align-items: center;
+    font-size: 27rpx;
   }
 }
 </style>