teacher.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. <template>
  2. <view>
  3. <view class="teachWrapper">
  4. <view v-for="(item, index) in teacherList" :key="index">
  5. <view class="teachDetail" @click="toTeachDetail(item)">
  6. <image class="teachImg" :mode="aspectFit" :src="item.profilePhoto"></image>
  7. <view class="teachIntro">
  8. <view class="teachIntroTop">
  9. <view>
  10. <view class="name">
  11. <text>{{item.name}}教员</text>
  12. </view>
  13. <view class="course">
  14. <text>科目:</text>
  15. <text class="teachCourse">{{item.subject}}</text>
  16. </view>
  17. <view class="school">
  18. <text class="schoolType">{{item.school}}</text>
  19. </view>
  20. </view>
  21. <view class="teachIntroRight">
  22. <view class="teachEduAndAge">
  23. <view>
  24. <text>{{item.education}}</text>
  25. </view>
  26. <view>
  27. <text class="teachAgeIcon">龄</text>
  28. <text class="teachAge">{{item.teachAge}}</text>
  29. </view>
  30. </view>
  31. <view>
  32. <view class="teachDistance">
  33. <text>距你</text>
  34. <text class="distance">{{item.kil}}</text>
  35. <text>km</text>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. <view class="experience">
  41. <text>成功经验:</text>
  42. <text class="teachExperience">{{item.experience}}</text>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. <uni-fab :pattern="pattern" horizontal="left" vertical="bottom" @fabClick="fabClick"></uni-fab>
  48. <uni-drawer ref="showRight" mode="left" width="280">
  49. <scroll-view style="height: 100%;" scroll-y="true">
  50. <uni-section title="请选择搜索条件" type="line"></uni-section>
  51. <view class="search-input" >
  52. <uni-data-select v-model="queryObject.sex" :localdata="sexs" placeholder="学员性别" />
  53. </view>
  54. <view class="search-input" >
  55. <uni-data-select v-model="queryObject.time" :localdata="time" placeholder="上课时间" />
  56. </view>
  57. <view class="search-input" >
  58. <uni-data-select v-model="queryObject.mode" :localdata="modes" placeholder="上门方式" />
  59. </view>
  60. <view class="search-input" >
  61. <uni-data-picker placeholder="课程类别" popup-title="课程大纲-具体课程" v-model="queryObject.course" :localdata="courseTree" preload="true" />
  62. </view>
  63. <view class="search-input" >
  64. <uni-data-select v-model="queryObject.identify" :localdata="identifies" placeholder="教员类型" />
  65. </view>
  66. <view class="search-input" >
  67. <uni-data-select v-model="queryObject.education" :localdata="educations" placeholder="教员学历" />
  68. </view>
  69. <view class="search-input" >
  70. <uni-data-select v-model="queryObject.school" :localdata="schools" placeholder="教员毕业学校" />
  71. </view>
  72. <view class="button-group">
  73. <button @click="submit" size="mini" type="primary">开始搜索</button>
  74. <button @click="closeDrawer" size="mini" type="warn">取消搜索</button>
  75. </view>
  76. </scroll-view>
  77. </uni-drawer>
  78. </view>
  79. </view>
  80. </template>
  81. <script>
  82. import { mapState } from 'vuex'
  83. export default {
  84. computed: {
  85. ...mapState('m_user', ['location'])
  86. },
  87. data() {
  88. return {
  89. // 选择课程
  90. courseTree: [{
  91. text: '一年级',
  92. value: '1-0',
  93. children: [{
  94. text: '1.1班',
  95. value: '1-1'
  96. }
  97. ]
  98. }
  99. ],
  100. pattern: {
  101. color: '#7A7E83',
  102. backgroundColor: '#fff',
  103. selectedColor: '#007AFF',
  104. buttonColor: '#007AFF',
  105. iconColor: '#fff'
  106. },
  107. isLoading: false, // 请求阀
  108. // 老师列表
  109. teacherList: [],
  110. // 查询总数量
  111. total: 0,
  112. // 查询对象
  113. queryObject: {
  114. pageNum: 1,
  115. pageSize: 10,
  116. course: '1-1',
  117. identify: '',
  118. education: '',
  119. sex: '',
  120. school: '',
  121. mode: '',
  122. time: ''
  123. },
  124. educations: [{
  125. value: '专科在读',
  126. text: '专科在读'
  127. }, {
  128. value: '专科毕业',
  129. text: '专科毕业'
  130. }, {
  131. value: '本科在读',
  132. text: '本科在读'
  133. }, {
  134. value: '本科毕业',
  135. text: '本科毕业'
  136. }, {
  137. value: '硕士在读',
  138. text: '硕士在读'
  139. }, {
  140. value: '硕士毕业',
  141. text: '硕士毕业'
  142. }, {
  143. value: '博士在读',
  144. text: '博士在读'
  145. }, {
  146. value: '博士毕业',
  147. text: '博士毕业'
  148. }],
  149. // 单选老师身份
  150. identifies: [{
  151. text: '专职老师',
  152. value: '专职老师'
  153. }, {
  154. text: '在校大学生',
  155. value: '在校大学生'
  156. }],
  157. // 单选性别数据源
  158. sexs: [{
  159. text: '男',
  160. value: '男'
  161. }, {
  162. text: '女',
  163. value: '女'
  164. }],
  165. time: [{
  166. text: '上午',
  167. value: '上午'
  168. }, {
  169. text: '下午',
  170. value: '下午'
  171. }, {
  172. text: '晚上',
  173. value: '晚上'
  174. }],
  175. schools: [{
  176. text: '四川大学',
  177. value: '四川大学'
  178. }, {
  179. text: '电子科技大学',
  180. value: '电子科技大学'
  181. }, {
  182. text: '西南交通大学',
  183. value: '西南交通大学'
  184. }, {
  185. text: '四川师范大学',
  186. value: '四川师范大学'
  187. }, {
  188. text: '成都大学',
  189. value: '成都大学'
  190. }],
  191. modes: [{
  192. text: '老师上门',
  193. value: '老师上门'
  194. }, {
  195. text: '学员上门',
  196. value: '学员上门'
  197. }, {
  198. text: '线上辅导',
  199. value: '线上辅导'
  200. }],
  201. }
  202. },
  203. created() {
  204. this.getTeacherList()
  205. this.getPriceAndTree()
  206. },
  207. methods: {
  208. // 树形结构的课程和价格表
  209. async getPriceAndTree() {
  210. const {
  211. data: result
  212. } = await uni.$http.get('/education/course-price/treeAndPrice')
  213. // console.log(result)
  214. this.courseTree = result.data.treeCourse
  215. },
  216. fabClick() {
  217. this.$refs.showRight.open();
  218. },
  219. submit() {
  220. this.$refs.showRight.close();
  221. // 课程科目
  222. if (this.queryObject.course !== '1-1') {
  223. for (let x = 0; x < this.courseTree.length; x++) {
  224. for (let y = 0; y < this.courseTree[x].children.length; y++) {
  225. if (this.courseTree[x].children[y].value === this.queryObject.course) {
  226. this.queryObject.course = this.courseTree[x].value + '/' + this.queryObject.course
  227. }
  228. }
  229. }
  230. }
  231. this.teacherList = []
  232. this.getTeacherList()
  233. // console.log(this.queryObject)
  234. },
  235. closeDrawer() {
  236. this.$refs.showRight.close();
  237. this.queryObject.sex = ''
  238. this.queryObject.time = ''
  239. this.queryObject.mode = ''
  240. this.queryObject.course = '1-1'
  241. this.queryObject.school = ''
  242. this.queryObject.education = ''
  243. this.queryObject.identify = ''
  244. this.teacherList = []
  245. this.getTeacherList()
  246. },
  247. // 老师细节
  248. toTeachDetail(item) {
  249. let teacher = JSON.stringify(item)
  250. uni.navigateTo({
  251. url: '/subpkg/teacher_detail/teacher_detail?item=' + encodeURIComponent(teacher)
  252. })
  253. },
  254. // 获取老师列表
  255. async getTeacherList(cb) {
  256. // 打开节流阀
  257. this.isLoading = true
  258. const { data: result } = await uni.$http.post('/education/teacher-courses/showCourse', this.queryObject)
  259. this.isLoading = false
  260. // 加载完数据执行
  261. cb && cb()
  262. for (let i = 0; i < result.data.course.length; i++) {
  263. // let str = Base64.encode(this.teacherList[i].imgUrl)
  264. let str = result.data.course[i].profilePhoto
  265. // console.log(str)
  266. result.data.course[i].profilePhoto = 'data:image/png;base64,' + str
  267. let arr = result.data.course[i].locationAl.split(",")
  268. let kil = this.space(arr[0], arr[1], this.location.latitude, this.location.longitude)
  269. result.data.course[i].kil = kil
  270. }
  271. console.log(this.teacherList)
  272. this.teacherList = [...this.teacherList, ...result.data.course]
  273. this.total = result.data.count
  274. },
  275. // 触底事件
  276. onReachBottom() {
  277. // 判断是否有下一页的数据
  278. if (this.queryObject.pageNum * this.queryObject.pageSize >= this.total) return uni.$showMsg('数据加载完毕!')
  279. // 判断是否正在请求其他数据
  280. if (this.isLoading) return
  281. this.queryObject.pageNum += 1
  282. // 重新获取数据
  283. this.getTeacherList()
  284. },
  285. // 下拉刷新事件
  286. onPullDownRefresh() {
  287. // 1. 重置关键数据
  288. this.queryObject.pageNum = 1
  289. this.total = 0
  290. this.isLoading = false
  291. this.teacherList = []
  292. // 2.重新发起请求
  293. this.getTeacherList(() => uni.stopPullDownRefresh())
  294. },
  295. space(lat1, lng1, lat2, lng2) {
  296. // console.log(lat1, lng1, lat2, lng2)
  297. var radLat1 = lat1 * Math.PI / 180.0;
  298. var radLat2 = lat2 * Math.PI / 180.0;
  299. var a = radLat1 - radLat2;
  300. var b = lng1 * Math.PI / 180.0 - lng2 * Math.PI / 180.0;
  301. var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
  302. Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
  303. s = s * 6378.137;
  304. s = Math.round(s * 10000) / 10000; // 单位千米
  305. return s.toFixed(2) // 保留两位小数
  306. }
  307. }
  308. }
  309. </script>
  310. <style scoped lang="scss">
  311. /* 设置页面背景 */
  312. .teachWrapper{
  313. background-color: #E2F0D9;
  314. height: 100%;
  315. padding: 20rpx;
  316. }
  317. /* 设置单个教员背景 */
  318. .teachDetail{
  319. display: flex;
  320. position: relative;
  321. /* border: 1rpx solid gray; */
  322. padding: 10rpx 0;
  323. border-radius: 20rpx;
  324. background-color: #FFF2CC;
  325. margin-bottom: 20rpx;
  326. font-weight: bold;
  327. font-size: 28rpx;
  328. }
  329. .teachIntroTop{
  330. display: flex;
  331. }
  332. /* 教员头像 */
  333. .teachImg{
  334. width: 22%;
  335. height: 150rpx;
  336. margin: 10rpx;
  337. border-radius: 20rpx;
  338. }
  339. .teachIntro{
  340. margin-left: 10rpx;
  341. }
  342. .school {
  343. margin-bottom: 8rpx;
  344. }
  345. .schoolType {
  346. width: 252rpx;
  347. display: block;
  348. white-space: nowrap;
  349. overflow: hidden;
  350. text-overflow: ellipsis;
  351. }
  352. .name {
  353. margin-bottom: 8rpx;
  354. }
  355. /* 科目 */
  356. .course{
  357. display: flex;
  358. margin-bottom: 8rpx;
  359. }
  360. .teachCourse{
  361. margin-left: 10rpx;
  362. width: 160rpx;
  363. display: block;
  364. white-space: nowrap;
  365. overflow: hidden;
  366. text-overflow: ellipsis;
  367. }
  368. /* 右侧部分定位 */
  369. .teachIntroRight{
  370. position: absolute;
  371. /* right: 30rpx; */
  372. left: 65%;
  373. }
  374. /* 教员学历和教龄 */
  375. .teachEduAndAge{
  376. display: flex;
  377. }
  378. /* 教龄图标 */
  379. .teachAgeIcon {
  380. margin-left: 20rpx;
  381. padding: 2rpx;
  382. border: 1rpx solid;
  383. border-radius: 10rpx;
  384. font-size: 26rpx;
  385. color: white;
  386. background-color: #FF6666;
  387. }
  388. /* 教龄 */
  389. .teachAge{
  390. margin-left: 10rpx;
  391. font-weight: bold;
  392. color: red;
  393. }
  394. /* 距离 */
  395. .teachDistance{
  396. margin-top: 20rpx;
  397. color: red;
  398. }
  399. /* 距离数字 */
  400. .distance{
  401. margin: 0 10rpx;
  402. font-size: 40rpx;
  403. font-weight: bold;
  404. }
  405. /* 成功经验 */
  406. .experience{
  407. display: flex;
  408. }
  409. .teachExperience{
  410. width: 300rpx;
  411. margin-left: 10rpx;
  412. display: block;
  413. white-space: nowrap;
  414. overflow: hidden;
  415. text-overflow: ellipsis;
  416. }
  417. .search-input {
  418. margin-bottom: 40rpx;
  419. }
  420. </style>