deming/pages/index/index.vue

451 lines
13 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">
2020-08-06 20:42:03 +08:00
<view class="sosuo" @click="goSearch">
<u-icon name="search" color="#555" size="34rpx"></u-icon>
</view>
2020-07-31 08:45:30 +08:00
<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>
2020-08-07 19:56:47 +08:00
<scroll-view style="width:100%;height:100%" scroll-y="true" lower-threshold="200" @scrolltolower="swiperBottom">
2020-07-31 08:45:30 +08:00
<view class="box">
<!-- <indexad style="width:690rpx"></indexad> -->
2020-08-04 14:36:35 +08:00
<u-swiper mode="dot" :list="indexImageSwiper" name="adv_code" @click="clickFImage"></u-swiper>
2020-07-31 08:45:30 +08:00
<view class="list">
<view>
2020-08-07 19:56:47 +08:00
<videoItem v-for="(item,id) in articleList.filter((_, index) => !(index&1))" :key="id" :item="item"
2020-07-31 08:45:30 +08:00
@getArticlelist="getArticlelist"></videoItem>
</view>
<view style="margin-left:20rpx">
2020-08-07 19:56:47 +08:00
<videoItem v-for="(item,id) in articleList.filter((_, index) => index&1)" :key="id" :item="item"
2020-07-31 08:45:30 +08:00
@getArticlelist="getArticlelist"></videoItem>
</view>
2020-07-17 08:36:53 +08:00
</view>
2020-08-07 19:56:47 +08:00
<u-loadmore :status="status" icon-type="iconType" margin-top="50" margin-bottom="50" :load-text="loadText" />
2020-07-17 08:36:53 +08:00
</view>
2020-08-03 14:37:02 +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" @click="clickSImage($event, 2)"></u-swiper>
<view class="list">
<view>
<zhiboItem v-for="item in tabLiveLists.filter((_, index) => !(index&1))" :zid="item.live_id" :rid="item.chatroom_id"
: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)" :zid="item.live_id" :rid="item.chatroom_id"
: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>
2020-08-07 19:56:47 +08:00
<scroll-view style="width:100%;height:100%" scroll-y="true" @scrolltolower="followBotton" lower-threshold="200">
2020-07-31 08:45:30 +08:00
<view class="box">
<view class="tuijian">
<view class="title" @click="toSearchPage">
<view class="left">
<view></view>
<text>推荐达人</text>
</view>
2020-08-05 21:06:29 +08:00
<u-icon name="arrow-right" color="#666" size="28"></u-icon>
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-08-05 21:06:29 +08:00
<view class="rec-list">
<view class="rec-box">
<!-- {{ fansList }} -->
2020-08-07 19:56:47 +08:00
<view class="item">
<videoItem isguanzhu="true" v-for="(item,id) in fansList" :key="id" :item="item"></videoItem>
</view>
<view class="no-data" v-if="!fansList.length">您还没有关注哦赶紧去点点关注</view>
<u-loadmore v-else :status="status_1" icon-type="iconType" margin-top="50" margin-bottom="50" :load-text="loadText" />
2020-07-31 08:45:30 +08:00
</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 {
display: flex;
2020-08-06 20:42:03 +08:00
flex-shrink: 0;
align-items: center;
2020-07-17 08:36:53 +08:00
justify-content: space-between;
width: 100%;
height: 88rpx;
2020-08-06 20:42:03 +08:00
padding: 0 30rpx;
2020-07-17 08:36:53 +08:00
.sosuo {
width: 32rpx;
height: 32rpx;
}
.tabs {
width: 334rpx;
/deep/ .u-tab-item {
font-weight: bold;
}
}
}
.card {
height: 100%;
width: 100%;
.box {
width: 100%;
2020-08-06 20:42:03 +08:00
height: 100%;
2020-07-17 08:36:53 +08:00
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-08-05 21:06:29 +08:00
.rec-list {
width: 100%;
.rec-box {
2020-08-07 19:56:47 +08:00
width: 100%;
.item {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
2020-08-05 21:06:29 +08:00
}
}
}
2020-07-17 08:36:53 +08:00
}
2020-08-07 19:56:47 +08:00
.no-data {
margin: 200rpx auto 0;
text-align: center;
}
2020-06-02 08:47:57 +08:00
</style>
<script>
2020-08-06 20:42:03 +08:00
import { mapState } from 'vuex'
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",
2020-08-06 20:42:03 +08:00
computed: {
...mapState(["hasLogin"])
},
2020-07-17 08:36:53 +08:00
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即第一页
2020-08-07 19:56:47 +08:00
follow_page: 0, //
2020-07-17 08:36:53 +08:00
articleList: [],
recommendList: [], // 推荐达人
indexImageSwiper: [],
zhiboImageSwiper: [],
2020-08-05 21:06:29 +08:00
tabLiveLists: [],
fansList: [], // 关注的发现列表
2020-08-07 19:56:47 +08:00
status: 'loadmore',
status_1: 'loadmore',
iconType: 'circle',
loadText: {
loadmore: '轻轻上拉',
loading: '努力加载中',
nomore: '实在没有了'
}
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() {
2020-08-07 19:56:47 +08:00
this.articleList = [];
this.page = 0;
2020-07-17 08:36:53 +08:00
this.getArticlelist();
this.getSwiper();
2020-06-30 18:06:50 +08:00
},
2020-08-07 11:40:13 +08:00
onLoad(){
if(this.$store.state.hasLogin){
const user = uni.getStorageSync('user_info');
console.log(user)
this.imService.login(user.member.member_id,user.member.member_nickname,user.member.member_avatar)
this.imService.connectIM()
let that = this
setTimeout(function(){
that.imService.disconnect()
console.log("guanbi")
},1000)
setTimeout(function(){
console.log("lianjie")
that.imService.connectIM()
},2000)
}
},
2020-08-01 16:36:48 +08:00
onPullDownRefresh() {
2020-08-04 22:13:50 +08:00
this.getArticlelist();
2020-08-01 16:36:48 +08:00
// this.getManicureList({ load: 'reload' });
},
2020-07-17 08:36:53 +08:00
methods: {
2020-08-06 20:42:03 +08:00
// 直播列表
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-08-05 21:06:29 +08:00
this.tabLiveLists = res.data;
2020-07-18 16:10:14 +08:00
})
},
2020-08-05 21:06:29 +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-08-05 21:06:29 +08:00
// 关注
2020-07-31 08:45:30 +08:00
changeType(member_id) {
2020-07-18 19:52:47 +08:00
console.log(member_id);
2020-08-05 21:06:29 +08:00
// this.$emit("pChangeType");
2020-07-18 19:52:47 +08:00
this.$u.api.attentionMember({
member_id: member_id
2020-07-31 08:45:30 +08:00
}).then((res) => {
2020-08-07 19:56:47 +08:00
console.log(res);
this.follow_page = 0;
this.getRecommendList(); // 关注列表
2020-08-05 21:06:29 +08:00
this.getFollowList(); // 刷新发现的列表
2020-07-18 19:52:47 +08:00
})
},
2020-07-17 08:36:53 +08:00
getZhiBoSwiper() {
this.$u.api.getZhiBoSwiper().then(res => {
if (res.errCode == 0) {
this.zhiboImageSwiper = res.data;
}
})
},
2020-08-05 21:06:29 +08:00
// 切换导航
2020-07-17 08:36:53 +08:00
dianji(a) {
2020-08-06 20:42:03 +08:00
// console.log(a);
2020-07-17 08:36:53 +08:00
if (typeof a == "object") {
this.num = a.detail.current
} else {
this.num = a
2020-06-30 18:06:50 +08:00
}
2020-08-06 20:42:03 +08:00
// 状态请求
if (this.num == 0) {
2020-08-07 19:56:47 +08:00
this.page = 0;
this.status = "loadmore";
2020-08-06 20:42:03 +08:00
this.getArticlelist();
this.getSwiper();
} else if (this.num == 1) {
this.getZhiBoSwiper(); // 直播轮播
this.tabLiveList();
} else if (this.num == 2) {
2020-08-07 19:56:47 +08:00
this.follow_page = 0;
this.status = "loadmore";
2020-08-06 20:42:03 +08:00
if (this.hasLogin) {
this.getFollowList(); // 关注列表
}
this.getRecommendList(); // 推荐达人
}
2020-07-17 08:36:53 +08:00
},
2020-08-05 21:06:29 +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-08-07 19:56:47 +08:00
this.status = "loading";
if (res.errCode == 0) {
// uni.stopPullDownRefresh();
// console.log('37647744ghj', res)
if (this.page == 0) {
this.articleList = res.data.list;
this.status = "loadmore";
} else if (res.data.length == 0 && this.page > 0) {
this.status = "nomore";
} else {
this.articleList = this.articleList.concat(res.data.list);
}
this.page++;
} else {
this.status = "nomore"
}
2020-07-17 08:36:53 +08:00
})
},
2020-08-07 19:56:47 +08:00
// 发现下拉加载
swiperBottom(e) {
this.getArticlelist();
// console.log(e);
},
followBotton(e) {
this.getFollowList();
// console.log(e);
},
2020-08-05 21:06:29 +08:00
// 达人列表
2020-07-17 08:36:53 +08:00
getRecommendList() {
this.$u.api.getRecommendList().then(res => {
2020-08-06 20:42:03 +08:00
console.log(res);
2020-07-17 08:36:53 +08:00
if (res.errCode == 0) {
this.recommendList = res.data.list;
}
})
},
2020-08-05 21:06:29 +08:00
// 关注发现列表
getFollowList() {
this.$u.post("article/attentionArticleList",{
2020-08-07 19:56:47 +08:00
page: this.follow_page,
2020-08-05 21:06:29 +08:00
}).then(res => {
2020-08-07 19:56:47 +08:00
this.status_1 = "loading";
2020-08-05 21:06:29 +08:00
if (res.errCode == 0) {
2020-08-07 19:56:47 +08:00
// uni.stopPullDownRefresh();
// console.log('37647744ghj', res)
if (this.follow_page == 0) {
this.fansList = res.data.list;
this.status_1 = "loadmore";
} else if (res.data.list.length == 0 && this.follow_page > 0) {
this.status_1 = "nomore";
} else {
this.fansList = this.fansList.concat(res.data.list);
}
this.follow_page++;
} else {
this.status_1 = "nomore"
2020-08-05 21:06:29 +08:00
}
})
},
2020-07-17 08:36:53 +08:00
toSearchPage() {
2020-07-31 08:45:30 +08:00
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);
2020-08-03 14:37:02 +08:00
this.activityLink({
type: item.url_type,
id: item.info_id
});
2020-07-30 20:33:16 +08:00
},
clickSImage(index) {
const item = this.zhiboImageSwiper[index];
console.log(item);
2020-08-03 14:37:02 +08:00
this.activityLink({
type: item.url_type,
id: item.info_id
});
2020-07-30 20:33:16 +08:00
},
2020-08-03 14:37:02 +08:00
activityLink({
type,
id
}) {
2020-08-04 14:36:35 +08:00
console.log(type,id);
2020-08-03 14:37:02 +08:00
if (type == 0) return false;
2020-07-30 20:33:16 +08:00
// type 1 商品详情页, 2 店铺详情页
const url = type == 1 ? 'pageB/sdetails/index' : 'pageC/merchant/index';
2020-08-03 14:37:02 +08:00
let params = {
id: id
};
2020-07-30 20:33:16 +08:00
// type: 1 // 商品详情 1普通 2拼团 3秒杀 4优惠券
2020-08-03 14:37:02 +08:00
if (type == 1) Object.assign(params, {
type: 1
});
2020-07-30 20:33:16 +08:00
this.$u.route({
url: url,
params: params
})
},
2020-08-06 20:42:03 +08:00
goSearch() {
2020-08-09 14:23:59 +08:00
this.$u.route("/pageB/search/index", {
type: 1,
});
2020-08-06 20:42:03 +08:00
}
2020-07-01 17:32:36 +08:00
},
2020-07-17 08:36:53 +08:00
}
2020-08-07 11:40:13 +08:00
</script>