C端小程序
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

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