teacher.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <template>
  2. <view>
  3. <view class="head">
  4. <uni-row>
  5. <uni-col :span="3">
  6. <view class="img-head">
  7. <image src="../../static/teachers.png"></image>
  8. </view>
  9. </uni-col>
  10. <uni-col :span="21">
  11. <view class="title-head" @click="switchIcon">
  12. <uni-title type="h4" title="找老师"></uni-title>
  13. <uni-icons :type="iconType" size="20"></uni-icons>
  14. </view>
  15. </uni-col>
  16. </uni-row>
  17. <view v-if="content">
  18. <view class="content">
  19. <uni-data-select class="ff" v-model="queryObject.course" :localdata="educations" placeholder="课程详情"/>
  20. <uni-data-select class="ff" v-model="queryObject.identify" :localdata="identifies" placeholder="老师身份" />
  21. <uni-data-select class="ff" v-model="queryObject.education" :localdata="educations" placeholder="老师学历" />
  22. </view>
  23. <view class="content, content2">
  24. <uni-data-select class="ff" v-model="queryObject.sex" :localdata="sexs" placeholder="老师性别" />
  25. <uni-data-select class="ff" v-model="queryObject.school" :localdata="schools" placeholder="毕业学校" />
  26. <uni-data-select class="ff" v-model="queryObject.mode" :localdata="modes" placeholder="老师照片" />
  27. </view>
  28. </view>
  29. </view>
  30. <!-- 筛选区与老师列表区之间的间隔 -->
  31. <view class="interval"></view>
  32. <view v-if="!isSearch">没有找到符合条件的信息</view>
  33. <view v-if="isSearch">
  34. <view class="teachInfo" @click="toTeachDetail(item)" v-for="(item, index) in teacherList" :key="index" >
  35. <image class="teachImg" mode="widthFix" :src="item.imgUrl"></image>
  36. <view class="introduce">
  37. <text class="teachName">{{item.name}}老师</text>
  38. <text class="attribute">{{item.teacherType}}</text>
  39. <text class="day">{{item.datetime}}</text>
  40. <view class="ageContainer">
  41. <text class="teachAgeIcon">龄</text>
  42. <text class="teachYears">{{item.teachAge}}年教龄</text>
  43. </view>
  44. <view class="courseList">
  45. <text>可授课科目:</text>
  46. <text>{{item.subject}}</text>
  47. </view>
  48. <view class="introduceDetail">
  49. <view>自我介绍:</view>
  50. <text>{{item.introduce || '无'}}</text>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </template>
  57. <script>
  58. export default {
  59. data() {
  60. return {
  61. isLoading: false, // 请求阀
  62. iconType: 'bottom',
  63. content: false,
  64. isSearch: true,
  65. // 老师列表
  66. teacherList: [],
  67. // 查询总数量
  68. total: 0,
  69. // 查询对象
  70. queryObject: {
  71. pageNum: 1,
  72. pageSize: 10,
  73. course: '',
  74. identify: '',
  75. education: '',
  76. sex: '',
  77. school: '',
  78. mode: '',
  79. imgUrl: '/static/teacher.png'
  80. },
  81. educations: [{
  82. value: '专科在读',
  83. text: '专科在读'
  84. }, {
  85. value: '专科毕业',
  86. text: '专科毕业'
  87. }, {
  88. value: '本科在读',
  89. text: '本科在读'
  90. }, {
  91. value: '本科毕业',
  92. text: '本科毕业'
  93. }, {
  94. value: '硕士在读',
  95. text: '硕士在读'
  96. }, {
  97. value: '硕士毕业',
  98. text: '硕士毕业'
  99. }, {
  100. value: '博士在读',
  101. text: '博士在读'
  102. }, {
  103. value: '博士毕业',
  104. text: '博士毕业'
  105. }],
  106. // 单选老师身份
  107. identifies: [{
  108. text: '专职老师',
  109. value: '专职老师'
  110. }, {
  111. text: '在校大学生',
  112. value: '在校大学生'
  113. }],
  114. // 单选性别数据源
  115. sexs: [{
  116. text: '男',
  117. value: '男'
  118. }, {
  119. text: '女',
  120. value: '女'
  121. }],
  122. schools: [{
  123. text: '四川大学',
  124. value: '四川大学'
  125. }, {
  126. text: '电子科技大学',
  127. value: '电子科技大学'
  128. }, {
  129. text: '西南交通大学',
  130. value: '西南交通大学'
  131. }, {
  132. text: '四川师范大学',
  133. value: '四川师范大学'
  134. }, {
  135. text: '成都大学',
  136. value: '成都大学'
  137. }],
  138. modes: [{
  139. text: '老师上门',
  140. value: '老师上门'
  141. }, {
  142. text: '学员上门',
  143. value: '学员上门'
  144. }, {
  145. text: '线上辅导',
  146. value: '线上辅导'
  147. }],
  148. }
  149. },
  150. created() {
  151. this.getTeacherList()
  152. },
  153. methods: {
  154. // 老师细节
  155. toTeachDetail(item) {
  156. let teacher = JSON.stringify(item)
  157. uni.navigateTo({
  158. url: '/subpkg/teacher_detail/teacher_detail?item=' + encodeURIComponent(teacher)
  159. })
  160. },
  161. // 展开搜索栏
  162. switchIcon() {
  163. if (this.iconType === 'bottom') {
  164. this.iconType = 'top'
  165. this.content = true
  166. } else {
  167. this.iconType = 'bottom'
  168. this.content = false
  169. }
  170. },
  171. // 获取老师列表
  172. async getTeacherList(cb) {
  173. // 打开节流阀
  174. this.isLoading = true
  175. const { data: result } = await uni.$http.post('/education/teacher-courses/showCourse', this.queryObject)
  176. this.isLoading = false
  177. // 加载完数据执行
  178. cb && cb()
  179. if (result.code !== 20000) return uni.$showMsg('获取数据失败')
  180. this.teacherList = [...this.teacherList, ...result.data.course]
  181. for (let i = 0; i < this.teacherList.length; i++) {
  182. // let str = Base64.encode(this.teacherList[i].imgUrl)
  183. let str = this.teacherList[i].profilePhoto
  184. // console.log(str)
  185. this.teacherList[i].imgUrl = 'data:image/png;base64,' + str
  186. }
  187. // console.log(this.teacherList)
  188. this.total = result.data.count
  189. },
  190. // 触底事件
  191. onReachBottom() {
  192. // 判断是否有下一页的数据
  193. if (this.queryObject.pageNum * this.queryObject.pageSize >= this.total) return uni.$showMsg('数据加载完毕!')
  194. // 判断是否正在请求其他数据
  195. if (this.isLoading) return
  196. this.queryObject.pageNum += 1
  197. // 重新获取数据
  198. this.getTeacherList()
  199. },
  200. // 下拉刷新事件
  201. onPullDownRefresh() {
  202. // 1. 重置关键数据
  203. this.queryObject.pageNum = 1
  204. this.total = 0
  205. this.isLoading = false
  206. this.teacherList = []
  207. // 2.重新发起请求
  208. this.getTeacherList(() => uni.stopPullDownRefresh())
  209. }
  210. }
  211. }
  212. </script>
  213. <style scoped lang="scss">
  214. .head {
  215. // position: sticky;
  216. // top: 0;
  217. // z-index: 999;
  218. image {
  219. height: 80rpx;
  220. width: 80rpx;
  221. }
  222. .title-head {
  223. display: flex;
  224. justify-content: space-between;
  225. align-items: center;
  226. }
  227. .content {
  228. display: flex;
  229. justify-content: space-around;
  230. .ff {
  231. width: 100px;
  232. }
  233. }
  234. .content2 {
  235. margin-top: 10rpx;
  236. padding-bottom: 10rpx;
  237. }
  238. }
  239. /* 搜索区下方的隔离区 */
  240. .interval{
  241. height: 5rpx;
  242. // margin-top: 20rpx;
  243. background-color: gray;
  244. }
  245. /* 老师列表 */
  246. .teachInfo {
  247. width: 96%;
  248. display: flex;
  249. margin-top: 20rpx;
  250. margin-left: 10rpx;
  251. padding: 10rpx 0;
  252. /* border: 1rpx solid red; */
  253. border-bottom: 1rpx solid gray;
  254. }
  255. /* 老师头像 */
  256. .teachImg {
  257. width: 20%;
  258. margin: 0 10rpx;
  259. border-radius: 20rpx;
  260. }
  261. /* 老师介绍外容器 */
  262. .introduce {
  263. width: 70%;
  264. /* height: 400rpx; */
  265. /* border: 1rpx solid red; */
  266. padding: 10rpx;
  267. }
  268. /* 老师名字 */
  269. .teachName {
  270. font-weight: bold;
  271. }
  272. /* 老师资质 */
  273. .attribute {
  274. margin-left: 20rpx;
  275. color: rgb(12, 182, 12);
  276. font-size: 26rpx;
  277. }
  278. /* 日期 */
  279. .day {
  280. float: right;
  281. color: pink;
  282. font-size: 28rpx;
  283. }
  284. /* 成交记录 */
  285. .transactionContainer {
  286. margin-top: 10rpx;
  287. display: flex;
  288. }
  289. /* 教龄和成交记录的标签 */
  290. .teachAgeIcon,
  291. .transaction {
  292. /* margin: 10rpx; */
  293. padding: 2rpx;
  294. border: 1rpx solid;
  295. border-radius: 10rpx;
  296. font-size: 26rpx;
  297. color: white;
  298. }
  299. /* 教龄标签的背景色 */
  300. .teachAgeIcon {
  301. background-color: rgba(255, 0, 0, .6);
  302. }
  303. /* 成交记录标签的背景色 */
  304. .transaction {
  305. background-color: rgba(0, 128, 0, .6);
  306. }
  307. /* 教龄和成交记录标签后的文字 */
  308. .teachYears,
  309. .transactionTotal {
  310. font-size: 24rpx;
  311. margin-left: 10rpx;
  312. }
  313. /* 最新接单 */
  314. .transactionList {
  315. margin-top: 10rpx;
  316. color: green;
  317. font-size: 24rpx;
  318. }
  319. /* 可授课科目 */
  320. .courseList {
  321. margin-top: 10rpx;
  322. font-size: 30rpx;
  323. }
  324. /* 自我介绍 */
  325. .introduceDetail {
  326. margin-top: 10rpx;
  327. font-size: 28rpx;
  328. }
  329. /* 自我介绍的内容 */
  330. .introduceDetail text {
  331. white-space: nowrap;
  332. overflow: hidden;
  333. text-overflow: ellipsis;
  334. display: -webkit-box;
  335. /*设置对齐模式*/
  336. -webkit-box-orient: vertical;
  337. /*设置多行的行数,本例为两行*/
  338. -webkit-line-clamp: 4;
  339. }
  340. </style>