tabBox.vue
3.25 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="tabBox">
<!-- 主内容区域 -->
<van-tabs @change="onChange" swipeable v-model="active">
<van-tab v-for="(item,index) in tabbar" :key="index" :title="item.title">
<div class="tabBox_main">
<div class="tabbar" v-for="(item, index) in tabbaromponents.ads" :key="index">
<!-- 关爱屋简介 -->
<html-box
v-if="item.style == '14'"
:htmls="item.content">
</html-box>
<!-- 精品推荐 -->
<img-list-box
v-if="item.style == '1'"
@detail="toDetail"
:imgLists="item.img">
</img-list-box>
<!-- 商品推荐 -->
<column-commodity-list-box
v-if="item.style == '15'"
@detail="toCommodityDetail"
:columnLists="item">
</column-commodity-list-box>
<!--优惠专区-->
<discountZone v-if="item.style == '1'" @more="toDetail" @toDetail="toDetail"
:discountZoneInfo="item">
</discountZone>
</div>
</div>
</van-tab>
</van-tabs>
</div>
</template>
<script>
import htmlBox from "@/components/htmlBox/htmlBox";
import imgListBox from "@/components/imgListBox/imgListBox";
import columnCommodityListBox from "@/components/columnCommodityListBox/columnCommodityListBox";
import discountZone from "@/components/discountZone/discountZone";
export default {
name: 'name',
data () {
return {
active: 0,
tabbaromponents: null, // 组件库
}
},
props:["tabbar"],
components: {
htmlBox,
imgListBox,
columnCommodityListBox,
discountZone
},
created(){
// 初始化的时选中关爱屋
this.tabbaromponents = this.tabbar.find((item)=>{
return item.title === "关爱屋"
});
console.log(this.tabbaromponents)
},
methods: {
onChange(name, title) {
// 切换tab时判断展示哪个组件
this.tabbaromponents = this.tabbar.find((item)=>{
return item.title === title
});
},
/**
* 调用通用跳转
* @param {object} item [通用跳转对象]
*/
toDetail(item) {
// 判断是否有通用跳转函数
if (typeof this.$parent.gotoDetail === "function") {
// 调用通用跳转
this.$parent.gotoDetail(item);
}
},
/**
* 特定跳转商品详情
* @param {object} item [跳转对象]
*/
toCommodityDetail(item) {
// 设置跳转参数
Object.assign(item, {
type: "2",
to: item.id
});
// 调用通用跳转
this.toDetail(item);
},
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style rel="stylesheet/less" lang="less">
@import './tabBox';
</style>