|
@@ -7,7 +7,9 @@ const {
|
|
|
Toast
|
|
|
} = require('../../utils/util.js');
|
|
|
var app = getApp();
|
|
|
-
|
|
|
+import {
|
|
|
+ getWxUserInfo
|
|
|
+} from '../../utils/request'
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
@@ -69,6 +71,7 @@ Page({
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
// this.isLongPolling()
|
|
|
+ // this.newLogin();
|
|
|
},
|
|
|
|
|
|
isLongPolling: function () {
|
|
@@ -385,136 +388,8 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
|
|
|
- // 微信改版了
|
|
|
- // _getUserInfoToLogin: function(e) {
|
|
|
- // Toast.showToast2('loading');
|
|
|
-
|
|
|
- // if (e.detail.encryptedData) {
|
|
|
- // // 可以将 res 发送给后台解码出 unionId
|
|
|
- // // app.globalData.userInfo = res.userInfo;
|
|
|
- // // app.globalData.encryptedData = res.encryptedData;
|
|
|
- // // app.globalData.iv = res.iv;
|
|
|
- // let {
|
|
|
- // encryptedData,
|
|
|
- // iv,
|
|
|
- // userInfo
|
|
|
- // } = e.detail;
|
|
|
-
|
|
|
- // console.log('---------',e);
|
|
|
-
|
|
|
- // app.globalData.userInfo = userInfo;
|
|
|
- // wx.setStorageSync("userInfo", userInfo)
|
|
|
- // this.setData({
|
|
|
- // avatarUrl: wx.getStorageSync('userInfo').avatarUrl
|
|
|
- // })
|
|
|
- // wx.login({
|
|
|
- // success: res => {
|
|
|
- // let {
|
|
|
- // code
|
|
|
- // } = res;
|
|
|
- // if (code) {
|
|
|
-
|
|
|
- // console.log(123456,code);
|
|
|
-
|
|
|
- // wx.request({
|
|
|
- // url: serverName + '/wx/api/user/getLoginSessionKey',
|
|
|
- // data: {
|
|
|
- // encryptedData,
|
|
|
- // iv,
|
|
|
- // code,
|
|
|
- // },
|
|
|
- // header: {
|
|
|
- // 'content-type': 'application/x-www-form-urlencoded'
|
|
|
- // },
|
|
|
- // method: 'post',
|
|
|
- // // dataType: 'json',
|
|
|
- // // responseType: 'text',
|
|
|
- // success: res => {
|
|
|
- // if (res.data.code > -1) {
|
|
|
- // let {
|
|
|
- // loginSessionKey
|
|
|
- // } = res.data.data;
|
|
|
- // wx.setStorageSync('token', loginSessionKey)
|
|
|
- // }
|
|
|
- // else{
|
|
|
- // Toast.showToast('warn', '登录失败,请重试');
|
|
|
- // }
|
|
|
- // },
|
|
|
- // fail: res => {
|
|
|
- // Toast.showToast('warn', '登录失败,请重试');
|
|
|
-
|
|
|
- // },
|
|
|
- // complete: res=> {
|
|
|
- // this._isLogin();
|
|
|
- // Toast.hideLoading();
|
|
|
- // },
|
|
|
- // })
|
|
|
-
|
|
|
-
|
|
|
- // request["getLoginSessionKey"]({
|
|
|
- // encryptedData,
|
|
|
- // iv,
|
|
|
- // code,
|
|
|
- // loginSessionKey:''
|
|
|
- // }, "post", res => {
|
|
|
- // if (res.data.code > -1) {
|
|
|
- // let {
|
|
|
- // loginSessionKey
|
|
|
- // } = res.data.data;
|
|
|
- // wx.setStorageSync('token', loginSessionKey)
|
|
|
- // this.isLongPolling();
|
|
|
- // console.log(loginSessionKey)
|
|
|
- // }
|
|
|
-
|
|
|
- // }, err => {
|
|
|
-
|
|
|
- // }, complete => {
|
|
|
- // this._isLogin();
|
|
|
- // Toast.hideLoading();
|
|
|
- // })
|
|
|
- // }
|
|
|
- // }
|
|
|
- // })
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- // // console.log(res.userInfo)
|
|
|
-
|
|
|
- // // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
|
|
|
- // // 所以此处加入 callback 以防止这种情况
|
|
|
- // if (this.userInfoReadyCallback) {
|
|
|
- // this.userInfoReadyCallback(res)
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
- // },
|
|
|
-
|
|
|
- // _login:function(e){
|
|
|
- // console.log(e)
|
|
|
- // // if(!this.data.isLogin){
|
|
|
- // // Toast.showToast2('loading');
|
|
|
- // // wx.getSetting({
|
|
|
- // // success: res => {
|
|
|
- // // console.log(res.authSetting['scope.userInfo'])
|
|
|
- // // if (!res.authSetting['scope.userInfo'] == undefined || res.authSetting['scope.userInfo'] == false) {
|
|
|
- // // Toast.showToast('tip', '四维看展申请获取个人信息权限', () => {
|
|
|
- // // wx.openSetting({
|
|
|
- // // success: res => {
|
|
|
- // // this._getUserInfoToLogin();
|
|
|
- // // }
|
|
|
- // // });
|
|
|
- // // });
|
|
|
- // // } else {
|
|
|
- // // // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
|
|
|
- // // this._getUserInfoToLogin();
|
|
|
- // // }
|
|
|
- // // }
|
|
|
- // // })
|
|
|
- // // }
|
|
|
- // },
|
|
|
|
|
|
_logout: function () {
|
|
|
-
|
|
|
if (this.data.isLogin) {
|
|
|
Toast.showToast2('loading');
|
|
|
let loginSessionKey = wx.getStorageSync('token');
|
|
@@ -562,7 +437,6 @@ Page({
|
|
|
// url="./my_order/index?status={{item.tag}}&&id={{item.id}}"
|
|
|
},
|
|
|
|
|
|
-
|
|
|
clickCell: function () {
|
|
|
wx.navigateTo({
|
|
|
url: './my_contact/index',
|
|
@@ -574,6 +448,52 @@ Page({
|
|
|
url: '/pages/user/personal/personal',
|
|
|
})
|
|
|
},
|
|
|
+
|
|
|
+ newLogin() {
|
|
|
+ wx.login({
|
|
|
+ success: res => {
|
|
|
+ let {
|
|
|
+ code
|
|
|
+ } = res;
|
|
|
+
|
|
|
+ console.log(789, res);
|
|
|
+
|
|
|
+ if (code) {
|
|
|
+ wx.request({
|
|
|
+ url: serverName + '/wx/api/user/getLoginSessionKey',
|
|
|
+ data: {
|
|
|
+ code,
|
|
|
+ },
|
|
|
+ header: {
|
|
|
+ 'content-type': 'application/x-www-form-urlencoded'
|
|
|
+ },
|
|
|
+ method: 'post',
|
|
|
+ // dataType: 'json',
|
|
|
+ // responseType: 'text',
|
|
|
+ success: res => {
|
|
|
+ if (res.data.code > -1) {
|
|
|
+ let {
|
|
|
+ loginSessionKey
|
|
|
+ } = res.data.data;
|
|
|
+ wx.setStorageSync('token', loginSessionKey)
|
|
|
+ } else {
|
|
|
+ Toast.showToast('warn', '登录失败,请重试');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fail: res => {
|
|
|
+ Toast.showToast('warn', '登录失败,请重试');
|
|
|
+
|
|
|
+ },
|
|
|
+ complete: res => {
|
|
|
+ this._isLogin();
|
|
|
+ Toast.hideLoading();
|
|
|
+ },
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ },
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|
|
@@ -597,6 +517,9 @@ Page({
|
|
|
avatarName: avatarName || '已登录'
|
|
|
})
|
|
|
this._isLogin()
|
|
|
+
|
|
|
+ getWxUserInfo('9fbbd7dfca6e49d9b20b77eb0f94e73a')
|
|
|
+ // debugger
|
|
|
},
|
|
|
|
|
|
/**
|