1const productReviewPage = document.querySelector('[data-toggle="product-review-page"]'); 2if (productReviewPage) { 3 const id = productReviewPage.closest('[data-block-id]')?.dataset.blockId || 0; 4 const BLOCK_SETTING = Array.from(BLOCKS).find(x => x.ID == id); 5 6 const productReviewApp = { 7 data() { 8 return { 9 COMMENTS: [], 10 DATA: {}, 11 SORT_LIST: ['date_asc', 'date_desc', 'rate_asc', 'rate_desc'], 12 SORT: 'date_desc', 13 SEARCH_WORD: '', 14 PARAMS: { 15 start: 0, 16 limit: 10, 17 sort: 'date', 18 dir: 'desc', 19 q: '', 20 }, 21 CURRENT_PAGE: 1, 22 HAS_MORE: true, 23 timeConverter: timeConverter, 24 BLOCK: BLOCK_SETTING || {}, 25 SETTING: BLOCK_SETTING?.SETTING || {}, 26 LOADED: false, 27 t: TRANSLATES['product-review'], 28 } 29 }, 30 methods: { 31 reviewSearch() { 32 const self = this; 33 if (self.PARAMS.q == self.SEARCH_WORD) { 34 return; 35 } 36 self.PARAMS.q = self.SEARCH_WORD; 37 self.load(); 38 }, 39 secret(string = null) { 40 if (string != null) return string.slice(0, 1) + '**'; 41 }, 42 async loadMore() { 43 const self = this; 44 self.HAS_MORE = false; 45 self.PARAMS.start += self.PARAMS.limit; 46 await self.load(self.PARAMS.start); 47 }, 48 async load(start = null) { 49 const self = this; 50 51 self.LOADED = false; 52 try { 53 if (start == null) { 54 self.PARAMS.start = 0; 55 } else { 56 loader(true); 57 } 58 59 const params = [];
60 Object.keys(self.PARAMS).forEach(key => { 61 const value = self.PARAMS[key]; 62 if (value || value === 0) { 63 params.push(`${key}=${value}`); 64 } 65 }); 66 const response = await request('GET', getEndpoint('PRODUCT_REVIEW_GET', `?${params.join('&')}`)); 67 self.DATA = response; 68 if (start == null) { 69 self.COMMENTS = response.comments; 70 } else { 71 self.COMMENTS = [...self.COMMENTS, ...response.comments] || []; 72 } 73 74 if (self.COMMENTS.length < self.DATA.total) { 75 self.HAS_MORE = true; 76 } else { 77 self.HAS_MORE = false; 78 } 79 } catch (error) { 80 console.warn(`PRODUCT_REVIEW_GET error => ${error}`); 81 } finally { 82 self.LOADED = true; 83 components.init(); 84 loader(); 85 } 86 } 87 }, 88 watch: { 89 'SORT'(value) { 90 const self = this; 91 if (value) { 92 const sortArr = value.split('_'); 93 self.PARAMS.sort = sortArr[0]; 94 self.PARAMS.dir = sortArr[1]; 95 } else { 96 self.PARAMS.sort = ''; 97 self.PARAMS.dir = ''; 98 } 99 self.load(); 100 } 101 }, 102 mounted() { 103 const self = this; 104 self.load(); 105 }, 106 } 107 108 BLOCK_JS['PRODUCT_REVIEW'] = Vue.createApp(productReviewApp).mount(productReviewPage); 109}
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.