category.vue 5.58 KB
Newer Older
wanli's avatar
wanli committed
1
<template>
wanli's avatar
wanli committed
2
  <div class="app-container">
3 4 5 6 7 8 9 10 11 12 13 14 15
    <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>
wanli's avatar
wanli committed
16
    </div>
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
    <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" />
wanli's avatar
wanli committed
33
        <div class="text">
34
          <p class="title">{{ item.name }}</p>
wanli's avatar
wanli committed
35 36 37 38 39 40 41 42 43 44 45 46
          <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>
47
          <p class="subtitle">{{ item.memo }}</p>
wanli's avatar
wanli committed
48 49 50 51
        </div>
        <button class="install">安装</button>
      </div>
    </div>
52
    <circle5 v-show="loading"></circle5>
wanli's avatar
wanli committed
53 54 55
  </div>
</template>
<script>
56 57
import { getTabList, getDataList } from "@/api/app-store";
import { Circle5 } from "vue-loading-spinner";
wanli's avatar
wanli committed
58
import StarRating from "vue-star-rating";
wanli's avatar
wanli committed
59
export default {
wanli's avatar
wanli committed
60 61 62
  name: "AppCategory",
  components: {
    StarRating,
63
    Circle5,
wanli's avatar
wanli committed
64
  },
wanli's avatar
wanli committed
65
  data() {
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
    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();
wanli's avatar
wanli committed
132 133 134 135
  },
};
</script>
<style lang="scss" scoped>
wanli's avatar
wanli committed
136 137
div.app-container {
  margin: 20px 0px;
138 139 140 141 142
  & > p {
    margin: 0px;
    font-size: 18px;
  }
  & > div.categories {
wanli's avatar
wanli committed
143
    display: flex;
144 145 146
    flex-direction: row;
    margin: 20px 0px;
    font-size: 14px;
wanli's avatar
wanli committed
147
    & > p {
148
      width: 100px;
wanli's avatar
wanli committed
149
      margin: 0px;
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
    }
    & > 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;
        }
wanli's avatar
wanli committed
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
      }
    }
  }
  & > 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;
        }
      }
    }
wanli's avatar
wanli committed
235 236 237
  }
}
</style>