C端小程序
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

206 行
6.1 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. // 来着问卷
  108. if (that.data.path =="wj"){
  109. wx.redirectTo({
  110. url: `/pages/questionnaire/questionnaire?id=${that.data.wjId}`
  111. })
  112. return;
  113. }
  114. /**a
  115. * 来自我的
  116. */
  117. if (that.data.path == 'main') {
  118. wx.switchTab({
  119. url: `/index/user`
  120. })
  121. return;
  122. }
  123. /**
  124. * 来自积分兑换
  125. */
  126. if (that.data.path == 'jifen') {
  127. wx.redirectTo({
  128. url: `/pages/integralmall/payIntegcoupondetail/index?couponChannelId=${that.data.paramData.couponChannelId}&couponId=${that.data.paramData.couponId}`
  129. })
  130. return;
  131. }
  132. /**
  133. * 来自拼团详情
  134. */
  135. if (that.data.path == 'spell') {
  136. if (that.data.paramData.avatarUrl) {
  137. wx.redirectTo({
  138. 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}`
  139. })
  140. } else {
  141. wx.redirectTo({
  142. url: `/pages/spellGroup/mySpellGroup/index?couponId=${that.data.paramData.couponId}&couponChannelId=${that.data.paramData.couponChannelId}`
  143. })
  144. }
  145. return;
  146. }
  147. /**
  148. * fromId若存在来自卡转赠
  149. */
  150. if (that.data.path == 'index' && !that.data.paramData.cuserId) {
  151. wx.redirectTo({
  152. url: "/pages/game/index?url=" + that.data.paramData.url + "&id=" + that.data.paramData.id + "&gameId=" + that.data.paramData.gameId,
  153. })
  154. } else if (that.data.path == 'index' && that.data.paramData.cuserId) {
  155. wx.redirectTo({
  156. 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
  157. })
  158. }
  159. /**
  160. * 活动报名
  161. */
  162. else if (that.data.signActivity) {
  163. wx.redirectTo({
  164. url: `/pages/radetail/joinActivity/edit?activityId=${that.data.signActivity}`
  165. })
  166. } else if (that.data.mineFlag == 'mine') {
  167. wx.switchTab({
  168. url: '/index/user'
  169. });
  170. } else if (that.data.mineFlag == 'index'){
  171. wx.switchTab({
  172. url: '/index/index'
  173. });
  174. }else {
  175. wx.showToast({
  176. title: res.data.msg,
  177. icon: "success",
  178. success: function(res) {
  179. if (that.data.couponChannelId) {
  180. wx.redirectTo({
  181. url: "/pages/coupon/detail/index?couponChannelId=" + that.data.couponChannelId + "&flag=pay"
  182. })
  183. } else {
  184. wx.switchTab({
  185. url: '/index/passCar',
  186. })
  187. }
  188. }
  189. });
  190. }
  191. })
  192. .catch(err => {
  193. wx.showToast({
  194. title: err.message,
  195. icon: 'none',
  196. duration: 2000,
  197. mask: false
  198. });
  199. })
  200. }
  201. });