599 lines
19 KiB
Vue
599 lines
19 KiB
Vue
<template>
|
||
<view>
|
||
<view class="status_bar"></view>
|
||
<view class="index">
|
||
<view class="top">
|
||
<view class="sosuo" @click="goSearch">
|
||
<u-icon name="search" color="#555" size="34rpx"></u-icon>
|
||
</view>
|
||
<view class="tabs">
|
||
<u-tabs :is-scroll="false" bar-width="70" ref="tabs" :list="list" :current="num" :bar-style="{
|
||
'background-color':'#FF780F',
|
||
'bottom':'10rpx'
|
||
}"
|
||
inactive-color="#333" :active-item-style="{
|
||
'color':'#333'
|
||
}" :bold="false"
|
||
@change="dianji($event)"></u-tabs>
|
||
</view>
|
||
<view class="sosuo"></view>
|
||
</view>
|
||
<swiper class="card" @change="dianji" :current="num" @touchmove.stop.prevent="moveHandle">
|
||
<swiper-item>
|
||
<scroll-view style="width:100%;height:100%" scroll-y="true" lower-threshold="200" upper-threshold="100" @scrolltolower="swiperBottom" @scrolltoupper="swiperTop">
|
||
<view class="box">
|
||
<!-- <indexad style="width:690rpx"></indexad> -->
|
||
<u-swiper mode="dot" :list="indexImageSwiper" name="adv_code" @click="clickFImage"></u-swiper>
|
||
<view class="list">
|
||
<view>
|
||
<videoItem v-for="(item,id) in articleList.filter((_, index) => !(index&1))" :key="id" :item="item"
|
||
@updateList="updateList"></videoItem>
|
||
</view>
|
||
<view style="margin-left:20rpx">
|
||
<videoItem v-for="(item,id) in articleList.filter((_, index) => index&1)" :key="id" :item="item"
|
||
@updateList="updateList"></videoItem>
|
||
</view>
|
||
</view>
|
||
<u-loadmore class="load-size" color="#999999" :status="status" icon-type="iconType" margin-top="50" margin-bottom="50" :load-text="loadText" />
|
||
</view>
|
||
</scroll-view>
|
||
</swiper-item>
|
||
<swiper-item>
|
||
<scroll-view style="width:100%;height:100%" scroll-y="true" @scrolltolower="swiperBottomLive(e)" :refresher-enabled="true" @refresherrefresh="dianji(1)" :refresher-triggered="refresher" @refresherpulling="onPulling"
|
||
@refresherrestore="onRestore" @refresherabort="onAbort">
|
||
<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.room_name" :image="item.cover_img" :url="item.url" :item="item" @updateList="updateList"></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.room_name" :image="item.cover_img" :url="item.url" :item="item" @updateList="updateList"></zhiboItem>
|
||
</view>
|
||
</view>
|
||
<view style="height:600rpx" v-if="tabLiveLists.length == 0">
|
||
<u-empty text="暂无直播信息" mode="list"></u-empty>
|
||
</view>
|
||
<u-loadmore class="load-size" color="#999999" :status="status" v-if="tabLiveLists.length !=0" icon-type="iconType" margin-top="50" margin-bottom="50" :load-text="loadText" />
|
||
</view>
|
||
|
||
</scroll-view>
|
||
</swiper-item>
|
||
<swiper-item>
|
||
<scroll-view style="width:100%;height:100%" scroll-y="true" @scrolltolower="followBotton" lower-threshold="200">
|
||
<view class="box">
|
||
<view class="tuijian">
|
||
<view class="title" @click="toSearchPage">
|
||
<view class="left">
|
||
<view></view>
|
||
<text>推荐达人</text>
|
||
</view>
|
||
<u-icon name="arrow-right" color="#666" size="28"></u-icon>
|
||
</view>
|
||
<view class="tuijianlist">
|
||
<!-- <darenItem style="margin-right:23rpx"></darenItem>
|
||
<darenItem style="margin-right:23rpx"></darenItem> -->
|
||
<darenItem v-for="item in recommendList.slice(0,3)" :key="item.id" :info="item" v-on:pChangeType="changeType"></darenItem>
|
||
</view>
|
||
</view>
|
||
<view class="rec-list">
|
||
<view class="rec-box">
|
||
<!-- {{ fansList }} -->
|
||
<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 class="load-size" v-else :status="status_1" icon-type="iconType" margin-top="50" :load-text="loadText" />
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</scroll-view>
|
||
</swiper-item>
|
||
</swiper>
|
||
</view>
|
||
</view>
|
||
|
||
</template>
|
||
<style lang="scss" scoped>
|
||
page {
|
||
background-color: #fff;
|
||
}
|
||
.index {
|
||
width: 750rpx;
|
||
display: flex;
|
||
flex-direction: column;
|
||
|
||
.top {
|
||
z-index: 10000;
|
||
position: fixed;
|
||
top: var(--status-bar-height);
|
||
left: 0;
|
||
display: flex;
|
||
flex-shrink: 0;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
width: 100%;
|
||
height: 88rpx;
|
||
padding: 0 30rpx;
|
||
background-color: #fff;
|
||
|
||
.sosuo {
|
||
width: 32rpx;
|
||
height: 32rpx;
|
||
}
|
||
|
||
.tabs {
|
||
width: 334rpx;
|
||
// pointer-events: none;
|
||
|
||
/deep/ .u-tab-item {
|
||
font-weight: bold;
|
||
}
|
||
}
|
||
}
|
||
|
||
.card {
|
||
width: 100%;
|
||
height: calc(100vh - 150rpx);
|
||
margin-top: 100rpx;
|
||
// padding-top: 100rpx;
|
||
|
||
.box {
|
||
width: 100%;
|
||
height: 100%;
|
||
padding: 0 30rpx 0;
|
||
// margin-top: 30rpx;
|
||
}
|
||
|
||
.list {
|
||
display: flex;
|
||
// height: 100vh;
|
||
// padding-bottom: 100rpx;
|
||
// margin-bottom: 50rpx;
|
||
}
|
||
}
|
||
|
||
.tuijian {
|
||
width: 750rpx;
|
||
padding: 30rpx;
|
||
margin-left: -30rpx;
|
||
height: 400rpx;
|
||
background-color: #ececec;
|
||
|
||
.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;
|
||
}
|
||
}
|
||
}
|
||
.rec-list {
|
||
width: 100%;
|
||
.rec-box {
|
||
width: 100%;
|
||
.item {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
justify-content: space-between;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
.no-data {
|
||
margin: 200rpx auto 0;
|
||
text-align: center;
|
||
}
|
||
|
||
|
||
</style>
|
||
<script>
|
||
import common from '@/static/js/common.js';
|
||
import { mapState } from 'vuex'
|
||
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",
|
||
computed: {
|
||
...mapState(["hasLogin"])
|
||
},
|
||
data() {
|
||
return {
|
||
list: [{
|
||
name: '发现'
|
||
}, {
|
||
name: '直播'
|
||
}, {
|
||
name: '关注'
|
||
}],
|
||
num: 0,
|
||
page: 1, // 0即第一页
|
||
follow_page: 0, //
|
||
live_page: 1, //
|
||
articleList: [],
|
||
recommendList: [], // 推荐达人
|
||
indexImageSwiper: [],
|
||
zhiboImageSwiper: [],
|
||
tabLiveLists: [],
|
||
fansList: [], // 关注的发现列表
|
||
status: 'loadmore',
|
||
status_1: 'loadmore',
|
||
status_live: 'loadmore',
|
||
iconType: 'circle',
|
||
loadText: {
|
||
loadmore: '轻轻上拉',
|
||
loading: '努力加载中',
|
||
nomore: '实在没有了'
|
||
},
|
||
refresher:true,
|
||
zqie:false
|
||
}
|
||
},
|
||
components: {
|
||
videoItem,
|
||
zhiboItem,
|
||
indexad,
|
||
darenItem
|
||
},
|
||
onShow() {
|
||
console.log(this.imService.status,this.$store.state.hasLogin)
|
||
if(!this.imService.status && 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()
|
||
|
||
}else if(!this.imService.status){
|
||
this.$u.api.getDefaultAvatar().then((res)=>{
|
||
console.log(res)
|
||
uni.setStorageSync("morenimg",res.data.avatar)
|
||
this.imService.login(new Date().getTime(),"123",res.data.avatar)
|
||
this.imService.connectIM()
|
||
console.log("用户信息")
|
||
})
|
||
console.log("链接")
|
||
}
|
||
|
||
// if(!this.imService.status && !this.imService.lianjie){
|
||
// console.log("1212")
|
||
// this.imService.lianjie = true
|
||
// let that = this
|
||
// setTimeout(function(){
|
||
// that.imService.disconnect()
|
||
// console.log("guanbi")
|
||
// },1000)
|
||
// setTimeout(function(){
|
||
// console.log("lianjie")
|
||
// that.imService.connectIM()
|
||
// },2000)
|
||
// }
|
||
// 新人优惠券
|
||
if (this.$store.state.showCoupons) {
|
||
this.isNewmembervoucher();
|
||
}
|
||
this.getRecommendList();
|
||
},
|
||
async onLoad(){
|
||
this.articleList = [];
|
||
this.getArticlelist();
|
||
this.getSwiper();
|
||
// 优惠券
|
||
// 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)
|
||
// await this.imService.connectIM()
|
||
|
||
// }else{
|
||
// await this.$u.api.getDefaultAvatar().then((res)=>{
|
||
// console.log(res)
|
||
// uni.setStorageSync("morenimg",res.data.avatar)
|
||
// this.imService.login(new Date().getTime(),"123",res.data.avatar)
|
||
// console.log("用户信息")
|
||
// })
|
||
// console.log("链接")
|
||
// await this.imService.connectIM()
|
||
|
||
// }
|
||
// console.log("1212")
|
||
// let that = this
|
||
// setTimeout(function(){
|
||
// that.imService.disconnect()
|
||
// console.log("guanbi")
|
||
// },1000)
|
||
// setTimeout(function(){
|
||
// console.log("lianjie")
|
||
// that.imService.connectIM()
|
||
// },2000)
|
||
},
|
||
onPullDownRefresh() {
|
||
this.page = 1;
|
||
this.getArticlelist();
|
||
// this.getManicureList({ load: 'reload' });
|
||
},
|
||
methods: {
|
||
moveHandle() {
|
||
return;
|
||
},
|
||
// 直播列表
|
||
tabLiveList() {
|
||
uni.showLoading({
|
||
title: "loading..."
|
||
})
|
||
if(this.zqie){
|
||
return ;
|
||
}
|
||
this.zqie = true;
|
||
this.$u.api.tabLiveList({page:this.live_page}).then((res) => {
|
||
// uni.stopPullDownRefresh();
|
||
this.status_live = "loading";
|
||
this.refresher = false;
|
||
console.log(res)
|
||
if (res.errCode == 0) {
|
||
uni.hideLoading();
|
||
if (this.live_page == 1) {
|
||
this.tabLiveLists = res.data.data;
|
||
this.status_live = "loadmore";
|
||
if (res.data.data.length < 4) {
|
||
this.status_live = "nomore";
|
||
}
|
||
} else if (res.data.data.length == 0 && this.live_page > 1) {
|
||
this.status_live = "nomore";
|
||
} else {
|
||
console.log(this.live_page,1223)
|
||
this.tabLiveLists = this.tabLiveLists.concat(res.data.data);
|
||
console.log(this.tabLiveLists)
|
||
}
|
||
if (res.data.data.length == 0 && this.live_page > 1) {
|
||
} else {
|
||
this.live_page++;
|
||
}
|
||
} else {
|
||
this.status_live = "nomore"
|
||
}
|
||
this.zqie = false;
|
||
|
||
|
||
})
|
||
},
|
||
// 轮播图
|
||
getSwiper() {
|
||
this.$u.api.getIndexSwiper().then(res => {
|
||
if (res.errCode == 0) {
|
||
this.indexImageSwiper = res.data;
|
||
}
|
||
})
|
||
},
|
||
// 关注
|
||
changeType(member_id) {
|
||
// console.log(member_id);
|
||
// this.$emit("pChangeType");
|
||
this.$u.api.attentionMember({
|
||
member_id: member_id
|
||
}).then((res) => {
|
||
this.follow_page = 0;
|
||
// this.getRecommendList(); // 关注列表
|
||
for(let i in this.recommendList){
|
||
if(this.recommendList[i].member_id == member_id){
|
||
this.recommendList[i].is_attention == 1 ? this.recommendList[i].is_attention = 0 : this.recommendList[i].is_attention = 1
|
||
}
|
||
}
|
||
this.getFollowList(); // 刷新发现的列表
|
||
})
|
||
},
|
||
getZhiBoSwiper() {
|
||
this.$u.api.getZhiBoSwiper().then(res => {
|
||
if (res.errCode == 0) {
|
||
this.zhiboImageSwiper = res.data;
|
||
}
|
||
})
|
||
},
|
||
// 切换导航
|
||
dianji(a) {
|
||
console.log(a);
|
||
|
||
if (a.type == "change") {
|
||
this.num = a.detail.current;
|
||
} else {
|
||
this.num = a;
|
||
}
|
||
// console.log(this.num);
|
||
// 状态请求
|
||
if (a.type == "change" || this.num == 1) { // 强制请求一次
|
||
if (this.num == 0) {
|
||
this.page = 1;
|
||
this.articleList = [];
|
||
this.status = "nomore";
|
||
this.getArticlelist();
|
||
this.getSwiper();
|
||
} else if (this.num == 1) {
|
||
this.live_page = 1;
|
||
this.status_live = "nomore";
|
||
this.getZhiBoSwiper(); // 直播轮播
|
||
this.tabLiveList();
|
||
} else if (this.num == 2) {
|
||
this.follow_page = 0;
|
||
this.fansList = [];
|
||
this.status_1 = "nomore";
|
||
if (this.hasLogin) {
|
||
this.getFollowList(); // 关注列表
|
||
}
|
||
this.getRecommendList(); // 推荐达人
|
||
}
|
||
}
|
||
},
|
||
// 发现列表
|
||
getArticlelist() {
|
||
this.$u.api.getArticlelist({
|
||
page: this.page,
|
||
is_video_img: 0, // 查询视频1 图文2 都查0
|
||
}).then(res => {
|
||
uni.stopPullDownRefresh();
|
||
this.status = "loading";
|
||
if (res.errCode == 0) {
|
||
if (this.page == 1) {
|
||
this.articleList = res.data.list;
|
||
if (!res.data.length) {
|
||
this.status = "nomore";
|
||
}
|
||
} else if (res.data.length == 0) {
|
||
this.status = "nomore";
|
||
} else {
|
||
this.articleList = this.articleList.concat(res.data.list);
|
||
}
|
||
}
|
||
})
|
||
console.log(this.page);
|
||
},
|
||
// 屏蔽更新列表
|
||
updateList() {
|
||
this.page = 1;
|
||
this.articleList = [];
|
||
this.getArticlelist();
|
||
this.tabLiveList();
|
||
},
|
||
// 发现下拉加载
|
||
swiperBottom(e) {
|
||
this.page++;
|
||
this.getArticlelist();
|
||
},
|
||
swiperBottomLive() {
|
||
this.tabLiveList();
|
||
},
|
||
swiperTop() {
|
||
// uni.startPullDownRefresh();
|
||
},
|
||
// 关注下拉
|
||
followBotton(e) {
|
||
this.getFollowList();
|
||
// console.log(e);
|
||
},
|
||
// 达人列表
|
||
getRecommendList() {
|
||
this.$u.api.getRecommendList().then(res => {
|
||
console.log(res);
|
||
if (res.errCode == 0) {
|
||
this.recommendList = res.data.list;
|
||
}
|
||
})
|
||
},
|
||
// 关注发现列表
|
||
getFollowList() {
|
||
this.$u.post("article/attentionArticleList",{
|
||
page: this.follow_page,
|
||
}).then(res => {
|
||
this.status_1 = "loading";
|
||
if (res.errCode == 0) {
|
||
if (this.fansList.length < 4) {
|
||
this.status_1 = "nomore";
|
||
}
|
||
// 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"
|
||
}
|
||
})
|
||
},
|
||
toSearchPage() {
|
||
uni.navigateTo({
|
||
url: '/pageB/follow/index'
|
||
});
|
||
},
|
||
clickFImage(index) {
|
||
const item = this.indexImageSwiper[index];
|
||
// console.log(item);
|
||
this.jumpPage({
|
||
type: item.url_type,
|
||
id: item.info_id,
|
||
adv_id: item.adv_id,
|
||
});
|
||
},
|
||
clickSImage(index) {
|
||
const item = this.zhiboImageSwiper[index];
|
||
// console.log(item);
|
||
this.jumpPage({
|
||
type: item.url_type,
|
||
id: item.info_id,
|
||
adv_id: item.adv_id,
|
||
});
|
||
},
|
||
goSearch() {
|
||
this.$u.route("/pageB/search/index", {
|
||
type: 2,
|
||
curent:2
|
||
});
|
||
},
|
||
// 是否显示新人优惠券
|
||
isNewmembervoucher() {
|
||
this.$store.commit('updateShowCoupons', false);
|
||
this.$u.api.isNewmembervoucher().then(res => {
|
||
if(res.errCode == 0) {
|
||
this.$u.route('/pageB/coupon/index');
|
||
}
|
||
})
|
||
},
|
||
onPulling(e) {
|
||
console.log("onpulling", e);
|
||
},
|
||
onRestore() {
|
||
this.refresher = 'restore'; // 需要重置
|
||
console.log("onRestore");
|
||
},
|
||
onAbort() {
|
||
console.log("onAbort");
|
||
},
|
||
jumpPage(uri) {
|
||
// console.log(uri);
|
||
this.$u.api.advClick({ adv_id: uri.adv_id });
|
||
common.jumpPage({ type: uri.type, id: uri.id });
|
||
}
|
||
},
|
||
}
|
||
</script>
|