1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- // pages/components/auth/auth.js
- const api = require('../../../config');
- const getReq = require('../../../config').getReq;
- let app = getApp();
- Component({
- /**
- * 组件的属性列表
- */
- properties: {
- },
- /**
- * 组件的初始数据
- */
- data: {
- },
- /**
- * 组件的方法列表
- */
- methods: {
- userInfoHandler(e) {
- let self = this
- if (e.detail.errMsg == "getUserInfo:ok") {
- app.globalData.userInfo = e.detail.userInfo;
- app.globalData.userInfo.nickname = e.detail.userInfo.nickName;
- let userInfo = app.globalData.userInfo;
- if (app.globalData.userId.unionid) {
- userInfo = Object.assign({}, app.globalData.userId, app.globalData.userInfo);
- }
- else {
- let { encryptedData, iv, signature } = e.detail
- userInfo = Object.assign({}, { encryptedData }, { signature }, { iv }, userInfo)
- }
- let params = {
- user_info: userInfo,
- act: "login",
- op: "wxauthen"
- }
- getReq(params, function (res) {
- if (res.code == 200) {
- self.triggerEvent('getAuth', {
- userInfo
- })
- }
- else {
- wx.showToast({
- icon: 'none',
- title: '登陆失败',
- duration: 2000
- })
- }
- })
- }
- }
- }
- })
|