抖音c端
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

197 行
6.4 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. validStartDate: util.formatTime(res.data.validStartDate, "yyyy-MM-dd"),
  98. validEndDate: util.formatTime(res.data.validEndDate, "yyyy-MM-dd"),
  99. pickStartDate: util.formatTime(res.data.pickStartDate, "yyyy-MM-dd"),
  100. pickEndDate: util.formatTime(res.data.pickEndDate, "yyyy-MM-dd"),
  101. });
  102. } else {
  103. if (res.data.validDays) {
  104. that.setData({
  105. validDays: res.data.validDays
  106. });
  107. }
  108. }
  109. if (res.data.itemGroup) {
  110. let tempObj = this.data.data
  111. tempObj.itemGroup = JSON.parse(tempObj.itemGroup)
  112. this.setData({
  113. data: tempObj
  114. })
  115. console.log(this.data.data, "data");
  116. }
  117. if (res.data.productAttrs && res.data.skuAttrs) {
  118. let tempObj = this.data.data
  119. tempObj.productAttrs = JSON.parse(tempObj.productAttrs)
  120. tempObj.skuAttrs = JSON.parse(tempObj.skuAttrs)
  121. tempObj.productAttrs.map(item => {
  122. if (item.key == "appointment") {
  123. let tempAppoinObj = JSON.parse(item.data)
  124. if (tempAppoinObj.need_appointment) {
  125. let subscribeSing = "";
  126. if (tempAppoinObj.ahead_time_type == 1) {
  127. subscribeSing = `需提前${tempAppoinObj.ahead_day_num}天致电商家预约`
  128. } else if (tempAppoinObj.ahead_time_type == 2) {
  129. subscribeSing = `需提前${tempAppoinObj.ahead_hour_num}小时致电商家预约`
  130. } else if (tempAppoinObj.ahead_time_type == 3) {
  131. subscribeSing = `需提前${tempAppoinObj.ahead_minute_num}分钟致电商家预约`
  132. }
  133. tempObj.subscribeSing = subscribeSing
  134. }
  135. }
  136. if (item.key == "Notification") {
  137. if (item.data != '') {
  138. tempObj.curLsit = JSON.parse(item.data)
  139. }
  140. }
  141. if (item.key == "bring_out_meal") {
  142. tempObj.besides = item.data
  143. }
  144. if (item.key == "free_pack") {
  145. tempObj.pack = item.data
  146. }
  147. if (item.key == "superimposed_discounts") {
  148. tempObj.superimposed_discounts = item.data
  149. }
  150. if (item.key == "private_room") {
  151. tempObj.private_room = item.data
  152. }
  153. if (item.key == "rec_person_num_max") {
  154. tempObj.rec_person_num_max = item.data
  155. }
  156. if (item.key == 'Description') {
  157. tempObj.Description = JSON.parse(item.data)
  158. }
  159. if (item.key == "can_no_use_date") {
  160. tempObj.can_no_use_date = JSON.parse(item.data)
  161. }
  162. })
  163. tempObj.skuAttrs.map(item => {
  164. if (item.key == "commodity") {
  165. if (item.data != '') {
  166. tempObj.itemGroup = JSON.parse(item.data)
  167. }
  168. }
  169. })
  170. this.setData({
  171. data: tempObj
  172. })
  173. console.log(this.data.data, "data");
  174. }
  175. }).catch(err => {
  176. tt.showToast({
  177. title: err.message,
  178. icon: 'none',
  179. duration: 2000,
  180. mask: false
  181. });
  182. })
  183. },
  184. })