| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372 |
- <template>
- <div
- :class="mobile ? 'mobileMain' : ''"
- :style="{marginTop: mainMarginTop, marginBottom: mobile ? '0px' : '30px !important'}">
- <div class="learn-wrapper" v-if="!mobile">
- <div class="learn-top">
- <div class="tabs">
- <!-- <a href="/skill/" class="tabs-item">技能服务</a> -->
- <a href="/consult/" class="tabs-item">咨询服务</a>
- <div class="tabs-item active">客栈学院</div>
- <!-- <el-button class="add-btn" @click="handleClickAdd">发布课程</el-button> -->
- </div>
- </div>
- <div class="learn-content">
- <div class="learn-list-wrapper" v-if="learnList.length">
- <div
- class="learn-item"
- v-for="item in learnList"
- :key="item.sale_id">
- <a class="cover-wrapper" :href="`/l/${item.sale_id}`">
- <img class="cover" :src="item.coverImage" alt="learnCover,cover">
- <img class="play-icon" src="@/assets/img/learn/play.png" alt="play">
- </a>
- <a class="owner-wrapper" :href="`/wo/${item.user.uid}`">
- <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>
- </template>
- <script>
- import {mapState} from "vuex"
- import DealSeoList from "@/components/learn/dealSeoList"
- import qs from "qs"
- export default {
- name: 'SeoLearnList',
- 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: {
- /** 分页获取技能列表数据 */
- _getLearnList () {
- 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,
- root_type: this.root_type
- }
- this.pagination.loading = true
- this.pagination.noMore = false
- this.$axios.$post('/api/sale/saleList', data).then(res => {
- if (Number(res.status) === 1) {
- let learnList = res.data.list || []
- learnList.forEach((item) => {
- let imageList = item.image.split(',')
- item.coverImage = imageList[0] || ''
- imageList.splice(0, 1)
- item.imageList = imageList
- })
- if (self.mobile) {
- self.learnList = self.learnList.concat(learnList)
- } else {
- self.learnList = learnList
- }
- 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.learnList = []
- window.scroll(0, 0)
- this._getLearnList()
- 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.learnList = []
- window.scroll(0, 0)
- this._getLearnList()
- },
- /** 分页页码改变时 */
- handlePageChange (val) {
- let query = {
- page: val
- }
- if (this.root_type && Number(this.root_type) > 0) {
- query.root_type = this.root_type
- }
- window.location.href = `${window.location.origin}${window.location.pathname}?${qs.stringify(query)}`
- },
- /** mobile 加载更多 */
- handleLoadMoreSkill () {
- if (this.pagination.loading) {
- return
- }
- this.pagination.page++
- this._getLearnList()
- },
- /** 点击筛选时 */
- 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.learnList = []
- window.scroll(0, 0)
- this._getLearnList()
- },
- /**
- * 点击 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}`
- }
- },
- /**
- * 点击成为讲师
- */
- handleClickAdd () {
- location.href = '/workbench/skill/index'
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- @import "@/assets/css/learn/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>
|