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.

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