C端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

168 line
4.4 KiB

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