C端小程序
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

162 linhas
4.6 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 == 'main') {
  81. wx.switchTab({
  82. url: `/index/user`
  83. })
  84. return;
  85. }
  86. /**
  87. * 来自积分兑换
  88. */
  89. if (that.data.path == 'jifen') {
  90. wx.redirectTo({
  91. url: `/pages/integralmall/payIntegcoupondetail/index?couponChannelId=${that.data.paramData.couponChannelId}&couponId=${that.data.paramData.couponId}`
  92. })
  93. return;
  94. }
  95. /**
  96. * 来自拼团详情
  97. */
  98. if (that.data.path == 'spell') {
  99. if (that.data.paramData.avatarUrl) {
  100. wx.redirectTo({
  101. 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}`
  102. })
  103. } else {
  104. wx.redirectTo({
  105. url: `/pages/spellGroup/mySpellGroup/index?couponId=${that.data.paramData.couponId}&couponChannelId=${that.data.paramData.couponChannelId}`
  106. })
  107. }
  108. return;
  109. }
  110. /**
  111. * fromId若存在来自卡转赠
  112. */
  113. if (that.data.path == 'index' && !that.data.paramData.cuserId) {
  114. wx.redirectTo({
  115. url: "/pages/game/index?url=" + that.data.paramData.url + "&id=" + that.data.paramData.id + "&gameId=" + that.data.paramData.gameId,
  116. })
  117. } else if (that.data.path == 'index' && that.data.paramData.cuserId) {
  118. wx.redirectTo({
  119. 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
  120. })
  121. }
  122. /**
  123. * 活动报名
  124. */
  125. else if (that.data.signActivity) {
  126. wx.redirectTo({
  127. url: `/pages/radetail/joinActivity/edit?activityId=${that.data.signActivity}`
  128. })
  129. } else if (that.data.mineFlag == 'mine'){
  130. wx.switchTab({
  131. url: '/index/user'
  132. });
  133. } else {
  134. wx.showToast({
  135. title: res.data.msg,
  136. icon: "success",
  137. success: function (res) {
  138. if (that.data.couponChannelId) {
  139. wx.redirectTo({
  140. url: "/pages/coupon/detail/index?couponChannelId=" + that.data.couponChannelId + "&flag=pay"
  141. })
  142. } else {
  143. wx.switchTab({
  144. url: '/index/passCar',
  145. })
  146. }
  147. }
  148. });
  149. }
  150. })
  151. .catch(err => {
  152. wx.showToast({
  153. title: "请授权手机号",
  154. icon: 'none',
  155. duration: 2000,
  156. mask: false
  157. });
  158. })
  159. }
  160. });