C端小程序
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

154 строки
3.8 KiB

  1. let util = require("../../utils/util");
  2. let Http = require("../../utils/HttpBasics");
  3. let config = require("../../config/config.js");
  4. let app = getApp();
  5. const imgurl = require("../../utils/imgurl");
  6. Page({
  7. data: {
  8. lineUrl: imgurl.line.url,
  9. wm01Url: imgurl.wm01.url,
  10. wm02Url: imgurl.wm02.url,
  11. wm03Url: imgurl.wm03.url,
  12. code: "",
  13. //存储计时器
  14. setInter: "",
  15. staticGamedata: {},
  16. showIf: false,
  17. },
  18. gotogame: function () {
  19. let that = this;
  20. wx.navigateTo({
  21. url: '/pages/game/index?url=' + that.data.staticGamedata.url + "&id=" + that.data.staticGamedata.id + "&gameId=" + that.data.staticGamedata.gameId,
  22. })
  23. },
  24. // 获取游戏
  25. getStaticGame(token) {
  26. let _this = this;
  27. Http.get({
  28. url: config.api.getGame,
  29. data: {
  30. triggleAction: 4
  31. }
  32. }).then(res => {
  33. if (res.data.id) {
  34. _this.setData({
  35. showIf: true
  36. })
  37. }
  38. _this.setData({
  39. staticGamedata: res.data
  40. })
  41. })
  42. .catch(err => {
  43. wx.showToast({
  44. title: err.errMsg,
  45. icon: 'none',
  46. duration: 2000,
  47. mask: false
  48. });
  49. })
  50. },
  51. onLoad: function (options) {
  52. let that = this;
  53. util.barcode("barcode", options.quancode, 500, 100);
  54. util.qrcode("qrcode", options.quancode, 350, 350);
  55. that.setData({
  56. code: options.quancode,
  57. title: options.title,
  58. subtitle: options.subtitle,
  59. remark: options.remark,
  60. couponorderstatus: options.couponorderstatus
  61. });
  62. /**
  63. * 如果没有核销
  64. */
  65. that.data.setInter = setInterval(function () {
  66. if (that.data.couponorderstatus == 0) {
  67. Http.get({
  68. url: config.api.getStatus,
  69. data: {
  70. couponOrderId: options.quancode
  71. }
  72. }).then(res => {
  73. console.log(res);
  74. that.setData({
  75. couponorderstatus: res.data.CouponOrderStatus
  76. });
  77. if (res.data.CouponOrderStatus == 1) {
  78. /**
  79. * 动态改变上一级页面的核销状态
  80. */
  81. that.getStaticGame()
  82. var pages = getCurrentPages();
  83. var prevPage = pages[pages.length - 2]; //上一个页面
  84. //直接调用上一个页面的setData()方法,把数据存到上一个页面中去
  85. prevPage.setData({
  86. mystatus: res.data.CouponOrderStatus
  87. });
  88. }
  89. })
  90. .catch(err => {
  91. wx.showToast({
  92. title: err.errMsg,
  93. icon: 'none',
  94. duration: 2000,
  95. mask: false
  96. });
  97. })
  98. }
  99. }, 2000);
  100. if (that.data.couponorderstatus == 1) {
  101. /**
  102. * 如果已经核销
  103. * 不需要循环
  104. */
  105. Http.get({
  106. url: config.api.getStatus,
  107. data: {
  108. couponOrderId: options.quancode
  109. }
  110. }).then(res => {
  111. that.setData({
  112. couponorderstatus: res.data.CouponOrderStatus
  113. });
  114. })
  115. .catch(err => {
  116. wx.showToast({
  117. title: err.errMsg,
  118. icon: 'none',
  119. duration: 2000,
  120. mask: false
  121. });
  122. })
  123. }
  124. /**
  125. * couponorderstatus
  126. * 0 没有核销
  127. * 1 已经核销成功
  128. */
  129. },
  130. // onShow(options) {
  131. // console.log("屏幕的亮度")
  132. // setTimeout(function () {
  133. // wx.setScreenBrightness({
  134. // value: 1,
  135. // })
  136. // }, 200)
  137. // },
  138. onUnload: function () {
  139. let that = this;
  140. clearInterval(that.data.setInter);
  141. },
  142. onHide: function () {
  143. let that = this;
  144. clearInterval(that.data.setInter);
  145. },
  146. // onHide:function(){
  147. // console.log(app.globalData.sight)
  148. // wx.setScreenBrightness({
  149. // value: app.globalData.sight,
  150. // })
  151. // }
  152. });