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.

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