|
| xqd
@@ -19,34 +19,34 @@ Page({
|
|
|
// this.userLogin()
|
|
|
this.getInfo()
|
|
|
var that = this
|
|
|
- try{
|
|
|
- wx.getStorage({
|
|
|
- key: 'logDate',
|
|
|
- success: function (res) {
|
|
|
- console.log('prelogDate:' + res.data)
|
|
|
- var nowDate = new Date()
|
|
|
- if (nowDate - res.data < 30 * 60 * 1000) {
|
|
|
- console.log(nowDate - res.data)
|
|
|
- wx.getStorage({
|
|
|
- key: 'userid',
|
|
|
- success: function (res) {
|
|
|
- wx.showLoading({
|
|
|
- title: '正在自动登录',
|
|
|
- })
|
|
|
- var app = getApp()
|
|
|
- app.userinfo.userid = res.data
|
|
|
- console.log(getApp().userinfo.userid)
|
|
|
- wx.redirectTo({
|
|
|
- url: "info/info",
|
|
|
- })
|
|
|
- },
|
|
|
- })
|
|
|
- }
|
|
|
- },
|
|
|
- })
|
|
|
- }catch(e){
|
|
|
-
|
|
|
- }
|
|
|
+ // try{
|
|
|
+ // wx.getStorage({
|
|
|
+ // key: 'logDate',
|
|
|
+ // success: function (res) {
|
|
|
+ // console.log('prelogDate:' + res.data)
|
|
|
+ // var nowDate = new Date()
|
|
|
+ // if (nowDate - res.data < 30 * 60 * 1000) {
|
|
|
+ // console.log(nowDate - res.data)
|
|
|
+ // wx.getStorage({
|
|
|
+ // key: 'userid',
|
|
|
+ // success: function (res) {
|
|
|
+ // wx.showLoading({
|
|
|
+ // title: '正在自动登录',
|
|
|
+ // })
|
|
|
+ // var app = getApp()
|
|
|
+ // app.userinfo.userid = res.data
|
|
|
+ // console.log(getApp().userinfo.userid)
|
|
|
+ // wx.redirectTo({
|
|
|
+ // url: "info/info",
|
|
|
+ // })
|
|
|
+ // },
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ // })
|
|
|
+ // }catch(e){
|
|
|
+
|
|
|
+ // }
|
|
|
},
|
|
|
|
|
|
/**
|
|
| xqd
@@ -143,7 +143,7 @@ Page({
|
|
|
}, //这里是可以填写服务器需要的参数
|
|
|
method: 'GET', // 声明GET请求
|
|
|
// header: {}, // 设置请求的 header,GET请求可以不填
|
|
|
- complete: function (res) {
|
|
|
+ success: function (res) {
|
|
|
let test = JSON.stringify(res.data)
|
|
|
let tet = JSON.parse(test)
|
|
|
that.setData({
|
|
| xqd
@@ -155,51 +155,92 @@ Page({
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- userLogin: function () {
|
|
|
- wx.showLoading({
|
|
|
- title: '登录中',
|
|
|
- })
|
|
|
+ userLogin: function (e) {
|
|
|
+ console.log(e.detail)
|
|
|
+ var un = JSON.parse(e.detail.rawData)
|
|
|
var that = this
|
|
|
- try {
|
|
|
- wx.login({
|
|
|
- success: function (res) {
|
|
|
- let code = res.code
|
|
|
- console.log(code)
|
|
|
- var c = getApp()
|
|
|
- c.userinfo.usercode = res.code
|
|
|
- wx.getUserInfo({
|
|
|
- success: function (res) {
|
|
|
- //let encrypted_data = res.encryptedData
|
|
|
- let tx = res.userInfo.avatarUrl
|
|
|
- let nn = res.userInfo.nickName
|
|
|
- wx.request({
|
|
|
- url: 'https://t10.9026.com/api/home/login',
|
|
|
- method: 'POST',
|
|
|
- data: {
|
|
|
- code: code,
|
|
|
- avatar: tx,
|
|
|
- nickName: nn,
|
|
|
- },
|
|
|
- success: function (res) {
|
|
|
- that.setData({
|
|
|
- userid: res.data.data.userinfo.id
|
|
|
- })
|
|
|
- var app = getApp()
|
|
|
- app.userinfo.userid = that.data.userid
|
|
|
- console.log(getApp().userinfo.userid)
|
|
|
- if (res.data.data.userinfo.has_agreed == 1) {
|
|
|
- wx.redirectTo({
|
|
|
- url: 'info/info'
|
|
|
+ if(that.data.isAgree == false){
|
|
|
+ }else{
|
|
|
+ wx.showLoading({
|
|
|
+ title: '登录中',
|
|
|
+ })
|
|
|
+ try {
|
|
|
+ wx.login({
|
|
|
+ success: function (res) {
|
|
|
+ let code = res.code
|
|
|
+ console.log(code)
|
|
|
+ let tx = un.avatarUrl
|
|
|
+ let nn = un.nickName
|
|
|
+ wx.request({
|
|
|
+ url: 'https://t10.9026.com/api/home/login',
|
|
|
+ method: 'POST',
|
|
|
+ data: {
|
|
|
+ code: code,
|
|
|
+ avatar: tx,
|
|
|
+ nickName: nn,
|
|
|
+ },
|
|
|
+ success: function (res) {
|
|
|
+ that.setData({
|
|
|
+ userid: res.data.data.userinfo.id
|
|
|
})
|
|
|
- } else {
|
|
|
- that.showTopTips()
|
|
|
+ var app = getApp()
|
|
|
+ app.userinfo.userid = that.data.userid
|
|
|
+ console.log(getApp().userinfo.userid)
|
|
|
+ if (res.data.data.userinfo.has_agreed == 1) {
|
|
|
+ wx.hideLoading();
|
|
|
+ wx.showToast({
|
|
|
+ title: '登录成功',
|
|
|
+ icon: 'success',
|
|
|
+ duration: 1000,
|
|
|
+ })
|
|
|
+ wx.redirectTo({
|
|
|
+ url: 'info/info'
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ that.showTopTips()
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- } catch (e) { }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } catch (e) { }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleUserInfo(e) {
|
|
|
+ var that = this
|
|
|
+ let msg = e.detail.errMsg;
|
|
|
+ if (msg === 'getUserInfo:ok') {
|
|
|
+ that.setData({
|
|
|
+ user: e.detail.userInfo
|
|
|
+ });
|
|
|
+ that.login(that.data.user)
|
|
|
+ } else {
|
|
|
+ }
|
|
|
},
|
|
|
+// login:function(userInfo) {
|
|
|
+// wx.login({
|
|
|
+// success: res => {
|
|
|
+// // 发送 res.code 到后台换取 openId, sessionKey, unionId
|
|
|
+// if (res.code) {
|
|
|
+// //存用户信息
|
|
|
+// wx.setStorageSync('UserInFo', userInfo)
|
|
|
+// // 扫面二维码进入
|
|
|
+// let Scene = wx.getStorageSync('scene')
|
|
|
+// let userInfoStr = JSON.stringify(userInfo);
|
|
|
+// wx.request({
|
|
|
+// url: api.WxUnionId,
|
|
|
+// data: {
|
|
|
+
|
|
|
+// },
|
|
|
+// method: 'POST',
|
|
|
+// header: {
|
|
|
+// 'content-type': 'application/x-www-form-urlencoded'
|
|
|
+// },
|
|
|
+// success: callback
|
|
|
+// })
|
|
|
+// } else {
|
|
|
+
|
|
|
+// }
|
|
|
+// }
|
|
|
+// })
|
|
|
})
|