student.vue 8.8 KB

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