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.

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