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

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