teacher_detail.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. <template>
  2. <view>
  3. <my-coursedetail :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. export default {
  10. computed: {
  11. ...mapState('m_user', ['userinfo'])
  12. },
  13. data() {
  14. return {
  15. isShowInvite: false,
  16. initeNeeds: '',
  17. myNeeds: [],
  18. collect: false,
  19. course: {},
  20. courseWeekday: [],
  21. location: [],
  22. marker: [{
  23. id: 1,
  24. joinCluster:true,
  25. latitude: 0,
  26. longitude: 0,
  27. width: 40,
  28. height: 40,
  29. iconPath: '/static/location.png',
  30. }],
  31. // 上课时间
  32. // 上午
  33. timeAM: [{
  34. value: 'A1',
  35. name: '1',
  36. checked: false
  37. },
  38. {
  39. name: '2',
  40. value: 'A2',
  41. checked: false
  42. },
  43. {
  44. name: '3',
  45. value: 'A3',
  46. checked: false
  47. },
  48. {
  49. name: '4',
  50. value: 'A4',
  51. checked: false
  52. },
  53. {
  54. name: '5',
  55. value: 'A5',
  56. checked: false
  57. },
  58. {
  59. name: '6',
  60. value: 'A6',
  61. checked: false
  62. },
  63. {
  64. name: '7',
  65. value: 'A7',
  66. checked: false
  67. }
  68. ],
  69. // 下午
  70. timePM: [{
  71. value: 'P1',
  72. name: '1',
  73. checked: false
  74. },
  75. {
  76. name: '2',
  77. value: 'P2',
  78. checked: false
  79. },
  80. {
  81. name: '3',
  82. value: 'P3',
  83. checked: false
  84. },
  85. {
  86. name: '4',
  87. value: 'P4',
  88. checked: false
  89. },
  90. {
  91. name: '5',
  92. value: 'P5',
  93. checked: false
  94. },
  95. {
  96. name: '6',
  97. value: 'P6',
  98. checked: false
  99. },
  100. {
  101. name: '7',
  102. value: 'P7',
  103. checked: false
  104. }
  105. ],
  106. // 晚上
  107. timeEvening: [{
  108. name: '1',
  109. value: 'E1',
  110. checked: false
  111. },
  112. {
  113. name: '2',
  114. value: 'E2',
  115. checked: false
  116. },
  117. {
  118. name: '3',
  119. value: 'E3',
  120. checked: false
  121. },
  122. {
  123. name: '4',
  124. value: 'E4',
  125. checked: false
  126. },
  127. {
  128. name: '5',
  129. value: 'E5',
  130. checked: false
  131. },
  132. {
  133. name: '6',
  134. value: 'E6',
  135. checked: false
  136. },
  137. {
  138. name: '7',
  139. value: 'E7',
  140. checked: false
  141. }
  142. ],
  143. };
  144. },
  145. onLoad(option) {
  146. this.course = JSON.parse(decodeURIComponent(option.item))
  147. this.location = this.course.locationAl.split(",")
  148. this.marker[0].latitude = Number(this.location[0])
  149. this.marker[0].longitude = Number(this.location[1])
  150. this.courseWeekday = this.course.teachTime.split(",")
  151. // console.log("选中的日期:" + this.courseWeekday)
  152. for (let i = 0; i < this.courseWeekday.length; i++) {
  153. for (let x = 0; x < this.timeAM.length; x++) {
  154. if (this.courseWeekday[i] == this.timeAM[x].value) {
  155. this.timeAM[x].checked = true
  156. }
  157. }
  158. for (let y = 0; y < this.timePM.length; y++) {
  159. if (this.courseWeekday[i] == this.timePM[y].value) {
  160. // console.log(this.timePM[y].value)
  161. this.timePM[y].checked = true
  162. }
  163. }
  164. for (let z = 0; z < this.timeEvening.length; z++) {
  165. if (this.courseWeekday[i] == this.timeEvening[z].value) {
  166. this.timeEvening[z].checked = true
  167. }
  168. }
  169. }
  170. this.getIsCollection()
  171. this.showMyStuNeeds()
  172. this.recordViewCount()
  173. },
  174. methods:{
  175. // 记录viewCount
  176. async recordViewCount() {
  177. const {data: result} = await uni.$http.get('/education/teacher-courses/recordCountByCourseId', {courseId: this.course.courseId})
  178. this.course.viewedCount = result.data.count
  179. },
  180. // 查看是否收藏过
  181. async getIsCollection() {
  182. const { data: result } = await uni.$http.get('/education/my-favorite-courses/findPersonCollect')
  183. // console.log(result)
  184. const list = result.data.requires
  185. for (let i = 0; i < list.length; i++) {
  186. if (this.course.courseId === list[i]) {
  187. this.collect = true
  188. }
  189. }
  190. },
  191. // 收藏、取消收藏
  192. async collecting() {
  193. // console.log(this.item)
  194. const queryObj = {
  195. courseId: this.course.courseId
  196. }
  197. if (!this.collect) {
  198. const { data: result1 } = await uni.$http.get('/education/my-favorite-courses/collect', queryObj)
  199. // console.log(result)
  200. if (result1.message === '收藏成功') {
  201. this.collect = true
  202. } else if (result1.message === '收藏失败') {
  203. uni.$showMsg('收藏失败')
  204. }
  205. } else if (this.collect) {
  206. const { data: result } = await uni.$http.get('/education/my-favorite-courses/cancelCollect', queryObj)
  207. if (result.message === '取消收藏成功') {
  208. this.collect = false
  209. } else if (result.message === '取消收藏失败') {
  210. uni.$showMsg('取消收藏失败')
  211. }
  212. }
  213. },
  214. async showMyStuNeeds() {
  215. const { data: result } = await uni.$http.get('/education/student-requirements/queryPersonSomeInfo')
  216. // console.log(result)
  217. this.myNeeds = result.data.list
  218. console.log(this.myNeeds)
  219. },
  220. // 获取最近成交时间和成交次数
  221. async getCountAndLastTime() {
  222. const query = {
  223. uid: this.teacherCourse.uid
  224. }
  225. const { data: result } = await uni.$http.get('/education/teacher-courses/queryCountAndLastTime', query)
  226. this.teacherCourse.count = result.data.count
  227. this.teacherCourse.latest = result.data.time
  228. },
  229. // 根据uid获取该老师学校学历等
  230. async getInfosByUid() {
  231. const { data: result } = await uni.$http.get('/education/teacher-certifications/findInfosByUid', { uid: this.teacherCourse.uid })
  232. this.teacherCourse.education = result.data.one.education
  233. this.teacherCourse.major = result.data.one.major
  234. this.teacherCourse.nativePlace = result.data.one.nativePlace
  235. this.teacherCourse.school = result.data.one.school
  236. },
  237. invite() {
  238. this.isShowInvite = true
  239. },
  240. cancelChosed() {
  241. this.isShowInvite = false
  242. },
  243. async commitChosed() {
  244. if (this.initeNeeds === '') return uni.$showMsg('请选择邀请的课程')
  245. this.initeNeeds.toUid = this.course.uid
  246. this.initeNeeds.courseId = this.course.courseId
  247. this.initeNeeds.fromUname = this.initeNeeds.name
  248. this.initeNeeds.toUname = this.course.name
  249. // console.log(this.initeNeeds)
  250. const {data: result} = await uni.$http.post('/education/invite-info/sendTeacherInvite', this.initeNeeds)
  251. uni.$showMsg(result.message)
  252. this.isShowInvite = false
  253. },
  254. clickRadio(item) {
  255. this.initeNeeds = item
  256. }
  257. }
  258. }
  259. </script>
  260. <style lang="scss" scoped>
  261. /* 整个页面样式 */
  262. .teachDeatil{
  263. display: flex;
  264. position: relative;
  265. flex-direction: column;
  266. margin-left: 20rpx;
  267. }
  268. .head{
  269. display: flex;
  270. }
  271. .headDetail{
  272. margin-left: 20rpx;
  273. display: flex;
  274. flex-direction: column;
  275. font-size: 28rpx;
  276. }
  277. .teachName{
  278. font-weight: bold;
  279. }
  280. .headDetail text{
  281. padding-bottom: 10rpx;
  282. }
  283. /* 头像设置 */
  284. .teachImg{
  285. width: 200rpx;
  286. }
  287. .settledDay{
  288. display: block;
  289. float: right;
  290. }
  291. /* 中部区域 */
  292. .midArea{
  293. display: flex;
  294. /* border: 1rpx solid red; */
  295. width: 96%;
  296. margin-top: 10rpx;
  297. justify-content: space-between;
  298. flex-wrap: wrap;
  299. }
  300. .midArea text{
  301. /* display: block; */
  302. width: 48%;
  303. height: 60rpx;
  304. line-height: 60rpx;
  305. font-size: 28rpx;
  306. }
  307. /* 可授课程 */
  308. .course{
  309. margin-top: 40rpx;
  310. }
  311. .courseList{
  312. margin-top: 10rpx;
  313. }
  314. /* 可授课区域 */
  315. .teachAera{
  316. margin-top: 40rpx;
  317. }
  318. .teachAreaDetail{
  319. margin-top: 10rpx;
  320. }
  321. /* 自我介绍及案例 */
  322. .introduceDetail{
  323. display: flex;
  324. flex-direction: column;
  325. margin-top: 40rpx;
  326. }
  327. .introduce-title{
  328. margin-bottom: 20rpx;
  329. color: yellowgreen;
  330. font-weight: bold;
  331. }
  332. .introduce-body{
  333. line-height: 50rpx;
  334. font-size: 28rpx;
  335. }
  336. /* 底部区域 */
  337. .bottomContainer{
  338. width: 99%;
  339. display: flex;
  340. position: absolute;
  341. bottom: 50rpx;
  342. /* background-color: #bfa; */
  343. /* border: 1rpx solid red; */
  344. justify-content: space-around;
  345. }
  346. .myCollect,
  347. .collection,
  348. .inviteTeach{
  349. width: 30%;
  350. height: 60rpx;
  351. line-height: 60rpx;
  352. font-weight: bold;
  353. border: 1rpx solid red;
  354. border-radius: 30rpx;
  355. text-align: center;
  356. }
  357. /* 我收藏的老师 */
  358. .myCollect{
  359. color: red;
  360. /* background-color: blue; */
  361. }
  362. /* 收藏老师 */
  363. .collection{
  364. color: yellowgreen;
  365. }
  366. /* 邀请老师 */
  367. .inviteTeach{
  368. color: pink;
  369. }
  370. /* 成交记录 */
  371. .transactionContainer {
  372. margin-top: 10rpx;
  373. display: flex;
  374. }
  375. /* 成交记录标签的背景色 */
  376. .transaction {
  377. background-color: rgba(0, 128, 0, .6);
  378. }
  379. /* 教龄和成交记录标签后的文字 */
  380. .teachYears,
  381. .transactionTotal {
  382. font-size: 24rpx;
  383. margin-left: 10rpx;
  384. }
  385. /* 最新接单 */
  386. .transactionList {
  387. margin-top: 10rpx;
  388. color: green;
  389. font-size: 24rpx;
  390. }
  391. </style>