|
|
@@ -0,0 +1,249 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <div class="works-wrapper" v-if="!mobile" v-loading="firstLoad">
|
|
|
+ <div class="works-category">
|
|
|
+ <div class="works-category-one">
|
|
|
+ <div
|
|
|
+ class="works-category-one-item"
|
|
|
+ :class="currentCategoryIndex === 0 ? 'active' : ''"
|
|
|
+ @click="handleClickCategoryOne(0)">
|
|
|
+ 全部
|
|
|
+ </div>
|
|
|
+ <div
|
|
|
+ class="works-category-one-item"
|
|
|
+ :class="currentCategoryIndex === index + 1 ? 'active' : ''"
|
|
|
+ v-for="(category, index) in categoryList"
|
|
|
+ :key="`category-one-${category.category_id}`"
|
|
|
+ @click="handleClickCategoryOne(index + 1)">
|
|
|
+ {{ category.name }}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="works-category-two">
|
|
|
+ <!-- 展开按钮 -->
|
|
|
+ <img
|
|
|
+ src="@/assets/img/works/expand-arrow@2x.png"
|
|
|
+ alt="expand"
|
|
|
+ class="works-expand-arrow"
|
|
|
+ :class="categoryExpanded ? 'active' : ''"
|
|
|
+ @click="handleClickExpandCategory">
|
|
|
+ <!-- 全部二级分类 -->
|
|
|
+ <div
|
|
|
+ class="works-category-two-wrapper"
|
|
|
+ :class="categoryExpanded ? 'expand' : ''"
|
|
|
+ v-show="currentCategoryIndex === 0">
|
|
|
+ <div
|
|
|
+ class="works-category-two-item"
|
|
|
+ :class="pagination.cate_id_two.indexOf(category.category_id) > -1 ? 'active' : ''"
|
|
|
+ v-for="category in categoryAll"
|
|
|
+ :key="`category-all-${category.category_id}`"
|
|
|
+ @click="handleClickCategoryTwo(category.category_id)">
|
|
|
+ {{ category.name }}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <!-- 接口返回的二级分类 -->
|
|
|
+ <div
|
|
|
+ class="works-category-two-wrapper"
|
|
|
+ :class="categoryExpanded ? 'expand' : ''"
|
|
|
+ v-for="(category, index) in categoryList"
|
|
|
+ :key="`category-two-wrapper-${category.category_id}`"
|
|
|
+ v-show="currentCategoryIndex === index + 1">
|
|
|
+ <div
|
|
|
+ class="works-category-two-item"
|
|
|
+ :class="pagination.cate_id_two.indexOf(categoryChild.category_id) > -1 ? 'active' : ''"
|
|
|
+ v-for="categoryChild in category.child"
|
|
|
+ :key="`category-two-${categoryChild.category_id}`"
|
|
|
+ @click="handleClickCategoryTwo(categoryChild.category_id)">
|
|
|
+ {{ categoryChild.name }}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="works-list" v-loading="loadingWorksList">
|
|
|
+ <div
|
|
|
+ class="works-item"
|
|
|
+ v-for="works in worksList"
|
|
|
+ :key="`works-item-${works.wid}`">
|
|
|
+ <div class="works-detail-wrapper">
|
|
|
+ <img v-if="works.image" class="works-image" :src="works.image" alt="works-image">
|
|
|
+ <div class="works-detail" :style="{'width': works.image ? '630px' : '770px'}">
|
|
|
+ <nuxt-link class="works-name" :to="`/w/${works.wid}`">{{ works.name }}</nuxt-link>
|
|
|
+ <div class="works-description">{{ works.description }}</div>
|
|
|
+ <div class="more-info-wrapper">
|
|
|
+ <div class="price-info">
|
|
|
+ <span class="works-price">¥{{ works.price }}</span>
|
|
|
+ <span class="download-count">{{ works.down_num }}人已下载</span>
|
|
|
+ </div>
|
|
|
+ <div class="more-info">
|
|
|
+ <img class="plus-img" src="@/assets/img/works/plus-icon@2x.png" alt="">
|
|
|
+ <span class="plus-count">{{ works.plus_co }}</span>
|
|
|
+ <span class="time">{{ works.update_time }}</span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <nuxt-link class="works-user-wrapper" :to="`/wo/${works.uid}`">
|
|
|
+ <img class="user-avatar" :src="works.icon_url" alt="avatar">
|
|
|
+ <div class="username">{{ works.nickname }}</div>
|
|
|
+ <div class="company">{{ works.company }} {{ works.kill_title || '' }}</div>
|
|
|
+ </nuxt-link>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="pagination-wrapper" v-if="pagination.total > pagination.pagesize">
|
|
|
+ <el-pagination
|
|
|
+ background
|
|
|
+ layout="prev, pager, next"
|
|
|
+ :current-page="pagination.page"
|
|
|
+ :total="pagination.total"
|
|
|
+ :page-size="pagination.pagesize"
|
|
|
+ @current-change="handlePageChange">
|
|
|
+ </el-pagination>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="works-wrapper-mobile" v-else>
|
|
|
+ 作品资源列表 mobile
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+export default {
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ categoryAll: [],
|
|
|
+ categoryList: [],
|
|
|
+ worksList: [],
|
|
|
+ currentCategoryIndex: 0,
|
|
|
+ categoryExpanded: false,
|
|
|
+ firstLoad: true,
|
|
|
+ loadingWorksList: false,
|
|
|
+ pagination: {
|
|
|
+ page: 1,
|
|
|
+ keywords: '',
|
|
|
+ cate_id_two: [],
|
|
|
+ // 非接口参数
|
|
|
+ pagesize: 20,
|
|
|
+ total: 0
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async asyncData ({...params}) {
|
|
|
+ return {
|
|
|
+ mobile: params.app.$deviceType.isMobile()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted () {
|
|
|
+ const self = this
|
|
|
+ const getWorksCategoryPromise = this._getWorksCategory()
|
|
|
+ const getWorksListPromise = this._getWorksList()
|
|
|
+
|
|
|
+ Promise.all([getWorksCategoryPromise, getWorksListPromise]).then(([a, b]) => {
|
|
|
+ console.log(a, b)
|
|
|
+ self.firstLoad = false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ /**
|
|
|
+ * 获取作品资源分类
|
|
|
+ */
|
|
|
+ _getWorksCategory () {
|
|
|
+ const self = this
|
|
|
+ const promise = new Promise((resolve, reject) => {
|
|
|
+ self.$axios.$post('/api/user_works/cate').then(res => {
|
|
|
+ if (res.status === 1) {
|
|
|
+ let categoryAll = []
|
|
|
+ self.categoryList = res.data || []
|
|
|
+ self.categoryList.forEach(category => {
|
|
|
+ if (category.child && category.child.length) {
|
|
|
+ category.child.forEach(categoryChild => {
|
|
|
+ categoryAll.push( categoryChild)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ self.categoryAll = categoryAll
|
|
|
+ }
|
|
|
+ resolve()
|
|
|
+ }).catch(err => {
|
|
|
+ reject(err)
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
+ return promise
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 获取作品列表
|
|
|
+ */
|
|
|
+ _getWorksList () {
|
|
|
+ const self = this
|
|
|
+
|
|
|
+ if (!this.firstLoad) {
|
|
|
+ this.loadingWorksList = true
|
|
|
+ }
|
|
|
+
|
|
|
+ const data = {
|
|
|
+ page: this.pagination.page,
|
|
|
+ keywords: this.pagination.keywords,
|
|
|
+ cate_id_two: this.pagination.cate_id_two.join(',')
|
|
|
+ }
|
|
|
+
|
|
|
+ const promise = new Promise((resolve, reject) => {
|
|
|
+ self.$axios.$post('/api/user_works/workFileList', data).then(res => {
|
|
|
+ if (res.status === 1) {
|
|
|
+ self.worksList = res.data.list || []
|
|
|
+ self.pagination.pagesize = res.data.pagesize || 20
|
|
|
+ self.pagination.total = res.data.total || 0
|
|
|
+ }
|
|
|
+ resolve()
|
|
|
+ }).catch(err => {
|
|
|
+ reject(err)
|
|
|
+ }).then(() => {
|
|
|
+ self.loadingWorksList = false
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
+ return promise
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 点击一级分类
|
|
|
+ */
|
|
|
+ handleClickCategoryOne (id) {
|
|
|
+ if (id !== this.currentCategoryIndex) {
|
|
|
+ this.currentCategoryIndex = id
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 点击二级分类
|
|
|
+ */
|
|
|
+ handleClickCategoryTwo (id) {
|
|
|
+ const index = this.pagination.cate_id_two.indexOf(id)
|
|
|
+ if (index > -1) {
|
|
|
+ // 已选择,移除
|
|
|
+ this.pagination.cate_id_two.splice(index, 1)
|
|
|
+ } else {
|
|
|
+ // 未选择,添加
|
|
|
+ this.pagination.cate_id_two.push(id)
|
|
|
+ }
|
|
|
+ this.pagination.page = 1
|
|
|
+
|
|
|
+ this._getWorksList()
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 展开二级分类
|
|
|
+ */
|
|
|
+ handleClickExpandCategory () {
|
|
|
+ this.categoryExpanded = !this.categoryExpanded
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 分页页码改变时
|
|
|
+ */
|
|
|
+ handlePageChange (val) {
|
|
|
+ this.pagination.page = val
|
|
|
+
|
|
|
+ this._getWorksList()
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+@import "@/assets/css/work_down/index.scss";
|
|
|
+</style>
|