teacher_course_all_detail.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <view>
  3. <my-coursedetail v-if="showDetail" :item="course" :location="location" :marker="marker" :timeAM="timeAM" :timePM="timePM" :timeEvening="timeEvening" buttonMessage="邀请" :collect="collect" :isShowCollect="true" @collecting="collecting" @publishButton="invite"></my-coursedetail>
  4. <my-invite :isShowInvite="isShowInvite" :item11="myNeeds" @cancelChosed="cancelChosed" @commitChosed="commitChosed" @clickRadio="clickRadio"></my-invite>
  5. </view>
  6. </template>
  7. <script>
  8. import {mapState} from 'vuex'
  9. import formTime from '@/mixins/form-time.js'
  10. export default {
  11. mixins: [formTime],
  12. computed: {
  13. ...mapState('m_user', ['userinfo'])
  14. },
  15. data() {
  16. return {
  17. showDetail: false,
  18. isShowInvite: false,
  19. initeNeeds: '',
  20. myNeeds: [],
  21. collect: false,
  22. course: {},
  23. location: [],
  24. marker: [{
  25. id: 1,
  26. joinCluster:true,
  27. latitude: 0,
  28. longitude: 0,
  29. width: 40,
  30. height: 40,
  31. iconPath: '/static/location.png',
  32. }],
  33. };
  34. },
  35. onLoad(option) {
  36. if (option.item !== undefined) {
  37. this.course = JSON.parse(decodeURIComponent(option.item))
  38. this.getCourseDetailById(this.course.courseId)
  39. }
  40. if (option.courseId !== undefined) {
  41. this.getPersonCourseDetailById(option.courseId)
  42. }
  43. this.getIsCollection()
  44. },
  45. methods:{
  46. async getPersonCourseDetailById(id) {
  47. const {data: result} = await uni.$http.get('/education/teacher-courses/getPersonCourseDetailById', {courseId: id})
  48. this.course = result.data.one
  49. if (this.course.viewedCount === null) {
  50. this.course.viewedCount = 0
  51. }
  52. this.formatForm()
  53. },
  54. // 获取课程详情
  55. async getCourseDetailById(id) {
  56. const {data: result} = await uni.$http.get('/education/teacher-courses/getCourseDetailById', {courseId: id})
  57. const item = result.data.one
  58. this.course = Object.assign(this.course, item)
  59. if (this.course.viewedCount === null) {
  60. this.course.viewedCount = 0
  61. }
  62. this.formatForm()
  63. },
  64. // 上课表格格式化
  65. formatForm() {
  66. this.location = this.course.locationAl.split(",")
  67. this.marker[0].latitude = Number(this.location[0])
  68. this.marker[0].longitude = Number(this.location[1])
  69. this.courseWeekday = this.course.teachTime.split(",")
  70. this.parseCourseWeekday()
  71. this.showDetail = true
  72. },
  73. // 查看是否收藏过
  74. async getIsCollection() {
  75. const { data: result } = await uni.$http.get('/education/my-favorite-courses/findPersonCollect')
  76. const list = result.data.requires
  77. if (list !== undefined) {
  78. for (let i = 0; i < list.length; i++) {
  79. if (this.course.courseId === list[i]) {
  80. this.collect = true
  81. }
  82. }
  83. }
  84. },
  85. // 收藏、取消收藏
  86. async collecting() {
  87. const queryObj = {
  88. courseId: this.course.courseId
  89. }
  90. // 没有收藏过
  91. if (!this.collect) {
  92. const { data: result1 } = await uni.$http.get('/education/my-favorite-courses/collect', queryObj)
  93. if (result1.message === '收藏成功') {
  94. return this.collect = true
  95. }
  96. if (result1.message === '收藏失败') {
  97. return uni.$showMsg('收藏失败')
  98. }
  99. }
  100. // 收藏过
  101. if (this.collect) {
  102. const { data: result } = await uni.$http.get('/education/my-favorite-courses/cancelCollect', queryObj)
  103. if (result.message === '取消收藏成功') {
  104. return this.collect = false
  105. } else if (result.message === '取消收藏失败') {
  106. return uni.$showMsg('取消收藏失败')
  107. }
  108. }
  109. },
  110. async showMyStuNeeds() {
  111. const { data: result } = await uni.$http.get('/education/student-requirements/queryPersonSomeInfo')
  112. if (this.userinfo.uid !== this.course.uid) {
  113. this.myNeeds = result.data.list
  114. }
  115. },
  116. invite() {
  117. this.isShowInvite = true
  118. this.showMyStuNeeds()
  119. },
  120. cancelChosed() {
  121. this.isShowInvite = false
  122. },
  123. async commitChosed() {
  124. if (this.initeNeeds === '') return uni.$showMsg('请选择邀请的课程')
  125. this.initeNeeds.toUid = this.course.uid
  126. this.initeNeeds.courseId = this.course.courseId
  127. this.initeNeeds.fromUname = this.initeNeeds.name
  128. this.initeNeeds.toUname = this.course.name
  129. const {data: result} = await uni.$http.post('/education/invite-info/sendTeacherInvite', this.initeNeeds)
  130. uni.$showMsg(result.message)
  131. this.isShowInvite = false
  132. },
  133. clickRadio(item) {
  134. this.initeNeeds = item
  135. }
  136. }
  137. }
  138. </script>
  139. <!-- 设置页面背景 -->
  140. <style lang="scss">
  141. page{
  142. height: 100%;
  143. // background-color: #FFF;
  144. }
  145. </style>
  146. <style lang="scss" scoped>
  147. </style>