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

161 行
4.2 KiB

  1. const util = require("../../../utils/util");
  2. const config = require("../../../config/config.js");
  3. const Http = require("../../../utils/HttpBasics");
  4. let app = getApp();
  5. //券详情页面
  6. Page({
  7. data: {
  8. code: "",
  9. data: {
  10. salePrice: null,
  11. price: null,
  12. usePrice: null
  13. },
  14. createDate: "",
  15. expiredTime: "",
  16. updateDate: "",
  17. //存储计时器
  18. setInter: "",
  19. staticGamedata: {},
  20. showIf: false,
  21. },
  22. onUnload:function(){
  23. let that = this;
  24. clearInterval(that.data.setInter);
  25. },
  26. onHide:function(){
  27. let that = this;
  28. clearInterval(that.data.setInter);
  29. },
  30. gotogame: function () {
  31. let that = this;
  32. wx.navigateTo({
  33. url: '/pages/game/index?url=' + that.data.staticGamedata.url + "&id=" + that.data.staticGamedata.id + "&gameId=" + that.data.staticGamedata.gameId,
  34. })
  35. },
  36. // 获取游戏
  37. getStaticGame(token) {
  38. let _this = this;
  39. Http.get({
  40. url: config.api.getGame,
  41. data: {
  42. triggleAction: 4
  43. }
  44. }).then(res => {
  45. if (res.data.id) {
  46. _this.setData({
  47. showIf: true
  48. })
  49. }
  50. _this.setData({
  51. staticGamedata: res.data
  52. })
  53. })
  54. .catch(err => {
  55. wx.showToast({
  56. title: err.errMsg,
  57. icon: 'none',
  58. duration: 2000,
  59. mask: false
  60. });
  61. })
  62. },
  63. // onShow(options) {
  64. // setTimeout(function () {
  65. // wx.setScreenBrightness({
  66. // value: 0.7,
  67. // })
  68. // }, 200)
  69. // },
  70. onLoad: function (options) {
  71. let that = this;
  72. that.setData({
  73. code: options.quancode,
  74. couponorderstatus: options.couponorderstatus
  75. });
  76. //获得优惠券的详情
  77. that.data.setInter = setInterval(function () {
  78. if (
  79. options.quancode &&
  80. that.data.couponorderstatus == 0
  81. ) {
  82. Http.get({
  83. url: config.api.couponOrderDetail,
  84. data: {
  85. couponOrderId: options.quancode
  86. }
  87. }).then(res => {
  88. console.log(res);
  89. that.setData({
  90. couponorderstatus: res.data.couponOrderStatus,
  91. data: res.data
  92. });
  93. if (res.data.couponOrderStatus == 1) {
  94. /**
  95. * 动态改变上一级页面的核销状态
  96. */
  97. that.getStaticGame()
  98. var pages = getCurrentPages();
  99. var prevPage = pages[pages.length - 2]; //上一个页面
  100. //直接调用上一个页面的setData()方法,把数据存到上一个页面中去
  101. prevPage.setData({
  102. mystatus: res.data.couponOrderStatus
  103. });
  104. }
  105. that.setData({
  106. expiredTime: util.formatTime(that.data.data.expiredTime, "yyyy-MM-dd hh:mm:ss"),
  107. updateDate: util.formatTime(that.data.data.updateDate, "yyyy-MM-dd hh:mm:ss"),
  108. createDate: util.formatTime(that.data.data.createDate, "yyyy-MM-dd hh:mm:ss")
  109. });
  110. })
  111. .catch(err => {
  112. wx.showToast({
  113. title: err.errMsg,
  114. icon: 'none',
  115. duration: 2000,
  116. mask: false
  117. });
  118. })
  119. }
  120. }, 2000);
  121. /**
  122. * 页面需要初始渲染的效果
  123. */
  124. Http.get({
  125. url: config.api.couponOrderDetail,
  126. data: {
  127. couponOrderId: options.quancode
  128. }
  129. }).then(res => {
  130. that.setData({
  131. couponorderstatus: res.data.couponOrderStatus,
  132. data: res.data
  133. });
  134. that.setData({
  135. expiredTime: util.formatTime(that.data.data.expiredTime, "yyyy-MM-dd hh:mm:ss"),
  136. updateDate: util.formatTime(that.data.data.updateDate, "yyyy-MM-dd hh:mm:ss"),
  137. createDate: util.formatTime(that.data.data.createDate, "yyyy-MM-dd hh:mm:ss")
  138. });
  139. util.barcode("barcode", options.quancode, 510, 100);
  140. util.qrcode("qrcode", options.quancode, 350, 350);
  141. })
  142. .catch(err => {
  143. wx.showToast({
  144. title: err.errMsg,
  145. icon: 'none',
  146. duration: 2000,
  147. mask: false
  148. });
  149. })
  150. },
  151. phone: function (e) {
  152. let that = this;
  153. if (e.currentTarget.dataset.merchantlinkphone) {
  154. wx.makePhoneCall({
  155. phoneNumber: e.currentTarget.dataset.merchantlinkphone
  156. });
  157. }
  158. }
  159. });