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

143 lines
3.6 KiB
Vue
Raw 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>
<!-- 套件列表 -->
<view class="kit-list">
<view class="kit-item" @tap.stop="toDetail(item.id)" v-for="(item,index) in kitList" :key="index">
<view class="kit-title">{{item.name}}</view>
<view class="kit-compose">
<text v-for="(item1,index1) in item.series" :key="index1">{{item1.name}}+</text>
<text>组合</text>
</view>
<view class="kit-img">
<image :src="item.cover" mode="widthFix"></image>
</view>
<view class="compose-list-bg">
<view class="compose-list flex" v-if="item.series.length>0" :style="{width:item.series.length*270-22+'rpx'}">
<view class="compose-item" v-for="(item2,index2) in item.series" :key="index2">
<view class="compose-img">
<image :src="item2.cover" mode="widthFix"></image>
</view>
<view class="compose-title clips1">{{item2.name}}</view>
</view>
</view>
</view>
</view>
</view>
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';
// 底部组件
import footTab from '@/components/foot-tab/foot-tab.vue';
import {getCartNum} from '@/jsFile/public-api.js';
import { mapState } from 'vuex'//引入mapState
export default {
components:{
statusNav,
enterCart,
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', //排序
}
},
computed:{
...mapState({
footHeight: state => state.moduleA.footHeight,
}),
},
onLoad(op) {
2022-07-12 10:07:08 +00:00
if(op.business_id){
this.$requst.post('/api/index/change-business',{business_id:op.business_id}).then(res=>{
if(res.code == 0){
this.getKitEv();
}
})
}else{
this.getKitEv();
}
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(){
uni.showLoading();
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,
cover:item.cover,
name:item.name,
series:item.series
}
newArr.push(obj);
})
this.kitList = 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();
})
},
// 跳转详情页
toDetail(id) {
uni.navigateTo({
url:'/pages/tabbar/kit/detail?id='+id
})
},
}
}
</script>
<style>
</style>