123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- // 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({
- /**
- * 组件的属性列表
- */
- properties: {
- item_data: {
- type: Object
- }
- },
- /**
- * 组件的初始数据
- */
- data: {
- },
- created() {
- console.log(this.properties.item_data);
- },
-
- /**
- * 组件的方法列表
- */
- methods: {
- onGetUserInfo(e) {
- console.log('onGetUserInfo');
- if (e.detail.errMsg == "getUserInfo:ok") {
- wx.showLoading({title: '加载中'});
- 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
- }
- self.triggerEvent('wxButtonEvent', { event_type: 'getUserInfo', authen: 'success' });
- wx.hideLoading()
- })
- }
- }
- })
|