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.

47 lines
1.2 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. couponId: null,
  8. },
  9. onLoad: function(options) {
  10. var that = this;
  11. console.log(options);
  12. that.setData({
  13. couponId: options.couponId
  14. })
  15. },
  16. getPhoneNumber: function(e) {
  17. var that = this;
  18. var iv = e.detail.iv;
  19. var encryptedData = e.detail.encryptedData;
  20. Http.post({
  21. url: config.api.getUserPhone,
  22. data: {
  23. encryptedData: encryptedData,
  24. iv: iv,
  25. }
  26. })
  27. .then(function(res) {
  28. console.log(res);
  29. app.globalData.phone = res.data.phone;
  30. wx.showToast({
  31. title: res.data.msg,
  32. icon: "success",
  33. success: function(res) {
  34. wx.redirectTo({
  35. url: '../coupon/detail/index?id=' + that.data.couponId + "&flag=pay",
  36. })
  37. }
  38. })
  39. },
  40. function(error) {
  41. wx.showToast({
  42. title: '请重新授权手机号',
  43. icon: "none",
  44. })
  45. })
  46. }
  47. })