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

155 строки
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. let value = JSON.stringify({ END: "C", TYPE: "couponorder", ID: options.quancode})
  54. // util.barcode("barcode", value, 500, 100);
  55. util.qrcode("qrcode", value, 350, 350);
  56. that.setData({
  57. code: options.quancode,
  58. title: options.title,
  59. subtitle: options.subtitle,
  60. remark: options.remark,
  61. couponorderstatus: options.couponorderstatus
  62. });
  63. /**
  64. * 如果没有核销
  65. */
  66. that.data.setInter = setInterval(function () {
  67. if (that.data.couponorderstatus == 0) {
  68. Http.get({
  69. url: config.api.getStatus,
  70. data: {
  71. couponOrderId: options.quancode
  72. }
  73. }).then(res => {
  74. console.log(res);
  75. that.setData({
  76. couponorderstatus: res.data.CouponOrderStatus
  77. });
  78. if (res.data.CouponOrderStatus == 1) {
  79. /**
  80. * 动态改变上一级页面的核销状态
  81. */
  82. that.getStaticGame()
  83. var pages = getCurrentPages();
  84. var prevPage = pages[pages.length - 2]; //上一个页面
  85. //直接调用上一个页面的setData()方法,把数据存到上一个页面中去
  86. prevPage.setData({
  87. mystatus: res.data.CouponOrderStatus
  88. });
  89. }
  90. })
  91. .catch(err => {
  92. wx.showToast({
  93. title: err.errMsg,
  94. icon: 'none',
  95. duration: 2000,
  96. mask: false
  97. });
  98. })
  99. }
  100. }, 2000);
  101. if (that.data.couponorderstatus == 1) {
  102. /**
  103. * 如果已经核销
  104. * 不需要循环
  105. */
  106. Http.get({
  107. url: config.api.getStatus,
  108. data: {
  109. couponOrderId: options.quancode
  110. }
  111. }).then(res => {
  112. that.setData({
  113. couponorderstatus: res.data.CouponOrderStatus
  114. });
  115. })
  116. .catch(err => {
  117. wx.showToast({
  118. title: err.errMsg,
  119. icon: 'none',
  120. duration: 2000,
  121. mask: false
  122. });
  123. })
  124. }
  125. /**
  126. * couponorderstatus
  127. * 0 没有核销
  128. * 1 已经核销成功
  129. */
  130. },
  131. // onShow(options) {
  132. // console.log("屏幕的亮度")
  133. // setTimeout(function () {
  134. // wx.setScreenBrightness({
  135. // value: 1,
  136. // })
  137. // }, 200)
  138. // },
  139. onUnload: function () {
  140. let that = this;
  141. clearInterval(that.data.setInter);
  142. },
  143. onHide: function () {
  144. let that = this;
  145. clearInterval(that.data.setInter);
  146. },
  147. // onHide:function(){
  148. // console.log(app.globalData.sight)
  149. // wx.setScreenBrightness({
  150. // value: app.globalData.sight,
  151. // })
  152. // }
  153. });