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

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