2022-07-08 08:15:29 +00:00
|
|
|
<template>
|
|
|
|
<view class="pad-b150">
|
|
|
|
<status-nav :ifReturn="false" navBarTitle="资讯" :marginBottom="0"></status-nav>
|
2022-07-15 10:39:41 +00:00
|
|
|
<view class="nav-list-bg news-nav-bg" :style="{top:newTop+'px'}">
|
2022-07-18 05:35:14 +00:00
|
|
|
<nav-tab :list="navTabList" :maxNum="5" @chooseEv="chooseEv" :newWidth="tabWidth"></nav-tab>
|
2022-07-08 08:15:29 +00:00
|
|
|
</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="articleList" :collection="0" @toDetail="toArticleDetail"></pull-list>
|
|
|
|
</view>
|
|
|
|
<!-- 暂无更多内容 -->
|
|
|
|
<view class="more-txt" v-if="totalAll == total">暂无更多内容</view>
|
|
|
|
<!-- 购物车btn -->
|
|
|
|
<enter-cart></enter-cart>
|
|
|
|
<!-- 底部tab -->
|
|
|
|
<foot-tab current="3"></foot-tab>
|
|
|
|
</view>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import statusNav from '@/components/status-navs/status-nav';
|
|
|
|
import navTab from '@/components/nav-tab/nav-tab.vue';
|
2022-07-18 05:35:14 +00:00
|
|
|
import swiperTab from '@/components/swiper-tab/swiper-tab.vue'
|
2022-07-08 08:15:29 +00:00
|
|
|
import pullList from '@/components/pull-list/pull-list.vue';
|
|
|
|
import enterCart from '@/components/enter-cart/enter-cart.vue';
|
|
|
|
// 底部组件
|
|
|
|
import footTab from '@/components/foot-tab/foot-tab.vue';
|
2022-07-13 08:04:38 +00:00
|
|
|
import {getCartNum,userInfoEv} from '@/jsFile/public-api.js';
|
|
|
|
import {mapState} from 'vuex'//引入mapState
|
2022-07-08 08:15:29 +00:00
|
|
|
export default {
|
|
|
|
components:{
|
|
|
|
statusNav,
|
|
|
|
navTab,
|
2022-07-18 05:35:14 +00:00
|
|
|
swiperTab,
|
2022-07-08 08:15:29 +00:00
|
|
|
pullList,
|
|
|
|
enterCart,
|
|
|
|
footTab,
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
scrollHeight:uni.getSystemInfoSync().windowHeight - uni.getSystemInfoSync().statusBarHeight - 50,
|
|
|
|
newWidth:uni.getSystemInfoSync().windowWidth,
|
|
|
|
newTop:uni.getSystemInfoSync().statusBarHeight + 50,
|
|
|
|
articleList:[], //解答&资讯列表
|
|
|
|
navTabList:[], //导航列表
|
|
|
|
currentIndex:0, //当前位置
|
|
|
|
page:1, //第几页
|
|
|
|
size:10, //查询条数
|
|
|
|
total:0, //总数
|
|
|
|
totalAll:-1,//总数
|
2022-07-15 03:05:54 +00:00
|
|
|
cacheBusinessId:-1, //商户id
|
2022-07-15 10:29:01 +00:00
|
|
|
isLoading:false,
|
2022-07-18 05:35:14 +00:00
|
|
|
tabWidth:'',
|
2022-07-08 08:15:29 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed:{
|
|
|
|
...mapState({
|
|
|
|
footHeight: state => state.moduleA.footHeight,
|
|
|
|
}),
|
|
|
|
},
|
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.articleList=[];
|
2022-07-12 10:07:08 +00:00
|
|
|
this.getArticleNav();
|
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.articleList=[];
|
2022-07-12 10:07:08 +00:00
|
|
|
this.getArticleNav();
|
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.articleList.length<this.total){
|
|
|
|
this.page++;
|
|
|
|
this.getArticleList();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 分享到微信
|
|
|
|
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: {
|
|
|
|
// 获取文章栏目
|
|
|
|
getArticleNav(){
|
|
|
|
this.$requst.get('/api/archives/category').then(res=>{
|
|
|
|
if(res.code == 0){
|
2022-07-15 10:29:01 +00:00
|
|
|
let newArr = [];
|
2022-07-08 08:15:29 +00:00
|
|
|
res.data.forEach(item=>{
|
|
|
|
let obj = {
|
|
|
|
id:item.id,
|
2022-07-18 05:35:14 +00:00
|
|
|
title:item.title,
|
|
|
|
name:item.title,
|
2022-07-08 08:15:29 +00:00
|
|
|
}
|
2022-07-15 10:29:01 +00:00
|
|
|
newArr.push(obj)
|
2022-07-08 08:15:29 +00:00
|
|
|
})
|
2022-07-15 10:29:01 +00:00
|
|
|
this.navTabList = newArr;
|
2022-07-18 05:35:14 +00:00
|
|
|
this.tabWidth = this.navTabList.length*210-50+'rpx';
|
2022-07-08 08:15:29 +00:00
|
|
|
this.articleNavId = this.navTabList[0].id;
|
|
|
|
// 获取文章列表
|
|
|
|
this.getArticleList();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 切换事件
|
|
|
|
chooseEv(index,id){
|
|
|
|
if(this.currentIndex !== index){
|
|
|
|
this.articleList = [];
|
|
|
|
this.page = 1;
|
|
|
|
this.currentIndex = index;
|
|
|
|
this.articleNavId = id;
|
|
|
|
// 获取文章列表
|
|
|
|
this.getArticleList();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 获取疑难解答、行业资讯列表
|
|
|
|
getArticleList(){
|
2022-07-14 02:00:23 +00:00
|
|
|
uni.showLoading({
|
|
|
|
title: '加载中'
|
|
|
|
});
|
2022-07-15 10:29:01 +00:00
|
|
|
this.isLoading =false;
|
2022-07-08 08:15:29 +00:00
|
|
|
let params = {
|
|
|
|
page:this.page,
|
|
|
|
size:this.size,
|
|
|
|
category_id:this.articleNavId
|
|
|
|
}
|
|
|
|
this.$requst.get('/api/archives/list',params).then(res=>{
|
|
|
|
if(res.code == 0){
|
|
|
|
this.total = res.data.total;
|
|
|
|
let newArr = [];
|
|
|
|
res.data.list.forEach(item=>{
|
|
|
|
let obj = {
|
|
|
|
id:item.id,
|
|
|
|
title:item.title,
|
2022-07-14 02:00:23 +00:00
|
|
|
time:this.dateFormat(item.published_at.replace(/-/g,'/')),
|
2022-07-08 08:15:29 +00:00
|
|
|
src:item.cover
|
|
|
|
}
|
|
|
|
newArr.push(obj)
|
|
|
|
})
|
2022-07-13 08:04:38 +00:00
|
|
|
this.articleList = this.articleList.concat(newArr);
|
2022-07-12 10:07:08 +00:00
|
|
|
if(this.articleList.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
|
|
|
})
|
|
|
|
},
|
|
|
|
// 时间格式转换
|
|
|
|
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
|
|
|
|
},
|
|
|
|
//去文章详情
|
|
|
|
toArticleDetail(id){
|
|
|
|
uni.navigateTo({
|
|
|
|
url:`/pages/tabbar/news/detail?id=${id.id}`
|
|
|
|
})
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
</style>
|