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.

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