2022-07-08 08:15:29 +00:00
|
|
|
<template>
|
|
|
|
<view>
|
|
|
|
<status-nav :ifReturn="true" navBarTitle="收藏" :marginBottom="0"></status-nav>
|
|
|
|
<!-- 导航 -->
|
|
|
|
<view class="nav-list-bg" :style="{top:newTop+'px'}">
|
|
|
|
<nav-tab :list="navTabList" @chooseEv="chooseEv"></nav-tab>
|
|
|
|
</view>
|
|
|
|
<!-- 列表 -->
|
2022-07-15 10:29:01 +00:00
|
|
|
<view class="news-list-bg" v-if="isLoading">
|
2022-07-08 08:15:29 +00:00
|
|
|
<pull-list :list="collectionList" :collection="1" :isShop="isShop" @toDetail="toArticleDetail" @collectionEv="collectionEv"></pull-list>
|
|
|
|
</view>
|
|
|
|
<!-- 暂无更多内容 -->
|
2022-07-13 08:04:38 +00:00
|
|
|
<view class="more-txt more-txt-other" v-if="total!==0 && totalAll == total">暂无更多内容</view>
|
|
|
|
<nothing-page v-if="total==0&&totalAll == total" content="还没有相关收藏哟(*^▽^*)"></nothing-page>
|
2022-07-08 08:15:29 +00:00
|
|
|
</view>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import statusNav from '@/components/status-navs/status-nav';
|
|
|
|
import navTab from '@/components/nav-tab/nav-tab.vue';
|
|
|
|
import pullList from '@/components/pull-list/pull-list.vue';
|
2022-07-25 03:18:38 +00:00
|
|
|
import {userInfoEv} from '@/jsFile/public-api.js';
|
2022-07-08 08:15:29 +00:00
|
|
|
export default {
|
|
|
|
components:{
|
|
|
|
statusNav,
|
|
|
|
navTab,
|
|
|
|
pullList
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
scrollHeight:uni.getSystemInfoSync().windowHeight - uni.getSystemInfoSync().statusBarHeight - 50,
|
|
|
|
newWidth:uni.getSystemInfoSync().windowWidth,
|
|
|
|
newTop:uni.getSystemInfoSync().statusBarHeight + 50,
|
|
|
|
collectionList:[], //解答&资讯列表
|
|
|
|
navTabList:[ //导航列表
|
|
|
|
{name:'商品'},
|
|
|
|
{name:'文章'},
|
|
|
|
],
|
|
|
|
currentIndex:0, //当前位置
|
|
|
|
page:1, //第几页
|
|
|
|
size:10, //查询条数
|
|
|
|
total:0, //总数
|
|
|
|
totalAll:-1, //计算总数
|
|
|
|
isShop:true, //是否商品
|
2022-07-15 03:05:54 +00:00
|
|
|
cacheBusinessId:-1, //商户id
|
2022-07-15 10:29:01 +00:00
|
|
|
isLoading:false,
|
2022-07-08 08:15:29 +00:00
|
|
|
}
|
|
|
|
},
|
2022-07-12 10:07:08 +00:00
|
|
|
onLoad(op) {
|
|
|
|
if(op.business_id){
|
2022-07-15 03:05:54 +00:00
|
|
|
this.cacheBusinessId = op.business_id;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onShow() {
|
|
|
|
if(this.cacheBusinessId !== -1){
|
|
|
|
this.$requst.post('/api/index/change-business',{business_id:this.cacheBusinessId}).then(res=>{
|
2022-07-12 10:07:08 +00:00
|
|
|
if(res.code == 0){
|
2022-07-15 10:29:01 +00:00
|
|
|
this.collectionList = [];
|
2022-07-12 10:07:08 +00:00
|
|
|
this.getCollectionList();
|
2022-07-13 08:04:38 +00:00
|
|
|
userInfoEv();
|
2022-07-12 10:07:08 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}else{
|
2022-07-15 10:29:01 +00:00
|
|
|
this.collectionList = [];
|
2022-07-12 10:07:08 +00:00
|
|
|
this.getCollectionList();
|
2022-07-13 08:04:38 +00:00
|
|
|
userInfoEv();
|
2022-07-12 10:07:08 +00:00
|
|
|
}
|
2022-07-08 08:15:29 +00:00
|
|
|
},
|
|
|
|
onReachBottom(e) {
|
|
|
|
if(this.collectionList.length<this.total){
|
|
|
|
this.page++;
|
|
|
|
this.getArticleList();
|
|
|
|
}
|
|
|
|
this.page++;
|
|
|
|
this.getCollectionList();
|
|
|
|
},
|
|
|
|
// 分享到微信
|
|
|
|
onShareAppMessage() {
|
2022-07-11 10:35:14 +00:00
|
|
|
let path = uni.getStorageSync('page-path-options')+'?business_id='+uni.getStorageSync('business_id');
|
|
|
|
return {
|
|
|
|
path:path
|
|
|
|
}
|
2022-07-08 08:15:29 +00:00
|
|
|
},
|
|
|
|
// 分享到朋友圈
|
2022-07-11 10:35:14 +00:00
|
|
|
onShareTimeline(res){
|
|
|
|
let path = uni.getStorageSync('page-path-options')+'?business_id='+uni.getStorageSync('business_id');
|
|
|
|
return {
|
|
|
|
path:path
|
|
|
|
}
|
2022-07-08 08:15:29 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
// 切换事件
|
|
|
|
chooseEv(type){
|
|
|
|
if(type == 0){
|
|
|
|
this.isShop = true;
|
|
|
|
}
|
|
|
|
if(type == 1){
|
|
|
|
this.isShop = false;
|
|
|
|
}
|
|
|
|
if(this.currentIndex !== type){
|
2022-07-13 08:04:38 +00:00
|
|
|
this.total=0;
|
|
|
|
this.totalAll=-1;
|
2022-07-08 08:15:29 +00:00
|
|
|
this.page = 1;
|
|
|
|
this.currentIndex = type;
|
2022-07-13 08:04:38 +00:00
|
|
|
this.collectionList=[];
|
2022-07-08 08:15:29 +00:00
|
|
|
this.getCollectionList();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 获取收藏列表
|
|
|
|
getCollectionList(){
|
|
|
|
let params = {
|
|
|
|
page:this.page,
|
|
|
|
size:this.size
|
|
|
|
}
|
2022-07-15 10:29:01 +00:00
|
|
|
this.isLoading =false;
|
2022-07-08 08:15:29 +00:00
|
|
|
if(this.currentIndex == 0){
|
2022-07-14 02:00:23 +00:00
|
|
|
uni.showLoading({
|
|
|
|
title: '加载中'
|
|
|
|
});
|
2022-07-08 08:15:29 +00:00
|
|
|
this.$requst.get('/api/spu/collection',params).then(res=>{
|
|
|
|
if(res.code == 0){
|
|
|
|
this.total = res.data.total;
|
|
|
|
let newArr = [];
|
|
|
|
res.data.list.forEach(item=>{
|
|
|
|
let obj = {
|
|
|
|
id:item.id,
|
|
|
|
src:item.cover,
|
|
|
|
title:item.name,
|
|
|
|
time:'',
|
|
|
|
}
|
|
|
|
newArr.push(obj)
|
|
|
|
})
|
2022-07-13 08:04:38 +00:00
|
|
|
this.collectionList = this.collectionList.concat(newArr);
|
|
|
|
if(this.collectionList.length == this.total){
|
|
|
|
this.totalAll = this.total;
|
|
|
|
}
|
2022-07-08 08:15:29 +00:00
|
|
|
}
|
|
|
|
uni.hideLoading();
|
2022-07-15 10:29:01 +00:00
|
|
|
this.isLoading =true;
|
2022-07-08 08:15:29 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
if(this.currentIndex == 1){
|
|
|
|
this.$requst.get('/api/archives/collects',params).then(res=>{
|
|
|
|
if(res.code == 0){
|
|
|
|
this.total = res.data.total;
|
|
|
|
let newArr = [];
|
|
|
|
res.data.list.forEach(item=>{
|
|
|
|
let obj = {
|
|
|
|
id:item.id,
|
|
|
|
src:item.cover,
|
|
|
|
title:item.title,
|
2022-07-15 10:39:41 +00:00
|
|
|
time:this.dateFormat(item.created_at.replace(/-/g,'/')),
|
2022-07-08 08:15:29 +00:00
|
|
|
}
|
|
|
|
newArr.push(obj)
|
|
|
|
})
|
2022-07-13 08:04:38 +00:00
|
|
|
this.collectionList = this.collectionList.concat(newArr);
|
|
|
|
if(this.collectionList.length == this.total){
|
|
|
|
this.totalAll = this.total;
|
|
|
|
}
|
2022-07-08 08:15:29 +00:00
|
|
|
}
|
2022-07-15 10:29:01 +00:00
|
|
|
uni.hideLoading();
|
|
|
|
this.isLoading =true;
|
2022-07-08 08:15:29 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 时间格式转换
|
|
|
|
dateFormat (dateData) {
|
|
|
|
var date = new Date(dateData)
|
|
|
|
var y = date.getFullYear()
|
|
|
|
var m = date.getMonth() + 1
|
|
|
|
m = m < 10 ? '0' + m : m
|
|
|
|
var d = date.getDate()
|
|
|
|
d = d < 10 ? '0' + d : d
|
|
|
|
const time = y + '.' + m + '.' + d
|
|
|
|
return time
|
|
|
|
},
|
|
|
|
//收藏
|
|
|
|
collectionEv(id){
|
2022-07-23 01:04:40 +00:00
|
|
|
|
2022-07-08 08:15:29 +00:00
|
|
|
if(this.currentIndex == 0){
|
|
|
|
let params = {
|
|
|
|
id:id.id,
|
|
|
|
action:'collect'
|
|
|
|
}
|
|
|
|
this.$requst.post('/api/spu/un-record',params).then(res=>{
|
|
|
|
if(res.code==0) {
|
|
|
|
this.$toolAll.tools.showToast('取消收藏成功');
|
2022-07-23 01:04:40 +00:00
|
|
|
this.collectionList=[];
|
2022-07-08 08:15:29 +00:00
|
|
|
this.getCollectionList();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if(this.currentIndex == 1){
|
|
|
|
let params = {
|
|
|
|
archive_id:id.id,
|
|
|
|
action:'collect'
|
|
|
|
}
|
|
|
|
this.$requst.post('/api/archives/un-record',params).then(res=>{
|
|
|
|
if(res.code==0) {
|
|
|
|
this.$toolAll.tools.showToast('取消收藏成功');
|
2022-07-23 01:04:40 +00:00
|
|
|
this.collectionList=[];
|
2022-07-08 08:15:29 +00:00
|
|
|
this.getCollectionList();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
//去文章详情
|
|
|
|
toArticleDetail(id){
|
|
|
|
if(this.currentIndex == 0){
|
|
|
|
uni.navigateTo({
|
|
|
|
url:`/pagesA/shop/detail?id=${id.id}&source=shop`
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if(this.currentIndex == 1){
|
|
|
|
uni.navigateTo({
|
|
|
|
url:`/pages/tabbar/news/detail?id=${id.id}`
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
|
|
|
</style>
|