|
@@ -1,4 +1,9 @@
|
|
|
// pages/components/wxbutton/wxbutton.js
|
|
|
+const api = require('../../../config');
|
|
|
+const getReq = require('../../../config').getReq;
|
|
|
+const ald = require('../../../utils/ald-stat.js')
|
|
|
+
|
|
|
+let app = getApp();
|
|
|
Component({
|
|
|
/**
|
|
|
* 组件的属性列表
|
|
@@ -23,8 +28,42 @@ Component({
|
|
|
* 组件的方法列表
|
|
|
*/
|
|
|
methods: {
|
|
|
- userInfoHandler() {
|
|
|
- console.log('userInfoHandler');
|
|
|
+ onGetUserInfo(e) {
|
|
|
+ console.log('onGetUserInfo');
|
|
|
+ if (e.detail.errMsg == "getUserInfo:ok") {
|
|
|
+ app.globalData.userInfo = e.detail.userInfo;
|
|
|
+ app.globalData.userInfo.nickname = e.detail.userInfo.nickName;
|
|
|
+ this.wxauthen(e)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ wxauthen: function (eInfo) {
|
|
|
+ let userInfo;
|
|
|
+ if (app.globalData.userId.unionid) {
|
|
|
+ userInfo = Object.assign({}, app.globalData.userId, app.globalData.userInfo);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ userInfo = eInfo.detail.userInfo;
|
|
|
+ let { encryptedData, iv, signature } = eInfo.detail
|
|
|
+ userInfo = Object.assign({}, { encryptedData }, { signature }, { iv }, userInfo)
|
|
|
+ }
|
|
|
+
|
|
|
+ let params = {
|
|
|
+ user_info: userInfo,
|
|
|
+ act: "login",
|
|
|
+ op: "wxauthen",
|
|
|
+ relay_id: app.globalData.relay_id,
|
|
|
+ channel: app.globalData.channel_num
|
|
|
+ }
|
|
|
+
|
|
|
+ let self = this;
|
|
|
+ getReq(app, params, function (res) {
|
|
|
+ if (res.code == 200) {
|
|
|
+ let datas = res.datas;
|
|
|
+ app.globalData.member_id = datas.member_id
|
|
|
+ app.globalData.hasmobile = datas.hasmobile
|
|
|
+ }
|
|
|
+ app.navigateto("pages/home/home")
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
})
|