C端小程序
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

160 linhas
4.1 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. .catch(err => {
  53. wx.showToast({
  54. title: err.errMsg,
  55. icon: 'none',
  56. duration: 2000,
  57. mask: false
  58. });
  59. })
  60. },
  61. onLoad: function(options) {
  62. let that = this;
  63. setTimeout(function() {
  64. wx.setScreenBrightness({
  65. value: 0.7,
  66. })
  67. }, 200),
  68. that.setData({
  69. sight: options.sight,
  70. code: options.quancode,
  71. couponorderstatus: options.couponorderstatus
  72. });
  73. //获得优惠券的详情
  74. that.data.setInter = setInterval(function() {
  75. if (
  76. options.quancode &&
  77. that.data.couponorderstatus == 0
  78. ) {
  79. Http.get({
  80. url: config.api.couponOrderDetail,
  81. data: {
  82. couponOrderId: options.quancode
  83. }
  84. }).then(res => {
  85. that.setData({
  86. couponorderstatus: res.data.couponOrderStatus,
  87. data: res.data
  88. });
  89. if (res.data.couponOrderStatus == 1) {
  90. /**
  91. * 动态改变上一级页面的核销状态
  92. */
  93. that.getStaticGame()
  94. var pages = getCurrentPages();
  95. var prevPage = pages[pages.length - 2]; //上一个页面
  96. //直接调用上一个页面的setData()方法,把数据存到上一个页面中去
  97. prevPage.setData({
  98. mystatus: res.data.couponOrderStatus
  99. });
  100. }
  101. that.setData({
  102. expiredTime: util.formatTime(that.data.data.expiredTime, "yyyy-MM-dd hh:mm:ss"),
  103. updateDate: util.formatTime(that.data.data.updateDate, "yyyy-MM-dd hh:mm:ss"),
  104. createDate: util.formatTime(that.data.data.createDate, "yyyy-MM-dd hh:mm:ss")
  105. });
  106. })
  107. .catch(err => {
  108. wx.showToast({
  109. title: err.errMsg,
  110. icon: 'none',
  111. duration: 2000,
  112. mask: false
  113. });
  114. })
  115. }
  116. }, 2000);
  117. /**
  118. * 页面需要初始渲染的效果
  119. */
  120. Http.get({
  121. url: config.api.couponOrderDetail,
  122. data: {
  123. couponOrderId: options.quancode
  124. }
  125. }).then(res => {
  126. that.setData({
  127. couponorderstatus: res.data.couponOrderStatus,
  128. data: res.data
  129. });
  130. that.setData({
  131. expiredTime: util.formatTime(that.data.data.expiredTime, "yyyy-MM-dd hh:mm:ss"),
  132. updateDate: util.formatTime(that.data.data.updateDate, "yyyy-MM-dd hh:mm:ss"),
  133. createDate: util.formatTime(that.data.data.createDate, "yyyy-MM-dd hh:mm:ss")
  134. });
  135. util.barcode("barcode", options.quancode, 510, 100);
  136. util.qrcode("qrcode", options.quancode, 350, 350);
  137. })
  138. .catch(err => {
  139. wx.showToast({
  140. title: err.errMsg,
  141. icon: 'none',
  142. duration: 2000,
  143. mask: false
  144. });
  145. })
  146. },
  147. phone: function() {
  148. let that = this;
  149. if (that.data.data.merchantLinkPhone) {
  150. wx.makePhoneCall({
  151. phoneNumber: that.data.data.merchantLinkPhone
  152. });
  153. }
  154. }
  155. });