student_require_all_detail.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <view style="background-color: #F0F0F0;">
  3. <my-requiredetail v-if="showDetail" :item="item" :location="location" :marker="marker" :timeAM="timeAM" :timePM="timePM" :timeEvening="timeEvening" :collect="collect" :isShowCollect="isShowCollect" buttonMessage="邀请" @collecting="collecting" @publishButton="invite"></my-requiredetail>
  4. <my-invite :isShowInvite="isShowInvite" :item11="myCourses" @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. initeCourse: '',
  19. myCourses: [],
  20. isShowInvite: false,
  21. isShowCollect: true,
  22. collect: false,
  23. item: {}, // 需求详情
  24. location: [],
  25. marker: [{
  26. id: 1,
  27. joinCluster:true,
  28. latitude: 0,
  29. longitude: 0,
  30. width: 40,
  31. height: 40,
  32. iconPath: '/static/location.png',
  33. }],
  34. };
  35. },
  36. onLoad(option) {
  37. if (option.requireId !== undefined) {
  38. const requireId = decodeURIComponent(option.requireId)
  39. this.getStuNeedsDetailById(requireId)
  40. }
  41. },
  42. methods: {
  43. // 获取需求详情
  44. async getStuNeedsDetailById(id) {
  45. const {data: result} = await uni.$http.get('/education/student-requirements/getStuNeedsDetailById', {requireId: id})
  46. this.item = result.data.one
  47. this.getIsCollection()
  48. this.formatForm()
  49. },
  50. // 上课表格格式化
  51. formatForm() {
  52. this.location = this.item.locationAl.split(",")
  53. this.marker[0].latitude = Number(this.location[0])
  54. this.marker[0].longitude = Number(this.location[1])
  55. this.courseWeekday = this.item.courseWeekday.split(",")
  56. this.parseCourseWeekday()
  57. this.showDetail = true
  58. },
  59. // 查看是否收藏过
  60. async getIsCollection() {
  61. const { data: result } = await uni.$http.get('/education/my-favorite-needs/findPersonCollect')
  62. const list = result.data.requires
  63. if (list !== undefined) {
  64. for (let i = 0; i < list.length; i++) {
  65. if (this.item.requireId === list[i]) {
  66. this.collect = true
  67. }
  68. }
  69. }
  70. },
  71. // 收藏、取消收藏
  72. async collecting() {
  73. const queryObj = {
  74. requireId: this.item.requireId
  75. }
  76. if (!this.collect) {
  77. const { data: result1 } = await uni.$http.get('/education/my-favorite-needs/collect', queryObj)
  78. if (result1.message === '收藏成功') {
  79. return this.collect = true
  80. }
  81. if (result1.message === '收藏失败') {
  82. return uni.$showMsg('收藏失败')
  83. }
  84. }
  85. if (this.collect) {
  86. const { data: result } = await uni.$http.get('/education/my-favorite-needs/cancelCollect', queryObj)
  87. if (result.message === '取消收藏成功') {
  88. return this.collect = false
  89. }
  90. if (result.message === '取消收藏失败') {
  91. return uni.$showMsg('取消收藏失败')
  92. }
  93. }
  94. },
  95. invite() {
  96. this.isShowInvite = true
  97. this.showMyCourse()
  98. },
  99. async showMyCourse() {
  100. const { data: result } = await uni.$http.get('/education/teacher-courses/queryPersonSomeInfo')
  101. this.myCourses = result.data.list
  102. const name = result.data.name
  103. if (this.myCourses !== undefined) {
  104. for (let i = 0; i < this.myCourses.length; i++) {
  105. this.myCourses[i].fromUname = name
  106. }
  107. }
  108. },
  109. cancelChosed() {
  110. this.isShowInvite = false
  111. },
  112. async commitChosed() {
  113. if (this.initeCourse === '') return uni.$showMsg('请选择邀请的课程')
  114. this.initeCourse.toUid = this.item.uid
  115. this.initeCourse.requireId = this.item.requireId
  116. this.initeCourse.salary = this.item.salary
  117. this.initeCourse.toUname = this.item.name
  118. const {data: result} = await uni.$http.post('/education/invite-info/sendInvite', this.initeCourse)
  119. uni.$showMsg(result.message)
  120. this.isShowInvite = false
  121. },
  122. clickRadio(item) {
  123. this.initeCourse = item
  124. }
  125. }
  126. }
  127. </script>
  128. <!-- 设置页面背景 -->
  129. <style lang="scss">
  130. page{
  131. height: 100%;
  132. // background-color: #FFF;
  133. }
  134. </style>
  135. <style lang="scss" scoped>
  136. </style>