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.

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