You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
2.3 KiB

5 years ago
// pages/login/index.js
import user from "../../utils/https/user.js"
import https from "../../utils/https.js"
var app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
err:null
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
5 years ago
},
cancel:function(){
wx.reLaunch({
url: '/pages/index/index',
})
5 years ago
},
getUserInfo:function(e){
let that = this;
if (!e.detail.userInfo){
wx.reLaunch({
url: '/pages/index/index',
})
return;
}
wx.login({
success: function (r) {
user._post("user/wxLogin", { code: r.code, encryptedData: e.detail.encryptedData, iv: e.detail.iv, loginType: 3 }).then(r => {
console.log(r)
// return;
// r.data.isBind是false的时候去绑定手机号 该用户没有注册过
// 已经注册的用户返回userinfo
5 years ago
if (r.data.isBindMobile === 0) {
5 years ago
wx.redirectTo({
5 years ago
url: '/pages/user/bindtel/index?regToken=' + encodeURIComponent(r.data.openid),
5 years ago
})
}
else if(r.data && r.data.id && r.data.token){
https.set_logininfo(r);
wx.navigateBack({
delta:1
})
}
else {
console.log('看这里看这里看这里')
wx.reLaunch({
url:"/pages/index/index"
})
}
}).catch(err=>{
wx.reLaunch({
url:"/pages/index/index"
})
})
},
fail:function(){
wx.reLaunch({
url:"/pages/index/index"
})
}
})
console.log(e);
},
addClick:function(e){
let id = e.currentTarget?e.currentTarget.dataset.clickid:e;
wx.uma.trackEvent(id)
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
}
})