1class ScriptSpecialOffers extends Script { 2 constructor(params) { 3 super(params) 4 this.$unit = document.getElementById(`${this.attrId}`) 5 if (this.$unit === null) return; 6 // æ´å¤ä¼æ ä¿¡æ¯æé® 7 this.$detail = this.$unit.querySelector('.unit-special-offers--detail') 8 // ææ£æ´å¤å表项 9 this.$discountList = this.$unit.querySelector('.unit-special-offers--discount-list') 10 // å计æ¶ï¼æ¶ï¼åç§ 11 this.$hh = this.$unit.querySelector('.unit-special-offers--date_limt--hh') 12 this.$mm = this.$unit.querySelector('.unit-special-offers--date_limt--mm') 13 this.$ss = this.$unit.querySelector('.unit-special-offers--date_limt--ss') 14 } 15 16 init() { 17 18 } 19 20 /** åå§åæ¾ç¤ºææ£ä¿¡æ¯ */ 21 async initDicountInfo() { 22 // è·åå½å产åçææ£ä¿¡æ¯ 23 //å¦ææ²¡æè¿å 24 // è®¾ç½®ææ£ä¿¡æ¯ 25 // æ¥æ¾åä»·ä¿¡æ¯å ç´ 26 const $price = this.$unit.querySelector('.unit-special-offers--prices_sell-price') 27 // åä»·éèå¨å计æ¶ç»ææ¾ç¤º 28 const $original = $price.querySelector('.unit-special-offers--prices_sell-price_original') 29 if ($original) $original.classList.add('d-none') 30 // æ¾ç¤ºææ£ä¸ºææ£çä»·æ ¼ 31 const $newPrice = $price.querySelector('.unit-special-offers--prices_sell-price_new') 32 if ($newPrice) $newPrice.innerHTML = `${window.app.info.productDetail.discount_price}` 33 // æ¾ç¤ºé»è®¤éèçéä»·ä¿¡æ¯ 34 const $off = this.$unit.querySelector('.unit-special-offers-prices_off') 35 if (!$off) return 36 $off.classList.remove('d-none') 37 // 设置æ¾ç¤ºéä»·çæ¯ç 38 const $offRate = $off.querySelector('.unit-special-offers--prices_dis') 39 if (!$offRate) return 40 $offRate.textContent = `${window.app.info.productDetail.off_rate}% OFF` 41 this.countTime() 42 } 43 44 /** 45 * æ ¹æ®äº§åä¿¡æ¯æ¾ç¤ºåè®¡æ¶ 46 * @param {产åä¿¡æ¯} product 47 */ 48 countTime() { 49 // 妿æå计æ¶ï¼å¤çæ¾ç¤ºåè®¡æ¶ 50 if (window.app.info.productDetail.is_discount) { 51 const $date = this.$unit.querySelector('.unit-special-offers--date') 52 if ($date) $date.classList.remove('d-none') 53 const $countTimeHint = this.$unit.querySelector('.unit-special-offers--date_ends') 54 const $limt = this.$unit.querySelector('.unit-special-offers--date_limt') 55 if (window.app.info.productDetail.detail_type === 'now') { //æ£å¨è¿è¡çæ´»å¨ 56 $countTimeHint.innerHTML = 'Ends in' 57 $limt.classList.add('unit-special-offers--date_limt--1') 58 $limt.classList.remove('unit-special-offers--date_limt--2') 59 } 60 else if (window.app.info.productDetail.detail_type === 'upcoming') { //å³å°è¿è¡çæ´»å¨ 61 $countTimeHint.innerHTML = 'Sale starts in' 62 $limt.classList.add('unit-special-offers--date_limt--2') 63 $limt.classList.remove('unit-special-offers--date_limt--1') 64 } 65 const time = window.app.info.productDetail.count_time 66 this.utilts.countTime(this.utilts.getTimeParseInt(time), this.$hh, this.$mm, this.$ss, () => { 67 // å¦ææ¯æ£å¨è¿è¡çæ´»å¨ï¼ä»·æ ¼æ¢å¤æ£å¸¸ 68 if (window.app.info.productDetail.detail_type === 'now') { 69 this.countTimeFinish() 70 } else if (window.app.info.productDetail.detail_type === 'upcoming') { 71 // 妿æ¯å³å°è¿è¡çæ´»å¨ï¼ç»§ç»å计æ¶ä¸ºæ£å¨è¿è¡çæ´»å¨ 72 this.countTime() 73 } 74 }) 75 } 76 } 77 78 /** åå§åæ´å¤detailå±å¼äºä»¶ */ 79 initDetailEvent() { 80 //å¦ææ²¡ædetail éåº 81 if (!this.$detail) return; 82 this.$detail.addEventListener('click', () => { 83 const clientHeight = this.$discountList.clientHeight 84 const height = this.$discountList.scrollHeight 85 if (clientHeight > 60) this.$discountList.style.height = '60px' 86 else this.$discountList.style.height = `${height}px` 87 }) 88 } 89 90 /** å计æ¶ç»ææ¶ï¼å¤çç¸å ³ä¿¡æ¯ */ 91 countTimeFinish() { 92 // ä»·æ ¼ä¿¡æ¯ 93 const $price = this.$unit.querySelector('.unit-special-offers--prices_sell-price') 94 if (!$price) return 95 // æ¾ç¤ºåä»· 96 const $original = $price.querySelector('.unit-special-offers--prices_sell-price_original') 97 if ($original) $original.classList.remove('d-none') 98 // éèææ£ä»·æ ¼ 99 const $newPrice = $price.querySelector('.unit-special-offers--prices_sell-price_new') 100 if ($newPrice) $newPrice.classList.add('d-none') 101 102 //éèåè®¡æ¶ 103 const $date = this.$unit.querySelector('.unit-special-offers--date') 104 if ($date) $date.classList.add('d-none') 105 // éèææ£ 106 const $off = this.$unit.querySelector('.unit-special-offers-prices_off') 107 if (!$off) return 108 $off.classList.add('d-none') 109 } 110 111 render() { 112 // åå§åæ´å¤detailå±å¼äºä»¶ 113 this.initDetailEvent() 114 this.initDicountInfo() 115 } 116}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.