| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536 |
- <template>
- <div
- :class="mobile ? 'mobileMain' : ''"
- :style="{marginTop: mainMarginTop, marginBottom: mobile ? '0px' : '30px !important'}">
- <div class="skill-wrapper" v-if="!mobile">
- <div class="skill-top">
- <div class="tabs">
- <div class="tabs-item active">技能培训</div>
- <a href="/consult/" class="tabs-item">咨询服务</a>
- </div>
- <div class="skill-category-wrapper">
- <!-- <div class="category-title">技术分类</div> -->
- <!-- 一级分类内容 -->
- <div
- class="category-one-wrapper"
- :class="categoryExpanded ? 'expand' : ''">
- <!-- 更多 -->
- <!-- <div
- class="category-more"
- @click="handleClickExpandCategory">{{ categoryExpanded ? '收起' : '更多' }}</div> -->
- <!-- 全部 -->
- <a
- href="/learn/"
- class="category-one-item"
- :class="pagination.selectedCateIdOne == '' ? 'active' : ''">全部</a>
- <!-- 一级分类 -->
- <a
- v-for="categoryOne in skillCate"
- :key="categoryOne.value"
- class="category-one-item"
- :class="pagination.selectedCateIdOne == categoryOne.value ? 'active' : ''"
- :href="`/learn/${categoryOne.value}/`">{{ categoryOne.label }}</a>
- </div>
- <!-- 二级分类内容 -->
- <div class="category-two-wrapper">
- <div
- class="category-two-content"
- v-for="categoryOne in skillCate"
- :key="`cate-two-parnet${categoryOne.value}`"
- v-show="pagination.selectedCateIdOne == categoryOne.value">
- <a
- class="category-two-item"
- :class="pagination.selectedCateIdTwo == categoryTwo.value ? 'active' : ''"
- :href="`/learn/${categoryTwo.value}/`"
- v-for="categoryTwo in categoryOne.children"
- :key="`cate-two-${categoryTwo.value}`">{{ categoryTwo.label }}</a>
- </div>
- </div>
- </div>
- </div>
- <div class="skill-content">
- <div class="skill-list-wrapper" v-if="skillList.length">
- <div
- class="skill-item"
- v-for="item in skillList"
- :key="item.sale_id">
- <a :href="`/l/${item.sale_id}`">
- <img class="cover" :src="item.coverImage" alt="skillCover,cover">
- </a>
- <a class="owner-wrapper" :href="`/wo/${item.user.uid}/skill`">
- <img class="avatar" :src="item.user.icon_url" alt="avatar">
- <div class="nickname">{{ item.user.nickname }}</div>
- </a>
- <a class="title" :href="`/l/${item.sale_id}`">{{ item.title }}</a>
- <div class="price-wrapper">
- <div class="price-text">¥{{ item.price }}</div>
- <div v-if="item.buy_num>0" class="buy-num">{{ item.buy_num }}人已学习</div>
- </div>
- </div>
- </div>
- <div class="result-empty-wrapper" v-else>
- <img src="@/assets/img/common/empty@2x.png" alt="empty">
- <span>暂无搜索内容</span>
- </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>
- <div class="skill-wrapper-mobile" v-else>
- <div class="skill-category">
- <div class="skill-category-one">
- <div class="category-scroller">
- <div
- class="skill-category-one-item"
- :class="!pagination.selectedCateIdOne ? 'active' : ''"
- @click="handleClickCategoryOne(0)">
- 全部
- </div>
- <div
- class="skill-category-one-item"
- :class="pagination.selectedCateIdOne == category.value ? 'active' : ''"
- v-for="(category) in skillCate"
- :key="`category-one-${category.value}`"
- @click="handleClickCategoryOne(category.value)">
- {{ category.label }}
- </div>
- </div>
- <!-- filter -->
- <div class="filter-bg"></div>
- <div class="filter-wrapper" @click="handleShowCategoryDrawer">
- <img src="@/assets/img/works/filter-icon@2x.png" alt="filter">
- </div>
- </div>
- <div class="skill-category-two">
- <!-- 全部二级分类 -->
- <div
- class="skill-category-two-wrapper"
- v-show="!pagination.selectedCateIdOne">
- <div
- class="skill-category-two-item"
- :class="pagination.selectedCateIdTwo == category.value ? 'active' : ''"
- v-for="category in skillCateAll"
- :key="`category-all-${category.value}`"
- @click="handleClickCategoryTwo(category.value)">
- {{ category.label }}
- </div>
- </div>
- <!-- 接口返回的二级分类 -->
- <div
- class="skill-category-two-wrapper"
- v-for="(category) in skillCate"
- :key="`category-two-wrapper-${category.value}`"
- v-show="pagination.selectedCateIdOne === category.value">
- <div
- class="skill-category-two-item"
- :class="pagination.selectedCateIdTwo == categoryChild.value ? 'active' : ''"
- v-for="categoryChild in category.children"
- :key="`category-two-${categoryChild.value}`"
- @click="handleClickCategoryTwo(categoryChild.value)">
- {{ categoryChild.label }}
- </div>
- </div>
- </div>
- </div>
- <div class="skill-list" :class="showWxHeader ? 'skill-list__showWxHeader' : ''">
- <ul
- class="skill-list-wrapper"
- v-infinite-scroll="handleLoadMoreSkill"
- :infinite-scroll-disabled="pagination.noMore"
- :infinite-scroll-immediate="false">
- <div
- class="skill-item"
- v-for="item in skillList"
- :key="item.sale_id"
- @click="handleClickSkillItem(item.sale_id)">
- <img class="cover" :src="item.coverImage" alt="skillCover,cover">
- <div class="owner-wrapper">
- <img class="avatar" :src="item.user.icon_url" alt="avatar">
- <div class="nickname">{{ item.user.nickname }}</div>
- </div>
- <div class="title">{{ item.title }}</div>
- <div class="price-wrapper">
- <div class="price-text">¥{{ item.price }}</div>
- <div class="right-info">{{ item.buy_num }}人已学习</div>
- </div>
- </div>
- <!-- 空数据 -->
- <div class="result-empty-wrapper" v-if="!skillList.length && !pagination.loading">
- <img src="@/assets/img/common/empty@2x.png" alt="empty">
- <span>暂无搜索内容</span>
- </div>
- <p v-if="pagination.loading" class="skill-list-tips">加载中...</p>
- <p v-if="skillList.length && pagination.noMore" class="skill-list-tips">没有更多了</p>
- </ul>
- </div>
- <!-- 弹出的分类选择 -->
- <el-drawer
- ref="categoryDrawer"
- class="category-drawer"
- :visible.sync="showCategoryDrawer"
- direction="ttb"
- :withHeader="false">
- <div class="drawer-category-one">
- <div
- class="drawer-category-one-item"
- :class="currentDrawerCategoryIndex === 0 ? 'active' : ''"
- @click="handleClickDrawerCategoryOne(0)">
- 全部
- </div>
- <div
- class="drawer-category-one-item"
- :class="currentDrawerCategoryIndex === index + 1 ? 'active' : ''"
- v-for="(category, index) in skillCate"
- :key="`drawer-category-one-${category.value}`"
- @click="handleClickDrawerCategoryOne(index + 1)">
- {{ category.label }}
- </div>
- </div>
- <div class="drawer-category-two">
- <!-- 全部二级分类 -->
- <div
- class="drawer-category-two-wrapper"
- v-show="currentDrawerCategoryIndex === 0">
- <div
- class="drawer-category-two-item"
- :class="currentDrawerCategoryId == category.value ? 'active' : ''"
- v-for="category in skillCateAll"
- :key="`drawer-category-all-${category.value}`"
- @click="handleClickDrawerCategoryTwo(category.value)">
- {{ category.label }}
- </div>
- </div>
- <!-- 接口返回的二级分类 -->
- <div
- class="drawer-category-two-wrapper"
- v-for="(category, index) in skillCate"
- :key="`drawer-category-two-wrapper-${category.value}`"
- v-show="currentDrawerCategoryIndex === index + 1">
- <div
- class="drawer-category-two-item"
- :class="currentDrawerCategoryId == categoryChild.value ? 'active' : ''"
- v-for="categoryChild in category.children"
- :key="`drawer-category-two-${categoryChild.value}`"
- @click="handleClickDrawerCategoryTwo(categoryChild.value)">
- {{ categoryChild.label }}
- </div>
- </div>
- </div>
- </el-drawer>
- </div>
- </div>
- </template>
- <script>
- import {mapState} from "vuex"
- import DealSeoList from "@/components/skill/dealSeoList"
- export default {
- name: 'SeoSkillList',
- data () {
- return {
- baseUrl: '',
- // firstLoad: true,
- isWeixinApp: true,
- categoryExpanded: true, // 更多按钮不要,默认为展开状态
- showCategoryDrawer: false,
- currentDrawerCategoryId: 0,
- currentDrawerCategoryIndex: 0
- }
- },
- head() {
- const {
- title = "",
- keyword = "",
- description = "",
- h1 = "",
- canonical = "",
- metaLocation
- } = this.head || {}
- let obj = {
- title: title,
- meta: [{
- name: "keywords",
- content: keyword
- }, {
- name: "description",
- content: description
- }, {
- name: "h1",
- content: h1
- }],
- link: [{rel: "canonical", href: canonical}]
- }
- if (metaLocation) {
- obj.meta.push({name: "location", content: metaLocation})
- }
- return obj
- },
- computed: {
- ...mapState(["deviceType"]),
- showWxHeader () {
- return !this.deviceType.app && !this.isWeixinApp &&
- (this.deviceType.android || this.deviceType.ios)
- },
- mainMarginTop () {
- if (this.mobile && this.showWxHeader) {
- return '64px !important'
- } else if (this.mobile) {
- return '0px !important'
- } else {
- return '20px !important'
- }
- }
- },
- async asyncData ({...params}) {
- let dealDataObj = new DealSeoList(params)
- let ans = await dealDataObj.dealData()
- return {
- ...ans
- }
- },
- mounted () {
- this.baseUrl = this.$store.state.domainConfig.siteUrl
- this.isWeixinApp = navigator.userAgent.indexOf("miniProgram") > -1
- },
- methods: {
- /** 分页获取技能列表数据 */
- _getSkillList () {
- const self = this
- const data = {
- type: 1,
- page: this.pagination.page,
- page_size: this.pagination.pagesize,
- cate_id: this.pagination.selectedCateIdTwo,
- status: 2,
- owner_type: 1
- }
- this.pagination.loading = true
- this.pagination.noMore = false
- this.$axios.$post('/api/sale/saleList', data).then(res => {
- if (Number(res.status) === 1) {
- let skillList = res.data.list || []
- skillList.forEach((item) => {
- let imageList = item.image.split(',')
- item.coverImage = imageList[0] || ''
- imageList.splice(0, 1)
- item.imageList = imageList
- })
- if (self.mobile) {
- self.skillList = self.skillList.concat(skillList)
- } else {
- self.skillList = skillList
- }
- self.pagination.total = res.data.total
- self.pagination.pagesize = res.data.page_size || 9
- if (self.pagination.page * self.pagination.pagesize >= self.pagination.total) {
- console.log('noMore true', self.pagination)
- self.pagination.noMore = true
- } else {
- console.log('noMore false', self.pagination)
- self.pagination.noMore = false
- }
- }
- }).then(() => {
- self.pagination.loading = false
- })
- },
- /** 点击展开、收起 */
- handleClickExpandCategory () {
- this.categoryExpanded = !this.categoryExpanded
- },
- /** 点击一级分类时 */
- handleClickCategoryOne (id) {
- if (id === 0) {
- // 点击全部时,移除筛选分类
- this.pagination.selectedCateIdOne = id
- this.pagination.selectedCateIdTwo = ''
- this.currentDrawerCategoryId = ''
- this.pagination.page = 1
- this.skillList = []
- window.scroll(0, 0)
- this._getSkillList()
- return
- }
- if (this.pagination.selectedCateIdOne !== id) {
- this.pagination.selectedCateIdOne = id
- }
- },
- /** 点击二级分类时:移动端 */
- handleClickCategoryTwo (id) {
- if (this.pagination.selectedCateIdTwo === id) {
- this.pagination.selectedCateIdTwo = ''
- this.currentDrawerCategoryId = ''
- } else {
- this.pagination.selectedCateIdTwo = id
- this.currentDrawerCategoryId = id
- }
- this.pagination.page = 1
- this.skillList = []
- window.scroll(0, 0)
- this._getSkillList()
- },
- /** 分页页码改变时 */
- handlePageChange (val) {
- window.location.href = `${window.location.origin}${window.location.pathname}?page=${val}`
- },
- /** mobile 加载更多 */
- handleLoadMoreSkill () {
- if (this.pagination.loading) {
- return
- }
- this.pagination.page++
- this._getSkillList()
- },
- /** 点击筛选时 */
- handleShowCategoryDrawer () {
- this.showCategoryDrawer = true
- },
- /**
- * 点击 mobile 分类 drawer 一级分类
- */
- handleClickDrawerCategoryOne (id) {
- if (id === 0) {
- this.showCategoryDrawer = false
- return
- }
- if (id !== this.currentDrawerCategoryIndex) {
- this.currentDrawerCategoryIndex = id
- }
- },
- /**
- * 点击 mobile 分类 drawer 二级分类
- */
- handleClickDrawerCategoryTwo (id) {
- if (this.currentDrawerCategoryId === id) {
- this.pagination.selectedCateIdTwo = ''
- } else {
- this.pagination.selectedCateIdTwo = id
- }
- this.currentDrawerCategoryId = id
- this.showCategoryDrawer = false
- this.pagination.page = 1
- this.skillList = []
- window.scroll(0, 0)
- this._getSkillList()
- },
- /**
- * 点击 mobile 的一项技能时
- */
- handleClickSkillItem (saleId) {
- if (this.deviceType.android || this.deviceType.ios) {
- // 端跳转
- let jumpUrl = `${this.baseUrl}/l/${saleId}`
- location.href = `proginn://webview?url=${jumpUrl}`
- } else {
- // web 跳转
- location.href = `/l/${saleId}`
- }
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- @import "@/assets/css/skill/list.scss";
- </style>
- <style lang="scss">
- .category-drawer {
- .el-drawer {
- height: 100vh !important;
- .el-drawer__body {
- position: relative;
- width: 100%;
- display: flex;
- }
- }
- .drawer-category-one {
- width: 100px;
- height: 100vh;
- padding-bottom: 34px;
- background: #f4f5f9;
- overflow-x: hidden;
- overflow-y: auto;
- -webkit-overflow-scrolling: touch;
- &::-webkit-scrollbar {
- display: none;
- }
- .drawer-category-one-item {
- width: 100%;
- height: 50px;
- line-height: 50px;
- text-align: center;
- font-size: 15px;
- font-family: PingFangSC, PingFangSC-Medium;
- font-weight: 500;
- color: #222222;
- background: inherit;
- &.active {
- color: #308eff;
- background: #ffffff;
- }
- }
- }
- .drawer-category-two {
- width: calc(100% - 100px);
- height: 100vh;
- padding: 4px 10px 34px;
- background: #ffffff;
- overflow-x: hidden;
- overflow-y: auto;
- -webkit-overflow-scrolling: touch;
- &::-webkit-scrollbar {
- display: none;
- }
- .drawer-category-two-wrapper {
- width: 100%;
- display: flex;
- flex-wrap: wrap;
- .drawer-category-two-item {
- margin: 8px 8px 0 0;
- padding: 0 12px;
- height: 35px;
- line-height: 35px;
- background: rgba(244,245,249,.8);
- border-radius: 4px;
- // opacity: 0.8;
- font-size: 13px;
- font-family: PingFangSC, PingFangSC-Regular;
- font-weight: 400;
- color: #222222;
- &.active {
- height: 33px;
- line-height: 33px;
- border: 1px solid #308eff;
- background: #ffffff;
- font-size: 12px;
- font-family: PingFangSC, PingFangSC-Medium;
- font-weight: 500;
- color: #308eff;
- }
- }
- }
- }
- }
- .wx-header-custom-list {
- position: fixed !important;
- z-index: 11 !important;
- }
- </style>
|