You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

441 lines
11 KiB

4 years ago
<template>
3 years ago
<view class="konwledge-index index">
3 years ago
<!-- <view class="header header-search acea-row row-center-wrapper"> -->
<!-- <view @click="goGoodSearch()" class="search acea-row row-middle">
3 years ago
<text class="iconfont icon-xiazai5"></text>
搜索商品
3 years ago
</view> -->
3 years ago
<!-- #ifndef H5 -->
3 years ago
<!-- <view class="qr" @click="startQr()" v-if="$deviceType !== 'weixin'">
<image src="../../static/saoyisao-icon.png" />
</view> -->
3 years ago
<!-- #endif -->
3 years ago
<!-- </view> -->
3 years ago
<view class="content-box">
3 years ago
<view class="tab-box" :class="isFixedTop ? 'fixed' : ''">
<!-- <wuc-tab :tab-list="tabList" :tabCur.sync="TabCur" @change="tabChange"
3 years ago
tab-class="text-center text-black bg-white" select-class="text-orange text-xl">
3 years ago
</wuc-tab> -->
<view class="tabs">
<scroll-view class="scroll-view_H" scroll-x="true" scroll-with-animation :scroll-left='scrollLeft'>
<view class="tab-item scroll-item" :class="index == tabSelect ? 'tab-item-active' : ''"
v-for="(item,index) in tabList" :key="item.id"
@click="tabChange(item,index)">{{item.categoryName}}</view>
</scroll-view>
</view>
<SecondMenu :menuList="secondMenu" :active.sync="active" @secondMenuClick="secondMenuClick" v-if="secondMenu.length > 0">
3 years ago
</SecondMenu>
</view>
3 years ago
<view class="bangdan-box" v-if="studyList.length > 0">
3 years ago
<view class="active-word">打卡榜</view>
3 years ago
<view class="bangdan-list">
3 years ago
<scroll-view class="scroll-view_H" scroll-x="true" v-if="studyList.length > 0">
3 years ago
<view class="bangdan-item"
:class="index%2 !== 0 ? 'bgR' : ''"
3 years ago
v-for="(item,index) in studyList" :key="index"
3 years ago
@click="toStudyDetail(item.id)">
3 years ago
<view>
<view>{{item.listName}}</view>
<view class="time">{{item.listStartTime.split(' ')[0]}} {{item.listEndTime.split(' ')[0]}}</view>
</view>
<view class="acea-row row-between-wrapper" style="width: 100%;margin-top: 30rpx;">
<view class="jifen">{{item.integral}}积分</view>
3 years ago
<view class="signin-btn">报名参加</view>
</view>
</view>
</scroll-view>
3 years ago
<!-- <view class="no-content" v-if="studyList.length == 0">暂无内容...</view> -->
4 years ago
</view>
3 years ago
</view>
<view class="knowledge-list">
3 years ago
<view class="active-word">课程</view>
<view class="no-content" v-if="courseList.length == 0">暂无内容...</view>
<view class="knowledge-item acea-row" v-for="(item,index) in courseList" :key="index" @click="toDetail(item.id)">
3 years ago
<view class="img-box">
3 years ago
<image :src="item.imageArr[0]" mode="aspectFill"></image>
3 years ago
</view>
<view class="knowledge-info-box">
<view class="title line1">{{item.courseName}}</view>
3 years ago
<view class="time">{{utils.spl(item.courseStartTime)[0]}}{{utils.spl(item.courseEndTime)[0]}}</view>
3 years ago
<view class="address">{{item.coursePlace}}</view>
<view class="type-box acea-row row-between row-middle">
3 years ago
<!-- <view class="price">{{item.courseCharge}}</view> -->
3 years ago
<!-- <view class="price">{{item.levelName}}</view> -->
<view></view>
3 years ago
<!-- <view class="price colG" v-if="item.chargeType == 0">免费</view> -->
3 years ago
<view class="signin-btn yellow">去报名</view>
3 years ago
</view>
</view>
</view>
4 years ago
</view>
</view>
3 years ago
</view>
4 years ago
</template>
3 years ago
<script module="utils" lang="wxs" src="../../utils/subutil.wxs"></script>
4 years ago
<script>
import WucTab from '@/components/wuc-tab/wuc-tab.vue';
import SecondMenu from '../knowledge/components/secondMenu.vue';
import { mapState, mapGetters, mapMutations, mapActions } from 'vuex'
3 years ago
import {
getCategory,
getArticle,
getStudyList,
getCourses
} from '@/api/knowledge';
4 years ago
export default {
computed: mapGetters(['userInfo']),
4 years ago
data() {
return {
3 years ago
windowWidth:'',
isFixedTop: false,
currentTab:null,
tabSelect:0,
scrollLeft:200,
3 years ago
tabList: [],
secondMenu: [],
active: null,
courseList: [],
studyList:[],
categoryTitle:'',
4 years ago
}
},
3 years ago
components: {
WucTab,
SecondMenu
},
3 years ago
onLoad() {
//获取节点距离顶部的距离
uni.createSelectorQuery().select('.tab-box').boundingClientRect((res) => {
if (res && res.top > 0) {
this.tabInitTop= res.top;
}
}).exec();
3 years ago
getCategory().then((res) => {
4 years ago
this.tabList = res.data
this.$set(this, 'secondMenu', res.data[0].categoryList)
3 years ago
this.$set(this, 'currentTab', res.data[0])
this.categoryTitle = res.data[0].categoryName;
3 years ago
if (res.data[0].categoryList.length > 0) {
4 years ago
this.$set(this, 'active', res.data[0].categoryList[0].id)
this.categoryTitle = this.categoryTitle +'·'+res.data[0].categoryList[0].categoryName
3 years ago
} else{
// this.$set(this, 'tabSelect', 0)
// this.scrollLeft = 0
4 years ago
}
3 years ago
}).then(() => {
this.getStudyList()
this.getCourses()
4 years ago
})
},
3 years ago
onShow() {
},
mounted() {
uni.getSystemInfo({
3 years ago
success:(res)=>{
3 years ago
this.windowWidth = res.windowWidth;
}
})
},
4 years ago
methods: {
3 years ago
onPageScroll(res) {
let scrollTop = res.scrollTop;
var isSatisfy = scrollTop >= this.tabInitTop? true : false;
//只有处于吸顶的临界值才会不相等
if (this.isFixedTop === isSatisfy) {
return false;
}
this.isFixedTop = isSatisfy
},
3 years ago
toStudyDetail(id) {
this.$yrouter.push({
path: '/pages/study/detail',
query: {
id: id,
},
})
},
toDetail(id) {
4 years ago
this.$yrouter.push({
3 years ago
path: '/pages/course/detail',
query: {
id: id,
},
4 years ago
})
},
3 years ago
getStudyList() {
3 years ago
uni.showLoading({
title:'正在加载中...'
})
4 years ago
var cid = null;
3 years ago
this.active == null ? cid = this.currentTab.id : cid = this.active
3 years ago
getStudyList({categoryId: cid,listState:0}).then((res) => {
if (res.success) {
this.studyList = res.data
}
3 years ago
uni.hideLoading()
3 years ago
})
},
getCourses() {
3 years ago
uni.showLoading({
title:'正在加载中...'
})
3 years ago
var cid = null;
3 years ago
this.active == null ? cid = this.currentTab.id : cid = this.active
getCourses({categoryId: cid,listState:0,uid:this.userInfo.uid}).then((res) => {
3 years ago
if (res.success) {
this.courseList = res.data
4 years ago
}
3 years ago
uni.hideLoading()
uni.stopPullDownRefresh()
4 years ago
})
},
3 years ago
tabChange(item,index) {
this.tabSelect = index
this.currentTab = item
this.moveTo(index)
this.categoryTitle = item.categoryName;
3 years ago
if (item.categoryList.length > 0) {
4 years ago
this.$set(this, 'active', item.categoryList[0].id)
this.categoryTitle = item.categoryList[0].categoryName;
4 years ago
}
this.secondMenu = item.categoryList;
3 years ago
this.getStudyList()
this.getCourses()
4 years ago
},
3 years ago
// 将点击元素移动到中间
moveTo(index) {
const query = uni.createSelectorQuery().in(this)
query.selectAll(`.scroll-item`).boundingClientRect(rect => {
const windowWidth = this.windowWidth // 屏幕宽度
let width = 0
// 循环获取计算当前点击的标签项距离左侧的距离
for (let i = 0; i < index; i++) {
width += rect[i].width
}
// 当大于屏幕一半的宽度则滚动,否则就设置位置为0
if (width > windowWidth / 2) {
this.scrollLeft = width + rect[index].width / 2 - windowWidth / 2
} else {
this.scrollLeft = 0
}
}).exec()
},
3 years ago
secondMenuClick(item) {
4 years ago
this.active = item.id;
this.categoryTitle = item.categoryName;
3 years ago
this.getStudyList()
this.getCourses()
3 years ago
},
onPullDownRefresh() {
3 years ago
this.getStudyList()
this.getCourses()
4 years ago
}
}
}
</script>
<style scoped lang="less">
3 years ago
.header{
.qr {
width: 36rpx;
height: 38rpx;
image{
width: 36rpx;
height: 38rpx;
}
}
}
4 years ago
.header-search {
transition: all linear 0.3s;
background: #fff;
3 years ago
.search {
4 years ago
border: 2rpx solid #EA533E;
background-color: #fff;
}
}
3 years ago
.colG{
color: #8FB85B !important;
}
3 years ago
.content-box{
width: 100%;
box-sizing: border-box;
.tab-box{
box-shadow: 0px 6px 12px 0px rgba(227,227,227,0.29);
3 years ago
.tabs{
width:auto;
height: 96rpx;
padding-left: 20rpx;
background: #fff;
.scroll-view_H{
white-space: nowrap;
width: 100%;
height: 96rpx;
}
.tab-item{
height: 96rpx;
line-height: 96rpx;
display: inline-block;
margin-right: 40rpx;
font-size: 32rpx;
color: #999999;
}
.tab-item-active{
3 years ago
color: #F99C10;
border-bottom: 2px solid #F99C10;
3 years ago
font-weight: bold;
}
}
3 years ago
}
/deep/.second-menu-box{
padding: 30rpx 32rpx;
4 years ago
}
3 years ago
.fixed{
position: -webkit-sticky;
position: sticky;
top: 0;
z-index: 99;
}
}
.active-word{
font-size: 34rpx;
}
.no-content{
font-size: 28rpx;
color: #666666;
text-align: center;
padding: 30rpx 0;
3 years ago
}
.bangdan-box{
width: 100%;
box-sizing: border-box;
padding-left: 30rpx;
3 years ago
margin-top: 30rpx;
3 years ago
.scroll-view_H{
white-space: nowrap;
4 years ago
width: 100%;
3 years ago
}
3 years ago
.bangdan-list{
padding: 16rpx 0 0;
}
3 years ago
.bangdan-item{
width: 514rpx;
height: 234rpx;
box-sizing: border-box;
padding: 20rpx;
color: #fff;
display: inline-block;
background: linear-gradient(165deg, #3ABFB8 0%, #7CE1DD 100%);
border-radius: 10rpx;
font-size: 34rpx;
margin-right: 20rpx;
3 years ago
display: inline-block;
3 years ago
.time{
font-size: 24rpx;
color: #FFFFFF;
line-height: 40rpx;
margin:10rpx 0 18rpx;
}
.jifen{
font-size: 46rpx;
font-weight: 500;
4 years ago
}
3 years ago
.signin-btn{
width: 180rpx;
height: 68rpx;
background: #FFFFFF;
border-radius: 40rpx;
text-align: center;
line-height: 68rpx;
color: #222222;
4 years ago
font-size: 26rpx;
}
}
3 years ago
.bgR{
background: linear-gradient(165deg, #FF7563 0%, #FEABA0 100%);
}
}
.konwledge-index {
min-height: 100%;
width: 100%;
background: #fff;
.knowledge-list {
4 years ago
width: 100%;
3 years ago
padding:0 32rpx;
3 years ago
margin-top: 30rpx;
3 years ago
.knowledge-item {
background: #fff;
3 years ago
padding: 16rpx 0;
4 years ago
border-bottom: 1px solid #ECECEC;
3 years ago
.img-box {
4 years ago
width: 204rpx;
height: 200rpx;
margin-right: 30rpx;
3 years ago
image {
4 years ago
width: 100%;
height: 100%;
3 years ago
border-radius: 10rpx;
4 years ago
}
}
3 years ago
.knowledge-info-box {
4 years ago
width: calc(100% - 234rpx);
3 years ago
.title {
3 years ago
font-size: 32rpx;
4 years ago
color: #333;
font-size: 500;
line-height: 40rpx;
}
3 years ago
.time,.address{
color: #999;
font-size: 24rpx;
margin-top: 5rpx;
line-height: 34rpx;
}
.intro {
4 years ago
font-size: 28rpx;
color: #999999;
line-height: 40rpx;
margin: 8rpx 0 36rpx;
}
3 years ago
.type-box {
4 years ago
font-size: 24rpx;
color: #999;
3 years ago
margin-top: 20rpx;
3 years ago
.price{
3 years ago
font-size: 28rpx;
3 years ago
color: #EA533E;
}
.signin-btn{
width: 156rpx;
height: 60rpx;
4 years ago
text-align: center;
3 years ago
line-height: 60rpx;
background: #FFEAE7;
border-radius: 12rpx;
font-size: 32rpx;
}
.red{
background: #FFEAE7;
color: #EE7060;
4 years ago
}
3 years ago
.blue {
4 years ago
color: #6E85EB;
3 years ago
background: #ECEFFD;
4 years ago
}
3 years ago
.yellow {
4 years ago
color: #F99C10;
background: #FFEDCC;
}
}
}
}
3 years ago
.knowledge-item:nth-last-child(1){
border: none;
}
4 years ago
}
}
</style>