C端小程序
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

103 行
2.5 KiB

  1. let util = require("../../utils/util");
  2. let Http = require("../../utils/HttpBasics");
  3. let config = require("../../config/config.js");
  4. Page({
  5. data: {
  6. code: "",
  7. //存储计时器
  8. setInter: ""
  9. },
  10. onLoad: function(options) {
  11. let that = this;
  12. setTimeout(function () {
  13. wx.setScreenBrightness({
  14. value: 0.7,
  15. })
  16. }, 200),
  17. util.barcode("barcode", options.quancode, 500, 100);
  18. util.qrcode("qrcode", options.quancode, 350, 350);
  19. that.setData({
  20. sight: options.sight,
  21. code: options.quancode,
  22. title: options.title,
  23. subtitle: options.subtitle,
  24. remark: options.remark,
  25. couponorderstatus: options.couponorderstatus
  26. });
  27. /**
  28. * 如果没有核销
  29. */
  30. that.data.setInter = setInterval(function() {
  31. if (that.data.couponorderstatus == 0) {
  32. Http.get({
  33. url: config.api.getStatus,
  34. data: {
  35. couponOrderId: options.quancode
  36. }
  37. }).then(res => {
  38. that.setData({
  39. couponorderstatus: res.data.CouponOrderStatus
  40. });
  41. if (res.data.CouponOrderStatus == 1) {
  42. /**
  43. * 动态改变上一级页面的核销状态
  44. */
  45. var pages = getCurrentPages();
  46. var prevPage = pages[pages.length - 2]; //上一个页面
  47. //直接调用上一个页面的setData()方法,把数据存到上一个页面中去
  48. prevPage.setData({
  49. mystatus: res.data.CouponOrderStatus
  50. });
  51. }
  52. })
  53. .catch(err => {
  54. wx.showToast({
  55. title: err.errMsg,
  56. icon: 'none',
  57. duration: 2000,
  58. mask: false
  59. });
  60. })
  61. }
  62. }, 2000);
  63. if (that.data.couponorderstatus == 1) {
  64. /**
  65. * 如果已经核销
  66. * 不需要循环
  67. */
  68. Http.get({
  69. url: config.api.getStatus,
  70. data: {
  71. couponOrderId: options.quancode
  72. }
  73. }).then(res => {
  74. that.setData({
  75. couponorderstatus: res.data.CouponOrderStatus
  76. });
  77. })
  78. .catch(err => {
  79. wx.showToast({
  80. title: err.errMsg,
  81. icon: 'none',
  82. duration: 2000,
  83. mask: false
  84. });
  85. })
  86. }
  87. /**
  88. * couponorderstatus
  89. * 0 没有核销
  90. * 1 已经核销成功
  91. */
  92. },
  93. onUnload: function() {
  94. let that = this;
  95. clearInterval(that.data.setInter);
  96. wx.setScreenBrightness({
  97. value: that.data.sight,
  98. })
  99. }
  100. });