C端小程序
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

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