C端小程序
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

106 righe
2.5 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. if (that.path == 'index') {
  62. wx.redirectTo({
  63. url: "/pages/game/index?url=" + that.data.paramData.url + "&id=" + that.data.paramData.id + "&gameId=" + that.data.paramData.gameId,
  64. })
  65. } else {
  66. wx.showToast({
  67. title: res.data.msg,
  68. icon: "success",
  69. success: function (res) {
  70. if (that.data.couponChannelId && that.data.couponId) {
  71. wx.redirectTo({
  72. url: "/pages/coupon/detail/index?couponChannelId=" +
  73. that.data.couponChannelId +
  74. "&couponId=" +
  75. that.data.couponId +
  76. "&flag=pay"
  77. })
  78. } else {
  79. wx.switchTab({
  80. url: '/pages/passCar/passCar',
  81. })
  82. }
  83. }
  84. });
  85. }
  86. },
  87. function (error) {
  88. wx.showToast({
  89. title: "请重新授权手机号",
  90. icon: "none"
  91. });
  92. }
  93. )
  94. .catch(err => {
  95. wx.showToast({
  96. title: err.errMsg,
  97. icon: 'none',
  98. duration: 2000,
  99. mask: false
  100. });
  101. })
  102. }
  103. });