C端小程序
Não pode escolher mais do que 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.

197 linhas
5.9 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. skipUrl: 0,
  15. // skip: app.globalData.skip
  16. },
  17. onLoad: function(options) {
  18. var that = this;
  19. console.log(options.skipUrl, "options.skipUrl")
  20. that.setData({
  21. skipUrl: options.skipUrl
  22. })
  23. that.setData({
  24. path: options.path
  25. })
  26. that.setData({
  27. paramData: options
  28. })
  29. if (options && options.couponChannelId) {
  30. that.setData({
  31. couponChannelId: options.couponChannelId
  32. });
  33. }
  34. if (options && options.mineFlag) {
  35. that.setData({
  36. mineFlag: options.mineFlag
  37. })
  38. }
  39. if (options && options.signActivity) {
  40. that.setData({
  41. signActivity: options.signActivity
  42. });
  43. }
  44. Http.get({
  45. url: config.api.marketicon,
  46. data: {
  47. appId: config.weapp.AppId
  48. }
  49. }).then(res => {
  50. that.setData({
  51. mallImgUrl: res.data.mallImgUrl
  52. });
  53. wx.setNavigationBarTitle({
  54. title: res.data.mallName
  55. })
  56. })
  57. .catch(err => {
  58. wx.showToast({
  59. title: err.errMsg,
  60. icon: 'none',
  61. duration: 2000,
  62. mask: false
  63. });
  64. })
  65. },
  66. backHome: function() {
  67. wx.setStorageSync("tabFlag", 1)
  68. wx.switchTab({
  69. url: '/index/index',
  70. })
  71. },
  72. getPhoneNumber: function(e) {
  73. wx.setStorageSync("tabFlag", 1)
  74. var that = this;
  75. var iv = e.detail.iv;
  76. var encryptedData = e.detail.encryptedData;
  77. Http.post({
  78. url: config.api.getUserPhone,
  79. data: {
  80. encryptedData: encryptedData,
  81. iv: iv
  82. }
  83. }).then(res => {
  84. app.globalData.phone = res.data.phone;
  85. if (that.data.skipUrl == '1') {
  86. console.log(app.globalData.skip,app.globalData.skipUrl,"跳转地址" )
  87. if (app.globalData.skip == 'redirectTo') {
  88. wx.redirectTo({
  89. url: app.globalData.skipUrl,
  90. })
  91. return;
  92. } else if (app.globalData.skip == 'navigateTo') {
  93. wx.navigateTo({
  94. url: app.globalData.skipUrl,
  95. })
  96. return;
  97. } else if (app.globalData.skip == 'reLaunch') {
  98. wx.reLaunch({
  99. url: app.globalData.skipUrl,
  100. })
  101. return;
  102. } else if (app.globalData.skip == 'switchTab') {
  103. wx.switchTab({
  104. url: app.globalData.skipUrl,
  105. })
  106. return;
  107. }
  108. }
  109. /**a
  110. * 来自我的
  111. */
  112. if (that.data.path == 'main') {
  113. wx.switchTab({
  114. url: `/index/user`
  115. })
  116. return;
  117. }
  118. /**
  119. * 来自积分兑换
  120. */
  121. if (that.data.path == 'jifen') {
  122. wx.redirectTo({
  123. url: `/pages/integralmall/payIntegcoupondetail/index?couponChannelId=${that.data.paramData.couponChannelId}&couponId=${that.data.paramData.couponId}`
  124. })
  125. return;
  126. }
  127. /**
  128. * 来自拼团详情
  129. */
  130. if (that.data.path == 'spell') {
  131. if (that.data.paramData.avatarUrl) {
  132. wx.redirectTo({
  133. 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}`
  134. })
  135. } else {
  136. wx.redirectTo({
  137. url: `/pages/spellGroup/mySpellGroup/index?couponId=${that.data.paramData.couponId}&couponChannelId=${that.data.paramData.couponChannelId}`
  138. })
  139. }
  140. return;
  141. }
  142. /**
  143. * fromId若存在来自卡转赠
  144. */
  145. if (that.data.path == 'index' && !that.data.paramData.cuserId) {
  146. wx.redirectTo({
  147. url: "/pages/game/index?url=" + that.data.paramData.url + "&id=" + that.data.paramData.id + "&gameId=" + that.data.paramData.gameId,
  148. })
  149. } else if (that.data.path == 'index' && that.data.paramData.cuserId) {
  150. wx.redirectTo({
  151. 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
  152. })
  153. }
  154. /**
  155. * 活动报名
  156. */
  157. else if (that.data.signActivity) {
  158. wx.redirectTo({
  159. url: `/pages/radetail/joinActivity/edit?activityId=${that.data.signActivity}`
  160. })
  161. } else if (that.data.mineFlag == 'mine') {
  162. wx.switchTab({
  163. url: '/index/user'
  164. });
  165. } else {
  166. wx.showToast({
  167. title: res.data.msg,
  168. icon: "success",
  169. success: function(res) {
  170. if (that.data.couponChannelId) {
  171. wx.redirectTo({
  172. url: "/pages/coupon/detail/index?couponChannelId=" + that.data.couponChannelId + "&flag=pay"
  173. })
  174. } else {
  175. wx.switchTab({
  176. url: '/index/passCar',
  177. })
  178. }
  179. }
  180. });
  181. }
  182. })
  183. .catch(err => {
  184. wx.showToast({
  185. title: err.message,
  186. icon: 'none',
  187. duration: 2000,
  188. mask: false
  189. });
  190. })
  191. }
  192. });