C端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

146 regels
4.3 KiB

  1. var config = require("../../config/config.js");
  2. const Http = require("../../utils/HttpBasics");
  3. var app = getApp();
  4. Page({
  5. data: {
  6. canIUse: wx.canIUse("button.open-type.getPhoneNumber"),
  7. couponChannelId: "",
  8. path:null,
  9. paramData:null,
  10. signActivity:"",
  11. mineFlag:null
  12. },
  13. onLoad: function (options) {
  14. var that = this;
  15. that.setData({
  16. path: options.path
  17. })
  18. that.setData({
  19. paramData: options
  20. })
  21. if (options&&options.couponChannelId) {
  22. that.setData({
  23. couponChannelId: options.couponChannelId
  24. });
  25. }
  26. if (options && options.mineFlag) {
  27. that.setData({
  28. mineFlag: options.mineFlag
  29. })
  30. }
  31. if (options&&options.signActivity){
  32. that.setData({
  33. signActivity: options.signActivity
  34. });
  35. }
  36. Http.get({
  37. url: config.api.marketicon,
  38. data: {
  39. appId: config.weapp.AppId
  40. }
  41. }).then(res => {
  42. that.setData({
  43. mallImgUrl: res.data.mallImgUrl
  44. });
  45. wx.setNavigationBarTitle({
  46. title: res.data.mallName
  47. })
  48. })
  49. .catch(err => {
  50. wx.showToast({
  51. title: err.errMsg,
  52. icon: 'none',
  53. duration: 2000,
  54. mask: false
  55. });
  56. })
  57. },
  58. getPhoneNumber: function (e) {
  59. var that = this;
  60. var iv = e.detail.iv;
  61. var encryptedData = e.detail.encryptedData;
  62. Http.post({
  63. url: config.api.getUserPhone,
  64. data: {
  65. encryptedData: encryptedData,
  66. iv: iv
  67. }
  68. }).then(res=>{
  69. app.globalData.phone = res.data.phone;
  70. /**
  71. * 来自积分兑换
  72. */
  73. if (that.data.path == 'jifen') {
  74. wx.redirectTo({
  75. url: `/pages/integralmall/payIntegcoupondetail/index?couponChannelId=${that.data.paramData.couponChannelId}&couponId=${that.data.paramData.couponId}`
  76. })
  77. return;
  78. }
  79. /**
  80. * 来自拼团详情
  81. */
  82. if (that.data.path == 'spell') {
  83. if (that.data.paramData.avatarUrl) {
  84. wx.redirectTo({
  85. 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}`
  86. })
  87. } else {
  88. wx.redirectTo({
  89. url: `/pages/spellGroup/mySpellGroup/index?couponId=${that.data.paramData.couponId}&couponChannelId=${that.data.paramData.couponChannelId}`
  90. })
  91. }
  92. return;
  93. }
  94. /**
  95. * fromId若存在来自卡转赠
  96. */
  97. if (that.data.path == 'index' && !that.data.paramData.cuserId) {
  98. wx.redirectTo({
  99. url: "/pages/game/index?url=" + that.data.paramData.url + "&id=" + that.data.paramData.id + "&gameId=" + that.data.paramData.gameId,
  100. })
  101. } else if (that.data.path == 'index' && that.data.paramData.cuserId) {
  102. wx.reLaunch({
  103. 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
  104. })
  105. }
  106. /**
  107. * 活动报名
  108. */
  109. else if (that.data.signActivity) {
  110. wx.redirectTo({
  111. url: `/pages/radetail/joinActivity/edit?activityId=${that.data.signActivity}`
  112. })
  113. } else if (that.data.mineFlag == 'mine'){
  114. wx.switchTab({
  115. url: '/pages/user/index'
  116. });
  117. } else {
  118. wx.showToast({
  119. title: res.data.msg,
  120. icon: "success",
  121. success: function (res) {
  122. if (that.data.couponChannelId) {
  123. wx.redirectTo({
  124. url: "/pages/coupon/detail/index?couponChannelId=" + that.data.couponChannelId + "&flag=pay"
  125. })
  126. } else {
  127. wx.switchTab({
  128. url: '/pages/passCar/passCar',
  129. })
  130. }
  131. }
  132. });
  133. }
  134. })
  135. .catch(err => {
  136. wx.showToast({
  137. title: err.message,
  138. icon: 'none',
  139. duration: 2000,
  140. mask: false
  141. });
  142. })
  143. }
  144. });