teacher_course_my_detail.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <view>
  3. <view>
  4. <my-coursedetail v-if="showDetail" :item="course" :location="location" :marker="marker" :timeAM="timeAM" :timePM="timePM" :timeEvening="timeEvening" buttonMessage="用作模板极速发布" :isShowCollect="false" :isShowPrivate="true" :isShowBtn="showButton" @publishButton="publishButton"></my-coursedetail>
  5. </view>
  6. <view class="button-wrapper">
  7. <button class="button1" @click="changeDisplay">{{DisplayBtnName}}</button>
  8. <button class="button2" @click="deleteThisCourse">删除</button>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. import formTime from '@/mixins/form-time.js'
  14. export default {
  15. mixins: [formTime],
  16. data() {
  17. return {
  18. publishCount: 0,
  19. DisplayBtnName: "上架",
  20. showButton: false,
  21. showDetail: 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. // console.log(option)
  37. if (option.courseId !== undefined) {
  38. const courseId = decodeURIComponent(option.courseId)
  39. this.getCourseDetailById(courseId)
  40. if (option.code !== undefined) {
  41. const code = decodeURIComponent(option.code)
  42. if (code == 0){this.showButton = true }
  43. }
  44. }
  45. },
  46. methods:{
  47. async deleteThisCourse(){
  48. const {data: result} = await uni.$http.get('/education/teacher-courses/deleteCourseByCourseId', {courseId: this.course.courseId})
  49. if (result.code === 20000) {
  50. uni.$showMsg('删除成功')
  51. //uni.redirectTo(关闭当前页面,跳转到其他页面)
  52. //uni.navigateTo 保留当前页面,跳转到应用内的某个页面,使用uni.navigateBack可以返回到原页面。
  53. uni.redirectTo({
  54. url:'/subpkg/teacher/course/teacher_course_pattern'
  55. })
  56. }else{
  57. uni.$showMsg('删除失败')
  58. }
  59. },
  60. // 上架,下架处理
  61. async changeDisplay(){
  62. // 查询个人上架了多少课程
  63. const { data: result1 } = await uni.$http.get('/education/teacher-courses/showPersonCourse')
  64. //console.log(result)
  65. this.publishCount = result1.data.publishCounts
  66. if (this.course.display === '下架') {
  67. if (this.course.verifyStatus !== '已通过') return uni.$showMsg('审核通过才能上架')
  68. if (this.course.deal === '已成交') return uni.$showMsg('已成交的课程不能上架')
  69. if (this.course.locked === '已锁') return uni.$showMsg('正在锁定的需求不能上架')
  70. if (this.publishCount >= 4) return uni.$showMsg('最多上架4个课程,上架失败')
  71. }
  72. const queryObj = {
  73. display: this.DisplayBtnName,
  74. courseId: this.course.courseId
  75. }
  76. const { data: result } = await uni.$http.get('/education/teacher-courses/updatePersonDisplay', queryObj)
  77. if (result.code === 20000) {
  78. if (this.DisplayBtnName === '上架') {
  79. this.course.display = '上架'
  80. uni.$showMsg('上架成功')
  81. this.DisplayBtnName = '下架'
  82. } else if (this.DisplayBtnName === '下架') {
  83. this.course.display = '下架'
  84. uni.$showMsg('下架成功')
  85. this.DisplayBtnName = '上架'
  86. }
  87. }
  88. },
  89. // 获取课程详情
  90. async getCourseDetailById(id) {
  91. const {data: result} = await uni.$http.get('/education/teacher-courses/getPersonCourseDetailById', {courseId: id})
  92. this.course = result.data.one
  93. // console.log(this.course)
  94. this.formatForm()
  95. if(this.course.display == "上架") {
  96. this.DisplayBtnName ="下架"
  97. }else{
  98. this.DisplayBtnName ="上架"
  99. }
  100. },
  101. // 上课表格格式化
  102. formatForm() {
  103. this.location = this.course.locationAl.split(",")
  104. this.marker[0].latitude = Number(this.location[0])
  105. this.marker[0].longitude = Number(this.location[1])
  106. this.courseWeekday = this.course.teachTime.split(",")
  107. this.parseCourseWeekday()
  108. this.showDetail = true
  109. },
  110. publishButton() {
  111. uni.redirectTo({
  112. url:'/subpkg/teacher/course/teacher_course_add?item=' + encodeURIComponent(JSON.stringify(this.course))
  113. })
  114. }
  115. }
  116. }
  117. </script>
  118. <!-- 设置页面背景 -->
  119. <style lang="scss">
  120. page{
  121. height: 100%;
  122. // background-color: #FFF;
  123. }
  124. </style>
  125. <style lang="scss" scoped>
  126. /* 底部按钮 */
  127. .button-wrapper{
  128. padding-top: 60rpx;
  129. display: flex;
  130. width: 100%;
  131. justify-content: space-around;
  132. // position: fixed;
  133. // bottom: 40rpx;
  134. padding-bottom: 60rpx;
  135. }
  136. .button1,
  137. .button2{
  138. font-size: 30rpx;
  139. padding: 0rpx 60rpx;
  140. border-radius: 50rpx;
  141. color: white;
  142. }
  143. .button1{
  144. background-color: #3ed598;
  145. }
  146. .button2{
  147. background-color: #35b882;
  148. }
  149. </style>