teacher.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  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="类型" />
  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. options: {
  62. styleIsolation: 'shared', // 解除样式隔离
  63. },
  64. data() {
  65. return {
  66. isShowDistance: false,
  67. // 选择课程
  68. courseTree: [{
  69. text: '一年级',
  70. value: '1-0',
  71. children: [{
  72. text: '1.1班',
  73. value: '1-1'
  74. }
  75. ]
  76. }
  77. ],
  78. pattern: {
  79. color: '#3ed598',
  80. backgroundColor: '#3ed598',
  81. selectedColor: '##3ed598',
  82. buttonColor: '##3ed598',
  83. iconColor: '#fff'
  84. },
  85. isLoading: false, // 请求阀
  86. // 老师列表
  87. teacherList: [],
  88. // 查询总数量
  89. total: 0,
  90. // 查询对象
  91. queryObject: {
  92. pageNum: 1,
  93. pageSize: 10,
  94. course: '1-1',
  95. identify: '',
  96. education: '',
  97. sex: '',
  98. school: '',
  99. mode: '',
  100. time: ''
  101. },
  102. educations: [{
  103. value: '专科在读',
  104. text: '专科在读'
  105. }, {
  106. value: '专科毕业',
  107. text: '专科毕业'
  108. }, {
  109. value: '本科在读',
  110. text: '本科在读'
  111. }, {
  112. value: '本科毕业',
  113. text: '本科毕业'
  114. }, {
  115. value: '硕士在读',
  116. text: '硕士在读'
  117. }, {
  118. value: '硕士毕业',
  119. text: '硕士毕业'
  120. }, {
  121. value: '博士在读',
  122. text: '博士在读'
  123. }, {
  124. value: '博士毕业',
  125. text: '博士毕业'
  126. }],
  127. // 单选老师身份
  128. identifies: [{
  129. text: '专职教员',
  130. value: '专职教员'
  131. }, {
  132. text: '学生教员',
  133. value: '学生教员'
  134. }],
  135. // 单选性别数据源
  136. sexs: [{
  137. text: '男',
  138. value: '男'
  139. }, {
  140. text: '女',
  141. value: '女'
  142. }],
  143. time: [{
  144. text: '上午',
  145. value: '上午'
  146. }, {
  147. text: '下午',
  148. value: '下午'
  149. }, {
  150. text: '晚上',
  151. value: '晚上'
  152. }],
  153. schools: [{
  154. text: '四川大学',
  155. value: '四川大学'
  156. }, {
  157. text: '电子科技大学',
  158. value: '电子科技大学'
  159. }, {
  160. text: '西南交通大学',
  161. value: '西南交通大学'
  162. }, {
  163. text: '四川师范大学',
  164. value: '四川师范大学'
  165. }, {
  166. text: '成都大学',
  167. value: '成都大学'
  168. }],
  169. modes: [{
  170. text: '老师上门',
  171. value: '老师上门'
  172. }, {
  173. text: '学员上门',
  174. value: '学员上门'
  175. }, {
  176. text: '线上辅导',
  177. value: '线上辅导'
  178. }],
  179. }
  180. },
  181. watch: {
  182. 'token': {
  183. handler() {
  184. if (this.token !== '') {
  185. this.isShowDistance = true
  186. this.teacherList = []
  187. this.getTeacherList()
  188. } else {
  189. this.isShowDistance = false
  190. }
  191. }
  192. }
  193. },
  194. created() {
  195. if (this.token !== '') {
  196. this.isShowDistance = true
  197. }
  198. this.getTeacherList()
  199. this.getPriceAndTree()
  200. },
  201. methods: {
  202. // 树形结构的课程和价格表
  203. async getPriceAndTree() {
  204. const {
  205. data: result
  206. } = await uni.$http.get('/education/course-price/treeAndPrice')
  207. this.courseTree = result.data.treeCourse
  208. },
  209. fabClick() {
  210. this.$refs.showRight.open();
  211. },
  212. submit() {
  213. this.$refs.showRight.close();
  214. // 课程科目
  215. if (this.queryObject.course !== '1-1') {
  216. for (let x = 0; x < this.courseTree.length; x++) {
  217. for (let y = 0; y < this.courseTree[x].children.length; y++) {
  218. if (this.courseTree[x].children[y].value === this.queryObject.course) {
  219. this.queryObject.course = this.courseTree[x].value + '/' + this.queryObject.course
  220. }
  221. }
  222. }
  223. }
  224. this.teacherList = []
  225. this.getTeacherList()
  226. },
  227. closeDrawer() {
  228. this.$refs.showRight.close();
  229. this.queryObject = {}
  230. this.queryObject.pageNum = 1
  231. this.queryObject.pageSize = 10
  232. this.queryObject.course = '1-1'
  233. this.teacherList = []
  234. this.getTeacherList()
  235. },
  236. // 老师细节
  237. toTeachDetail(item) {
  238. uni.navigateTo({
  239. url: '/subpkg/teacher/course/teacher_course_all_detail?item=' + encodeURIComponent(JSON.stringify(item))
  240. })
  241. },
  242. // 获取老师列表
  243. async getTeacherList(cb) {
  244. // 打开节流阀
  245. this.isLoading = true
  246. const { data: result } = await uni.$http.post('/education/teacher-courses/showCourse', this.queryObject)
  247. this.isLoading = false
  248. // 加载完数据执行
  249. cb && cb()
  250. for (let i = 0; i < result.data.course.length; i++) {
  251. let arr = result.data.course[i].locationAl.split(",")
  252. let kil = this.space(arr[0], arr[1], this.location.latitude, this.location.longitude)
  253. result.data.course[i].kil = kil
  254. result.data.course[i].nickname = result.data.course[i].name.slice(0,1)
  255. }
  256. this.teacherList = [...this.teacherList, ...result.data.course]
  257. this.total = result.data.count
  258. },
  259. // 触底事件
  260. onReachBottom() {
  261. // 判断是否有下一页的数据
  262. if (this.queryObject.pageNum * this.queryObject.pageSize >= this.total) return uni.$showMsg('数据加载完毕!')
  263. // 判断是否正在请求其他数据
  264. if (this.isLoading) return
  265. this.queryObject.pageNum += 1
  266. // 重新获取数据
  267. this.getTeacherList()
  268. },
  269. // 下拉刷新事件
  270. onPullDownRefresh() {
  271. // 1. 重置关键数据
  272. this.queryObject.pageNum = 1
  273. this.total = 0
  274. this.teacherList = []
  275. // 2.重新发起请求
  276. this.getTeacherList(() => uni.stopPullDownRefresh())
  277. }
  278. }
  279. }
  280. </script>
  281. <!-- 设置页面背景 -->
  282. <style lang="scss">
  283. page{
  284. height: 100%;
  285. //background-color: #FFF2CC;
  286. }
  287. </style>
  288. <style scoped lang="scss">
  289. .itemFather{
  290. position: relative;
  291. display: flex;
  292. padding: 10rpx;
  293. height: 170rpx;
  294. align-items: center;
  295. }
  296. .searchInput {
  297. margin-bottom: 40rpx;
  298. }
  299. /* 设置单个教员背景 */
  300. .publicItem{
  301. margin-left: 20rpx;
  302. margin-right: 20rpx;
  303. margin-top: 10rpx ;
  304. margin-bottom: 10rpx ;
  305. // border: 0rpx solid gray;
  306. padding: 10rpx 20rpx;
  307. border-radius: 30rpx;
  308. background-color: #ffffff;
  309. }
  310. .teachTitle{
  311. font-size: 14px;
  312. position: absolute;
  313. left: 200rpx;
  314. top: 10rpx;
  315. font-weight: bold;
  316. color: #6d6d6d;
  317. }
  318. /* 教员头像 */
  319. .teachImg{
  320. width: 25%;
  321. height: 95%;
  322. border-radius: 20%;
  323. }
  324. /* 距离 */
  325. .teachDistance{
  326. position: absolute;
  327. left: 330rpx;
  328. top: 10rpx;
  329. font-weight: bold;
  330. color: #3ed598;
  331. font-size: 12px;
  332. }
  333. /* teachsex */
  334. .publicSex{
  335. position: absolute;
  336. right: 10rpx;
  337. top: 5rpx;
  338. // border: 0rpx solid gray;
  339. padding: 5rpx 10rpx;
  340. border-radius: 50%;
  341. background-color: #3ed598;
  342. color: #ffffff;
  343. font-size: 12px;
  344. }
  345. /* teachEdu */
  346. .teachEdu{
  347. position: absolute;
  348. right: 10rpx;
  349. top: 60rpx;
  350. // border: 0rpx solid gray;
  351. padding: 5rpx 10rpx;
  352. border-radius: 30rpx;
  353. background-color: #3ed598;
  354. color: #ffffff;
  355. font-size: 12px;
  356. }
  357. /* teach课程 */
  358. .teachSubject{
  359. position: absolute;
  360. left: 200rpx;
  361. top: 115rpx;
  362. // border: 0rpx solid gray;
  363. padding: 5rpx 12rpx;
  364. border-radius: 30rpx;
  365. background-color: #3ed598;
  366. color: #ffffff;
  367. font-size: 12px;
  368. }
  369. /* teach课程 */
  370. .teachYears{
  371. position: absolute;
  372. right: 10rpx;
  373. top: 115rpx;
  374. border: 2px solid #3ed598;
  375. padding: 5rpx 20rpx;
  376. border-radius: 30rpx;
  377. color: #3ed598;
  378. font-size: 12px;
  379. font-weight: bold;
  380. }
  381. .teachCollege{
  382. border: 2px solid #3ed598;
  383. border-radius: 30rpx;
  384. padding: 0rpx 10rpx;
  385. font-size: 12px;
  386. position: absolute;
  387. left: 200rpx;
  388. top: 60rpx;
  389. color: #3ed598;
  390. }
  391. .button-group {
  392. padding: 100rpx 40rpx;
  393. display: flex;
  394. justify-content: space-between;
  395. }
  396. /* myButton1 */
  397. .myButton1{
  398. // border: 0rpx solid gray;
  399. padding: 15rpx 60rpx;
  400. border-radius: 50rpx;
  401. background-color: #35b882;
  402. color: #ffffff;
  403. font-size: 14px;
  404. }
  405. /* myButton1 */
  406. .myButton2{
  407. // border: 0rpx solid gray;
  408. padding: 15rpx 60rpx;
  409. border-radius: 50rpx;
  410. background-color: #3ed598;
  411. color: #ffffff;
  412. font-size: 14px;
  413. }
  414. ::v-deep .uni-fab__circle {
  415. background-color: #3ed598 !important;
  416. }
  417. </style>