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

99 行
2.9 KiB

  1. const util = require("../../../utils/util");
  2. const config = require("../../../config/config.js");
  3. const Http = require("../../../utils/HttpBasics");
  4. //券详情页面
  5. Page({
  6. data: {
  7. code: "",
  8. data: {},
  9. createDate: "",
  10. expiredTime: "",
  11. updateDate: "",
  12. //存储计时器
  13. setInter: ""
  14. },
  15. onUnload: function() {
  16. let that = this;
  17. clearInterval(that.data.setInter);
  18. },
  19. onLoad: function(options) {
  20. console.log(options);
  21. let that = this;
  22. that.setData({
  23. code: options.quancode,
  24. couponorderstatus: options.couponorderstatus
  25. });
  26. //获得优惠券的详情
  27. that.data.setInter = setInterval(function() {
  28. if (
  29. options.quancode != null &&
  30. options.quancode != "" &&
  31. options.quancode != undefined &&
  32. that.data.couponorderstatus == 0
  33. ) {
  34. Http.get({
  35. url: config.api.couponOrderDetail,
  36. data: {
  37. couponOrderId: options.quancode
  38. }
  39. }).then(res => {
  40. console.log(res);
  41. that.setData({
  42. couponorderstatus: res.data.couponOrderStatus,
  43. data: res.data
  44. });
  45. if (res.data.couponOrderStatus == 1) {
  46. /**
  47. * 动态改变上一级页面的核销状态
  48. */
  49. var pages = getCurrentPages();
  50. var prevPage = pages[pages.length - 2]; //上一个页面
  51. //直接调用上一个页面的setData()方法,把数据存到上一个页面中去
  52. prevPage.setData({
  53. mystatus: res.data.couponOrderStatus
  54. });
  55. }
  56. that.setData({
  57. expiredTime: util.formatTime(that.data.data.expiredTime, "yyyy-MM-dddd hh:mm:ss"),
  58. updateDate: util.formatTime(that.data.data.updateDate, "yyyy-MM-dddd hh:mm:ss"),
  59. createDate: util.formatTime(that.data.data.createDate, "yyyy-MM-dddd hh:mm:ss")
  60. });
  61. });
  62. }
  63. }, 2000);
  64. /**
  65. * 页面需要初始渲染的效果
  66. */
  67. Http.get({
  68. url: config.api.couponOrderDetail,
  69. data: {
  70. couponOrderId: options.quancode
  71. }
  72. }).then(res => {
  73. console.log(res);
  74. that.setData({
  75. couponorderstatus: res.data.couponOrderStatus,
  76. data: res.data
  77. });
  78. that.setData({
  79. expiredTime: util.formatTime(that.data.data.expiredTime, "yyyy-MM-dddd hh:mm:ss"),
  80. updateDate: util.formatTime(that.data.data.updateDate, "yyyy-MM-dddd hh:mm:ss"),
  81. createDate: util.formatTime(that.data.data.createDate, "yyyy-MM-dddd hh:mm:ss")
  82. });
  83. util.barcode("barcode", options.quancode, 510, 100);
  84. util.qrcode("qrcode", options.quancode, 350, 350);
  85. })
  86. },
  87. phone: function() {
  88. let that = this;
  89. console.log(that.data);
  90. if (that.data.data.merchantLinkPhone) {
  91. wx.makePhoneCall({
  92. phoneNumber: that.data.data.merchantLinkPhone
  93. });
  94. }
  95. }
  96. });