C端小程序
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

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