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.

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