C端小程序
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

137 行
4.0 KiB

  1. var config = require("../../config/config.js");
  2. const Http = require("../../utils/HttpBasics");
  3. var app = getApp();
  4. Page({
  5. data: {
  6. canIUse: wx.canIUse("button.open-type.getPhoneNumber"),
  7. couponChannelId: "",
  8. path:null,
  9. paramData:null,
  10. signActivity:""
  11. },
  12. onLoad: function (options) {
  13. this.setData({
  14. path: options.path
  15. })
  16. this.setData({
  17. paramData: options
  18. })
  19. var that = this;
  20. if (options.couponChannelId) {
  21. that.setData({
  22. couponChannelId: options.couponChannelId
  23. });
  24. }
  25. if (options.signActivity){
  26. that.setData({
  27. signActivity: options.signActivity
  28. });
  29. }
  30. Http.get({
  31. url: config.api.marketicon,
  32. data: {
  33. appId: config.weapp.AppId
  34. }
  35. }).then(res => {
  36. that.setData({
  37. mallImgUrl: res.data.mallImgUrl
  38. });
  39. wx.setNavigationBarTitle({
  40. title: res.data.mallName
  41. })
  42. })
  43. .catch(err => {
  44. wx.showToast({
  45. title: err.errMsg,
  46. icon: 'none',
  47. duration: 2000,
  48. mask: false
  49. });
  50. })
  51. },
  52. getPhoneNumber: function (e) {
  53. var that = this;
  54. var iv = e.detail.iv;
  55. var encryptedData = e.detail.encryptedData;
  56. Http.post({
  57. url: config.api.getUserPhone,
  58. data: {
  59. encryptedData: encryptedData,
  60. iv: iv
  61. }
  62. }).then(res=>{
  63. app.globalData.phone = res.data.phone;
  64. /**
  65. * 来自积分兑换
  66. */
  67. if (that.data.path == 'jifen') {
  68. wx.redirectTo({
  69. url: `/pages/integralmall/payIntegcoupondetail/index?couponChannelId=${that.data.paramData.couponChannelId}&couponId=${that.data.paramData.couponId}`
  70. })
  71. return;
  72. }
  73. /**
  74. * 来自拼团详情
  75. */
  76. if (that.data.path == 'spell') {
  77. if (that.data.paramData.avatarUrl) {
  78. wx.redirectTo({
  79. 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}`
  80. })
  81. } else {
  82. wx.redirectTo({
  83. url: `/pages/spellGroup/mySpellGroup/index?couponId=${that.data.paramData.couponId}&couponChannelId=${that.data.paramData.couponChannelId}`
  84. })
  85. }
  86. return;
  87. }
  88. /**
  89. * fromId若存在来自卡转赠
  90. */
  91. if (that.data.path == 'index' && !that.data.paramData.cuserId) {
  92. wx.redirectTo({
  93. url: "/pages/game/index?url=" + that.data.paramData.url + "&id=" + that.data.paramData.id + "&gameId=" + that.data.paramData.gameId,
  94. })
  95. } else if (that.data.path == 'index' && that.data.paramData.cuserId) {
  96. wx.reLaunch({
  97. 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
  98. })
  99. }
  100. /**
  101. * 活动报名
  102. */
  103. else if (that.data.signActivity) {
  104. wx.redirectTo({
  105. url: `/pages/radetail/joinActivity/edit?activityId=${that.data.signActivity}`
  106. })
  107. } else {
  108. wx.showToast({
  109. title: res.data.msg,
  110. icon: "success",
  111. success: function (res) {
  112. if (that.data.couponChannelId) {
  113. wx.redirectTo({
  114. url: "/pages/coupon/detail/index?couponChannelId=" + that.data.couponChannelId + "&flag=pay"
  115. })
  116. } else {
  117. wx.switchTab({
  118. url: '/pages/passCar/passCar',
  119. })
  120. }
  121. }
  122. });
  123. }
  124. })
  125. .catch(err => {
  126. wx.showToast({
  127. title: err.message,
  128. icon: 'none',
  129. duration: 2000,
  130. mask: false
  131. });
  132. })
  133. }
  134. });