teacher.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. <template>
  2. <view>
  3. <view v-for="(item, index) in teacherList" :key="index">
  4. <view class="publicItem" @click="toTeachDetail(item)">
  5. <view class="itemFather">
  6. <image class="teachImg" :src="item.profilePhoto"></image>
  7. <view class="teachTitle">{{item.nickname}}教员</view>
  8. <view class="publicSex">{{item.sex}}</view>
  9. <view class="teachCollege">{{item.school}}</view>
  10. <view class="teachEdu">{{item.education}}</view>
  11. <view class="teachDistance" v-if="isShowDistance">
  12. <uni-icons type="location" color="#3ed598" ></uni-icons>
  13. <text>{{item.kil}}</text>km</view>
  14. <view class="teachSubject">{{item.subject}}</view>
  15. <view class="teachYears">教龄 {{item.teachAge}}</view>
  16. </view>
  17. </view>
  18. </view>
  19. <uni-fab :pattern="pattern" horizontal="left" vertical="bottom" @fabClick="fabClick"></uni-fab>
  20. <uni-drawer ref="showRight" mode="left" width="280">
  21. <scroll-view style="height: 100%;" scroll-y="true">
  22. <uni-section title="条件搜索" type="line"></uni-section>
  23. <view class="searchInput" >
  24. <uni-data-select v-model="queryObject.sex" :localdata="sexs" placeholder="教员性别" />
  25. </view>
  26. <view class="searchInput" >
  27. <uni-data-select v-model="queryObject.time" :localdata="time" placeholder="上课时间" />
  28. </view>
  29. <view class="searchInput" >
  30. <uni-data-select v-model="queryObject.mode" :localdata="modes" placeholder="上课方式" />
  31. </view>
  32. <view class="searchInput" >
  33. <uni-data-picker placeholder="课程类别" popup-title="课程大纲-具体课程" v-model="queryObject.course" :localdata="courseTree" preload="true" />
  34. </view>
  35. <view class="searchInput" >
  36. <uni-data-select v-model="queryObject.identify" :localdata="identifies" placeholder="类型" @change="teachIdChange"/>
  37. </view>
  38. <view class="searchInput" >
  39. <uni-data-select v-model="queryObject.education" :localdata="educations" placeholder="学历" />
  40. </view>
  41. <view class="searchInput" >
  42. <uni-data-select v-model="queryObject.school" :localdata="schools" placeholder="毕业学校" />
  43. </view>
  44. <view class="button-group">
  45. <button @click="submit" class="myButton1">搜索</button>
  46. <button @click="closeDrawer" class="myButton2">取消</button>
  47. </view>
  48. </scroll-view>
  49. </uni-drawer>
  50. </view>
  51. </template>
  52. <script>
  53. import computeDistance from '@/mixins/compute-distance.js'
  54. import badgeMix from '@/mixins/tabbar-badge.js'
  55. import { mapState } from 'vuex'
  56. export default {
  57. mixins: [badgeMix, computeDistance],
  58. computed: {
  59. ...mapState('m_user', ['location','token']),
  60. //选中的教员类型
  61. activeTeach(){
  62. return this.identifies[this.idIndex]
  63. }
  64. },
  65. options: {
  66. styleIsolation: 'shared', // 解除样式隔离
  67. },
  68. data() {
  69. return {
  70. isShowDistance: false,
  71. // 选择课程
  72. courseTree: [{
  73. text: '一年级',
  74. value: '1-0',
  75. children: [{
  76. text: '1.1班',
  77. value: '1-1'
  78. }
  79. ]
  80. }
  81. ],
  82. pattern: {
  83. color: '#3ed598',
  84. backgroundColor: '#3ed598',
  85. selectedColor: '##3ed598',
  86. buttonColor: '##3ed598',
  87. iconColor: '#fff'
  88. },
  89. isLoading: false, // 请求阀
  90. // 老师列表
  91. teacherList: [],
  92. // 查询总数量
  93. total: 0,
  94. // 查询对象
  95. queryObject: {
  96. pageNum: 1,
  97. pageSize: 10,
  98. course: '1-1',
  99. identify: '',
  100. education: '',
  101. sex: '',
  102. school: '',
  103. mode: '',
  104. time: ''
  105. },
  106. educations: [],
  107. // 单选老师身份
  108. identifies: [{
  109. text: '专职教员',
  110. value: '专职教员'
  111. }, {
  112. text: '学生教员',
  113. value: '学生教员'
  114. }],
  115. // 单选性别数据源
  116. sexs: [{
  117. text: '男',
  118. value: '男'
  119. }, {
  120. text: '女',
  121. value: '女'
  122. }],
  123. time: [{
  124. text: '上午',
  125. value: '上午'
  126. }, {
  127. text: '下午',
  128. value: '下午'
  129. }, {
  130. text: '晚上',
  131. value: '晚上'
  132. }],
  133. schools: [{
  134. text: '四川大学',
  135. value: '四川大学'
  136. }],
  137. modes: [{
  138. text: '老师上门',
  139. value: '老师上门'
  140. }, {
  141. text: '学员上门',
  142. value: '学员上门'
  143. }, {
  144. text: '线上辅导',
  145. value: '线上辅导'
  146. }],
  147. }
  148. },
  149. watch: {
  150. 'token': {
  151. handler() {
  152. if (this.token !== '') {
  153. this.isShowDistance = true
  154. this.teacherList = []
  155. this.getTeacherList()
  156. } else {
  157. this.isShowDistance = false
  158. }
  159. }
  160. }
  161. },
  162. created() {
  163. if (this.token !== '') {
  164. this.isShowDistance = true
  165. }
  166. this.getTeacherList()
  167. this.getPriceAndTree()
  168. this.getSchools()
  169. },
  170. methods: {
  171. teachIdChange(e){
  172. for(let i = 0;i < this.identifies.length;i++){
  173. if(e == this.identifies[i].value){
  174. // this.idIndex = i
  175. if(i == 0){
  176. this.educations = [{
  177. value: '专科在读',
  178. text: '专科在读'
  179. }, {
  180. value: '专科毕业',
  181. text: '专科毕业'
  182. }, {
  183. value: '本科在读',
  184. text: '本科在读'
  185. }, {
  186. value: '本科毕业',
  187. text: '本科毕业'
  188. }, {
  189. value: '硕士在读',
  190. text: '硕士在读'
  191. }, {
  192. value: '硕士毕业',
  193. text: '硕士毕业'
  194. }, {
  195. value: '博士在读',
  196. text: '博士在读'
  197. }, {
  198. value: '博士毕业',
  199. text: '博士毕业'
  200. }]
  201. }else if(i == 1){
  202. this.educations = [{
  203. value: '专科毕业',
  204. text: '专科毕业'
  205. }, {
  206. value: '本科毕业',
  207. text: '本科毕业'
  208. }, {
  209. value: '硕士毕业',
  210. text: '硕士毕业'
  211. }, {
  212. value: '博士毕业',
  213. text: '博士毕业'
  214. }]
  215. }else if(i == 2){
  216. this.educations = [{
  217. value: '专科在读',
  218. text: '专科在读'
  219. }, {
  220. value: '本科在读',
  221. text: '本科在读'
  222. }, {
  223. value: '硕士在读',
  224. text: '硕士在读'
  225. }, {
  226. value: '博士在读',
  227. text: '博士在读'
  228. }]
  229. }
  230. }
  231. }
  232. },
  233. // 获取所有老师注册过的所有学校
  234. async getSchools() {
  235. const {data: result} = await uni.$http.get('/education/teacher-certifications/getAllSchools')
  236. this.schools = result.data.schools
  237. },
  238. // 树形结构的课程和价格表
  239. async getPriceAndTree() {
  240. const {
  241. data: result
  242. } = await uni.$http.get('/education/course-price/treeAndPrice')
  243. this.courseTree = result.data.treeCourse
  244. },
  245. fabClick() {
  246. this.$refs.showRight.open();
  247. },
  248. submit() {
  249. this.$refs.showRight.close();
  250. // 课程科目
  251. if (this.queryObject.course !== '1-1') {
  252. for (let x = 0; x < this.courseTree.length; x++) {
  253. for (let y = 0; y < this.courseTree[x].children.length; y++) {
  254. if (this.courseTree[x].children[y].value === this.queryObject.course) {
  255. this.queryObject.course = this.courseTree[x].value + '/' + this.queryObject.course
  256. }
  257. }
  258. }
  259. }
  260. this.queryObject.pageNum = 1
  261. this.queryObject.pageSize = 10
  262. this.teacherList = []
  263. this.getTeacherList()
  264. this.queryObject.course = '1-1'
  265. },
  266. closeDrawer() {
  267. this.$refs.showRight.close();
  268. this.queryObject = {}
  269. this.queryObject.pageNum = 1
  270. this.queryObject.pageSize = 10
  271. this.queryObject.course = '1-1'
  272. this.teacherList = []
  273. this.getTeacherList()
  274. },
  275. // 老师细节
  276. toTeachDetail(item) {
  277. uni.navigateTo({
  278. url: '/subpkg/teacher/course/teacher_course_all_detail?item=' + encodeURIComponent(JSON.stringify(item))
  279. })
  280. },
  281. // 获取老师列表
  282. async getTeacherList(cb) {
  283. // 打开节流阀
  284. this.isLoading = true
  285. const { data: result } = await uni.$http.post('/education/teacher-courses/showCourse', this.queryObject)
  286. this.isLoading = false
  287. // 加载完数据执行
  288. cb && cb()
  289. for (let i = 0; i < result.data.course.length; i++) {
  290. let arr = result.data.course[i].locationAl.split(",")
  291. let kil = this.space(arr[0], arr[1], this.location.latitude, this.location.longitude)
  292. result.data.course[i].kil = kil
  293. result.data.course[i].nickname = result.data.course[i].name.slice(0,1)
  294. }
  295. this.teacherList = [...this.teacherList, ...result.data.course]
  296. this.total = result.data.count
  297. },
  298. // 触底事件
  299. onReachBottom() {
  300. // 判断是否有下一页的数据
  301. if (this.queryObject.pageNum * this.queryObject.pageSize >= this.total) return uni.$showMsg('数据加载完毕!')
  302. // 判断是否正在请求其他数据
  303. if (this.isLoading) return
  304. this.queryObject.pageNum += 1
  305. // 重新获取数据
  306. this.getTeacherList()
  307. },
  308. // 下拉刷新事件
  309. onPullDownRefresh() {
  310. // 1. 重置关键数据
  311. this.queryObject.pageNum = 1
  312. this.total = 0
  313. this.teacherList = []
  314. // 2.重新发起请求
  315. this.getTeacherList(() => uni.stopPullDownRefresh())
  316. }
  317. }
  318. }
  319. </script>
  320. <!-- 设置页面背景 -->
  321. <style lang="scss">
  322. page{
  323. height: 100%;
  324. //background-color: #FFF2CC;
  325. }
  326. </style>
  327. <style scoped lang="scss">
  328. .itemFather{
  329. position: relative;
  330. display: flex;
  331. padding: 10rpx;
  332. height: 170rpx;
  333. align-items: center;
  334. }
  335. .searchInput {
  336. margin-bottom: 40rpx;
  337. }
  338. /* 设置单个教员背景 */
  339. .publicItem{
  340. margin-left: 20rpx;
  341. margin-right: 20rpx;
  342. margin-top: 10rpx ;
  343. margin-bottom: 10rpx ;
  344. // border: 0rpx solid gray;
  345. padding: 10rpx 20rpx;
  346. border-radius: 30rpx;
  347. background-color: #ffffff;
  348. }
  349. .teachTitle{
  350. font-size: 14px;
  351. position: absolute;
  352. left: 200rpx;
  353. top: 10rpx;
  354. font-weight: bold;
  355. color: #6d6d6d;
  356. }
  357. /* 教员头像 */
  358. .teachImg{
  359. width: 25%;
  360. height: 95%;
  361. border-radius: 20%;
  362. }
  363. /* 距离 */
  364. .teachDistance{
  365. position: absolute;
  366. left: 330rpx;
  367. top: 10rpx;
  368. font-weight: bold;
  369. color: #3ed598;
  370. font-size: 12px;
  371. }
  372. /* teachsex */
  373. .publicSex{
  374. position: absolute;
  375. right: 10rpx;
  376. top: 5rpx;
  377. // border: 0rpx solid gray;
  378. padding: 5rpx 10rpx;
  379. border-radius: 50%;
  380. background-color: #3ed598;
  381. color: #ffffff;
  382. font-size: 12px;
  383. }
  384. /* teachEdu */
  385. .teachEdu{
  386. position: absolute;
  387. right: 10rpx;
  388. top: 60rpx;
  389. // border: 0rpx solid gray;
  390. padding: 5rpx 10rpx;
  391. border-radius: 30rpx;
  392. background-color: #3ed598;
  393. color: #ffffff;
  394. font-size: 12px;
  395. }
  396. /* teach课程 */
  397. .teachSubject{
  398. position: absolute;
  399. left: 200rpx;
  400. top: 115rpx;
  401. // border: 0rpx solid gray;
  402. padding: 5rpx 12rpx;
  403. border-radius: 30rpx;
  404. background-color: #3ed598;
  405. color: #ffffff;
  406. font-size: 12px;
  407. }
  408. /* teach课程 */
  409. .teachYears{
  410. position: absolute;
  411. right: 10rpx;
  412. top: 115rpx;
  413. border: 2px solid #3ed598;
  414. padding: 5rpx 20rpx;
  415. border-radius: 30rpx;
  416. color: #3ed598;
  417. font-size: 12px;
  418. font-weight: bold;
  419. }
  420. .teachCollege{
  421. border: 2px solid #3ed598;
  422. border-radius: 30rpx;
  423. padding: 0rpx 10rpx;
  424. font-size: 12px;
  425. position: absolute;
  426. left: 200rpx;
  427. top: 60rpx;
  428. color: #3ed598;
  429. }
  430. .button-group {
  431. padding: 100rpx 40rpx;
  432. display: flex;
  433. justify-content: space-between;
  434. }
  435. /* myButton1 */
  436. .myButton1{
  437. // border: 0rpx solid gray;
  438. padding: 15rpx 60rpx;
  439. border-radius: 50rpx;
  440. background-color: #35b882;
  441. color: #ffffff;
  442. font-size: 14px;
  443. }
  444. /* myButton1 */
  445. .myButton2{
  446. // border: 0rpx solid gray;
  447. padding: 15rpx 60rpx;
  448. border-radius: 50rpx;
  449. background-color: #3ed598;
  450. color: #ffffff;
  451. font-size: 14px;
  452. }
  453. ::v-deep .uni-fab__circle {
  454. background-color: #3ed598 !important;
  455. }
  456. </style>