C端小程序
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

136 righe
3.6 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. staticGamedata: {},
  15. showIf:false
  16. },
  17. onUnload: function() {
  18. let that = this;
  19. clearInterval(that.data.setInter);
  20. wx.setScreenBrightness({
  21. value: that.data.sight,
  22. })
  23. },
  24. gotogame: function () {
  25. let that = this;
  26. wx.navigateTo({
  27. url: '/pages/game/index?url=' + that.data.staticGamedata.url + "&id=" + that.data.staticGamedata.id + "&gameId=" + that.data.staticGamedata.gameId,
  28. })
  29. },
  30. // 获取游戏
  31. getStaticGame(token) {
  32. let _this = this;
  33. Http.get({
  34. url: config.api.getGame,
  35. data: {
  36. triggleAction: 3
  37. }
  38. }).then(res => {
  39. if (res.data.id) {
  40. _this.setData({
  41. showIf: true
  42. })
  43. }
  44. _this.setData({
  45. staticGamedata: res.data
  46. })
  47. })
  48. },
  49. onLoad: function(options) {
  50. let that = this;
  51. console.log(options.sight);
  52. setTimeout(function() {
  53. wx.setScreenBrightness({
  54. value: 0.7,
  55. })
  56. }, 200),
  57. that.setData({
  58. sight: options.sight,
  59. code: options.quancode,
  60. couponorderstatus: options.couponorderstatus
  61. });
  62. //获得优惠券的详情
  63. that.data.setInter = setInterval(function() {
  64. if (
  65. options.quancode &&
  66. that.data.couponorderstatus == 0
  67. ) {
  68. Http.get({
  69. url: config.api.couponOrderDetail,
  70. data: {
  71. couponOrderId: options.quancode
  72. }
  73. }).then(res => {
  74. console.log(res);
  75. that.setData({
  76. couponorderstatus: res.data.couponOrderStatus,
  77. data: res.data
  78. });
  79. if (res.data.couponOrderStatus == 1) {
  80. /**
  81. * 动态改变上一级页面的核销状态
  82. */
  83. that.getStaticGame()
  84. var pages = getCurrentPages();
  85. var prevPage = pages[pages.length - 2]; //上一个页面
  86. //直接调用上一个页面的setData()方法,把数据存到上一个页面中去
  87. prevPage.setData({
  88. mystatus: res.data.couponOrderStatus
  89. });
  90. }
  91. that.setData({
  92. expiredTime: util.formatTime(that.data.data.expiredTime, "yyyy-MM-dd hh:mm:ss"),
  93. updateDate: util.formatTime(that.data.data.updateDate, "yyyy-MM-dd hh:mm:ss"),
  94. createDate: util.formatTime(that.data.data.createDate, "yyyy-MM-dd hh:mm:ss")
  95. });
  96. });
  97. }
  98. }, 2000);
  99. /**
  100. * 页面需要初始渲染的效果
  101. */
  102. Http.get({
  103. url: config.api.couponOrderDetail,
  104. data: {
  105. couponOrderId: options.quancode
  106. }
  107. }).then(res => {
  108. console.log(res);
  109. that.setData({
  110. couponorderstatus: res.data.couponOrderStatus,
  111. data: res.data
  112. });
  113. that.setData({
  114. expiredTime: util.formatTime(that.data.data.expiredTime, "yyyy-MM-dd hh:mm:ss"),
  115. updateDate: util.formatTime(that.data.data.updateDate, "yyyy-MM-dd hh:mm:ss"),
  116. createDate: util.formatTime(that.data.data.createDate, "yyyy-MM-dd hh:mm:ss")
  117. });
  118. util.barcode("barcode", options.quancode, 510, 100);
  119. util.qrcode("qrcode", options.quancode, 350, 350);
  120. })
  121. },
  122. phone: function() {
  123. let that = this;
  124. console.log(that.data);
  125. if (that.data.data.merchantLinkPhone) {
  126. wx.makePhoneCall({
  127. phoneNumber: that.data.data.merchantLinkPhone
  128. });
  129. }
  130. }
  131. });