C端小程序
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

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