C端小程序
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

192 строки
5.7 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.switchTab({
  68. url: '/index/index',
  69. })
  70. },
  71. getPhoneNumber: function(e) {
  72. var that = this;
  73. var iv = e.detail.iv;
  74. var encryptedData = e.detail.encryptedData;
  75. Http.post({
  76. url: config.api.getUserPhone,
  77. data: {
  78. encryptedData: encryptedData,
  79. iv: iv
  80. }
  81. }).then(res => {
  82. app.globalData.phone = res.data.phone;
  83. if (that.data.skipUrl == '1') {
  84. if (app.globalData.skip == 'redirectTo') {
  85. wx.redirectTo({
  86. url: app.globalData.skipUrl,
  87. })
  88. return;
  89. } else if (app.globalData.skip == 'navigateTo') {
  90. wx.navigateTo({
  91. url: app.globalData.skipUrl,
  92. })
  93. return;
  94. } else if (app.globalData.skip == 'reLaunch') {
  95. wx.reLaunch({
  96. url: app.globalData.skipUrl,
  97. })
  98. return;
  99. } else if (app.globalData.skip == 'switchTab') {
  100. wx.switchTab({
  101. url: app.globalData.skipUrl,
  102. })
  103. return;
  104. }
  105. }
  106. /**a
  107. * 来自我的
  108. */
  109. if (that.data.path == 'main') {
  110. wx.switchTab({
  111. url: `/index/user`
  112. })
  113. return;
  114. }
  115. /**
  116. * 来自积分兑换
  117. */
  118. if (that.data.path == 'jifen') {
  119. wx.redirectTo({
  120. url: `/pages/integralmall/payIntegcoupondetail/index?couponChannelId=${that.data.paramData.couponChannelId}&couponId=${that.data.paramData.couponId}`
  121. })
  122. return;
  123. }
  124. /**
  125. * 来自拼团详情
  126. */
  127. if (that.data.path == 'spell') {
  128. if (that.data.paramData.avatarUrl) {
  129. wx.redirectTo({
  130. 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}`
  131. })
  132. } else {
  133. wx.redirectTo({
  134. url: `/pages/spellGroup/mySpellGroup/index?couponId=${that.data.paramData.couponId}&couponChannelId=${that.data.paramData.couponChannelId}`
  135. })
  136. }
  137. return;
  138. }
  139. /**
  140. * fromId若存在来自卡转赠
  141. */
  142. if (that.data.path == 'index' && !that.data.paramData.cuserId) {
  143. wx.redirectTo({
  144. url: "/pages/game/index?url=" + that.data.paramData.url + "&id=" + that.data.paramData.id + "&gameId=" + that.data.paramData.gameId,
  145. })
  146. } else if (that.data.path == 'index' && that.data.paramData.cuserId) {
  147. wx.redirectTo({
  148. 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
  149. })
  150. }
  151. /**
  152. * 活动报名
  153. */
  154. else if (that.data.signActivity) {
  155. wx.redirectTo({
  156. url: `/pages/radetail/joinActivity/edit?activityId=${that.data.signActivity}`
  157. })
  158. } else if (that.data.mineFlag == 'mine') {
  159. wx.switchTab({
  160. url: '/index/user'
  161. });
  162. } else {
  163. wx.showToast({
  164. title: res.data.msg,
  165. icon: "success",
  166. success: function(res) {
  167. if (that.data.couponChannelId) {
  168. wx.redirectTo({
  169. url: "/pages/coupon/detail/index?couponChannelId=" + that.data.couponChannelId + "&flag=pay"
  170. })
  171. } else {
  172. wx.switchTab({
  173. url: '/index/passCar',
  174. })
  175. }
  176. }
  177. });
  178. }
  179. })
  180. .catch(err => {
  181. wx.showToast({
  182. title: err.message,
  183. icon: 'none',
  184. duration: 2000,
  185. mask: false
  186. });
  187. })
  188. }
  189. });