var config = require("../../config/config.js"); var app = getApp(); const Http = require("../../utils/HttpBasics"); Page({ data: { canIUse: wx.canIUse("button.open-type.getUserInfo"), path:null }, onLoad: function(options) { var that = this; if (options.path == 'index') { this.path = options.path } Http.get({ url: config.api.marketicon, data: { appId: config.weapp.AppId } }).then(res => { console.log(res.data.mallImgUrl); that.setData({ mallImgUrl: res.data.mallImgUrl }); wx.setNavigationBarTitle({ title: res.data.mallName }) }) .catch(err => { wx.showToast({ title: err.message, image: "../../assets/img/fail.png", duration: 2000, mask: false }); }) }, bindGetUserInfo: function(e) { let that=this; console.log(e); var iv = e.detail.iv; var encryptedData = e.detail.encryptedData; console.log(iv); console.log(encryptedData); Http.post({ url: config.api.getUserInfo, data: { encryptedData: encryptedData, iv: iv } }).then( function(res) { console.log(res); console.log("授权个人信息返回的数据", that.path) if(that.path=='index'){ wx.reLaunch({ url: "/pages/game/index" }); }else{ //返回主页 wx.switchTab({ url: "/pages/index/index" }); } }, function(error) { wx.showToast({ title: "请授权个人信息", icon: "none" }); } ) .catch(err => { wx.showToast({ title: err.errMsg, icon: 'none', duration: 2000, mask: false }); }) } });