course_publish.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <view>
  3. <uni-section title="已发布课程" type="line"></uni-section>
  4. <uni-swipe-action>
  5. <template v-for="(item, index) in courses" >
  6. <uni-swipe-action-item :threshold="0" :right-options="options" @click="bindClick(item.courseId)">
  7. <uni-list :border="true">
  8. <!-- 显示圆形头像 -->
  9. <uni-list-chat :avatar-circle="true" :title="item.subject"
  10. :avatar="item.image"
  11. :note="item.deal" :time="item.datetime"></uni-list-chat>
  12. </uni-list>
  13. </uni-swipe-action-item>
  14. </template>
  15. </uni-swipe-action>
  16. <uni-fab :pattern="pattern" horizontal="left" vertical="bottom"
  17. :direction="direction" @fabClick="fabClick" />
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. data() {
  23. return {
  24. options: [{
  25. text: '删除',
  26. style: {
  27. backgroundColor: '#F56C6C'
  28. }
  29. }],
  30. publishCourse: {
  31. course: '',
  32. introduce: '',
  33. avatar: '',
  34. time: ''
  35. },
  36. courses: [],
  37. pattern: {
  38. color: '#7A7E83',
  39. backgroundColor: '#fff',
  40. selectedColor: '#C00000',
  41. buttonColor: '#C00000',
  42. iconColor: '#fff'
  43. }
  44. }
  45. },
  46. created() {
  47. this.getCourses()
  48. },
  49. methods: {
  50. // 点击悬浮按钮
  51. async fabClick() {
  52. // 查询是否有正在审核的课程
  53. const {
  54. data: result
  55. } = await uni.$http.get('/education/teacher-courses/queryPersonVerifyCourse')
  56. if (result.data.flag) {
  57. return uni.$showMsg("正在审核中,请耐心等候")
  58. }
  59. // 查询未成交的课程
  60. const {
  61. data: result1
  62. } = await uni.$http.get('/education/teacher-courses/queryPersonNoDeal')
  63. if (result1.data.count >= 4) {
  64. return uni.$showMsg("最多同时发布4门课程")
  65. }
  66. uni.navigateTo({
  67. url:'/subpkg/add_course/add_course'
  68. })
  69. },
  70. // 查询个人发布成功的课程
  71. async getCourses() {
  72. const { data: result } = await uni.$http.get('/education/teacher-courses/showPersonCourse')
  73. this.courses = result.data.courses
  74. if (this.courses.length > 0) {
  75. for(let i = 0; i < this.courses.length; i++) {
  76. let dateArray = this.courses[i].datetime.split(' ')
  77. this.courses[i].datetime = dateArray[0]
  78. this.courses[i].image = '/static/c' + (i+1) +'.png'
  79. console.log(this.courses[i])
  80. }
  81. }
  82. },
  83. // 点击删除
  84. async bindClick(courseId) {
  85. const query = {
  86. courseId: courseId
  87. }
  88. const { data: result } = await uni.$http.get('/education/teacher-courses/deletePersonCourse', query)
  89. console.log(result)
  90. uni.$showMsg(result.message)
  91. this.getCourses()
  92. },
  93. }
  94. }
  95. </script>
  96. <style scoped lang="scss">
  97. </style>