C端小程序
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
3.1 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. wx.setScreenBrightness({
  19. value: that.data.sight,
  20. })
  21. },
  22. onLoad: function(options) {
  23. let that = this;
  24. console.log(options.sight);
  25. setTimeout(function() {
  26. wx.setScreenBrightness({
  27. value: 0.7,
  28. })
  29. }, 200),
  30. that.setData({
  31. sight: options.sight,
  32. code: options.quancode,
  33. couponorderstatus: options.couponorderstatus
  34. });
  35. //获得优惠券的详情
  36. that.data.setInter = setInterval(function() {
  37. if (
  38. options.quancode != null &&
  39. options.quancode != "" &&
  40. options.quancode != undefined &&
  41. that.data.couponorderstatus == 0
  42. ) {
  43. Http.get({
  44. url: config.api.couponOrderDetail,
  45. data: {
  46. couponOrderId: options.quancode
  47. }
  48. }).then(res => {
  49. console.log(res);
  50. that.setData({
  51. couponorderstatus: res.data.couponOrderStatus,
  52. data: res.data
  53. });
  54. if (res.data.couponOrderStatus == 1) {
  55. /**
  56. * 动态改变上一级页面的核销状态
  57. */
  58. var pages = getCurrentPages();
  59. var prevPage = pages[pages.length - 2]; //上一个页面
  60. //直接调用上一个页面的setData()方法,把数据存到上一个页面中去
  61. prevPage.setData({
  62. mystatus: res.data.couponOrderStatus
  63. });
  64. }
  65. that.setData({
  66. expiredTime: util.formatTime(that.data.data.expiredTime, "yyyy-MM-dd hh:mm:ss"),
  67. updateDate: util.formatTime(that.data.data.updateDate, "yyyy-MM-dd hh:mm:ss"),
  68. createDate: util.formatTime(that.data.data.createDate, "yyyy-MM-dd hh:mm:ss")
  69. });
  70. });
  71. }
  72. }, 2000);
  73. /**
  74. * 页面需要初始渲染的效果
  75. */
  76. Http.get({
  77. url: config.api.couponOrderDetail,
  78. data: {
  79. couponOrderId: options.quancode
  80. }
  81. }).then(res => {
  82. console.log(res);
  83. that.setData({
  84. couponorderstatus: res.data.couponOrderStatus,
  85. data: res.data
  86. });
  87. that.setData({
  88. expiredTime: util.formatTime(that.data.data.expiredTime, "yyyy-MM-dd hh:mm:ss"),
  89. updateDate: util.formatTime(that.data.data.updateDate, "yyyy-MM-dd hh:mm:ss"),
  90. createDate: util.formatTime(that.data.data.createDate, "yyyy-MM-dd hh:mm:ss")
  91. });
  92. util.barcode("barcode", options.quancode, 510, 100);
  93. util.qrcode("qrcode", options.quancode, 350, 350);
  94. })
  95. },
  96. phone: function() {
  97. let that = this;
  98. console.log(that.data);
  99. if (that.data.data.merchantLinkPhone) {
  100. wx.makePhoneCall({
  101. phoneNumber: that.data.data.merchantLinkPhone
  102. });
  103. }
  104. }
  105. });