C端小程序
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
2.6 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. console.log(options);
  21. if (options.couponChannelId && options.couponId) {
  22. that.setData({
  23. couponChannelId: options.couponChannelId,
  24. couponId: options.couponId
  25. });
  26. }
  27. Http.get({
  28. url: config.api.marketicon,
  29. data: {
  30. appId: config.weapp.AppId
  31. }
  32. }).then(res => {
  33. console.log(res.data.mallImgUrl);
  34. that.setData({
  35. mallImgUrl: res.data.mallImgUrl
  36. });
  37. wx.setNavigationBarTitle({
  38. title: res.data.mallName
  39. })
  40. });
  41. },
  42. getPhoneNumber: function (e) {
  43. var that = this;
  44. var iv = e.detail.iv;
  45. var encryptedData = e.detail.encryptedData;
  46. Http.post({
  47. url: config.api.getUserPhone,
  48. data: {
  49. encryptedData: encryptedData,
  50. iv: iv
  51. }
  52. }).then(
  53. function (res) {
  54. console.log(res);
  55. console.log("这是用户授权手机号的结果");
  56. console.log(that.data.couponChannelId);
  57. console.log(that.data.couponId);
  58. console.log("这是从立即支付传回来的值 因为用户没有授权手机号");
  59. app.globalData.phone = res.data.phone;
  60. if (that.path == 'index') {
  61. wx.redirectTo({
  62. url: "/pages/game/index?url=" + that.data.paramData.url + "&id=" + that.data.paramData.id + "&gameId=" + that.data.paramData.gameId,
  63. })
  64. } else {
  65. wx.showToast({
  66. title: res.data.msg,
  67. icon: "success",
  68. success: function (res) {
  69. if (that.data.couponChannelId && that.data.couponId) {
  70. wx.redirectTo({
  71. url: "/pages/coupon/detail/index?couponChannelId=" +
  72. that.data.couponChannelId +
  73. "&couponId=" +
  74. that.data.couponId +
  75. "&flag=pay"
  76. })
  77. } else {
  78. wx.switchTab({
  79. url: '/pages/passCar/passCar',
  80. })
  81. }
  82. }
  83. });
  84. }
  85. },
  86. function (error) {
  87. wx.showToast({
  88. title: "请重新授权手机号",
  89. icon: "none"
  90. });
  91. }
  92. );
  93. }
  94. });