|
- const navigationBarHeight = (getApp().statusBarHeight + 44) + 'px'
- var config = require("../../config/config.js");
- const Http = require("../../utils/HttpBasics");
- var app = getApp();
- Page({
- data: {
- navigationBarHeight,
- canIUse: wx.canIUse("button.open-type.getPhoneNumber"),
- couponChannelId: "",
- path: null,
- paramData: null,
- signActivity: "",
- mineFlag: null,
- skipUrl: 0,
- // skip: app.globalData.skip
- },
- onLoad: function(options) {
-
- var that = this;
- console.log(options.skipUrl, "options.skipUrl")
- that.setData({
- skipUrl: options.skipUrl
- })
- that.setData({
- path: options.path
- })
- that.setData({
- paramData: options
- })
- if (options && options.couponChannelId) {
- that.setData({
- couponChannelId: options.couponChannelId
- });
- }
-
- if (options && options.mineFlag) {
- that.setData({
- mineFlag: options.mineFlag
- })
- }
- if (options && options.signActivity) {
- that.setData({
- signActivity: options.signActivity
- });
- }
-
- 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
- });
- })
- },
- backHome: function() {
- wx.switchTab({
- url: '/index/index',
- })
- },
- 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(res => {
- app.globalData.phone = res.data.phone;
- if (that.data.skipUrl == '1') {
- console.log(app.globalData.skip,app.globalData.skipUrl,"跳转地址" )
- if (app.globalData.skip == 'redirectTo') {
- wx.redirectTo({
- url: app.globalData.skipUrl,
- })
- return;
- } else if (app.globalData.skip == 'navigateTo') {
- wx.navigateTo({
- url: app.globalData.skipUrl,
- })
- return;
- } else if (app.globalData.skip == 'reLaunch') {
- wx.reLaunch({
- url: app.globalData.skipUrl,
- })
- return;
- } else if (app.globalData.skip == 'switchTab') {
- wx.switchTab({
- url: app.globalData.skipUrl,
- })
- return;
- }
- }
- /**a
- * 来自我的
- */
- if (that.data.path == 'main') {
- wx.switchTab({
- url: `/index/user`
- })
- return;
- }
- /**
- * 来自积分兑换
- */
- if (that.data.path == 'jifen') {
- wx.redirectTo({
- url: `/pages/integralmall/payIntegcoupondetail/index?couponChannelId=${that.data.paramData.couponChannelId}&couponId=${that.data.paramData.couponId}`
- })
- return;
- }
- /**
- * 来自拼团详情
- */
- if (that.data.path == 'spell') {
- if (that.data.paramData.avatarUrl) {
- wx.redirectTo({
- url: `/pages/joinFrDpell/index?couponId=${that.data.paramData.couponId}&orderGroupId=${that.data.paramData.orderGroupId}&couponChannelId=${that.data.paramData.couponChannelId}&orderId=${that.data.paramData.orderId}&avatarUrl=${that.data.paramData.avatarUrl}&nickName=${that.data.paramData.nickName}`
- })
- } else {
- wx.redirectTo({
- url: `/pages/spellGroup/mySpellGroup/index?couponId=${that.data.paramData.couponId}&couponChannelId=${that.data.paramData.couponChannelId}`
- })
- }
- 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.redirectTo({
- 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 if (that.data.signActivity) {
- wx.redirectTo({
- url: `/pages/radetail/joinActivity/edit?activityId=${that.data.signActivity}`
- })
- } else if (that.data.mineFlag == 'mine') {
- wx.switchTab({
- url: '/index/user'
- });
- } 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: '/index/passCar',
- })
- }
- }
- });
- }
- })
- .catch(err => {
- wx.showToast({
- title: err.message,
- icon: 'none',
- duration: 2000,
- mask: false
- });
- })
- }
- });
|