student.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. <template>
  2. <view>
  3. <view v-for="(item, index) in stuNeeds" :key="index">
  4. <view class="publicItem" @click="goDetail(item.requireId)">
  5. <view class="hotStudent">
  6. <template v-if="item.profilePhoto">
  7. <image class="teachImg" :src="item.profilePhoto"></image>
  8. </template>
  9. <template v-else-if="item.sex === '女'">
  10. <image class="teachImg" src="../../static/girl.png"></image>
  11. </template>
  12. <template v-else>
  13. <image class="teachImg" src="../../static/boy.png"></image>
  14. </template>
  15. <view class="hotStudentText">
  16. <view class="studentTitle">{{item.nickname}}学员</view>
  17. <view class="publicSex">{{item.sex}}</view>
  18. <view class="stuGoal">{{item.goal}}</view>
  19. <view class="studentDistance" v-if="isShowDistance">
  20. <uni-icons type="location" color="#3ed598" ></uni-icons>
  21. <text>{{item.kil}}</text>km
  22. </view>
  23. </view>
  24. <view class="stuSubject">{{item.subjectBig + "/" + item.subjectSmall}}</view>
  25. </view>
  26. </view>
  27. </view>
  28. <uni-fab :pattern="pattern" horizontal="left" vertical="bottom" @fabClick="fabClick"></uni-fab>
  29. <uni-drawer ref="showRight" mode="left" width="280">
  30. <scroll-view style="height: 100%;" scroll-y="true">
  31. <uni-section title="条件搜索" type="line"></uni-section>
  32. <view class="searchInput" >
  33. <uni-data-select v-model="queryObj.sex" :localdata="sexs" placeholder="学员性别" />
  34. </view>
  35. <view class="searchInput" >
  36. <uni-data-select v-model="queryObj.time" :localdata="time" placeholder="上课时间" />
  37. </view>
  38. <view class="searchInput" >
  39. <uni-data-select v-model="queryObj.money" :localdata="money" placeholder="需求金额" />
  40. </view>
  41. <view class="searchInput" >
  42. <uni-data-picker placeholder="课程类别" popup-title="课程大纲-具体课程" v-model="queryObj.subject" :localdata="courseTree" preload="true" />
  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 badgeMix from '@/mixins/tabbar-badge.js'
  54. import computeDistance from '@/mixins/compute-distance.js'
  55. import { mapState } from 'vuex'
  56. export default {
  57. mixins: [badgeMix, computeDistance],
  58. computed: {
  59. ...mapState('m_user', ['location','token'])
  60. },
  61. data() {
  62. return {
  63. isShowDistance: false,
  64. pattern: {
  65. color: '#7A7E83',
  66. backgroundColor: '#fff',
  67. selectedColor: '#3ed598',
  68. buttonColor: '#3ed598',
  69. iconColor: '#fff'
  70. },
  71. stuNeeds: [],
  72. queryObj: {
  73. pageNum: 1,
  74. pageSize: 10,
  75. sex: '',
  76. time: '',
  77. money: '',
  78. subject: '1-1',
  79. subjectBig: '',
  80. },
  81. total: 0,
  82. isloading: false,
  83. // 选择课程
  84. courseTree: [{
  85. text: '一年级',
  86. value: '1-0',
  87. children: [{
  88. text: '1.1班',
  89. value: '1-1'
  90. }
  91. ]
  92. }
  93. ],
  94. // 单选性别数据源
  95. sexs: [{
  96. text: '男',
  97. value: '男'
  98. }, {
  99. text: '女',
  100. value: '女'
  101. }],
  102. time: [{
  103. text: '上午',
  104. value: '上午'
  105. }, {
  106. text: '下午',
  107. value: '下午'
  108. }, {
  109. text: '晚上',
  110. value: '晚上'
  111. }],
  112. money: [{
  113. text: '100以内',
  114. value: '0-100'
  115. }, {
  116. text: '100到200以内',
  117. value: '100-200'
  118. }, {
  119. text: '200-400以内',
  120. value: '200-400'
  121. }, {
  122. text: '400以上',
  123. value: '400-2000'
  124. }]
  125. };
  126. },
  127. watch: {
  128. 'token': {
  129. handler() {
  130. if (this.token !== '') {
  131. this.isShowDistance = true
  132. this.stuNeeds = []
  133. this.getAllStuNeeds()
  134. } else {
  135. this.isShowDistance = false
  136. }
  137. }
  138. }
  139. },
  140. created() {
  141. if (this.token !== '') {
  142. this.isShowDistance = true
  143. }
  144. this.getAllStuNeeds(),
  145. this.getPriceAndTree()
  146. },
  147. methods: {
  148. // 树形结构的课程和价格表
  149. async getPriceAndTree() {
  150. const {
  151. data: result
  152. } = await uni.$http.get('/education/course-price/treeAndPrice')
  153. this.courseTree = result.data.treeCourse
  154. },
  155. submit() {
  156. this.$refs.showRight.close();
  157. if (this.queryObj.subject !== '1-1') {
  158. // 课程科目
  159. for (let x = 0; x < this.courseTree.length; x++) {
  160. for (let y = 0; y < this.courseTree[x].children.length; y++) {
  161. if (this.courseTree[x].children[y].value === this.queryObj.subject) {
  162. this.queryObj.subjectBig = this.courseTree[x].value
  163. }
  164. }
  165. }
  166. }
  167. this.queryObj.pageNum = 1
  168. this.queryObj.pageSize = 10
  169. this.stuNeeds = []
  170. this.getAllStuNeeds()
  171. this.queryObj.subject = '1-1'
  172. this.queryObj.subjectBig = ''
  173. },
  174. closeDrawer() {
  175. this.$refs.showRight.close();
  176. this.queryObj.pageNum = 1
  177. this.queryObj.pageSize = 10
  178. this.queryObj.sex = ''
  179. this.queryObj.time = ''
  180. this.queryObj.money = ''
  181. this.queryObj.subject = '1-1'
  182. this.queryObj.subjectBig = ''
  183. this.stuNeeds = []
  184. this.getAllStuNeeds()
  185. },
  186. fabClick() {
  187. this.$refs.showRight.open();
  188. },
  189. async getAllStuNeeds(cb) {
  190. // 打开节流阀
  191. this.isloading = true
  192. // 发起请求
  193. const {
  194. data: result
  195. } = await uni.$http.post('/education/student-requirements/getAllRequirements', this.queryObj)
  196. // 关闭节流阀
  197. this.isloading = false
  198. // 只要数据请求完毕,就立即按需调用 cb 回调函数
  199. cb && cb()
  200. for (let i = 0; i < result.data.list.length; i++) {
  201. let arr = result.data.list[i].locationAl.split(",")
  202. let kil = this.space(arr[0], arr[1], this.location.latitude, this.location.longitude)
  203. result.data.list[i].kil = kil
  204. result.data.list[i].nickname = result.data.list[i].name.slice(0,1)
  205. if (result.data.list[i].goal.length == 0) {
  206. result.data.list[i].goal = "无"
  207. }
  208. }
  209. // 新旧拼接
  210. this.stuNeeds = [...this.stuNeeds, ...result.data.list]
  211. this.total = result.data.total
  212. },
  213. // 下拉刷新
  214. onPullDownRefresh() {
  215. if (this.isloading) return
  216. this.queryObj.pageNum = 1
  217. this.total = 0
  218. this.stuNeeds = []
  219. this.isloading = false
  220. this.getAllStuNeeds(() => uni.stopPullDownRefresh())
  221. },
  222. // 触底事件
  223. onReachBottom() {
  224. // 判断是否有下一页
  225. if (this.queryObj.pageNum * this.queryObj.pageSize >= this.total) return uni.$showMsg('数据加载完毕!')
  226. // 判断是否正在请求数据
  227. if (this.isloading) return
  228. this.queryObj.pageNum += 1
  229. this.getAllStuNeeds()
  230. },
  231. goDetail(id) {
  232. uni.navigateTo({
  233. url: '/subpkg/student/require/student_require_all_detail?requireId=' + encodeURIComponent(id)
  234. })
  235. }
  236. }
  237. }
  238. </script>
  239. <!-- 设置页面背景 -->
  240. <style lang="scss">
  241. page{
  242. height: 100%;
  243. // background-color: #FFF2CC;
  244. }
  245. </style>
  246. <style lang="scss" scoped>
  247. .button-group {
  248. padding: 100rpx 40rpx;
  249. display: flex;
  250. justify-content: space-between;
  251. }
  252. .searchInput {
  253. margin-bottom: 40rpx;
  254. }
  255. /* 教员、学员头像 */
  256. .teachImg,
  257. .studentImg{
  258. width: 25%;
  259. height: 95%;
  260. border-radius: 20%;
  261. }
  262. .stuSubject{
  263. position: absolute;
  264. left: 200rpx;
  265. top: 60rpx;
  266. // border: 0rpx solid gray;
  267. padding: 5rpx 10rpx;
  268. border-radius: 30rpx;
  269. background-color: #3ed598;
  270. color: #ffffff;
  271. font-size: 12px;
  272. }
  273. .studentTitle{
  274. font-size: 14px;
  275. position: absolute;
  276. left: 200rpx;
  277. top: 10rpx;
  278. font-weight: bold;
  279. color: #6d6d6d;
  280. }
  281. /* 距离 */
  282. .studentDistance{
  283. position: absolute;
  284. left: 300rpx;
  285. top: 10rpx;
  286. font-weight: bold;
  287. color: #3ed598;
  288. font-size: 12px;
  289. }
  290. .stuGoal{
  291. border: 2px solid #3ed598;
  292. border-radius: 30rpx;
  293. padding: 0rpx 10rpx;
  294. font-size: 12px;
  295. position: absolute;
  296. left: 200rpx;
  297. top: 115rpx;
  298. color: #3ed598;
  299. overflow: hidden;
  300. text-overflow: ellipsis;
  301. display: -webkit-box;
  302. -webkit-box-orient: vertical;
  303. -webkit-line-clamp: 1;
  304. }
  305. /* item */
  306. .publicItem{
  307. margin-left: 20rpx;
  308. margin-right: 20rpx;
  309. margin-top: 10rpx ;
  310. margin-bottom: 10rpx ;
  311. // border: 0rpx solid gray;
  312. padding: 10rpx 20rpx;
  313. border-radius: 30rpx;
  314. background-color: #ffffff;
  315. }
  316. .hotStudent{
  317. position: relative;
  318. display: flex;
  319. padding: 10rpx;
  320. height: 170rpx;
  321. align-items: center;
  322. }
  323. /* teachsex */
  324. .publicSex{
  325. position: absolute;
  326. right: 10rpx;
  327. top: 5rpx;
  328. // border: 0rpx solid gray;
  329. padding: 5rpx 10rpx;
  330. border-radius: 50%;
  331. background-color: #3ed598;
  332. color: #ffffff;
  333. font-size: 12px;
  334. }
  335. .myButton1{
  336. // border: 0rpx solid gray;
  337. padding: 10rpx 60rpx;
  338. border-radius: 50rpx;
  339. background-color: #35b882;
  340. color: #ffffff;
  341. font-size: 14px;
  342. }
  343. /* myButton1 */
  344. .myButton2{
  345. // border: 0rpx solid gray;
  346. padding: 10rpx 60rpx;
  347. border-radius: 50rpx;
  348. background-color: #3ed598;
  349. color: #ffffff;
  350. font-size: 14px;
  351. }
  352. </style>