优化分类列表
This commit is contained in:
parent
1cb80769a9
commit
bc819831f0
|
@ -75,6 +75,10 @@ export default {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 0,
|
default: 0,
|
||||||
},
|
},
|
||||||
|
activeId: {
|
||||||
|
type: [String, Number],
|
||||||
|
default: 0,
|
||||||
|
},
|
||||||
data: {
|
data: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: [],
|
default: [],
|
||||||
|
@ -108,7 +112,6 @@ export default {
|
||||||
// H5窗口高度会计算tabbar高度,这里减去
|
// H5窗口高度会计算tabbar高度,这里减去
|
||||||
this.wrapHeight -= this.$utils.rpx2px(100);
|
this.wrapHeight -= this.$utils.rpx2px(100);
|
||||||
// #endif
|
// #endif
|
||||||
// this.switchCate(5);
|
|
||||||
},
|
},
|
||||||
destroyed() {},
|
destroyed() {},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -247,6 +250,11 @@ export default {
|
||||||
this.$emit("clickItem", id);
|
this.$emit("clickItem", id);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
activeId(activeId) {
|
||||||
|
this.switchCate(activeId);
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ export default {
|
||||||
config: (state) => state.system.config,
|
config: (state) => state.system.config,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
onLoad() {
|
async onLoad() {
|
||||||
let x = this.config.windowWidth - this.$utils.rpx2px(94);
|
let x = this.config.windowWidth - this.$utils.rpx2px(94);
|
||||||
let y = this.config.windowHeight - this.$utils.rpx2px(94);
|
let y = this.config.windowHeight - this.$utils.rpx2px(94);
|
||||||
// H5平台减去tabBar高度
|
// H5平台减去tabBar高度
|
||||||
|
@ -61,7 +61,7 @@ export default {
|
||||||
y: y - this.$utils.rpx2px(40),
|
y: y - this.$utils.rpx2px(40),
|
||||||
};
|
};
|
||||||
// 加载分类
|
// 加载分类
|
||||||
this.loadHot();
|
await this.loadHot();
|
||||||
this.loadCate();
|
this.loadCate();
|
||||||
},
|
},
|
||||||
onShow() {},
|
onShow() {},
|
||||||
|
@ -72,8 +72,8 @@ export default {
|
||||||
/**
|
/**
|
||||||
* 热门推荐
|
* 热门推荐
|
||||||
*/
|
*/
|
||||||
loadHot() {
|
async loadHot() {
|
||||||
this.$request({
|
await this.$request({
|
||||||
api: "service.hotCate",
|
api: "service.hotCate",
|
||||||
}).then((response) => {
|
}).then((response) => {
|
||||||
let child = [];
|
let child = [];
|
||||||
|
@ -95,8 +95,8 @@ export default {
|
||||||
/**
|
/**
|
||||||
* 分类
|
* 分类
|
||||||
*/
|
*/
|
||||||
loadCate() {
|
async loadCate() {
|
||||||
this.$request({
|
await this.$request({
|
||||||
api: "service.cate",
|
api: "service.cate",
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<app-layout minHeight="unset" btnType="back" title="服务列表" headerBackgroundColor="#FFFFFF" backgroundColor="#FFFFFF">
|
<app-layout minHeight="unset" btnType="back" title="服务列表" headerBackgroundColor="#FFFFFF" backgroundColor="#FFFFFF">
|
||||||
<view class="cate">
|
<view class="cate">
|
||||||
<app-cate :offsetHeight="0" :data="data" cateType="list" @clickItem="clickItem" />
|
<app-cate :offsetHeight="0" :data="data" cateType="list" @clickItem="clickItem" :activeId="currentId" />
|
||||||
</view>
|
</view>
|
||||||
<view class="common-bottom-components" :style="{ bottom: config.safeAreaInsets.bottom + 'px' }">
|
<view class="common-bottom-components" :style="{ bottom: config.safeAreaInsets.bottom + 'px' }">
|
||||||
<view class="cart" @click="utils.toPage('/pages/service/cart')">
|
<view class="cart" @click="utils.toPage('/pages/service/cart')">
|
||||||
|
@ -28,9 +28,10 @@ export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
utils: this.$utils,
|
utils: this.$utils,
|
||||||
cateId: 0,
|
|
||||||
data: [],
|
data: [],
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
|
|
||||||
|
currentId: 0,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
@ -42,14 +43,14 @@ export default {
|
||||||
config: (state) => state.system.config,
|
config: (state) => state.system.config,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
onLoad(e) {
|
async onLoad(e) {
|
||||||
if (e.id) {
|
if (!e.id) {
|
||||||
this.cateId = e.id;
|
|
||||||
} else {
|
|
||||||
this.$utils.toast("参数错误");
|
this.$utils.toast("参数错误");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.loadList();
|
await this.loadList(e.id);
|
||||||
|
// 赋值,触发watch
|
||||||
|
this.currentId = e.id;
|
||||||
},
|
},
|
||||||
onShow() {},
|
onShow() {},
|
||||||
onReady() {},
|
onReady() {},
|
||||||
|
@ -59,10 +60,10 @@ export default {
|
||||||
/**
|
/**
|
||||||
* 加载列表
|
* 加载列表
|
||||||
*/
|
*/
|
||||||
loadList() {
|
async loadList(cateId) {
|
||||||
this.$request({
|
await this.$request({
|
||||||
api: "service.list",
|
api: "service.list",
|
||||||
query: "id=" + this.cateId,
|
query: "id=" + cateId,
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
response.data.forEach((item) => {
|
response.data.forEach((item) => {
|
||||||
|
|
Loading…
Reference in New Issue