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.

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