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.

58 lines
1.6 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. util.barcode("barcode", options.quancode, 500, 100);
  13. util.qrcode("qrcode", options.quancode, 350, 350);
  14. that.setData({
  15. code: options.quancode,
  16. title: options.title,
  17. subtitle: options.subtitle,
  18. remark: options.remark,
  19. couponorderstatus: options.couponorderstatus
  20. });
  21. that.data.setInter = setInterval(function() {
  22. if (that.data.couponorderstatus == 0) {
  23. Http.get({
  24. url: config.api.getStatus,
  25. data: {
  26. couponOrderId: options.quancode
  27. }
  28. }).then(res => {
  29. console.log(res);
  30. that.setData({
  31. couponorderstatus: res.data.CouponOrderStatus
  32. });
  33. /**
  34. * 动态改变上一级页面的核销状态
  35. */
  36. var pages = getCurrentPages();
  37. var currPage = pages[pages.length - 1]; //当前页面
  38. var prevPage = pages[pages.length - 2]; //上一个页面
  39. //直接调用上一个页面的setData()方法,把数据存到上一个页面中去
  40. prevPage.setData({
  41. mystatus:res.data.CouponOrderStatus
  42. });
  43. });
  44. }
  45. }, 2000);
  46. /**
  47. * couponorderstatus
  48. * 0 没有核销
  49. * 1 已经核销成功
  50. */
  51. },
  52. onUnload: function() {
  53. let that = this;
  54. clearInterval(that.data.setInter);
  55. }
  56. });