|
|
|
<template>
|
|
|
|
<view>
|
|
|
|
<view class="filter">
|
|
|
|
<uni-search-bar class="search" radius="30" placeholder="请输入课程名称" v-model="keyword" clearButton="auto" cancelButton="none" />
|
|
|
|
</view>
|
|
|
|
|
|
|
|
<ul class="tab-wrap">
|
|
|
|
<scroll-view scroll-x :scroll-left="scrollLeft" class="tab tab-scroll">
|
|
|
|
<li v-for="(tab, i) in tabs" :key="i" :class="{active: curTab === tab.classificationId}" @click="tabChange(tab.classificationId)">{{ tab.classificationName }}</li>
|
|
|
|
</scroll-view>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<ul class="list">
|
|
|
|
<li v-for="(item, i) in list" :key="i" @click="toDetail(item)">
|
|
|
|
<image class="cover" :src="item.coverUrl"></image>
|
|
|
|
<view class="name">{{ item.goodsName }}</view>
|
|
|
|
<view class="entry">进入课程</view>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<uni-popup ref="alertDialog">
|
|
|
|
<uni-forms>
|
|
|
|
<uni-forms-item label="真实姓名">
|
|
|
|
<uni-easyinput type="text" v-model.trim="form.account" placeholder="请输入真实姓名" />
|
|
|
|
</uni-forms-item>
|
|
|
|
<uni-forms-item label="学号">
|
|
|
|
<uni-easyinput type="text" v-model.trim="form.account" placeholder="请输入学号" />
|
|
|
|
</uni-forms-item>
|
|
|
|
</uni-forms>
|
|
|
|
<button class="btn" type="primary" @click="realNameSubmit">确认</button>
|
|
|
|
</uni-popup>
|
|
|
|
</view>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { schoolCourse, recentUse, getSchoolCourseAuthority } from '@/apis/modules/course.js'
|
|
|
|
import { checkUserNameOrWorkNumber } from '@/apis/modules/user.js'
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
curTab: 0,
|
|
|
|
tabs: [],
|
|
|
|
scrollLeft: 0,
|
|
|
|
reachBottom: 0, // 是否是上拉加载。0->否,1->是,-1->加载完所有数据
|
|
|
|
status: 'more', // 上拉加载状态 more|loading|noMore
|
|
|
|
searchTimer: null,
|
|
|
|
sort: 0,
|
|
|
|
keyword: '',
|
|
|
|
list: [],
|
|
|
|
page: 1,
|
|
|
|
pageSize: 10,
|
|
|
|
total: 0,
|
|
|
|
realNameForm: {
|
|
|
|
userName: '',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
keyword () {
|
|
|
|
clearTimeout(this.searchTimer)
|
|
|
|
this.searchTimer = setTimeout(() => {
|
|
|
|
this.initList()
|
|
|
|
}, 500)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 下拉刷新
|
|
|
|
onPullDownRefresh() {
|
|
|
|
this.initList()
|
|
|
|
setTimeout(() => {
|
|
|
|
uni.stopPullDownRefresh()
|
|
|
|
}, 1500)
|
|
|
|
},
|
|
|
|
onShow() {
|
|
|
|
// uni.setStorageSync('token', 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJsb2dpblR5cGUiOiJsb2dpbiIsImxvZ2luSWQiOjM5NTc2LCJyblN0ciI6Ik5vcTB1UlNEZ0V0UExOUzBSUWtSZHlVVGsxOFYycnpNIiwiYWNjb3VudElkIjozOTU3NiwidXNlcklkIjozOTU3NSwic2Nob29sSWQiOjI4NDYsInVzZXJOYW1lIjoiYWMiLCJwbGF0Zm9ybUlkIjoiMSJ9.-YiaJdr5H2j6TGezs1eDS1EX5bNYCWGGghRw6eD3jk4')
|
|
|
|
this.handleRealName()
|
|
|
|
this.getTab()
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
// 课程列表
|
|
|
|
async getList() {
|
|
|
|
// 最近使用
|
|
|
|
if (this.curTab === 0) {
|
|
|
|
const { page } = await recentUse({
|
|
|
|
pageNum: 1,
|
|
|
|
pageSize: 100,
|
|
|
|
goodsName: this.keyword,
|
|
|
|
})
|
|
|
|
this.list = page.records
|
|
|
|
} else {
|
|
|
|
const { data } = await schoolCourse({
|
|
|
|
authority: this.curTab === -1 ? '' : this.curTab,
|
|
|
|
goodsName: this.keyword,
|
|
|
|
})
|
|
|
|
this.list = data
|
|
|
|
}
|
|
|
|
},
|
|
|
|
initList() {
|
|
|
|
this.page = 1
|
|
|
|
this.reachBottom = 0
|
|
|
|
this.getList()
|
|
|
|
},
|
|
|
|
// 获取tab
|
|
|
|
async getTab () {
|
|
|
|
const { data } = await getSchoolCourseAuthority()
|
|
|
|
this.tabs = [
|
|
|
|
{
|
|
|
|
classificationId: 0,
|
|
|
|
classificationName: '最近使用',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
classificationId: -1,
|
|
|
|
classificationName: '全部',
|
|
|
|
},
|
|
|
|
...data,
|
|
|
|
]
|
|
|
|
this.getList()
|
|
|
|
},
|
|
|
|
// 提示填写姓名(登录后调用一次)
|
|
|
|
async handleRealName () {
|
|
|
|
const res = await checkUserNameOrWorkNumber()
|
|
|
|
// 如果没有真实姓名,则弹框提示填写
|
|
|
|
if (!res.hasName) this.$refs.alertDialog.open()
|
|
|
|
},
|
|
|
|
// tab切换
|
|
|
|
tabChange(id) {
|
|
|
|
this.curTab = id
|
|
|
|
this.initList()
|
|
|
|
},
|
|
|
|
// 真实姓名提交
|
|
|
|
async realNameSubmit() {
|
|
|
|
const form = this.realNameForm
|
|
|
|
if (!form.userName) return this.$util.errMsg('请输入真实姓名!')
|
|
|
|
const { token, teamId } = await weChatToken({
|
|
|
|
...form,
|
|
|
|
openid: this.openid,
|
|
|
|
phone: this.phone
|
|
|
|
})
|
|
|
|
uni.removeStorageSync('realNameTiped')
|
|
|
|
uni.setStorageSync('token', data.token)
|
|
|
|
uni.reLaunch({
|
|
|
|
url: '../index/index'
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 跳转详情
|
|
|
|
toDetail(item) {
|
|
|
|
this.$util.to(`/course/courseDetail/courseDetail?cid=${item.cid}&mallId=${item.mallId}`)
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
.tab-wrap {
|
|
|
|
display: flex;
|
|
|
|
.tab-scroll {
|
|
|
|
white-space: nowrap;
|
|
|
|
li {
|
|
|
|
display: inline-block;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.list {
|
|
|
|
display: flex;
|
|
|
|
flex-wrap: wrap;
|
|
|
|
padding: 40rpx 30rpx 30rpx;
|
|
|
|
li {
|
|
|
|
width: calc(50% - 16rpx);
|
|
|
|
padding: 24rpx;
|
|
|
|
margin: 0 30rpx 52rpx 0;
|
|
|
|
border-radius: 16rpx;
|
|
|
|
background-color: #fff;
|
|
|
|
box-sizing: border-box;
|
|
|
|
&:nth-child(2n) {
|
|
|
|
margin-right: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.cover {
|
|
|
|
width: 100%;
|
|
|
|
height: 160rpx;
|
|
|
|
margin-top: -50rpx;
|
|
|
|
border-radius: 20rpx;
|
|
|
|
object-fit: cover;
|
|
|
|
}
|
|
|
|
.name {
|
|
|
|
display: -webkit-box;
|
|
|
|
-webkit-box-orient: vertical;
|
|
|
|
-webkit-line-clamp: 2;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
overflow: hidden;
|
|
|
|
height: 76rpx;
|
|
|
|
margin: 10rpx 0 16rpx;
|
|
|
|
font-size: 28rpx;
|
|
|
|
color: #333;
|
|
|
|
|
|
|
|
}
|
|
|
|
.entry {
|
|
|
|
font-size: 28rpx;
|
|
|
|
line-height: 1.9;
|
|
|
|
color: #333;
|
|
|
|
text-align: center;
|
|
|
|
border: 1px solid #dadada;
|
|
|
|
border-radius: 40rpx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|