C端小程序
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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