C端小程序
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

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