zhaoxiaohai 2 yıl önce
ebeveyn
işleme
2681a25395

+ 74 - 0
pages/login/modules/account.js

@@ -0,0 +1,74 @@
+const loginMsg = require("./login"),
+    md5 = require("../../../utils/md5"),
+    _Http = getApp().globalData.http;
+
+Component({
+    properties: {},
+    options: {
+        addGlobalClass: true
+    },
+    data: {
+        accountno: "",
+        password: "",
+        inputType: "password", //密码输入框类型
+        memory: true, //记忆
+        focus: false,
+    },
+    lifetimes: {
+        attached: function () {
+            /* 恢复缓存中保存的账号密码 */
+            this.setData({
+                ...wx.getStorageSync('loginMsg')
+            });
+            this.allowOrNot();
+        }
+    },
+    methods: {
+        /* input输入 */
+        inputChange(e) {
+            this.setData({
+                [e.target.dataset.name]: e.detail.value.trim()
+            })
+            this.allowOrNot()
+        },
+        /* 验证是否允许登录 */
+        allowOrNot() {
+            getCurrentPages()[0].setData({
+                disabled: (this.data.accountno.length > 0 && this.data.password.length > 0) ? false : true
+            })
+        },
+        /* 改变密码输入框类型 */
+        changePasswordType() {
+            this.setData({
+                inputType: this.data.inputType == "text" ? 'password' : 'text'
+            })
+        },
+        /* 是否记忆密码 */
+        isMemory() {
+            this.setData({
+                memory: !this.data.memory
+            })
+        },
+        /* 处理登录 */
+        handleLogin() {
+            _Http.login({
+                "accountno": this.data.accountno,
+                "password": md5.hexMD5(this.data.password),
+                "systemclient": "wechatsaletool"
+            }).then(res => {
+                getCurrentPages()[0].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);
+            })
+        }
+    }
+})

+ 6 - 0
pages/login/modules/account.json

@@ -0,0 +1,6 @@
+{
+    "component": true,
+    "usingComponents": {
+        "van-checkbox": "@vant/weapp/checkbox/index"
+    }
+}

+ 32 - 0
pages/login/modules/account.scss

@@ -0,0 +1,32 @@
+.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;
+    }
+}

+ 18 - 0
pages/login/modules/account.wxml

@@ -0,0 +1,18 @@
+<van-cell>
+    <text slot='icon' class="iconfont icon-a-biaoqianlanwodexuanzhong" />
+    <input class="input" type="text" value='{{accountno}}' bindinput="inputChange" data-name="accountno" placeholder="请输入账户名" />
+</van-cell>
+<van-cell>
+    <text slot='icon' class="iconfont icon-a-wodemima" />
+    <input class="input" wx:if="{{inputType=='text'}}" focus='{{focus}}' bindinput="inputChange" data-name="password" value="{{password}}" placeholder="请输入密码" />
+    <input class="input" wx:else type="password" focus='{{focus}}' bindinput="inputChange" data-name="password" 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>
+<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>

+ 102 - 0
pages/login/modules/phone.js

@@ -0,0 +1,102 @@
+let loginMsg = require("./login"),
+    md5 = require("../../../utils/md5"),
+    _Http = getApp().globalData.http,
+    deleteMark = require("../../../utils/deleteMark"),
+    downCount = null;
+
+Component({
+    options: {
+        addGlobalClass: true
+    },
+    data: {
+        phonenumber: '',
+        password: '',
+        showText: "获取验证码",
+        memory: true
+    },
+    lifetimes: {
+        attached: function () {
+            /* 恢复缓存中保存的账号密码 */
+            if (wx.getStorageSync('loginMsg')) {
+                this.setData({
+                    ...wx.getStorageSync('loginMsg')
+                });
+                this.allowOrNot();
+            }
+        }
+    },
+    methods: {
+        /* 获取验证码 */
+        getPassword() {
+            if (this.data.showText != "获取验证码") return;
+            if (!deleteMark.CheckPhoneNumber(this.data.phonenumber)) return;
+            _Http.getpassword({
+                "phonenumber": this.data.phonenumber,
+                "systemclient": "wechatsaletool"
+            }).then(res => {
+                wx.showToast({
+                    title: res.msg,
+                    icon: "none",
+                    duration: 3000
+                })
+                if (res.code != 1) return;
+                this.setData({
+                    showText: 30
+                })
+                downCount = setInterval(() => {
+                    let showText = this.data.showText;
+                    if (showText == 0) {
+                        clearInterval(downCount)
+                        showText = '获取验证码'
+                    } else {
+                        showText--
+                    }
+                    this.setData({
+                        showText
+                    })
+                }, 1000)
+            })
+        },
+        /* input输入 */
+        inputChange(e) {
+            this.setData({
+                [e.target.dataset.name]: e.detail.value.trim()
+            })
+            this.allowOrNot();
+        },
+        /* 验证是否允许登录 */
+        allowOrNot() {
+            getCurrentPages().forEach(v => {
+                if (['pages/login/phone'].includes(v.__route__)) v.setData({
+                    disabled: this.data.phonenumber.length == 0 || this.data.password.length == 0
+                })
+            })
+        },
+        /* 处理登录 */
+        handleLogin() {
+            _Http.plogin({
+                "phonenumber": this.data.phonenumber,
+                "password": md5.hexMD5(this.data.password),
+                "systemclient": "wechatsaletool"
+            }).then(res => {
+                getCurrentPages()[0].setData({
+                    loading: false
+                })
+                if (res.msg != '成功') return wx.showToast({
+                    title: res.msg,
+                    icon: "none"
+                })
+                wx.setStorageSync('loginMsg', {
+                    phonenumber: (this.data.memory) ? this.data.phonenumber : ''
+                })
+                loginMsg.loginMsg(res);
+            })
+        },
+        /* 是否记忆密码 */
+        isMemory() {
+            this.setData({
+                memory: !this.data.memory
+            })
+        },
+    }
+})

+ 6 - 0
pages/login/modules/phone.json

@@ -0,0 +1,6 @@
+{
+    "component": true,
+    "usingComponents": {
+        "van-checkbox": "@vant/weapp/checkbox/index"
+    }
+}

+ 14 - 0
pages/login/modules/phone.scss

@@ -0,0 +1,14 @@
+@import './account.scss';
+
+.box {
+    width: 100vw;
+    padding: 0 50rpx;
+    box-sizing: border-box;
+}
+
+.right-icon {
+    width: 180rpx;
+    text-align: center;
+    height: 22.4px;
+    border-left: 1rpx solid #ddd;
+}

+ 16 - 0
pages/login/modules/phone.wxml

@@ -0,0 +1,16 @@
+<van-cell>
+    <text slot='icon' class="iconfont icon-a-wodemendianxinxidianhua" />
+    <input class="input" type="number" value='{{phonenumber}}' bindinput="inputChange" data-name="phonenumber" placeholder="请输入手机号" />
+</van-cell>
+<van-cell>
+    <text slot='icon' class="iconfont icon-a-biaoqianlanxiaoxixuanzhong" />
+    <input class="input" type="number" bindinput="inputChange" data-name="password" value="{{password}}" placeholder="请输入验证码" />
+    <view slot='right-icon' class="right-icon" catchtap="getPassword">
+        {{showText=='获取验证码'?showText:showText+'s'}}
+    </view>
+</van-cell>
+<view class="box">
+    <van-checkbox custom-class='checkbox' label-class='label' icon-size="28rpx" value="{{ memory }}" shape="square" bind:change="isMemory">
+        记住号码
+    </van-checkbox>
+</view>

BIN
static/image/logo.png