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, couponChannelId: null, couponId:null, cuserId:null, coverImg:null, couponOrderId:null }, onLoad: function(options) { var that = this; if (options.couponChannelId && options.couponId && !options.cuserId||options.orderId) { that.setData({ couponChannelId: options.couponChannelId, couponId: options.couponId, orderId:options.orderId }) } /** * 来自转赠 */ if (options.couponChannelId && options.cuserId){ console.log(1231231231,options) that.setData({ couponChannelId: options.couponChannelId, couponId: options.couponId, cuserId: options.cuserId, coverImg: options.coverImg, userName: options.userName, avatarUrl: options.avatarUrl, couponOrderId: options.couponOrderId }) } if (options.path == 'index') { that.path = options.path } Http.get({ url: config.api.marketicon, data: { appId: config.weapp.AppId } }).then(res => { that.setData({ mallImgUrl: res.data.mallImgUrl }); wx.setNavigationBarTitle({ title: res.data.mallName }) }) .catch(err => { wx.showToast({ title: err.errMsg, icon: 'none', duration: 2000, mask: false }); }) }, bindGetUserInfo: function (e) { let that = this; var iv = e.detail.iv; var encryptedData = e.detail.encryptedData; Http.post({ url: config.api.getUserInfo, data: { encryptedData: encryptedData, iv: iv } }) .then( function (res) { console.log(res) if (that.path == 'index') { wx.reLaunch({ url: "/pages/game/index" }); } else { //返回主页 if (that.data.couponChannelId && that.data.couponId && !that.data.cuserId) { wx.navigateTo({ url: `/pages/coupon/detail/index?couponChannelId=${that.data.couponChannelId}&couponId=${that.data.couponId}` }); } else if (that.data.couponChannelId && that.data.couponId && that.data.cuserId) { /** * 来自转赠 */ wx.reLaunch({ url: `/pages/coupon/detail/index?couponChannelId=${that.data.couponChannelId}&couponId=${that.data.couponId}&cuserId=${that.data.cuserId}&coverImg=${that.data.coverImg}&userName=${that.data.userName}&avatarUrl=${that.data.avatarUrl}&couponOrderId=${that.data.couponOrderId}` }); } else if (that.data.orderId) { wx.navigateTo({ url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${that.data.orderId}&from=${"friend"}` }); } else { wx.switchTab({ url: "/pages/login/index" }); } } }, function (error) { console.log(error) wx.showToast({ title: "请授权个人信息", icon: "none" }); } ) .catch(err => { wx.showToast({ title: err.errMsg, icon: 'none', duration: 2000, mask: false }); }) } });