|
|
|
@ -5,6 +5,7 @@ import { zconfig, loginToken, getBaseInfo } from "../../api/ztb" |
|
|
|
import { pconfig } from "../../api/payment" |
|
|
|
import { mconfig } from "../../api/moment" |
|
|
|
import { sconfig } from "../../api/saas" |
|
|
|
const tdsdk = require('../../libs/tdweapp.js') |
|
|
|
const storage = require('../../utils/storage') |
|
|
|
const util = require('../../utils/util') |
|
|
|
const event = require('../../utils/event') |
|
|
|
@ -124,13 +125,9 @@ Page({ |
|
|
|
}, |
|
|
|
changePwd: function () { |
|
|
|
if (this.data.pwdType === 'password') { |
|
|
|
this.setData({ |
|
|
|
pwdType: 'text' |
|
|
|
}) |
|
|
|
this.setData({ pwdType: 'text' }) |
|
|
|
} else { |
|
|
|
this.setData({ |
|
|
|
pwdType: 'password' |
|
|
|
}) |
|
|
|
this.setData({ pwdType: 'password' }) |
|
|
|
} |
|
|
|
}, |
|
|
|
bindInput: function (e) { |
|
|
|
@ -139,29 +136,19 @@ Page({ |
|
|
|
var enable = false |
|
|
|
if ((/^1\d{10}$/.test(e.detail.value)) && e.detail.value.length == 11) { |
|
|
|
enable = true |
|
|
|
this.setData({ |
|
|
|
mobileEnable: enable |
|
|
|
}) |
|
|
|
this.setData({ mobileEnable: enable }) |
|
|
|
} |
|
|
|
} |
|
|
|
if ((/^1\d{10}$/.test(this.data.form.account)) && this.data.form.account.length == 11) { |
|
|
|
if (this.data.type == 1 && !util.isEmpty(this.data.form.captcha)) { |
|
|
|
this.setData({ |
|
|
|
loginEnable: false |
|
|
|
}) |
|
|
|
this.setData({ loginEnable: false }) |
|
|
|
} else if (this.data.type == 0 && !util.isEmpty(this.data.form.password)) { |
|
|
|
this.setData({ |
|
|
|
loginEnable: false |
|
|
|
}) |
|
|
|
this.setData({ loginEnable: false }) |
|
|
|
} else { |
|
|
|
this.setData({ |
|
|
|
loginEnable: true |
|
|
|
}) |
|
|
|
this.setData({ loginEnable: true }) |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.setData({ |
|
|
|
loginEnable: true |
|
|
|
}) |
|
|
|
this.setData({ loginEnable: true }) |
|
|
|
} |
|
|
|
}, |
|
|
|
loginForm: function () { |
|
|
|
@ -177,10 +164,7 @@ Page({ |
|
|
|
util.showToast('请输入密码') |
|
|
|
return |
|
|
|
} |
|
|
|
wx.showLoading({ |
|
|
|
title: '登录中', |
|
|
|
mask: true |
|
|
|
}) |
|
|
|
wx.showLoading({ title: '登录中', mask: true }) |
|
|
|
if (this.data.type == 1) { |
|
|
|
loginCaptcha(this.data.form).then(result => { |
|
|
|
storage.put('Authorization', result.data.token) |
|
|
|
@ -203,17 +187,9 @@ Page({ |
|
|
|
}, |
|
|
|
changeType: function () { |
|
|
|
if (this.data.type == 1) { |
|
|
|
this.setData({ |
|
|
|
type: 0, |
|
|
|
['form.captcha']: null, |
|
|
|
loginEnable: true |
|
|
|
}) |
|
|
|
this.setData({ type: 0, ['form.captcha']: null, loginEnable: true }) |
|
|
|
} else { |
|
|
|
this.setData({ |
|
|
|
type: 1, |
|
|
|
['form.password']: null, |
|
|
|
loginEnable: true |
|
|
|
}) |
|
|
|
this.setData({ type: 1, ['form.password']: null, loginEnable: true }) |
|
|
|
} |
|
|
|
}, |
|
|
|
fetchCode: function (e) { |
|
|
|
@ -222,33 +198,19 @@ Page({ |
|
|
|
return |
|
|
|
} |
|
|
|
if (this.second && this.second.interval) return !1 |
|
|
|
wx.showLoading({ |
|
|
|
title: '正在获取', |
|
|
|
mask: true |
|
|
|
}) |
|
|
|
postCaptcha({ |
|
|
|
verifiableAccount: this.data.form.account, |
|
|
|
verifiableAccountType: 1, |
|
|
|
purpose: 1 |
|
|
|
}).then(result => { |
|
|
|
wx.showLoading({ title: '正在获取', mask: true }) |
|
|
|
postCaptcha({ verifiableAccount: this.data.form.account, verifiableAccountType: 1, purpose: 1 }).then(result => { |
|
|
|
wx.hideLoading() |
|
|
|
this.setData({ |
|
|
|
codeEnable: false |
|
|
|
}) |
|
|
|
this.setData({ codeEnable: false }) |
|
|
|
util.showToast('验证码已经发送') |
|
|
|
this.wuxCountDown = new $wuxCountDown({ |
|
|
|
date: +(new Date) + 60000, |
|
|
|
onEnd() { |
|
|
|
this.setData({ |
|
|
|
second: '重新获取验证码', |
|
|
|
codeEnable: true |
|
|
|
}) |
|
|
|
this.setData({ second: '重新获取验证码', codeEnable: true }) |
|
|
|
}, |
|
|
|
render(date) { |
|
|
|
const sec = this.leadingZeros(date.sec, 2) + ' 秒 ' |
|
|
|
date.sec !== 0 && this.setData({ |
|
|
|
second: sec |
|
|
|
}) |
|
|
|
date.sec !== 0 && this.setData({ second: sec }) |
|
|
|
}, |
|
|
|
}) |
|
|
|
}).catch(error => { |
|
|
|
@ -257,31 +219,20 @@ Page({ |
|
|
|
}) |
|
|
|
}, |
|
|
|
readAgreement: function () { |
|
|
|
wx.navigateTo({ |
|
|
|
url: '/pages/html/agreement/index' |
|
|
|
}) |
|
|
|
wx.navigateTo({ url: '/pages/html/agreement/index' }) |
|
|
|
}, |
|
|
|
onGotUserInfo: function (e) { |
|
|
|
this.setData({ |
|
|
|
loging: true |
|
|
|
}) |
|
|
|
loginWechat({ |
|
|
|
encryptedData: e.detail.encryptedData, |
|
|
|
iv: e.detail.iv |
|
|
|
}).then(result => { |
|
|
|
this.setData({ loging: true }) |
|
|
|
loginWechat({ encryptedData: e.detail.encryptedData, iv: e.detail.iv }).then(result => { |
|
|
|
storage.put('Authorization', result.data.token) |
|
|
|
app.globalData.token = result.data.token |
|
|
|
this.fetchUserInfo() |
|
|
|
}).catch(error => { |
|
|
|
wx.hideLoading() |
|
|
|
this.setData({ |
|
|
|
loging: false |
|
|
|
}) |
|
|
|
this.setData({ loging: false }) |
|
|
|
if (error && error.data) { |
|
|
|
if (error.code == 200101) { |
|
|
|
this.setData({ |
|
|
|
wxflag: true |
|
|
|
}) |
|
|
|
this.setData({ wxflag: true }) |
|
|
|
} |
|
|
|
this.data.userInfo = e.detail.userInfo |
|
|
|
this.data.form.tmpAuthToken = error.data.tmpAuthToken |
|
|
|
@ -289,7 +240,14 @@ Page({ |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
onShow: function () { |
|
|
|
tdsdk.Page.onShow() |
|
|
|
}, |
|
|
|
onHide: function(){ |
|
|
|
tdsdk.Page.onHide() |
|
|
|
}, |
|
|
|
onUnload: function () { |
|
|
|
tdsdk.Page.onUnload() |
|
|
|
if (this.wuxCountDown) { |
|
|
|
this.wuxCountDown.stop() |
|
|
|
this.wuxCountDown = null |
|
|
|
|