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.

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