| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 | 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')            });            setTimeout(() => {                this.allowOrNot();            }, 100)        }    },    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);                console.log('是否为初始密码', res.remindchangepassword == 1)                getApp().globalData.remindchangepassword = res.remindchangepassword == 1;            })        }    }})
 |