Showing
3 changed files
with
199 additions
and
13 deletions
@@ -138,6 +138,12 @@ export default { | @@ -138,6 +138,12 @@ export default { | ||
138 | this.sortItem = item; | 138 | this.sortItem = item; |
139 | let id = item.id; | 139 | let id = item.id; |
140 | let name = item.name; | 140 | let name = item.name; |
141 | + let subList ; | ||
142 | + if (id === '-1') { | ||
143 | + subList = this.fetchBrandList({ id }); | ||
144 | + } else { | ||
145 | + subList = this.fetchCategorySubList({ id, name }); | ||
146 | + } | ||
141 | 147 | ||
142 | this.$store.dispatch('reportYas', { | 148 | this.$store.dispatch('reportYas', { |
143 | params: { | 149 | params: { |
@@ -148,13 +154,7 @@ export default { | @@ -148,13 +154,7 @@ export default { | ||
148 | } | 154 | } |
149 | } | 155 | } |
150 | }); | 156 | }); |
151 | - this.reportYas(scrollHeight); | ||
152 | - let subList ; | ||
153 | - if (id === '-1') { | ||
154 | - subList = this.fetchBrandList({ id }); | ||
155 | - } else { | ||
156 | - subList = this.fetchCategorySubList({ id, name }); | ||
157 | - } | 157 | + this.reportYas(); |
158 | } | 158 | } |
159 | }, | 159 | }, |
160 | goProductList(item, index, itemSub) { | 160 | goProductList(item, index, itemSub) { |
@@ -112,15 +112,17 @@ export default { | @@ -112,15 +112,17 @@ export default { | ||
112 | computed: { | 112 | computed: { |
113 | ...mapState(['channelList']), | 113 | ...mapState(['channelList']), |
114 | navList() { | 114 | navList() { |
115 | - this.$nextTick(() => { | ||
116 | - this.refreshProductList(this.active); | ||
117 | - }); | ||
118 | return get(find(this.channelList.list, ['template_name', 'guessLike']), 'data') || []; | 115 | return get(find(this.channelList.list, ['template_name', 'guessLike']), 'data') || []; |
119 | } | 116 | } |
120 | }, | 117 | }, |
121 | watch: { | 118 | watch: { |
122 | 'channelList.list': function() { | 119 | 'channelList.list': function() { |
123 | this.init(); | 120 | this.init(); |
121 | + }, | ||
122 | + navList() { | ||
123 | + this.$nextTick(() => { | ||
124 | + this.refreshProductList(this.active); | ||
125 | + }); | ||
124 | } | 126 | } |
125 | }, | 127 | }, |
126 | activated() { | 128 | activated() { |
@@ -140,6 +142,9 @@ export default { | @@ -140,6 +142,9 @@ export default { | ||
140 | async serverPrefetch() { | 142 | async serverPrefetch() { |
141 | return this.fetchChannelList(); | 143 | return this.fetchChannelList(); |
142 | }, | 144 | }, |
145 | + mounted() { | ||
146 | + this.refreshProductList(this.active); | ||
147 | + }, | ||
143 | methods: { | 148 | methods: { |
144 | ...mapActions(['fetchChannelList']), | 149 | ...mapActions(['fetchChannelList']), |
145 | ...mapActionsList(['fetchProductList']), | 150 | ...mapActionsList(['fetchProductList']), |
@@ -205,7 +210,7 @@ export default { | @@ -205,7 +210,7 @@ export default { | ||
205 | }, | 210 | }, |
206 | setYasParam: function(params) { | 211 | setYasParam: function(params) { |
207 | let {total, list} = this.productList; | 212 | let {total, list} = this.productList; |
208 | - | 213 | + |
209 | if (params && typeof params === 'object' && Object.keys(params).length) { | 214 | if (params && typeof params === 'object' && Object.keys(params).length) { |
210 | let P_NAME = 'XY_UFOSearchList', TYPE_ID = 1, P_PARAM = '', PRD_LIST = []; | 215 | let P_NAME = 'XY_UFOSearchList', TYPE_ID = 1, P_PARAM = '', PRD_LIST = []; |
211 | for (let item of list) { | 216 | for (let item of list) { |
@@ -276,7 +281,7 @@ export default { | @@ -276,7 +281,7 @@ export default { | ||
276 | // this.$refs.scroll.forceUpdate(); | 281 | // this.$refs.scroll.forceUpdate(); |
277 | // return; | 282 | // return; |
278 | // } | 283 | // } |
279 | - | 284 | + |
280 | await this.fetchList(this.selectedCategory); | 285 | await this.fetchList(this.selectedCategory); |
281 | this.$refs.scroll.forceUpdate(); | 286 | this.$refs.scroll.forceUpdate(); |
282 | }, | 287 | }, |
@@ -455,7 +460,7 @@ export default { | @@ -455,7 +460,7 @@ export default { | ||
455 | position: relative; | 460 | position: relative; |
456 | z-index: 1; | 461 | z-index: 1; |
457 | } | 462 | } |
458 | - | 463 | + |
459 | .channel-no-item { | 464 | .channel-no-item { |
460 | padding-top: 200px; | 465 | padding-top: 200px; |
461 | } | 466 | } |
apps/pages/list/components/productItem.vue
0 → 100644
1 | +<template> | ||
2 | + <div class="bg"> | ||
3 | + <div class="product-list-item" @click="goDetail(product, itemIndex)" | ||
4 | + :key="itemIndex" :class="(itemIndex) % 2 === 0 && 'magrin-right'"> | ||
5 | + <div class="item-top"> | ||
6 | + <div class="item-price"> | ||
7 | + <span class="price-flag">{{product[priceKey] && '¥'}}</span><span>{{product[priceKey] || ' '}}</span> | ||
8 | + </div> | ||
9 | + <div class="item-sales">{{product.sales && product.sales + '人付款'}}</div> | ||
10 | + </div> | ||
11 | + <ImgSize class="item-imge" :src="product.default_images" :width="274" :height="274"/> | ||
12 | + <div class="item-name">{{product.product_name}}</div> | ||
13 | + </div> | ||
14 | + </div> | ||
15 | +</template> | ||
16 | + | ||
17 | +<script> | ||
18 | + import {Scroll} from 'cube-ui'; | ||
19 | + import ImgSize from '../../../components/img-size'; | ||
20 | + | ||
21 | + export default { | ||
22 | + props: { | ||
23 | + list: Array, | ||
24 | + product: Object, | ||
25 | + itemIndex: Number, | ||
26 | + yasParams: Object, | ||
27 | + priceKey: { | ||
28 | + type: String, | ||
29 | + default: 'available_now_price', | ||
30 | + }, | ||
31 | + }, | ||
32 | + data: function() { | ||
33 | + return { | ||
34 | + yasFirstId: 0, | ||
35 | + }; | ||
36 | + }, | ||
37 | + methods: { | ||
38 | + goDetail(product, index) { | ||
39 | + if (this.yasParams && Object.keys(this.yasParams).length) { | ||
40 | + this.yasDetail(product.id, index); | ||
41 | + } | ||
42 | + this.$router.push({ | ||
43 | + name: 'ProductDetail', | ||
44 | + params: { | ||
45 | + productId: product.id, | ||
46 | + } | ||
47 | + }); | ||
48 | + }, | ||
49 | + yasShowEvent(height) { | ||
50 | + // 获取列表单个元素高度 | ||
51 | + let index = 0; | ||
52 | + | ||
53 | + if (height) { | ||
54 | + // 获取第一个曝光元素 | ||
55 | + let item = document.querySelector('.product-list-item'); | ||
56 | + let itemHeight = item.offsetHeight; | ||
57 | + let row = parseInt((height - 12) / itemHeight) + 1; | ||
58 | + | ||
59 | + index = row * 2 - 2; | ||
60 | + } | ||
61 | + | ||
62 | + // 获取曝光列表 | ||
63 | + let list = []; | ||
64 | + | ||
65 | + for (let i = 0; i < 6; i++) { | ||
66 | + if (this.list[i + index]) { | ||
67 | + list.push(this.list[i + index]); | ||
68 | + } | ||
69 | + } | ||
70 | + | ||
71 | + // 判断是否是重复曝光 | ||
72 | + if (list.length && list[0].id !== this.yasFirstId) { | ||
73 | + this.yasFirstId = list[0].id; | ||
74 | + | ||
75 | + // 1.P_NAME:页面名称,XY_UFOSearchList,XY_UFOSeriesList,XY_UFOBrandList、XY_UFOProductPoolList等; | ||
76 | + // 2.TYPE_ID:列表页入口类型,1-搜索结果页,2-系列,3-品牌,4-商品池; | ||
77 | + // 3.P_PARAM:页面参数,搜索关键词,系列ID,品牌ID,商品池ID; | ||
78 | + // 4.TAB_ID:tab切id,1-人气,2-价格,3-新品; | ||
79 | + // 5.TAB_NAME:tab切名称,人气,价格,新品; | ||
80 | + // 6.I_INDEX:曝光顺序; | ||
81 | + // 7.PRD_ID:商品id; | ||
82 | + let DATA = []; | ||
83 | + | ||
84 | + list.map((value, i) => { | ||
85 | + DATA.push({...this.yasParams, I_INDEX: i + index, PRD_ID: value.id}); | ||
86 | + }); | ||
87 | + this.$store.dispatch('reportYas', { | ||
88 | + params: { | ||
89 | + param: {DATA}, | ||
90 | + appop: 'XY_UFO_SHOW_EVENT' | ||
91 | + } | ||
92 | + }); | ||
93 | + } | ||
94 | + }, | ||
95 | + | ||
96 | + yasDetail(id, index) { | ||
97 | + // XY_UFO_PRD_LIST_C | ||
98 | + // 1.P_NAME:页面名称,XY_UFOSearchList,XY_UFOSeriesList,XY_UFOBrandList、XY_UFOProductPoolList等; | ||
99 | + // 2.TYPE_ID:列表页入口类型,1-搜索结果页,2-系列,3-品牌,4-商品池; | ||
100 | + // 3.P_PARAM:页面参数,搜索关键词,系列ID,品牌ID,商品池ID; | ||
101 | + // 4.TAB_ID:tab切id,1-人气,2-价格,3-新品; | ||
102 | + // 5.TAB_NAME:tab切名称,人气,价格,新品; | ||
103 | + // 6.I_INDEX:商品顺序号,从1开始递增; | ||
104 | + // 7.PRD_ID:商品id | ||
105 | + this.$store.dispatch('reportYas', { | ||
106 | + params: { | ||
107 | + param: {...this.yasParams, I_INDEX: index, PRD_ID: id }, | ||
108 | + appop: 'XY_UFO_PRD_LIST_C' | ||
109 | + } | ||
110 | + }); | ||
111 | + } | ||
112 | + }, | ||
113 | + components: { | ||
114 | + ImgSize, | ||
115 | + Scroll, | ||
116 | + } | ||
117 | + }; | ||
118 | +</script> | ||
119 | + | ||
120 | +<style lang="scss" scoped> | ||
121 | + .magrin-right { | ||
122 | + margin-right: 14px; | ||
123 | + } | ||
124 | + | ||
125 | + .product-list-item { | ||
126 | + border-radius: 16px; | ||
127 | + width: 344px; | ||
128 | + padding: 24px 24px 32px; | ||
129 | + // height: 498px; | ||
130 | + background: #fff; | ||
131 | + margin-bottom: 16px; | ||
132 | + } | ||
133 | + | ||
134 | + .item-top { | ||
135 | + height: 40px; | ||
136 | + display: flex; | ||
137 | + justify-content: space-between; | ||
138 | + margin-bottom: 32px; | ||
139 | + align-items: center; | ||
140 | + } | ||
141 | + | ||
142 | + .item-price { | ||
143 | + color: #d0021b; | ||
144 | + font-size: 32px; | ||
145 | + vertical-align: center; | ||
146 | + } | ||
147 | + | ||
148 | + .item-imge { | ||
149 | + width: 274px; | ||
150 | + height: 274px; | ||
151 | + margin: 0 10px; | ||
152 | + } | ||
153 | + | ||
154 | + .item-name { | ||
155 | + font-size: 24px; | ||
156 | + color: #000; | ||
157 | + letter-spacing: 0; | ||
158 | + line-height: 40px; | ||
159 | + margin-top: 14px; | ||
160 | + word-break: break-all; | ||
161 | + display: -webkit-box; | ||
162 | + -webkit-line-clamp: 2; | ||
163 | + -webkit-box-orient: vertical; | ||
164 | + overflow: hidden; | ||
165 | + } | ||
166 | + | ||
167 | + .item-sales { | ||
168 | + font-size: 22px; | ||
169 | + color: #999; | ||
170 | + } | ||
171 | + | ||
172 | + .price-flag { | ||
173 | + font-size: 24px; | ||
174 | + } | ||
175 | + | ||
176 | + .bg { | ||
177 | + padding: 24px; | ||
178 | + display: flex; | ||
179 | + flex-wrap: wrap; | ||
180 | + } | ||
181 | +</style> |
-
Please register or login to post a comment