<template> <div class="app-container"> <p class="title">应用分类</p> <div class="categories"> <p>分类</p> <ul> <li :class="tabIndex == index ? 'active' : ''" v-for="(item, index) in tabList" :key="index" @click="onTabClick(index)" > {{ item.tabName }} </li> </ul> </div> <div class="categories"> <p>子分类</p> <ul> <li :class="tabChildIndex == index ? 'active' : ''" v-for="(item, index) in tabChildList" :key="index" @click="onTabChildClick(index)" > {{ item.tabName }} </li> </ul> </div> <div v-show="!loading" class="content"> <div class="item" v-for="(item, index) in dataList" :key="index"> <img :src="item.icon" alt="icon" /> <div class="text"> <p class="title">{{ item.name }}</p> <p class="subtitle"> <star-rating v-bind:rating="3.5" v-bind:increment="0.1" v-bind:max-rating="5" v-bind:star-size="15" v-bind:read-only="true" inactive-color="#9E9E9E" active-color="#FFC83D" > </star-rating> </p> <p class="subtitle">{{ item.memo }}</p> </div> <button class="install">安装</button> </div> </div> <circle5 v-show="loading"></circle5> </div> </template> <script> import { getTabList, getDataList } from "@/api/app-store"; import { Circle5 } from "vue-loading-spinner"; import StarRating from "vue-star-rating"; export default { name: "AppCategory", components: { StarRating, Circle5, }, data() { return { loading: false, tabIndex: 0, tabChildIndex: 0, tabList: [], tabChildList: [], query: { method: "internal.getTabDetail", serviceType: 20, reqPageNum: 1, uri: "b2b4752f0a524fe5ad900870f88c11ed", maxResults: 25, zone: "", locale: "zh", }, dataList: [], }; }, methods: { getTabList() { this.loading = true; getTabList(this.query) .then((res) => { if (res.tabInfo && res.tabInfo.length) { this.tabList = res.tabInfo; this.tabChildList = this.tabList[this.tabIndex].tabInfo; } }) .catch((err) => { if (err.tabInfo && err.tabInfo.length) { this.tabList = err.tabInfo; this.tabChildList = this.tabList[this.tabIndex].tabInfo; this.query.uri = this.tabChildList[this.tabChildIndex].realTabId; this.getDataList(); } }) .finally(() => { this.loading = false; }); }, getDataList() { getDataList(this.query) .then((res) => { console.log(res); }) .catch((err) => { console.log(err); if (err.layoutData && err.layoutData.length) { this.dataList = err.layoutData[0].dataList; } }); }, onTabClick(index) { this.tabIndex = index; this.tabChildList = this.tabList[index].tabInfo; this.query.uri = this.tabChildList[this.tabChildIndex].realTabId; this.getTabList(); }, onTabChildClick(index) { this.tabChildIndex = index; this.query.uri = this.tabChildList[this.tabChildIndex].realTabId; this.getTabList(); }, }, created() { this.getTabList(); }, }; </script> <style lang="scss" scoped> div.app-container { margin: 20px 0px; & > p { margin: 0px; font-size: 18px; } & > div.categories { display: flex; flex-direction: row; margin: 20px 0px; font-size: 14px; & > p { width: 100px; margin: 0px; } & > ul { flex: 1; display: grid; grid-column-gap: 10px; grid-row-gap: 10px; grid-template-columns: repeat(auto-fill, 100px); & > li { cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; &.active { color: #4cd1e0; } &:hover { color: #4cd1e0; } } } } & > div.content { display: flex; flex-direction: row; flex-wrap: wrap; flex-grow: 1; flex-shrink: 0; & > div.item { flex: 1; width: 50%; max-width: 50%; min-width: 50%; cursor: pointer; display: inline-flex; flex-direction: row; box-sizing: border-box; border: none; margin: 0px; padding: 10px 20px; & > img { width: 80px; height: 80px; } & > button { width: 100px; } & > button.install { width: auto; min-width: 72px; max-width: 100px; height: 28px; margin: 10px auto; padding: 0 12px; font-size: 14px; font-weight: bolder; border-radius: 14px; color: #007dff; background: rgba(0, 0, 0, 0.05); border: 0; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; z-index: 1; outline: none; } & > div.text { flex: 1; padding: 15px 0px; margin-left: 20px; border-bottom: 1px solid #f2f2f2; & > p { margin: 1px 0px; } & > p.title { line-height: 18px; } & > p.subtitle { color: grey; font-size: 12px; line-height: 18px; } } } } } </style>