安徽博创起重uniapp
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

233 lines
5.6 KiB

<template>
<view class="news-list">
<mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"
:up="upOption">
<view class="contain">
<!-- 城市 -->
<router-link class="m-l-16 flex row-center" to="/bundle_b/pages/city/city">
<text class="m-r-6">{{ cityInfo.name || '选择' }}</text>
<u-icon name="arrow-down" size="24" color="#FFFFFF"></u-icon>
<!-- <image class="icon-md m-l-30" src="/static/images/icon_news.png">
</image> -->
</router-link>
<view class="banner">
<ad-swipers :pid="30" height="340rpx">
</ad-swipers>
</view>
<tabs :current="active" @change="changeActive" :bar-width="60">
<tab name="全部"></tab>
<tab v-for="(item, index) in categoryList" :key="index" :name="item.name"></tab>
</tabs>
<view class="main">
<view class="article-list">
<view class="article-item bg-white" v-for="(item, index) in newsList" :key="index" >
<router-link :to="{path: '/pages/resource_details/resource_details', query: {id: item.id, type}}">
<view class="flex col-top">
<view class="info flex-1">
<view class="title lg line-2 m-b-20">{{ item.title }}</view>
<view class="lighter line-2">
<view>{{ item.intro }}</view>
</view>
</view>
<u-image width="240rpx" height="180rpx" class="img m-l-20" :src="item.image" />
</view>
<view class="flex row-between m-t-20">
<view class="xs muted">价格: <b style="color: red;">{{item.price_str}}</b></view>
</view>
<view class="flex row-between m-t-20">
<view class="xs muted">发布时间: {{item.create_time}}</view>
<view class="flex">
<image class="icon-sm" src="/static/images/icon_see.png"></image>
<view class="m-l-10 xs muted">{{ item.visit }}人浏览</view>
</view>
</view>
</router-link>
</view>
</view>
</view>
</view>
</mescroll-body>
</view>
</template>
<script>
import {
mapGetters,
mapActions
} from 'vuex'
import {
getResourceCategoryList,
getResourceList
} from '@/api/store';
import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins";
export default {
mixins: [MescrollMixin],
data() {
return {
active: 0,
upOption: {
auto: false,
empty: {
icon: '/static/images/news_null.png',
tip: "暂无数据",
}
},
categoryList: [],
newsList: [],
type: -1,
};
},
async onShow() {
this.type = 0;
uni.setNavigationBarTitle({
title: '资料库'
});
// 选择城市后是否刷新
await this.downCallback();
},
async onLoad(options) {
this.type = 0;
uni.setNavigationBarTitle({
title: '资料库'
});
console.log(11111)
// 选择城市后是否刷新
await this.downCallback();
},
methods: {
changeActive(e) {
this.active = e;
this.newsList = [] // 先置空列表,显示加载进度
this.mescroll.resetUpScroll() // 再刷新列表数据
},
async downCallback() {
await this.getCategoryListFun();
this.mescroll.resetUpScroll();
},
upCallback(page) {
const { type, active, categoryList } = this
console.log(categoryList,11222)
console.log(categoryList[active-1],22333)
getResourceList({
type: this.type,
cid: this.active ? categoryList[active-1].id : '',
page_size:page.size,
page_no:page.num
}).then(({
data
}) => {
if (page.num == 1) this.newsList = [];
let curPageData = data.list;
let curPageLen = curPageData.length;
let hasNext = !!data.more;
this.newsList = this.newsList.concat(curPageData);
this.mescroll.endSuccess(curPageLen, hasNext);
}).catch(() => {
this.mescroll.endErr()
})
},
async getCategoryListFun() {
let {
cityInfo,
isLogin
} = this;
const {
code,
data
} = await getResourceCategoryList({
type: this.type
})
if (code == 1) {
this.categoryList = data
}
let item = {id:0,name:"全国"}
if(cityInfo.id !=null && cityInfo.id!=undefined && cityInfo.id>0){
item = {id:"city_"+cityInfo.id,name:"本地"}
}
this.categoryList.push(item)
if(isLogin){
item = {id:"my_buy",name:"我的购买"}
this.categoryList.push(item)
item = {id:"my_download",name:"我的下载"}
this.categoryList.push(item)
}
},
},
computed: {
...mapGetters(['cityInfo'])
}
};
</script>
<style lang="scss">
.news-list {
.main {
.article-list {
padding-top: 20rpx;
.article-item {
padding: 20rpx;
align-items: flex-start;
&:not(:last-of-type){
border-bottom: $-solid-border;
}
}
}
}
}
page {
padding: 0;
}
.index-bg {
background-image: url('../../static/images/index_bg.png');
background-size: 100% auto;
background-repeat: no-repeat;
}
.index {
min-height: calc(100vh - var(--window-bottom));
.u-navbar {
::v-deep .u-search {
padding: 0 30rpx;
}
}
// 胶囊提示
.capsule-tips {
width: 584rpx;
color: #FFFFFF;
padding: 12rpx 18rpx;
border-radius: 14rpx;
background: rgba(0, 0, 0, 0.7);
position: relative;
position: absolute;
z-index: 9999;
bottom: -80rpx;
right: -150rpx;
}
.capsule-tips::after {
content: '';
border-bottom: 14rpx solid rgba(0, 0, 0, 0.7);
border-right: 14rpx solid transparent;
border-left: 14rpx solid transparent;
position: absolute;
top: -14rpx;
right: 88rpx;
}
.cate-btn {
padding: 12rpx 16rpx 12rpx 20rpx;
border-radius: 60rpx 0 0 60rpx;
background-color: rgba(256, 256, 256, .4);
}
}
</style>