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, cuserId:null, coverImg:null, couponOrderId:null, optionData:null }, onLoad: function(options) { var that = this; if (options.couponChannelId && !options.cuserId||options.orderId) { that.setData({ couponChannelId: options.couponChannelId, orderId:options.orderId }) } this.setData({ optionData:options }) if (options&&options.path == 'index') { that.setData({ path: options.path }) } /** * 来自转赠 */ if (options.couponChannelId && options.cuserId){ console.log(1231231231,options) that.setData({ couponChannelId: options.couponChannelId, cuserId: options.cuserId, coverImg: options.coverImg, userName: options.userName, avatarUrl: options.avatarUrl, couponOrderId: options.couponOrderId }) } 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, that.data,6666666666) if (that.data.optionData.orderGroupId){ wx.reLaunch({ url: `/pages/joinFrDpell/index?couponId=${that.data.optionData.couponId}&orderGroupId=${that.data.optionData.orderGroupId}&couponChannelId=${that.data.optionData.couponChannelId}&orderId=${that.data.optionData.orderId}` }); return; } if (that.data.path == 'index') { wx.reLaunch({ url: "/pages/game/index" }); } else { //返回主页 if (that.data.couponChannelId && !that.data.cuserId) { wx.navigateTo({ url: `/pages/coupon/detail/index?couponChannelId=${that.data.couponChannelId}}` }); } else if (that.data.couponChannelId && that.data.cuserId) { /** * 来自转赠 */ wx.reLaunch({ url: `/pages/coupon/detail/index?couponChannelId=${that.data.couponChannelId}&cuserId=${that.data.cuserId}&coverImg=${that.data.coverImg}&userName=${that.data.userName}&avatarUrl=${that.data.avatarUrl}&couponOrderId=${that.data.couponOrderId}&updateDate=${that.data.updateDate}` }); } else if (that.data.orderId) { wx.navigateTo({ url: `/pages/bargain/bargainDatail/bargainDatail?orderId=${that.data.orderId}&from=${"friend"}` }); } else { wx.switchTab({ url: "/pages/main/index" }); } } }, function (error) { console.log(error) wx.showToast({ title: "请授权个人信息", icon: "none" }); } ) .catch(err => { wx.showToast({ title: err.errMsg, icon: 'none', duration: 2000, mask: false }); }) } });