var config = require("../../config/config.js"); const Http = require("../../utils/HttpBasics"); var app = getApp(); Page({ data: { canIUse: wx.canIUse("button.open-type.getPhoneNumber"), couponChannelId: "", path:null, paramData:null }, onLoad: function (options) { console.log(options,98888) this.setData({ path: options.path }) this.setData({ paramData: options }) var that = this; if (options.couponChannelId) { that.setData({ couponChannelId: options.couponChannelId }); } 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 }); }) }, getPhoneNumber: function (e) { var that = this; var iv = e.detail.iv; var encryptedData = e.detail.encryptedData; Http.post({ url: config.api.getUserPhone, data: { encryptedData: encryptedData, iv: iv } }).then( function (res) { app.globalData.phone = res.data.phone; /** * 来自拼团详情 */ console.log(that.data, 98888) if (that.data.path == 'spell') { wx.redirectTo({ url: "/pages/spellGroup/mySpellGroup/index?couponChannelId=" + that.data.paramData.couponChannelId + "&couponId=" + that.data.paramData.couponId }) return; } /** * fromId若存在来自卡转赠 */ if (that.data.path == 'index' && !that.data.paramData.cuserId) { wx.redirectTo({ url: "/pages/game/index?url=" + that.data.paramData.url + "&id=" + that.data.paramData.id + "&gameId=" + that.data.paramData.gameId, }) } else if (that.data.path == 'index' && that.data.paramData.cuserId){ wx.reLaunch({ url: "/pages/coupon/detail/index?cuserId=" + that.data.paramData.cuserId + '&couponChannelId=' + that.data.paramData.couponChannelId + '&coverImg=' + that.data.paramData.coverImg + '&avatarUrl=' + that.data.paramData.avatarUrl + '&userName=' + that.data.paramData.userName + '&couponOrderId=' + that.data.paramData.couponOrderId + "&updateDate=" + that.data.paramData.updateDate }) } else { wx.showToast({ title: res.data.msg, icon: "success", success: function (res) { if (that.data.couponChannelId) { wx.redirectTo({ url: "/pages/coupon/detail/index?couponChannelId=" +that.data.couponChannelId +"&flag=pay" }) } else { wx.switchTab({ url: '/pages/passCar/passCar', }) } } }); } }, function (error) { wx.showToast({ title: "请重新授权手机号", icon: "none" }); } ) .catch(err => { wx.showToast({ title: err.errMsg, icon: 'none', duration: 2000, mask: false }); }) } });