Browse Source

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

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

53
components/ShopLiveCard.vue

@ -19,7 +19,8 @@
</view>
<slot name="liveGoods">
<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>
<view class="live-goods__price" v-if="index < 2">{{ goods.price }}</view>
<view class="live-goods__mark" v-else>
@ -33,7 +34,9 @@
</template>
<script>
import { dataFormatL } from "@/utils";
import {
dataFormatL
} from "@/utils";
let HAS_LIVE = false
// #ifdef MP-WEIXIN
HAS_LIVE = true
@ -111,27 +114,45 @@
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
getLiveStatus() {
if (HAS_LIVE) {
let that = this;
let date = '';
if (that.detail.liveStatus == 102) {
date = dataFormatL('mm-dd HH:MM', new Date(that.detail.starttime * 1000)).replace('-',
'/');
that.liveStatus['102'].title = '预告 ' + date;
date = this.dateFormat('mm-dd HH:MM', new Date(that.detail.startTime * 1000)).replace('-','/');
that.liveStatus['102'].title = '预告 ' + date;
}
livePlayer
.getLiveStatus({
room_id: that.detail.roomId
})
.then(res => {
// 101: , 102: , 103: , 104: , 105: , 106: 107
that.detail.liveStatus = res.liveStatus;
})
.catch(err => {
console.log('get live status', err);
});
// livePlayer
// .getLiveStatus({
// room_id: that.detail.roomId
// })
// .then(res => {
// // 101: , 102: , 103: , 104: , 105: , 106: 107
// that.detail.liveStatus = res.liveStatus;
// })
// .catch(err => {
// console.log('get live status', err);
// });
}
}
}

5
pages/activity/DargainDetails/index.vue

@ -244,11 +244,12 @@
}, 500);
},
methods: {
onShareAppMessage: function() {
onShareAppMessage: function () {
return {
title: this.storeInfo.title,
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) {
uni.showToast({
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>
</scroll-view>
</view>
<Loading :loaded="loaded" :loading="loading"></Loading>
</view>
</template>
@ -26,26 +27,30 @@
yxWechatLive
} from "@/api/live";
import ShopLiveCard from '@/components/ShopLiveCard.vue'
import Loading from "@/components/Loading";
export default {
components: {
ShopLiveCard
ShopLiveCard,
Loading
},
data() {
return {
tabCur: 'all',
liveStatus: '',
loaded: false,
loading: false,
liveTab: [{
title: 'all',
name: '全部',
code: ''
},
{
title: 'prevue',
name: '预告',
code: '102'
},
{
title: 'prevue',
name: '预告',
code: '102'
},
{
title: 'living',
name: '直播中',
@ -79,30 +84,31 @@
this.liveList = [];
this.getLiveList();
},
//
loadMore() {
if (this.currentPage < this.lastPage) {
this.currentPage += 1;
this.getLiveList();
}
},
//
getLiveList() {
let that = this;
if (this.loading || this.loaded) return;
this.loading = true;
yxWechatLive({
liveStatus: that.liveStatus,
page: that.currentPage,
size: that.size
}).then(res => {
that.liveList = [...that.liveList, ...res.data.content];
that.lastPage = res.data.lastPage;
if (that.currentPage < res.data.lastPage) {
that.loadStatus = '';
} else {
that.loadStatus = 'over';
}
that.liveList = [...that.liveList, ...res.data.content];
this.currentPage++;
this.loaded = res.data.content.length < that.size;
this.loading = false;
// if (that.currentPage < res.data.lastPage) {
// that.loadStatus = '';
// } else {
// that.loadStatus = 'over';
// }
});
}
},
onReachBottom() {
!this.loading && this.getLiveList();
}
};
</script>

Loading…
Cancel
Save