leave-unused/pages/idle/idle.vue

125 lines
3.2 KiB
Vue

<template>
<view class="pad-x120" v-if="isLoading">
<!-- 头部 -->
<status-nav :ifReturn="false" :navBarTitle="pageTitle" :estate="1" :ifCenter="false"></status-nav>
<!-- 商品列表 -->
<goods-list :goodsList="goodsList"></goods-list>
<!-- 没有更多 -->
<view class="no-more mar-s20 font24 color-99" v-if="goodsList.length==total"></view>
<!-- -->
<tabbar></tabbar>
</view>
</template>
<script>
import goodsList from '@/components/goods-list/goods-list.vue';
import tabbar from '@/components/tabbar/tabbar';
export default {
components:{
goodsList,
tabbar
},
data() {
return {
statusHeight:uni.getSystemInfoSync().statusBarHeight, //状态栏高度
pageTitle:'', //页面标题
goodsList:[], //商品列表
category_id:0, //分类id
keyword:'', //关键词
page:1, //页数
size:10, //条数
total:0, //总数
isLoading:false, //是否加载完成
area_id:0, //小区id
}
},
onLoad() {
if(uni.getStorageSync('area_id')&&uni.getStorageSync('area_name')){
this.area_id = uni.getStorageSync('area_id');
this.pageTitle = uni.getStorageSync('area_name')+'-闲置商品';
// 查询商品列表
this.getGoodsList();
}else{
// 查询小区列表
this.getEstateList();
}
},
onShareAppMessage(res) {
let shareObj = {
title:'老农极鲜',
path: uni.getStorageSync('page-path-options')+'?invite_code='+uni.getStorageSync('invite_code'),
imageUrl:'/static/img/shear-index.jpg',
}
// 返回shareObj
return shareObj;
},
onShareTimeline(res){
let shareObj = {
title:'老农极鲜',
query: '?invite_code='+uni.getStorageSync('invite_code'),
path: uni.getStorageSync('page-path-options')+'?invite_code='+uni.getStorageSync('invite_code'),
imageUrl:'/static/img/shear-index.jpg',
}
// 返回shareObj
return shareObj;
},
onReachBottom(e) {
if(this.goodsList.length<this.total){
this.page++;
//
this.getGoodsList();
}
},
methods: {
//
getEstateList(){
this.$requst.get('/api/v1/goods/area').then(res=>{
if(res.code == 0){
this.area_id = res.data.list[0].id;
this.pageTitle = res.data.list[0].title+'-闲置商品';
// 查询商品列表
this.getGoodsList();
}
})
},
// 查询商品列表
getGoodsList(){
uni.showLoading({
title:'加载中'
})
let params = {
page:this.page,
size:this.size,
area_id:this.area_id
}
if(this.page==1) this.goodsList = [];
this.$requst.get('/api/v1/goods/list',params).then(res=>{
if(res.code == 0){
console.log(res,'闲置商品列表')
this.total = res.data.total;
let goodsArr = [];
res.data.list.forEach(item=>{
let obj = {
id:item.id,
cover:item.cover,
name:item.title,
original_price:item.original_price,
price:item.price
}
goodsArr.push(obj)
})
this.goodsList = this.goodsList.concat(goodsArr);
}
uni.hideLoading();
this.isLoading = true;
})
},
}
}
</script>
<style scoped>
.no-more{
text-align: center;
line-height: 2;
}
</style>