|
@@ -1,34 +1,15 @@
|
|
|
import Toast from '@vant/weapp/toast/toast';
|
|
|
-const _Http = getApp().globalData.http;
|
|
|
-const md5 = require("../../utils/md5");
|
|
|
-const loginMsg = require("./modules/login");
|
|
|
+const _Http = getApp().globalData.http,
|
|
|
+ loginMsg = require("./modules/login");
|
|
|
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()
|
|
|
- },
|
|
|
/* 微信登录 */
|
|
|
wechatLogin() {
|
|
|
if (!this.data.isAgree) return Toast({
|
|
@@ -42,6 +23,7 @@ Page({
|
|
|
wechat_code: res.code,
|
|
|
"systemclient": "wechatsaletool"
|
|
|
}).then(res => {
|
|
|
+ console.log("微信快捷登录", res)
|
|
|
if (res.code == 0) return wx.showToast({
|
|
|
title: res.msg,
|
|
|
icon: "none"
|
|
@@ -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,30 +56,4 @@ 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
|
|
|
- })
|
|
|
- },
|
|
|
})
|