horizListFlex.vue
3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<template>
<div class="horiz-list-flex-box" v-if="lists && lists.length">
<slot name="title-box"></slot>
<div class="container-box">
<div class="container">
<div class="item-box" v-for="(item, index) in lists" :key="index">
<!--
com=1:goodsItem_1组件,pid:1、3,固定不滚动;2、4,滚动
事件:
@jump:整个点击跳转事件
@addCart:右下角加入购物车按钮事件,已阻止事件冒泡
com=2:goodsItem_2组件,pid: 1,带标题,不显示附加信息;2、不带标题,显示附加信息
事件:
@jump:整个点击跳转事件
com=3:goodsItem_3组件,无pid参数
事件:
@jump:整个点击跳转事件
@primary:右下角红色主按钮点击事件,已阻止事件冒泡
-->
<!-- 商品展示样式 1 -->
<goods-item-1 v-if="com == '1'" @jump="jump" @addCart="addCart"
:item="item"
:pid="pid">
</goods-item-1>
<!-- 商品展示样式 2 -->
<goods-item-2 v-if="com == '2'" @jump="jump"
:item="item"
:pid="pid">
<!-- 添加flag -->
<flag slot="flag" v-if="flags && flags.icon && flags.icon[index]"
:flag="flags.icon[index]"
:position="flags.position"
:width="flags.width">
</flag>
</goods-item-2>
<!-- 商品展示样式 3 -->
<goods-item-3 v-if="com == '3'" @jump="jump" @primary="primary"
:item="item">
</goods-item-3>
</div>
</div>
</div>
</div>
</template>
<script>
// 引入组件
import goodsItem1 from "@/components/goodsItem_1/goodsItem_1";
import goodsItem2 from "@/components/goodsItem_2/goodsItem_2";
import goodsItem3 from "@/components/goodsItem_3/goodsItem_3";
import flag from "@/components/flag/flag";
export default {
data: function () {
return {
}
},
props: ["lists", "com", "pid", "flags", "position"],
components: {
goodsItem1,
goodsItem2,
goodsItem3,
flag
},
methods: {
/**
* 点击跳转
* @param {object} item [数据对象]
*/
jump(item) {
this.$emit("jump", item);
},
/**
* 加入购物车
* @param {object} item [数据对象]
*/
addCart(item) {
this.$emit("addCart", item);
},
/**
* 主按钮点击事件
* @param {object} item [数据对象]
*/
primary(item) {
this.$emit("primary", item);
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style rel="stylesheet/less" lang="less" scoped>
@import './horizListFlex';
</style>