C端小程序
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

95 řádky
2.4 KiB

  1. const navigationBarHeight = (getApp().statusBarHeight + 60) + 'px'
  2. const util = require("../../utils/util.js");
  3. const Http = require("../../utils/HttpBasics");
  4. const config = require("../../config/config");
  5. const imgurl = require("../../utils/imgurl");
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. navigationBarHeight
  12. },
  13. // 兑换
  14. exchange(e){
  15. let that = this;
  16. let code = e.detail.value.code;
  17. let formId = e.detail.formId;
  18. if (!code || !code.replace(/\s*/g, "")){
  19. wx.showToast({
  20. title: '请输入兑换码',
  21. icon:"none",
  22. duration:2500
  23. })
  24. return;
  25. }
  26. that.checkPhoneStatus(e.detail.value.code,formId = e.detail.formId);
  27. },
  28. checkPhoneStatus: function (password, formId) {
  29. let that = this;
  30. Http.get({
  31. url: config.api.checkPhoneStatus,
  32. data: {}
  33. })
  34. .then(res => {
  35. that.getCouponOrderByPassword(password, formId);
  36. })
  37. .catch(err => {
  38. if (err.code == 11005) {
  39. /**
  40. * 手机号没有授权,将值传到用户手机号授权的页面
  41. *
  42. */
  43. wx.redirectTo({
  44. url: "/pages/getphoneInfo/index",
  45. })
  46. } else {
  47. wx.showToast({
  48. title: err.message,
  49. icon: 'none',
  50. duration: 2500
  51. })
  52. }
  53. })
  54. },
  55. getCouponOrderByPassword(password, formId) {
  56. let that = this;
  57. Http.post({
  58. url: config.api.getCouponOrderByPassword,
  59. data: {
  60. password: password,
  61. formId: formId
  62. }
  63. })
  64. .then(res => {
  65. wx.showModal({
  66. title: '兑换成功',
  67. content: '消费卡已发放到"我的卡包"',
  68. showCancel: true,
  69. cancelText: "知道了",
  70. cancelColor: '',
  71. confirmText: "去查看",
  72. confirmColor: '#FD832D',
  73. success: function (res) {
  74. if (res.cancel) {
  75. //点击取消,默认隐藏弹框
  76. } else {
  77. wx.redirectTo({
  78. url: '/pages/cardorder/index/index',
  79. })
  80. }
  81. },
  82. fail: function (res) { },//接口调用失败的回调函数
  83. complete: function (res) { },//接口调用结束的回调函数(调用成功、失败都会执行)
  84. })
  85. })
  86. .catch(err => {
  87. wx.showToast({
  88. title: err.message,
  89. icon: 'none',
  90. duration: 2000
  91. })
  92. })
  93. }
  94. })