C端小程序
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

153 righe
4.5 KiB

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