59 lines
1.9 KiB
JavaScript
59 lines
1.9 KiB
JavaScript
var e = getApp(), o = require("../../utils/login.js");
|
|
|
|
Page({
|
|
data: {
|
|
logs: [],
|
|
isnotInfo: 1
|
|
},
|
|
fromPage: "",
|
|
onLoad: function(e) {
|
|
var o = this;
|
|
this.fromPage = e.fromPage, wx.getUserInfo({
|
|
success: function(e) {
|
|
o.setData({
|
|
isnotInfo: 2
|
|
}), o.userInfo = e;
|
|
}
|
|
});
|
|
},
|
|
onGotUserInfo: function(e) {
|
|
"getUserInfo:ok" == e.detail.errMsg ? (this.setData({
|
|
isnotInfo: 2
|
|
}), this.userInfo = e.detail) : wx.redirectTo({
|
|
url: "/pages/register/register"
|
|
});
|
|
},
|
|
userInfo: {},
|
|
toAuthorization: function(t, a) {
|
|
var n = Object.assign(this.userInfo, t, {
|
|
code: a
|
|
});
|
|
o.request(e.globalData.config.authorization, n, !0).then(function(o) {
|
|
if (wx.hideLoading(), console.log("toAuthorization", "app.globalData.needJumpUrl", e.globalData.needJumpUrl, o),
|
|
200 != o.code) return wx.showModal({
|
|
title: "提示",
|
|
content: o.message
|
|
}), !1;
|
|
wx.setStorageSync("session", o.data.session), wx.showToast({
|
|
title: o.message,
|
|
icon: "none"
|
|
}), e.globalData.user = o.data, e.globalData.isneedUpload = !0, e.globalData.needJumpUrl ? wx.redirectTo({
|
|
url: e.globalData.needJumpUrl
|
|
}) : wx.navigateBack({});
|
|
}).catch(function(e) {
|
|
wx.hideLoading();
|
|
});
|
|
},
|
|
ongetPhoneNumber: function(o) {
|
|
console.log("ongetPhoneNumber", o);
|
|
var t = this;
|
|
if ("getPhoneNumber:ok" == o.detail.errMsg) return wx.login({
|
|
success: function(a) {
|
|
e.globalData.code = a.code, t.toAuthorization(o.detail, a.code);
|
|
}
|
|
}), !1;
|
|
wx.redirectTo({
|
|
url: "/pages/register/register"
|
|
});
|
|
}
|
|
}); |