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.

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