Browse Source

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

master
Gao xiaosong 4 years ago
parent
commit
c412b80a3c
  1. 26
      components/Loading.vue
  2. 53
      components/ShopLiveCard.vue
  3. 5
      pages/activity/DargainDetails/index.vue
  4. 48
      pages/shop/Live/LiveList/index.vue

26
components/Loading.vue

@ -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>

53
components/ShopLiveCard.vue

@ -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);
}); // });
} }
} }
} }

5
pages/activity/DargainDetails/index.vue

@ -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: '分享成功'

48
pages/shop/Live/LiveList/index.vue

@ -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>

Loading…
Cancel
Save