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

132 行
3.9 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/joinFrDpell/index?couponChannelId=${that.data.paramData.couponChannelId}`
  66. })
  67. }
  68. /**
  69. * 来自拼团详情
  70. */
  71. console.log(that.data, 98888)
  72. if (that.data.path == 'spell') {
  73. if (that.data.paramData.avatarUrl){
  74. wx.redirectTo({
  75. 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}`
  76. })
  77. }else{
  78. wx.redirectTo({
  79. url: `/pages/spellGroup/mySpellGroup/index?couponId=${that.data.paramData.couponId}&couponChannelId=${that.data.paramData.couponChannelId}`
  80. })
  81. }
  82. return;
  83. }
  84. /**
  85. * fromId若存在来自卡转赠
  86. */
  87. if (that.data.path == 'index' && !that.data.paramData.cuserId) {
  88. wx.redirectTo({
  89. url: "/pages/game/index?url=" + that.data.paramData.url + "&id=" + that.data.paramData.id + "&gameId=" + that.data.paramData.gameId,
  90. })
  91. } else if (that.data.path == 'index' && that.data.paramData.cuserId){
  92. wx.reLaunch({
  93. 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
  94. })
  95. } else {
  96. wx.showToast({
  97. title: res.data.msg,
  98. icon: "success",
  99. success: function (res) {
  100. if (that.data.couponChannelId) {
  101. wx.redirectTo({
  102. url: "/pages/coupon/detail/index?couponChannelId=" +that.data.couponChannelId +"&flag=pay"
  103. })
  104. } else {
  105. wx.switchTab({
  106. url: '/pages/passCar/passCar',
  107. })
  108. }
  109. }
  110. });
  111. }
  112. },
  113. function (error) {
  114. wx.showToast({
  115. title: "请重新授权手机号",
  116. icon: "none"
  117. });
  118. }
  119. )
  120. .catch(err => {
  121. wx.showToast({
  122. title: err.errMsg,
  123. icon: 'none',
  124. duration: 2000,
  125. mask: false
  126. });
  127. })
  128. }
  129. });