diff --git a/src/components/service-list/service_list.vue b/src/components/service-list/service_list.vue index b704dad90e79adffce3072eb16430faeec39cc36..a007695ab28617f2b0bc0b4e53516763971a82e1 100644 --- a/src/components/service-list/service_list.vue +++ b/src/components/service-list/service_list.vue @@ -9,7 +9,9 @@
- {{ $t('lang.service_shop') }} + {{ + $t("lang.service_shop") + }} {{ name }}
@@ -24,45 +26,81 @@
-
+
{{ item.name }}:
  • 全部 + :class=" + activeOptions[index].length == 0 + ? 'classification_act' + : '' + " + >全部
  • {{ items.name }} + :class=" + activeOptions[index].indexOf(items.id) != -1 + ? 'classification_act' + : '' + " + >{{ items.name }} @@ -82,8 +120,14 @@ > 收起 展开 - - + +
@@ -96,11 +140,23 @@ >
{{ itemChildren.name }} + :class=" + activeChildOptions[index].indexOf(itemChildren.id) != + -1 + ? 'classification_act' + : '' + " + >{{ itemChildren.name }}
@@ -111,7 +167,11 @@
@@ -119,11 +179,14 @@ v-for="(item, index) in buttonFilter" :key="item.name" size="small" - :class="index == activeBtn ? 'button_filter_act':'button_filter'" + :class="index == activeBtn ? 'button_filter_act' : 'button_filter'" @click="clickButtonFilter(index)" - >{{ item.name }} + >{{ item.name }}
- 支持二次开发 + 支持二次开发
@@ -146,12 +209,12 @@ import BlockRadius from "@/components/general/block-radius"; export default { components: { "commodity-list": CommodityList, - BlockRadius + BlockRadius, }, props: { urlFilter: { type: String, - default: "" + default: "", }, url: { type: String, default: "" }, name: { type: String, default: "" }, @@ -159,8 +222,8 @@ export default { type: Array, default: () => { []; - } - } + }, + }, }, data: () => ({ search: "", @@ -169,23 +232,23 @@ export default { { index: null, state: false, act: null }, { index: null, state: false, act: null }, { index: null, state: false, act: null }, - { index: null, state: false, act: null } + { index: null, state: false, act: null }, ], activeOptions: [[], [], [], []], activeChildOptions: [[], [], [], []], buttonFilter: [ { - name: "综合排序" + name: "综合排序", }, { - name: "最新更新" + name: "最新更新", }, { - name: "最高人气" + name: "最高人气", }, { - name: "最好评价" - } + name: "最好评价", + }, ], activeBtn: 0, lists: [], @@ -195,26 +258,26 @@ export default { id: 110, name: "", prop: "", - childDomains: [] + childDomains: [], }, { id: 10, name: "", prop: "serviceTypeInfo", - childDomains: [] + childDomains: [], }, { id: 11, name: "", prop: "serviceDomain", - childDomains: [] + childDomains: [], }, { id: 100, name: "", prop: "organizations", - childDomains: [] - } + childDomains: [], + }, ], page: 1, limit: 10, @@ -223,12 +286,13 @@ export default { refresh_app_2: false, refresh_app_3: false, time_app: null, - times: null + times: null, }), mounted() { - window.onresize = () => { - this.judgeHeight(); - }; + window.addEventListener("resize", this.judgeHeight); + }, + destroyed() { + window.removeEventListener("resize", this.judgeHeight); }, watch: { urlFilter: { @@ -238,7 +302,7 @@ export default { { index: null, state: false, act: null }, { index: null, state: false, act: null }, { index: null, state: false, act: null }, - { index: null, state: false, act: null } + { index: null, state: false, act: null }, ]; this.activeOptions = [[], [], [], []]; this.activeChildOptions = [[], [], [], []]; @@ -252,27 +316,27 @@ export default { id: 2, name: "平台应用", prop: "", - childDomains: null + childDomains: null, }, { id: 1, name: "开发者应用", prop: "", - childDomains: null - } - ] + childDomains: null, + }, + ], }); } else { this.$set(this.filterLists, 0, { id: 110, name: "", prop: "", - childDomains: [] + childDomains: [], }); } this.getShopFilter(); } - } + }, }, filterNames: { handler(val) { @@ -280,8 +344,8 @@ export default { this.filterLists[i + 1].name = val[i]; } console.log(this.filterLists); - } - } + }, + }, }, methods: { getShopList() { @@ -302,9 +366,9 @@ export default { : "evaluation", page: this.page, limit: this.limit, - search: this.search + search: this.search, }; - this.$api.serviceShop.getAppList(query).then(response => { + this.$api.serviceShop.getAppList(query).then((response) => { if (response.data.success == "1") { this.lists = response.data.data; this.total = response.data.total; @@ -322,9 +386,9 @@ export default { organizeIds: this.activeOptions[3].join(","), orderBy: this.activeBtn, Page: this.page, - Size: this.limit + Size: this.limit, }; - this.$api.serviceShop.getServiceShopList(query).then(response => { + this.$api.serviceShop.getServiceShopList(query).then((response) => { if (response.data.success == "1") { this.lists = response.data.data; this.total = response.data.total; @@ -348,9 +412,9 @@ export default { }, 50); } else { let query = { - type: this.urlFilter + type: this.urlFilter, }; - this.$api.serviceShop.getServiceShopFilter(query).then(response => { + this.$api.serviceShop.getServiceShopFilter(query).then((response) => { if (response.data.success == 1) { let data = response.data.data; this.filterLists[1].childDomains = data.serviceTypeInfo @@ -373,19 +437,21 @@ export default { } }, judgeHeight() { - let list = this.filterLists; - for (let i = 0; i < list.length; i++) { - if (list[i].childDomains.length != 0) { - let offHeight = document.getElementById(list[i].id).offsetHeight; - if (offHeight > 60) { - list[i].showOpen = true; - this.openList[i] = "up"; - } else { - list[i].showOpen = false; + this.$nextTick(() => { + let list = this.filterLists; + for (let i = 0; i < list.length; i++) { + if (list[i].childDomains.length != 0) { + let offHeight = Math.ceil(document.getElementById(list[i].id).offsetHeight); + if (offHeight > 60) { + list[i].showOpen = true; + this.openList[i] = "up"; + } else { + list[i].showOpen = false; + } } } - } - this.filterLists = [...list]; + this.filterLists = [...list]; + }); }, clickOpen(index) { let list = this.openList; @@ -403,7 +469,7 @@ export default { } else { this.activeOptions[index].splice(i, 1); if (items.childDomains) { - items.childDomains.forEach(e => { + items.childDomains.forEach((e) => { let i = this.activeChildOptions[index].indexOf(e.id); if (i != -1) { this.activeChildOptions[index].splice(i, 1); @@ -419,20 +485,20 @@ export default { this.$set(this.openChildren, index, { index: indexs, state: !this.openChildren[index].state, - act: items.childDomains + act: items.childDomains, }); } else { this.$set(this.openChildren, index, { index: items.id, state: true, - act: items.childDomains + act: items.childDomains, }); } } else { this.$set(this.openChildren, index, { index: null, state: false, - act: null + act: null, }); } }, @@ -477,7 +543,7 @@ export default { this.getShopList(); }, getAppArea() { - this.$api.serviceShop.getAppArea().then(response => { + this.$api.serviceShop.getAppArea().then((response) => { if (response.data.success == 1) { this.filterLists[2].childDomains = response.data.data; this.refresh_app_2 = true; @@ -487,7 +553,7 @@ export default { }); }, getAppType() { - this.$api.serviceShop.getAppType().then(response => { + this.$api.serviceShop.getAppType().then((response) => { if (response.data.success == 1) { this.filterLists[1].childDomains = response.data.data; this.refresh_app_1 = true; @@ -497,7 +563,7 @@ export default { }); }, getAppOrg() { - this.$api.serviceShop.getAppOrg().then(response => { + this.$api.serviceShop.getAppOrg().then((response) => { if (response.data.success == 1) { this.filterLists[3].childDomains = response.data.data; this.refresh_app_3 = true; @@ -505,8 +571,8 @@ export default { console.log(response.data.errMsg); } }); - } - } + }, + }, }; \ No newline at end of file +