抖音c端
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

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