deming/pages/index/index.vue

319 lines
8.1 KiB
Vue
Raw Normal View History

2020-05-29 11:13:55 +08:00
<template>
2020-07-31 08:45:30 +08:00
<view>
<view class="status_bar"></view>
<view class="index">
<view class="top">
<view class="sosuo"></view>
<view class="tabs">
<u-tabs :is-scroll="false" bar-width="70" ref="tabs" :list="list" :current="num" :bar-style="{
2020-06-02 16:45:02 +08:00
'background-color':'#FF780F',
'bottom':'10rpx'
}"
2020-07-31 08:45:30 +08:00
inactive-color="#333" :active-item-style="{
2020-06-02 16:45:02 +08:00
'color':'#333'
2020-07-17 08:36:53 +08:00
}" :bold="false"
2020-07-31 08:45:30 +08:00
@change="dianji"></u-tabs>
</view>
<view class="sosuo"></view>
2020-07-17 08:36:53 +08:00
</view>
2020-07-31 08:45:30 +08:00
<swiper class="card" @change="dianji" :current="num">
<swiper-item>
<scroll-view style="width:100%;height:100%" scroll-y="true">
<view class="box">
<!-- <indexad style="width:690rpx"></indexad> -->
<u-swiper mode="dot" :list="indexImageSwiper" name="adv_code"></u-swiper>
<view class="list">
<view>
<videoItem v-for="item in articleList.filter((_, index) => !(index&1))" :key="item.article_id" :item="item"
@getArticlelist="getArticlelist"></videoItem>
</view>
<view style="margin-left:20rpx">
<videoItem v-for="item in articleList.filter((_, index) => index&1)" :key="item.article_id" :item="item"
@getArticlelist="getArticlelist"></videoItem>
</view>
2020-07-17 08:36:53 +08:00
</view>
</view>
2020-07-31 08:45:30 +08:00
</scroll-view>
</swiper-item>
<swiper-item>
<scroll-view style="width:100%;height:100%" scroll-y="true">
<view class="box">
<u-swiper mode="dot" :list="zhiboImageSwiper" name="adv_code"></u-swiper>
<view class="list">
<view>
<zhiboItem v-for="item in tabLiveLists.filter((_, index) => !(index&1))" :key="item.live_id" :name="item.store_name"
:image="item.cover_img" :url="item.url"></zhiboItem>
</view>
<view style="margin-left:20rpx">
<zhiboItem v-for="item in tabLiveLists.filter((_, index) => index&1)" :key="item.live_id" :name="item.store_name"
:image="item.cover_img" :url="item.url"></zhiboItem>
</view>
2020-07-17 08:36:53 +08:00
</view>
</view>
2020-07-31 08:45:30 +08:00
</scroll-view>
</swiper-item>
<swiper-item>
<scroll-view style="width:100%;height:100%" scroll-y="true">
<view class="box">
<view class="tuijian">
<view class="title" @click="toSearchPage">
<view class="left">
<view></view>
<text>推荐达人</text>
</view>
<image class="right" src="/static/image/common/1.png"></image>
2020-07-17 08:36:53 +08:00
</view>
2020-07-31 08:45:30 +08:00
<view class="tuijianlist">
<!-- <darenItem style="margin-right:23rpx"></darenItem>
2020-06-30 18:06:50 +08:00
<darenItem style="margin-right:23rpx"></darenItem> -->
2020-07-31 08:45:30 +08:00
<darenItem v-for="item in recommendList.slice(0,3)" :key="item.id" :info="item" v-on:pChangeType="changeType"></darenItem>
</view>
2020-07-17 08:36:53 +08:00
</view>
2020-07-31 08:45:30 +08:00
<view class="list">
<view>
<!-- <videoItem isguanzhu="true" v-for="item in 10"></videoItem> -->
<videoItem isguanzhu="true" v-for="item in articleList.filter((_, index) => !(index&1))" :key="item.article_id"
:item="item" @getArticlelist="getArticlelist"></videoItem>
</view>
<view style="margin-left:20rpx">
<!-- <videoItem isguanzhu="true" v-for="item in 10"></videoItem> -->
<videoItem isguanzhu="true" v-for="item in articleList.filter((_, index) => index&1)" :key="item.article_id"
:item="item" @getArticlelist="getArticlelist"></videoItem>
</view>
2020-07-17 08:36:53 +08:00
</view>
</view>
2020-07-31 08:45:30 +08:00
</scroll-view>
</swiper-item>
</swiper>
</view>
2020-07-17 08:36:53 +08:00
</view>
2020-05-29 11:13:55 +08:00
2020-06-02 08:47:57 +08:00
</template>
2020-05-29 17:10:25 +08:00
<style lang="scss" scoped>
2020-07-17 08:36:53 +08:00
.index {
width: 750rpx;
display: flex;
flex-direction: column;
height: 100vh;
.top {
padding: 0 30rpx;
display: flex;
justify-content: space-between;
width: 100%;
height: 88rpx;
align-items: center;
flex-shrink: 0;
.sosuo {
width: 32rpx;
height: 32rpx;
}
.tabs {
width: 334rpx;
/deep/ .u-tab-item {
font-weight: bold;
}
}
}
.card {
height: 100%;
width: 100%;
.box {
width: 100%;
padding: 0 30rpx;
}
.list {
display: flex;
}
}
.tuijian {
width: 750rpx;
margin-left: -30rpx;
height: 400rpx;
background-color: #ececec;
padding: 30rpx;
.title {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
.left {
display: flex;
align-items: center;
>view {
width: 6rpx;
height: 30rpx;
background-color: #FF780F;
}
>text {
font-size: 30rpx;
color: 30rpx;
margin-left: 14rpx;
}
}
.right {
width: 14rpx;
height: 24rpx;
}
}
.tuijianlist {
width: 100%;
height: 282rpx;
margin-top: 30rpx;
display: flex;
>view:not(:last-child) {
margin-right: 23rpx;
}
2020-06-30 18:06:50 +08:00
}
2020-07-17 08:36:53 +08:00
}
}
2020-06-02 08:47:57 +08:00
</style>
<script>
2020-07-17 08:36:53 +08:00
import videoItem from "@/components/index/video-item/index"
import zhiboItem from "@/components/index/zhibo-item/index"
import indexad from "@/components/index/ad/index"
import darenItem from "@/components/index/daren-item/index"
export default {
name: "index",
data() {
return {
list: [{
2020-06-02 16:45:02 +08:00
name: '发现'
}, {
name: '直播'
}, {
name: '关注'
2020-07-17 08:36:53 +08:00
}],
num: 0,
page: 0, // 0即第一页
articleList: [],
recommendList: [], // 推荐达人
indexImageSwiper: [],
zhiboImageSwiper: [],
2020-07-31 08:45:30 +08:00
tabLiveLists: []
2020-07-17 08:36:53 +08:00
}
2020-07-15 16:21:43 +08:00
},
2020-07-17 08:36:53 +08:00
components: {
videoItem,
zhiboItem,
indexad,
darenItem
2020-06-29 17:24:57 +08:00
},
2020-07-17 08:36:53 +08:00
onShow() {
this.getArticlelist();
this.getRecommendList();
this.getSwiper();
this.getZhiBoSwiper();
2020-07-18 16:10:14 +08:00
this.tabLiveList();
2020-06-30 18:06:50 +08:00
},
2020-08-01 16:36:48 +08:00
onPullDownRefresh() {
// this.getManicureList({ load: 'reload' });
},
2020-07-17 08:36:53 +08:00
methods: {
2020-07-31 08:45:30 +08:00
tabLiveList() {
this.$u.api.tabLiveList().then((res) => {
2020-07-18 16:10:14 +08:00
console.log(res)
2020-07-27 14:35:32 +08:00
this.tabLiveLists = res.data
2020-07-18 16:10:14 +08:00
})
},
2020-07-17 08:36:53 +08:00
getSwiper() {
this.$u.api.getIndexSwiper().then(res => {
if (res.errCode == 0) {
this.indexImageSwiper = res.data;
}
})
},
2020-07-31 08:45:30 +08:00
changeType(member_id) {
2020-07-18 19:52:47 +08:00
console.log(member_id);
this.$emit("pChangeType")
this.$u.api.attentionMember({
member_id: member_id
2020-07-31 08:45:30 +08:00
}).then((res) => {
2020-07-18 19:52:47 +08:00
console.log(res)
this.getRecommendList();
})
},
2020-07-17 08:36:53 +08:00
getZhiBoSwiper() {
this.$u.api.getZhiBoSwiper().then(res => {
if (res.errCode == 0) {
this.zhiboImageSwiper = res.data;
}
})
},
dianji(a) {
// console.log(a)
if (typeof a == "object") {
this.num = a.detail.current
} else {
this.num = a
2020-06-30 18:06:50 +08:00
}
2020-07-17 08:36:53 +08:00
},
getArticlelist() {
this.$u.api.getArticlelist({
page: this.page,
is_video_img: 0, // 查询视频1 图文2 都查0
}).then(res => {
2020-07-31 08:45:30 +08:00
console.log('37647744ghj', res)
2020-07-17 08:36:53 +08:00
if (res.errCode == 0) {
this.articleList = res.data.list;
}
})
},
getRecommendList() {
this.$u.api.getRecommendList().then(res => {
console.log(res)
if (res.errCode == 0) {
this.recommendList = res.data.list;
}
})
},
toSearchPage() {
2020-07-31 08:45:30 +08:00
console.log("22");
uni.navigateTo({
url: '/pageB/follow/index'
});
2020-07-17 08:36:53 +08:00
},
2020-07-30 20:33:16 +08:00
clickFImage(index) {
const item = this.indexImageSwiper[index];
console.log(item);
this.activityLink({ type: item.url_type, id: item.info_id });
},
clickSImage(index) {
const item = this.zhiboImageSwiper[index];
console.log(item);
this.activityLink({ type: item.url_type, id: item.info_id });
},
activityLink({ type, id }) {
if(type == 0) return false;
// type 1 商品详情页, 2 店铺详情页
const url = type == 1 ? 'pageB/sdetails/index' : 'pageC/merchant/index';
let params = { id: id };
// type: 1 // 商品详情 1普通 2拼团 3秒杀 4优惠券
if(type == 1) Object.assign(params, { type: 1 });
this.$u.route({
url: url,
params: params
})
},
2020-07-01 17:32:36 +08:00
},
2020-07-17 08:36:53 +08:00
}
2020-07-18 16:10:14 +08:00
</script>