C端小程序
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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