抖音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.

199 lines
6.3 KiB

  1. const navigationBarHeight = (getApp().statusBarHeight + 50) + 'px'
  2. var config = require("../../../config/config.js");
  3. var app = getApp();
  4. const Http = require("../../../utils/HttpBasics");
  5. const util = require("../../../utils/util");
  6. const imgurl = require("../../../utils/imgurl");
  7. Page({
  8. data: {
  9. couponIds: "",
  10. couponChannelId: "",
  11. showPage: false,
  12. data: {},
  13. spuIdObj: {},
  14. priceAndStockObj: {},
  15. validStartDate: "",
  16. validEndDate: "",
  17. },
  18. onLoad: function (options) {
  19. console.log(options.couponChannelId);
  20. this.getDetail(options.couponChannelId)
  21. },
  22. getDetail: function (couponChannelId, flag) {
  23. let that = this;
  24. let data = {};
  25. // that.getCouponPriceAndStock(couponChannelId);//获取券价格和库存
  26. if (that.data.couponIds) {
  27. data.couponId = couponChannelId
  28. } else {
  29. data.couponChannelId = couponChannelId
  30. }
  31. var parmer = {
  32. url: config.api.newCouponDetail,
  33. data: data
  34. };
  35. Http.get(parmer).then(res => {
  36. that.setData({
  37. couponId: res.data.couponId
  38. })
  39. /**
  40. * activityStatus==0 活动未开始
  41. * activityStatus==1 活动已开始
  42. * flag == endclock 说明倒计时已经结束
  43. */
  44. if (res.data.endTime && res.data.beginTime) {
  45. that.setData({
  46. begin_time: res.data.beginTime,
  47. end_time: res.data.endTime,
  48. activityStatus: res.data.actStatus ? res.data.actStatus : ''
  49. })
  50. if (res.data.actStatus == 0 && flag != 'endclock') {
  51. that.countdown(res.data.beginTime);
  52. } else if (res.data.actStatus != 0 && flag != 'endclock') {
  53. that.countdown(res.data.endTime);
  54. } else {
  55. clearInterval(that.data.setInterval)
  56. }
  57. if (res.data.actStatus == 0) {
  58. var beginTime = util.formatTime(res.data.beginTime, "yyyy-MM-dd hh:mm:ss");
  59. if (util.timechuo(beginTime).indexOf('-') == 0) {
  60. that.setData({
  61. beginTime: "活动已结束",
  62. });
  63. } else {
  64. that.setData({
  65. beginTime: util.timechuo(beginTime)
  66. });
  67. }
  68. } else {
  69. var endTime = util.formatTime(res.data.endTime, "yyyy-MM-dd hh:mm:ss");
  70. if (util.timechuo(endTime).indexOf('-') == 0) {
  71. that.setData({
  72. endtime: "活动已结束",
  73. });
  74. } else {
  75. that.setData({
  76. endtime: util.timechuo(endTime)
  77. });
  78. }
  79. }
  80. }
  81. tt.hideLoading();
  82. that.setData({
  83. data: res.data,
  84. });
  85. if (res.data.type == 10) {
  86. that.setData({
  87. salePriceStr: res.data.salePriceStr,
  88. pickEndDate: util.formatTime(res.data.pickEndDate, "yyyy-MM-dd"),
  89. pickStartDate: util.formatTime(res.data.pickStartDate, "yyyy-MM-dd"),
  90. priceStr: res.data.priceStr,
  91. tailPriceStr: res.data.tailPriceStr,
  92. origPriceStr: res.data.origPriceStr
  93. })
  94. }
  95. if (res.data.validType == 1) {
  96. that.setData({
  97. soldStartTime: util.timestampToTime(res.data.soldStartTime, "YYYY-MM-DD") || null,
  98. soldEndTime: util.timestampToTime(res.data.soldEndTime, "YYYY-MM-DD") || null,
  99. validStartDate: util.timestampToTime(res.data.validStartDate, "YYYY-MM-DD"),
  100. validEndDate: util.timestampToTime(res.data.validEndDate, "YYYY-MM-DD"),
  101. pickStartDate: util.formatTime(res.data.pickStartDate, "yyyy-MM-dd"),
  102. pickEndDate: util.formatTime(res.data.pickEndDate, "yyyy-MM-dd"),
  103. });
  104. } else {
  105. if (res.data.validDays) {
  106. that.setData({
  107. validDays: res.data.validDays
  108. });
  109. }
  110. }
  111. if (res.data.itemGroup) {
  112. let tempObj = this.data.data
  113. tempObj.itemGroup = JSON.parse(tempObj.itemGroup)
  114. this.setData({
  115. data: tempObj
  116. })
  117. console.log(this.data.data, "data");
  118. }
  119. if (res.data.productAttrs && res.data.skuAttrs) {
  120. let tempObj = this.data.data
  121. tempObj.productAttrs = JSON.parse(tempObj.productAttrs)
  122. tempObj.skuAttrs = JSON.parse(tempObj.skuAttrs)
  123. tempObj.productAttrs.map(item => {
  124. if (item.key == "appointment") {
  125. let tempAppoinObj = JSON.parse(item.data)
  126. if (tempAppoinObj.need_appointment) {
  127. let subscribeSing = "";
  128. if (tempAppoinObj.ahead_time_type == 1) {
  129. subscribeSing = `需提前${tempAppoinObj.ahead_day_num}天预约`
  130. } else if (tempAppoinObj.ahead_time_type == 2) {
  131. subscribeSing = `需提前${tempAppoinObj.ahead_hour_num}小时预约`
  132. } else if (tempAppoinObj.ahead_time_type == 3) {
  133. subscribeSing = `需提前${tempAppoinObj.ahead_minute_num}分钟预约`
  134. }
  135. tempObj.subscribeSing = subscribeSing
  136. }
  137. }
  138. if (item.key == "Notification") {
  139. if (item.data != '') {
  140. tempObj.curLsit = JSON.parse(item.data)
  141. }
  142. }
  143. if (item.key == "bring_out_meal") {
  144. tempObj.besides = item.data
  145. }
  146. if (item.key == "free_pack") {
  147. tempObj.pack = item.data
  148. }
  149. if (item.key == "superimposed_discounts") {
  150. tempObj.superimposed_discounts = item.data
  151. }
  152. if (item.key == "private_room") {
  153. tempObj.private_room = item.data
  154. }
  155. if (item.key == "rec_person_num_max") {
  156. tempObj.rec_person_num_max = item.data
  157. }
  158. if (item.key == 'Description' && item.isRequired) {
  159. tempObj.Description = JSON.parse(item.data)
  160. }
  161. if (item.key == "can_no_use_date") {
  162. tempObj.can_no_use_date = JSON.parse(item.data)
  163. }
  164. })
  165. tempObj.skuAttrs.map(item => {
  166. if (item.key == "commodity") {
  167. if (item.data != '') {
  168. tempObj.itemGroup = JSON.parse(item.data)
  169. }
  170. }
  171. })
  172. this.setData({
  173. data: tempObj
  174. })
  175. console.log(this.data.data, "data");
  176. }
  177. }).catch(err => {
  178. tt.showToast({
  179. title: err.message,
  180. icon: 'none',
  181. duration: 2000,
  182. mask: false
  183. });
  184. })
  185. },
  186. })