C端小程序
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

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