123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <template>
- <view>
- <uni-section title="已发布课程" type="line"></uni-section>
- <uni-swipe-action>
- <template v-for="(item, index) in courses" >
- <uni-swipe-action-item :threshold="0" :right-options="options" @click="bindClick(item.courseId)">
- <uni-list :border="true">
- <!-- 显示圆形头像 -->
- <uni-list-chat :avatar-circle="true" :title="item.subject"
- :avatar="item.image"
- :note="item.deal" :time="item.datetime"></uni-list-chat>
- </uni-list>
- </uni-swipe-action-item>
- </template>
- </uni-swipe-action>
-
- <uni-fab :pattern="pattern" horizontal="left" vertical="bottom"
- :direction="direction" @fabClick="fabClick" />
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- options: [{
- text: '删除',
- style: {
- backgroundColor: '#F56C6C'
- }
- }],
- publishCourse: {
- course: '',
- introduce: '',
- avatar: '',
- time: ''
- },
- courses: [],
- pattern: {
- color: '#7A7E83',
- backgroundColor: '#fff',
- selectedColor: '#C00000',
- buttonColor: '#C00000',
- iconColor: '#fff'
- }
- }
- },
- created() {
- this.getCourses()
- },
- methods: {
- // 点击悬浮按钮
- async fabClick() {
- // 查询是否有正在审核的课程
- const {
- data: result
- } = await uni.$http.get('/education/teacher-courses/queryPersonVerifyCourse')
- if (result.data.flag) {
- return uni.$showMsg("正在审核中,请耐心等候")
- }
-
- // 查询未成交的课程
- const {
- data: result1
- } = await uni.$http.get('/education/teacher-courses/queryPersonNoDeal')
- if (result1.data.count >= 4) {
- return uni.$showMsg("最多同时发布4门课程")
- }
- uni.navigateTo({
- url:'/subpkg/add_course/add_course'
- })
- },
- // 查询个人发布成功的课程
- async getCourses() {
- const { data: result } = await uni.$http.get('/education/teacher-courses/showPersonCourse')
- this.courses = result.data.courses
- if (this.courses.length > 0) {
- for(let i = 0; i < this.courses.length; i++) {
- let dateArray = this.courses[i].datetime.split(' ')
- this.courses[i].datetime = dateArray[0]
- this.courses[i].image = '/static/c' + (i+1) +'.png'
- console.log(this.courses[i])
- }
- }
- },
- // 点击删除
- async bindClick(courseId) {
- const query = {
- courseId: courseId
- }
- const { data: result } = await uni.$http.get('/education/teacher-courses/deletePersonCourse', query)
- console.log(result)
- uni.$showMsg(result.message)
- this.getCourses()
- },
- }
- }
- </script>
- <style scoped lang="scss">
- </style>
|