111 lines
3.5 KiB
JavaScript
111 lines
3.5 KiB
JavaScript
var t = getApp(), o = require("../../utils/login.js");
|
|
|
|
Page({
|
|
data: {
|
|
type: "login",
|
|
issubmit: !1,
|
|
info: {
|
|
mobile: "",
|
|
smscode: ""
|
|
},
|
|
token: "",
|
|
provision: {},
|
|
tips: [],
|
|
showTips: !1,
|
|
approve: !0
|
|
},
|
|
onLoad: function(a) {
|
|
var e = this;
|
|
this.setData({
|
|
type: a.type || "login"
|
|
}), o.pageStart(t).then(function(o) {
|
|
console.log(t.globalData), e.setData({
|
|
protocol: t.globalData.protocol
|
|
});
|
|
});
|
|
},
|
|
input: function(t) {
|
|
this.data.info[t.currentTarget.dataset.name] = t.detail.value, this.setData({
|
|
info: this.data.info
|
|
});
|
|
},
|
|
bindsubmit: function(t) {
|
|
if (console.log(t.detail.formId), this.data.issubmit) return !1;
|
|
this.setData({
|
|
issubmit: !0
|
|
}), wx.showLoading({
|
|
title: ""
|
|
});
|
|
var o = this;
|
|
"reset" == this.data.type ? this.submitForm() : wx.login({
|
|
success: function(t) {
|
|
console.log(t.code), wx.getUserInfo({
|
|
success: function(a) {
|
|
o.submitForm(t.code, a);
|
|
},
|
|
fail: function() {
|
|
o.submitForm(t.code);
|
|
}
|
|
});
|
|
},
|
|
fail: function(t) {}
|
|
});
|
|
},
|
|
submitForm: function(a, e) {
|
|
var i = this, n = {};
|
|
Object.assign(n, e, {
|
|
token: this.data.token,
|
|
smscode: this.data.info.smscode,
|
|
code: a
|
|
}), console.log(n), o.request(t.globalData.config.verify[i.data.type], n, !0).then(function(o) {
|
|
return wx.hideLoading(), i.setData({
|
|
issubmit: !1
|
|
}), 200 == o.code && (i.setData({
|
|
countdowntime: 0
|
|
}), "login" == i.data.type && wx.setStorageSync("session", o.data.session), wx.showToast({
|
|
title: o.message,
|
|
icon: "none"
|
|
}), t.globalData.isneedUpload = !0, t.globalData.needJumpUrl ? (wx.redirectTo({
|
|
url: t.globalData.needJumpUrl
|
|
}), t.globalData.needJumpUrl = !1, !1) : void wx.navigateBack({
|
|
delta: 1
|
|
}));
|
|
}).catch(function(t) {
|
|
i.setData({
|
|
issubmit: !1
|
|
});
|
|
});
|
|
},
|
|
sendMsg: function() {
|
|
if ("" == this.data.info.mobile.trim()) return wx.showModal({
|
|
title: "提示",
|
|
content: "请输入手机号码~"
|
|
}), !1;
|
|
var a = this;
|
|
o.request(t.globalData.config.verify.sms, {
|
|
mobile: a.data.info.mobile,
|
|
type: a.data.type
|
|
}, !0).then(function(t) {
|
|
console.log("daa", t), wx.showToast({
|
|
title: "验证码已发送~",
|
|
icon: "none"
|
|
}), a.setData({
|
|
token: t.data.token,
|
|
countdowntime: t.data.countdowntime
|
|
}, function() {
|
|
a.timer = setInterval(function() {
|
|
if (0 == a.data.countdowntime) return clearInterval(a.timer), !1;
|
|
a.data.countdowntime--, a.setData({
|
|
countdowntime: a.data.countdowntime
|
|
});
|
|
}, 1e3);
|
|
});
|
|
}).catch(function(t) {});
|
|
},
|
|
timer: null,
|
|
showprovision: function() {
|
|
this.setData({
|
|
showTips: !this.data.showTips
|
|
});
|
|
}
|
|
}); |