C端小程序
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

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