<template>
<view>
<u-sticky class="srickTop">
<u-tabs style="background-color: #F5F5F5;height: 110rpx;" :list="list1" :current="current"
:scrollable="true" @change="switchtab"></u-tabs>
</u-sticky>
<view class="home-news">
<swiper :current="navIndex" :style="'height:'+scrollHeight+'px!important;'" @change="change">
<swiper-item :style="'height:'+scrollHeight+'px!important;'">
<scroll-view :style="'height:' + scrollHeight + 'px!important'" scroll-x="false" scroll-y="true">
<view v-for="(item, index) in homenewslist0">
<view class="title">
{{item.name}}
</view>
<view class="brand-list">
<view class="brand-list-info" v-for="key in item.data" @click="gotospring(item)">
<view>
<image :src="key.nvcCompanyLogo" mode="widthFix"></image>
</view>
<text>{{key.nvcProductSmallTypeName}}</text>
</view>
</view>
</view>
</scroll-view>
</swiper-item>
<swiper-item :style="'height:'+scrollHeight+'px!important;'">
<scroll-view :style="'height:' + scrollHeight + 'px!important'" scroll-x="false" scroll-y="true">
<view v-for="(item, index) in homenewslist1">
<view class="title">
{{item.name}}
</view>
<view class="brand-list">
<view class="brand-list-info" v-for="key in item.data" @click="gotospring(item)">
<view>
<image :src="key.nvcCompanyLogo" mode="widthFix"></image>
</view>
<text>{{key.nvcProductSmallTypeName}}</text>
</view>
</view>
</view>
</scroll-view>
</swiper-item>
<swiper-item :style="'height:'+scrollHeight+'px!important;'">
<scroll-view :style="'height:' + scrollHeight + 'px!important'" scroll-x="false" scroll-y="true">
<view v-for="(item, index) in homenewslist2">
<view class="title">
{{item.name}}
</view>
<view class="brand-list">
<view class="brand-list-info" v-for="key in item.data" @click="gotospring(item)">
<view>
<image :src="key.nvcCompanyLogo" mode="widthFix"></image>
</view>
<text>{{key.nvcProductSmallTypeName}}</text>
</view>
</view>
</view>
</scroll-view>
</swiper-item>
<swiper-item :style="'height:'+scrollHeight+'px!important;'">
<scroll-view :style="'height:' + scrollHeight + 'px!important'" scroll-x="false" scroll-y="true">
<view v-for="(item, index) in homenewslist3">
<view class="title">
{{item.name}}
</view>
<view class="brand-list">
<view class="brand-list-info" v-for="key in item.data" @click="gotospring(item)">
<view>
<image :src="key.nvcCompanyLogo" mode="widthFix"></image>
</view>
<text>{{key.nvcProductSmallTypeName}}</text>
</view>
</view>
</view>
</scroll-view>
</swiper-item>
</swiper>
</view>
</view>
</template>
<script>
import {
mapState
} from 'vuex';
import {
getbrandDisplayList
} from '../../config/api/index.js';
export default {
data() {
return {
current: 0,
list1: [{
name: '耐火原料',
id:0
}, {
name: '耐火制品',
id:1
}, {
name: '冶金辅料',
id:2
}, {
name: '生产装备',
id:3
}],
homenewslist0: [
],
homenewslist1: [
],
homenewslist2: [
],
homenewslist3: [
],
scrollHeight: '',
navIndex: 0,
};
},
computed: {
},
onReady() {
let _this = this;
uni.getSystemInfo({//获取信息
success: function(res) {
_this.bodyHeight = res.windowHeight;
let obj2 = uni.createSelectorQuery().select('.srickTop');
obj2.boundingClientRect(function(data) {
console.log(data);
_this.scrollHeight = _this.bodyHeight - data.height - 20;
}).exec();
}
});
},
onLoad() {
this.getbrand("耐火原料")
this.getbrand("耐火制品")
this.getbrand("冶金辅料")
this.getbrand("生产装备")
},
methods: {
change(e) {
console.log(e)
this.current = e.detail.current;
this.navIndex = e.detail.current;
},
switchtab(index) {
this.navIndex = index.id;
},
getbrand(name) {
let parms = {
nvc_product: name
}
接口(parms).then(res => {
if (res.success == true) {
var that = this
const brandlist = []
for (var key in res.data) {
let obj = {
name: key,
data: res.data[key]
}
brandlist.push(obj) //获取key值
}
if(name=="耐火原料"){
that.homenewslist0 = brandlist;
}else if(name=="耐火制品"){
that.homenewslist1 = brandlist;
}else if(name=="冶金辅料"){
that.homenewslist2 = brandlist;
}else{
that.homenewslist3 = brandlist;
}
} else {}
}).catch(errors => {
})
},
//品牌详情
gotospring(url) {
uni.navigateTo({
url: "/pages/webview/webview?webviewUrl=" + url.data[0].nvcLink
})
}
}
};
</script>
<style lang="scss" scoped>
.home-news {
width: 93%;
background: #fff;
padding: 2%;
box-sizing: border-box;
border-radius: 20rpx;
margin: 0 auto;
margin-bottom: 40rpx;
overflow: hidden;
overflow-y: auto;
swiper-item{
padding: 20rpx 0;
.brand-list {
width: 100%;
display: flex;
flex-direction: row;
flex-wrap: wrap;
.brand-list-info {
width: 27%;
display: flex;
align-items: center;
flex-direction: column;
margin: 19rpx;
padding: 20rpx 0;
view {
width: 200rpx;
height: 200rpx;
display: flex;
align-items: center;
justify-content: center;
image {
width: 170rpx;
}
}
text {
text-align: center;
margin: 15rpx 0rem;
font-size: 20rpx;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
line-clamp: 2;
-webkit-box-orient: vertical;
}
}
}
}
}
</style>