C端小程序
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

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