|
|
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> |