修改直播列表页面分页不生效的问题,吸怪直播模块报错的问题

This commit is contained in:
Gao xiaosong
2020-09-13 21:22:49 +08:00
parent f4c5247998
commit c412b80a3c
4 changed files with 77 additions and 55 deletions

View File

@ -1,27 +1,21 @@
<template> <template>
<view <view class="Loads acea-row row-center-wrapper" v-if="loading || !loaded" style="margin-top: 20rpx;">
class="Loads acea-row row-center-wrapper"
v-if="loading || !loaded"
style="margin-top: 20rpx;"
>
<template v-if="loading"> <template v-if="loading">
<view <view class="iconfont icon-jiazai loading acea-row row-center-wrapper"></view>
class="iconfont icon-jiazai loading acea-row row-center-wrapper"
></view>
正在加载中 正在加载中
</template> </template>
<template v-else> <template v-if="!loading">
上拉加载更多 上拉加载更多
</template> </template>
</view> </view>
</template> </template>
<script> <script>
export default { export default {
name: "Loading", name: "Loading",
props: { props: {
loaded: Boolean, loaded: Boolean,
loading: Boolean loading: Boolean
} }
}; };
</script> </script>

View File

@ -19,7 +19,8 @@
</view> </view>
<slot name="liveGoods"> <slot name="liveGoods">
<view class="live-goods" v-if="detail.product.length"> <view class="live-goods" v-if="detail.product.length">
<view class="live-goods__item" v-for="(goods, index) in detail.product" :key="goods.goodsId" v-if="index < 3"> <view class="live-goods__item" v-for="(goods, index) in detail.product" :key="goods.goodsId"
v-if="index < 3">
<image class="live-goods__img" :src="goods.coverImgeUrl" mode=""></image> <image class="live-goods__img" :src="goods.coverImgeUrl" mode=""></image>
<view class="live-goods__price" v-if="index < 2">{{ goods.price }}</view> <view class="live-goods__price" v-if="index < 2">{{ goods.price }}</view>
<view class="live-goods__mark" v-else> <view class="live-goods__mark" v-else>
@ -33,7 +34,9 @@
</template> </template>
<script> <script>
import { dataFormatL } from "@/utils"; import {
dataFormatL
} from "@/utils";
let HAS_LIVE = false let HAS_LIVE = false
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
HAS_LIVE = true HAS_LIVE = true
@ -111,27 +114,45 @@
url: `plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${that.detail.roomId}` url: `plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${that.detail.roomId}`
}); });
}, },
dateFormat(fmt, date) {
let ret;
const opt = {
"Y+": date.getFullYear().toString(), // 年
"m+": (date.getMonth() + 1).toString(), // 月
"d+": date.getDate().toString(), // 日
"H+": date.getHours().toString(), // 时
"M+": date.getMinutes().toString(), // 分
"S+": date.getSeconds().toString() // 秒
// 有其他格式化字符需求可以继续添加,必须转化成字符串
};
for (let k in opt) {
ret = new RegExp("(" + k + ")").exec(fmt);
if (ret) {
fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, "0")))
};
};
return fmt;
},
// 轮询liveStatus // 轮询liveStatus
getLiveStatus() { getLiveStatus() {
if (HAS_LIVE) { if (HAS_LIVE) {
let that = this; let that = this;
let date = ''; let date = '';
if (that.detail.liveStatus == 102) { if (that.detail.liveStatus == 102) {
date = dataFormatL('mm-dd HH:MM', new Date(that.detail.starttime * 1000)).replace('-', date = this.dateFormat('mm-dd HH:MM', new Date(that.detail.startTime * 1000)).replace('-','/');
'/'); that.liveStatus['102'].title = '预告 ' + date;
that.liveStatus['102'].title = '预告 ' + date;
} }
livePlayer // livePlayer
.getLiveStatus({ // .getLiveStatus({
room_id: that.detail.roomId // room_id: that.detail.roomId
}) // })
.then(res => { // .then(res => {
// 101: 直播中, 102: 未开始, 103: 已结束, 104: 禁播, 105: 暂停中, 106: 异常107已过期 // // 101: 直播中, 102: 未开始, 103: 已结束, 104: 禁播, 105: 暂停中, 106: 异常107已过期
that.detail.liveStatus = res.liveStatus; // that.detail.liveStatus = res.liveStatus;
}) // })
.catch(err => { // .catch(err => {
console.log('get live status', err); // console.log('get live status', err);
}); // });
} }
} }
} }

View File

@ -244,11 +244,12 @@
}, 500); }, 500);
}, },
methods: { methods: {
onShareAppMessage: function() { onShareAppMessage: function () {
return { return {
title: this.storeInfo.title, title: this.storeInfo.title,
imageUrl: this.storeInfo.image, imageUrl: this.storeInfo.image,
path: "pages/activity/DargainDetails/index?id="+this.storeInfo.id+"&spread=" + uni.getStorageSync("uid"), path: "pages/activity/DargainDetails/index?id=" + this.storeInfo.id + "&spread=" + uni.getStorageSync(
"uid"),
success(res) { success(res) {
uni.showToast({ uni.showToast({
title: '分享成功' title: '分享成功'

View File

@ -18,6 +18,7 @@
<view v-if="liveList.length" class="cu-load text-gray" :class="loadStatus"></view> <view v-if="liveList.length" class="cu-load text-gray" :class="loadStatus"></view>
</scroll-view> </scroll-view>
</view> </view>
<Loading :loaded="loaded" :loading="loading"></Loading>
</view> </view>
</template> </template>
@ -26,26 +27,30 @@
yxWechatLive yxWechatLive
} from "@/api/live"; } from "@/api/live";
import ShopLiveCard from '@/components/ShopLiveCard.vue' import ShopLiveCard from '@/components/ShopLiveCard.vue'
import Loading from "@/components/Loading";
export default { export default {
components: { components: {
ShopLiveCard ShopLiveCard,
Loading
}, },
data() { data() {
return { return {
tabCur: 'all', tabCur: 'all',
liveStatus: '', liveStatus: '',
loaded: false,
loading: false,
liveTab: [{ liveTab: [{
title: 'all', title: 'all',
name: '全部', name: '全部',
code: '' code: ''
}, },
{ {
title: 'prevue', title: 'prevue',
name: '预告', name: '预告',
code: '102' code: '102'
}, },
{ {
title: 'living', title: 'living',
name: '直播中', name: '直播中',
@ -79,30 +84,31 @@
this.liveList = []; this.liveList = [];
this.getLiveList(); this.getLiveList();
}, },
// 加载更多
loadMore() {
if (this.currentPage < this.lastPage) {
this.currentPage += 1;
this.getLiveList();
}
},
// 直播列表 // 直播列表
getLiveList() { getLiveList() {
let that = this; let that = this;
if (this.loading || this.loaded) return;
this.loading = true;
yxWechatLive({ yxWechatLive({
liveStatus: that.liveStatus, liveStatus: that.liveStatus,
page: that.currentPage, page: that.currentPage,
size: that.size size: that.size
}).then(res => { }).then(res => {
that.liveList = [...that.liveList, ...res.data.content]; that.liveList = [...that.liveList, ...res.data.content];
that.lastPage = res.data.lastPage; this.currentPage++;
if (that.currentPage < res.data.lastPage) { this.loaded = res.data.content.length < that.size;
that.loadStatus = ''; this.loading = false;
} else {
that.loadStatus = 'over'; // if (that.currentPage < res.data.lastPage) {
} // that.loadStatus = '';
// } else {
// that.loadStatus = 'over';
// }
}); });
} }
},
onReachBottom() {
!this.loading && this.getLiveList();
} }
}; };
</script> </script>