ソースを参照

新增登录方式

zhaoxiaohai 2 年 前
コミット
c7aa5c3ae3
4 ファイル変更21 行追加129 行削除
  1. 3 70
      pages/login/phone.js
  2. 3 2
      pages/login/phone.json
  3. 0 33
      pages/login/phone.scss
  4. 15 24
      pages/login/phone.wxml

+ 3 - 70
pages/login/phone.js

@@ -1,7 +1,5 @@
 import Toast from '@vant/weapp/toast/toast';
 const _Http = getApp().globalData.http;
-const md5 = require("../../utils/md5");
-const loginMsg = require("./modules/login");
 Page({
 
     /**
@@ -9,26 +7,10 @@ Page({
      */
     data: {
         isAgree: true,
-        accountno: "",
-        password: "",
-        inputType: "password", //密码输入框类型
-        focus: false,
-        memory: true, //记忆
         disabled: true, //是否禁用
         loading: false, //登陆中
     },
-
-    /**
-     * 生命周期函数--监听页面加载
-     */
-    onLoad(options) {
-        /* 恢复缓存中保存的账号密码 */
-        this.setData({
-            ...wx.getStorageSync('loginMsg')
-        })
-        /* 验证登录条件 */
-        this.allowOrNot()
-    },
+    onLoad(options) {},
     /* 微信登录 */
     wechatLogin() {
         if (!this.data.isAgree) return Toast({
@@ -64,30 +46,7 @@ Page({
         this.setData({
             loading: true
         })
-        _Http.login({
-            "accountno": this.data.accountno,
-            "password": md5.hexMD5(this.data.password),
-            "systemclient": "wechatsaletool"
-        }).then(res => {
-            this.setData({
-                loading: false
-            })
-            if (res.msg != '成功') return wx.showToast({
-                title: res.msg,
-                icon: "none"
-            })
-            wx.setStorageSync('loginMsg', {
-                accountno: this.data.accountno,
-                password: (this.data.memory) ? this.data.password : ''
-            })
-            loginMsg.loginMsg(res);
-        })
-    },
-    /* 改变密码输入框类型 */
-    changePasswordType() {
-        this.setData({
-            inputType: this.data.inputType == "text" ? 'password' : 'text'
-        })
+        this.selectComponent('#login').handleLogin();
     },
     /* 授权 */
     agreementChange({
@@ -97,31 +56,5 @@ Page({
             isAgree: detail
         })
     },
-    /* 手机号 */
-    inputPhone(e) {
-        this.setData({
-            accountno: e.detail.value.trim()
-        })
-        this.allowOrNot()
-    },
-    /* 密码 */
-    inputPassword(e) {
-        this.setData({
-            password: e.detail.value.trim()
-        })
-        this.allowOrNot()
-    },
-    /* 验证是否允许登录 */
-    allowOrNot() {
-        this.setData({
-            disabled: (this.data.accountno.length > 0 && this.data.password.length > 5) ? false : true
-        })
-    },
-    /* 是否记忆密码 */
-    isMemory() {
-        this.setData({
-            memory: !this.data.memory
-        })
-    },
-    onShareAppMessage() { }
+    onShareAppMessage() {}
 })

+ 3 - 2
pages/login/phone.json

@@ -2,7 +2,8 @@
     "navigationBarTitleText": "账户登录",
     "usingComponents": {
         "Agreement": "./modules/agreement",
-        "van-checkbox": "@vant/weapp/checkbox/index",
-        "van-divider": "@vant/weapp/divider/index"
+        "van-divider": "@vant/weapp/divider/index",
+        "account": "./modules/account",
+        "phone": "./modules/phone"
     }
 }

+ 0 - 33
pages/login/phone.scss

@@ -23,39 +23,6 @@ page {
     color: var(--assist);
 }
 
-.input {
-    text-align: left;
-    margin-left: 50rpx;
-}
-
-.image {
-    width: 40rpx !important;
-    height: 40rpx !important;
-}
-
-.box {
-    display: flex;
-    justify-content: space-between;
-    width: 690rpx;
-    margin: 40rpx auto 0;
-    font-family: PingFang SC-Regular, PingFang SC;
-
-    .checkbox {
-        font-size: 24rpx;
-        color: #666666;
-        margin-top: -3rpx;
-    }
-
-    .label {
-        margin-left: -10rpx;
-    }
-
-    .view {
-        font-size: 24rpx;
-        color: #999999;
-    }
-}
-
 .login {
     width: 650rpx;
     height: 90rpx;

+ 15 - 24
pages/login/phone.wxml

@@ -2,33 +2,24 @@
     <image src="/static/image/logo.png" />
 </view>
 
-<van-cell>
-    <text slot='icon' class="iconfont icon-a-biaoqianlanwodexuanzhong" />
-    <input class="input" type="text" value='{{accountno}}' bindinput="inputPhone" placeholder="请输入账户名" />
-</van-cell>
-<van-cell>
-    <text slot='icon' class="iconfont icon-a-wodemima" />
-    <input class="input" wx:if="{{inputType=='text'}}" focus='{{focus}}' bindinput="inputPassword" value="{{password}}" placeholder="请输入密码" />
-    <input class="input" wx:else type="password" focus='{{focus}}' bindinput="inputPassword" value="{{password}}" placeholder="请输入密码" />
-    <view slot='right-icon' style="width: 90rpx;height: 22.4px; display: flex; justify-content: flex-end;" catchtap="changePasswordType">
-        <image class="image" src="{{inputType=='password'?'/static/image/dp-none.svg':'/static/image/dp-show.svg'}}" />
-    </view>
-</van-cell>
+<!-- 账号登录 -->
+<account id='login' />
+<!-- 手机号登录 -->
+<phone id='login' wx:if="{{false}}" />
 
-<view class="box">
-    <van-checkbox custom-class='checkbox' label-class='label' icon-size="28rpx" value="{{ memory }}" shape="square" bind:change="isMemory">
-        记住密码
-    </van-checkbox>
-    <navigator url="./retrievePassword" class="view">忘记密码?</navigator>
-</view>
 <view style="width: 100vw; text-align: center;margin-top: 60rpx;margin-bottom: 40rpx;">
     <van-button disabled='{{disabled}}' custom-class='login' bindtap="userLogin" loading='{{loading}}' loading-text="登陆中..." color='linear-gradient(90deg, #3874F6 0%, #095DE0 100%);'>登录</van-button>
 </view>
+<!-- 隐私协议 -->
 <Agreement isAgree='{{isAgree}}' bindcallBack='agreementChange' />
-<van-toast id="van-toast" />
 
-<view style="height: 100rpx;" />
-<van-divider contentPosition="center">其他登录方式</van-divider>
-<view style="width: 100%; text-align: center;">
-    <text class="iconfont icon-a-wodebangdingweixin" style="font-size: 100rpx; color:#07C160;" bindtap="wechatLogin" />
-</view>
+<!-- 快捷登录 -->
+<block wx:if="{{false}}">
+    <view style="height: 100rpx;" />
+    <van-divider contentPosition="center">其他登录方式</van-divider>
+    <view style="width: 100%; text-align: center;">
+        <text class="iconfont icon-a-wodebangdingweixin" style="font-size: 100rpx; color:#07C160;" bindtap="wechatLogin" />
+    </view>
+</block>
+
+<van-toast id="van-toast" />