luban-mall/pages/tabbar/kit/kit.vue

135 lines
3.2 KiB
Vue
Raw Permalink Normal View History

2022-07-08 08:15:29 +00:00
<template>
<view class="pad-b150">
<status-nav :ifReturn="false" navBarTitle="套件" :marginBottom="20"></status-nav>
<!-- 套件列表 -->
2022-07-23 01:04:40 +00:00
<pull-list :list="kitList" :isKit="true" @toDetail="toDetail"></pull-list>
2022-07-12 10:07:08 +00:00
<!-- 暂无更多内容 -->
<view class="more-txt" v-if="totalAll == total"></view>
2022-07-08 08:15:29 +00:00
<!-- 购物车btn -->
<enter-cart></enter-cart>
<!-- 底部tab -->
<foot-tab current="2"></foot-tab>
</view>
</template>
<script>
import statusNav from '@/components/status-navs/status-nav';
import enterCart from '@/components/enter-cart/enter-cart.vue';
2022-07-23 01:04:40 +00:00
import pullList from '@/components/pull-list/pull-list.vue';
2022-07-08 08:15:29 +00:00
// 底部组件
import footTab from '@/components/foot-tab/foot-tab.vue';
2022-07-25 03:18:38 +00:00
import {userInfoEv,getCartNum} from '@/jsFile/public-api.js';
2022-07-08 08:15:29 +00:00
export default {
components:{
statusNav,
enterCart,
2022-07-23 01:04:40 +00:00
pullList,
2022-07-08 08:15:29 +00:00
footTab
},
data() {
return {
scrollHeight:uni.getSystemInfoSync().windowHeight - uni.getSystemInfoSync().statusBarHeight - 50,
newWidth:uni.getSystemInfoSync().windowWidth,
kitList:[], //套件列表
page:1, //页数
size:10, //数量
total:0, //总数
totalAll:-1, //计算总数
category_id:0, //分类id
sort:'new', //排序
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
}
},
onLoad(op) {
2022-07-12 10:07:08 +00:00
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.kitList = [];
2022-07-12 10:07:08 +00:00
this.getKitEv();
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.kitList = [];
2022-07-12 10:07:08 +00:00
this.getKitEv();
2022-07-13 08:04:38 +00:00
userInfoEv();
2022-07-12 10:07:08 +00:00
}
2022-07-25 03:18:38 +00:00
getCartNum();
2022-07-08 08:15:29 +00:00
},
onReachBottom(e) {
if(this.kitList.length<this.total){
this.page++;
//查询套件列表
this.getKitEv();
}
},
// 分享到微信
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: {
// 查询套件列表
getKitEv(){
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.category_id,
sort:this.sort
}
this.$requst.post('/api/spu/series',params).then(res=>{
if(res.code==0) {
this.total = res.data.total;
let newArr = [];
res.data.list.forEach(item=>{
let obj = {
id:item.id,
2022-07-23 01:04:40 +00:00
src:item.cover,
title:item.name,
subtitle:item.subtitle,
2022-07-08 08:15:29 +00:00
series:item.series
}
newArr.push(obj);
})
2022-07-13 08:04:38 +00:00
this.kitList = this.kitList.concat(newArr);
2022-07-12 10:07:08 +00:00
if(this.kitList.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
})
},
// 跳转详情页
toDetail(id) {
uni.navigateTo({
2022-07-23 01:04:40 +00:00
url:`/pages/tabbar/kit/detail?id=${id.id}`
2022-07-08 08:15:29 +00:00
})
},
}
}
</script>
<style>
</style>