Commit 77a156696c618795067890ea14cda04da9dae5a3

Authored by zhiyangdu
1 parent 3f0c28e1

新增tab组件

src/components/tabBox/tabBox.less 0 → 100644
  1 +.main-box {
  2 + .tabs-box {
  3 + padding-top: 30px;
  4 + padding-bottom: 30px;
  5 + width: 750px;
  6 + height: auto;
  7 + &.bg-white {
  8 + background-color: #ffffff;
  9 + }
  10 + &.bg-excessive-color {
  11 + background: linear-gradient(90deg, rgba(255, 246, 248, 1) 0%, rgba(255, 233, 239, 1) 100%);
  12 + }
  13 + .box {
  14 + display: flex;
  15 + justify-content: space-around;
  16 + align-items: center;
  17 + margin: 0 auto;
  18 + width: 690px;
  19 + height: 100%;
  20 + .tab {
  21 + color: #B4B4B4;
  22 + font-size: 32px;
  23 + .line {
  24 + background-color: transparent;
  25 + margin: 8px auto 0 auto;
  26 + width: 40px;
  27 + height: 4px;
  28 + }
  29 + &.active {
  30 + color: #333333;
  31 + .line {
  32 + background-color: #FC1541;
  33 + width: 40px;
  34 + height: 4px;
  35 + }
  36 + }
  37 + }
  38 + }
  39 + }
  40 + .tabs-swiper-box {
  41 + width: 750px;
  42 + height: auto;
  43 + .swipe {
  44 + width: 100%;
  45 + height: 100%;
  46 + .swipe-item {
  47 + width: 100%;
  48 + height: 100%;
  49 + .skeleton {
  50 + &.brief {
  51 + background-color: #ffffff;
  52 + }
  53 + &.boutique {
  54 + background: linear-gradient(90deg, rgba(255, 246, 248, 1) 0%, rgba(255, 233, 239, 1) 100%);
  55 + }
  56 + &.commodity {
  57 + background-color: #F9F9F9;
  58 + .column-commodity-excessive {
  59 + background: linear-gradient(180deg, rgba(255, 255, 255, 1) 0%, rgba(249, 249, 249, 1) 100%);
  60 + width: 750px;
  61 + height: 30px;
  62 + }
  63 + }
  64 + }
  65 + }
  66 + }
  67 + }
  68 +}
src/components/tabBox/tabBox.vue 0 → 100644
  1 +<template>
  2 + <div class="tabBox">
  3 + <!-- 主内容区域 -->
  4 + <van-tabs @change="onChange" swipeable v-model="active">
  5 + <van-tab v-for="(item,index) in tabbar" :key="index" :title="item.title">
  6 + <div class="tabBox_main">
  7 + <div class="tabbar" v-for="(item, index) in tabbaromponents.ads" :key="index">
  8 + <!-- 关爱屋 -->
  9 + <html-box
  10 + v-if="item.style == '14'"
  11 + :htmls="item">
  12 + </html-box>
  13 + <img-list-box
  14 + v-if="item.style == '1'"
  15 + @detail="toDetail"
  16 + :imgLists="item">
  17 + </img-list-box>
  18 + <column-commodity-list-box
  19 + v-if="item.style == '15'"
  20 + @detail="toCommodityDetail"
  21 + :columnLists="item">
  22 + </column-commodity-list-box>
  23 + </div>
  24 + </div>
  25 + </van-tab>
  26 + </van-tabs>
  27 + </div>
  28 +</template>
  29 +
  30 +<script>
  31 + import htmlBox from "@/components/htmlBox/htmlBox";
  32 + import imgListBox from "@/components/imgListBox/imgListBox";
  33 + import columnCommodityListBox from "@/components/columnCommodityListBox/columnCommodityListBox";
  34 + import discountZone from "@/components/discountZone/discountZone";
  35 + export default {
  36 + name: 'name',
  37 + data () {
  38 + return {
  39 + active: 0,
  40 + tabbaromponents: null, // 组件库
  41 + }
  42 + },
  43 + props:["tabbar"],
  44 + components: {
  45 + htmlBox,
  46 + imgListBox,
  47 + columnCommodityListBox,
  48 + discountZone
  49 + },
  50 + created(){
  51 + // 初始化的时选中关爱屋
  52 + this.tabbaromponents = this.tabbar.find((item)=>{
  53 + return item.title === "关爱屋"
  54 + });
  55 + console.log(this.tabbaromponents)
  56 + },
  57 + methods: {
  58 + onChange(name, title) {
  59 + // 切换tab时判断展示哪个组件
  60 + this.tabbaromponents = this.tabbar.find((item)=>{
  61 + return item.title === title
  62 + });
  63 + }
  64 + }
  65 + }
  66 +</script>
  67 +
  68 +<!-- Add "scoped" attribute to limit CSS to this component only -->
  69 +<style rel="stylesheet/less" lang="less">
  70 + @import './tabBox';
  71 +</style>
src/main.js
@@ -6,7 +6,7 @@ import VueHead from &quot;vue-head&quot;; @@ -6,7 +6,7 @@ import VueHead from &quot;vue-head&quot;;
6 import sha1 from "sha1"; 6 import sha1 from "sha1";
7 import 'mint-ui/lib/style.css'; 7 import 'mint-ui/lib/style.css';
8 import { Toast, Indicator,InfiniteScroll } from "mint-ui"; 8 import { Toast, Indicator,InfiniteScroll } from "mint-ui";
9 -import { Rate, Popup, Lazyload, Search, PullRefresh, Picker } from "vant"; 9 +import { Rate, Popup, Lazyload, Search, PullRefresh, Picker, Tab, Tabs} from "vant";
10 import App from "./App"; 10 import App from "./App";
11 import IdCard from './common/IdCard'; 11 import IdCard from './common/IdCard';
12 import VueBus from 'vue-bus'; 12 import VueBus from 'vue-bus';
@@ -18,6 +18,8 @@ Vue.use(Rate); @@ -18,6 +18,8 @@ Vue.use(Rate);
18 Vue.use(Popup); 18 Vue.use(Popup);
19 Vue.use(PullRefresh); 19 Vue.use(PullRefresh);
20 Vue.use(Picker); 20 Vue.use(Picker);
  21 +Vue.use(Tab);
  22 +Vue.use(Tabs);
21 Vue.use(Lazyload, { 23 Vue.use(Lazyload, {
22 preload: 90, 24 preload: 90,
23 loading: "static/img/x.jpg", 25 loading: "static/img/x.jpg",
src/pages/mall/mall.vue
@@ -20,6 +20,7 @@ @@ -20,6 +20,7 @@
20 20
21 <!-- 遍历ads,输出列表数据 --> 21 <!-- 遍历ads,输出列表数据 -->
22 <div class="ads-box"> 22 <div class="ads-box">
  23 + <tabBox v-if="tabbar" :tabbar="tabbar"></tabBox>
23 <div class="ads" v-for="(item, index) in ads" :key="index"> 24 <div class="ads" v-for="(item, index) in ads" :key="index">
24 25
25 <!--优惠专区--> 26 <!--优惠专区-->
@@ -58,7 +59,7 @@ @@ -58,7 +59,7 @@
58 import videoArea from "@/components/videoArea/videoArea"; 59 import videoArea from "@/components/videoArea/videoArea";
59 import style7 from "@/components/style_7/style_7"; 60 import style7 from "@/components/style_7/style_7";
60 import horizList from "@/components/horizList/horizList"; 61 import horizList from "@/components/horizList/horizList";
61 - 62 + import tabBox from "@/components/tabBox/tabBox";
62 export default { 63 export default {
63 name: 'mall', 64 name: 'mall',
64 data() { 65 data() {
@@ -67,7 +68,8 @@ @@ -67,7 +68,8 @@
67 isLoading: false, // 下拉刷新控制 68 isLoading: false, // 下拉刷新控制
68 banner:null, // banner 69 banner:null, // banner
69 navs: null, // 导航 70 navs: null, // 导航
70 - ads: null // 列表 71 + ads: null, // 列表
  72 + tabbar:null // tabbar嵌套组件
71 } 73 }
72 }, 74 },
73 components:{ 75 components:{
@@ -77,7 +79,8 @@ @@ -77,7 +79,8 @@
77 preferential, 79 preferential,
78 videoArea, 80 videoArea,
79 style7, 81 style7,
80 - horizList 82 + horizList,
  83 + tabBox
81 }, 84 },
82 created() { 85 created() {
83 86
@@ -150,7 +153,10 @@ @@ -150,7 +153,10 @@
150 if (datas.ads && datas.ads.length) { 153 if (datas.ads && datas.ads.length) {
151 this.$set(this, "ads", datas.ads); 154 this.$set(this, "ads", datas.ads);
152 } 155 }
153 - 156 + // 设置tabbar数据
  157 + if (datas.tabbar && datas.tabbar.length) {
  158 + this.$set(this, "tabbar", datas.tabbar);
  159 + }
154 /* 获取优选库精选活动数据 结束 */ 160 /* 获取优选库精选活动数据 结束 */
155 161
156 } else if (res.code == 400) { 162 } else if (res.code == 400) {