student.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. <template>
  2. <view>
  3. <view class="studentWrapper">
  4. <view v-for="(item,index) in stuNeeds" :key="index">
  5. <view class="studentList" @click="goDetail(item)">
  6. <view class="studentLeft">
  7. <view class="studentLeftTitle">
  8. <text>{{item.name}}<text style="font-weight: 400; margin-left: 4px">学员</text></text>
  9. </view>
  10. <view class="studentNeedCourse">
  11. <text>科目:</text>
  12. <text class="needCourse">{{item.subjectBig}}/{{item.subjectSmall}}</text>
  13. </view>
  14. <view class="studentExpect">
  15. <text>期望目标:</text>
  16. <text class="expect">{{item.goal}}</text>
  17. </view>
  18. </view>
  19. <view class="studentRight">
  20. <view class="studentRightTitle">
  21. <text>{{item.salary}}/小时</text>
  22. </view>
  23. <view class="studentSex">
  24. <text>{{item.sex}}</text>
  25. </view>
  26. <view class="studentRightTitle">
  27. <text>{{item.kil}}km</text>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. <uni-fab :pattern="pattern" horizontal="left" vertical="bottom" @fabClick="fabClick"></uni-fab>
  34. <uni-drawer ref="showRight" mode="left" width="280">
  35. <scroll-view style="height: 100%;" scroll-y="true">
  36. <uni-section title="请选择搜索条件" type="line"></uni-section>
  37. <view class="search-input" >
  38. <uni-data-select v-model="queryObj.sex" :localdata="sexs" placeholder="学员性别" />
  39. </view>
  40. <view class="search-input" >
  41. <uni-data-select v-model="queryObj.time" :localdata="time" placeholder="上课时间" />
  42. </view>
  43. <view class="search-input" >
  44. <uni-data-select v-model="queryObj.money" :localdata="money" placeholder="需求金额" />
  45. </view>
  46. <view class="search-input" >
  47. <uni-data-picker placeholder="课程类别" popup-title="课程大纲-具体课程" v-model="queryObj.subject" :localdata="courseTree" preload="true" />
  48. </view>
  49. <view class="button-group">
  50. <button @click="submit" size="mini" type="primary">开始搜索</button>
  51. <button @click="closeDrawer" size="mini" type="warn">取消搜索</button>
  52. </view>
  53. </scroll-view>
  54. </uni-drawer>
  55. </view>
  56. </template>
  57. <script>
  58. import badgeMix from '@/mixins/tabbar-badge.js'
  59. import {
  60. mapState
  61. } from 'vuex'
  62. export default {
  63. mixins: [badgeMix],
  64. computed: {
  65. ...mapState('m_user', ['location'])
  66. },
  67. data() {
  68. return {
  69. pattern: {
  70. color: '#7A7E83',
  71. backgroundColor: '#fff',
  72. selectedColor: '#007AFF',
  73. buttonColor: '#007AFF',
  74. iconColor: '#fff'
  75. },
  76. stuNeeds: [],
  77. queryObj: {
  78. pageNum: 1,
  79. pageSize: 7,
  80. sex: '',
  81. time: '',
  82. money: '',
  83. subject: '1-1',
  84. subjectBig: '',
  85. },
  86. total: 0,
  87. isloading: false,
  88. // 选择课程
  89. courseTree: [{
  90. text: '一年级',
  91. value: '1-0',
  92. children: [{
  93. text: '1.1班',
  94. value: '1-1'
  95. }
  96. ]
  97. }
  98. ],
  99. // 单选性别数据源
  100. sexs: [{
  101. text: '男',
  102. value: '男'
  103. }, {
  104. text: '女',
  105. value: '女'
  106. }],
  107. time: [{
  108. text: '上午',
  109. value: '上午'
  110. }, {
  111. text: '下午',
  112. value: '下午'
  113. }, {
  114. text: '晚上',
  115. value: '晚上'
  116. }],
  117. money: [{
  118. text: '100以内',
  119. value: '0-100'
  120. }, {
  121. text: '100到200以内',
  122. value: '100-200'
  123. }, {
  124. text: '200-400以内',
  125. value: '200-400'
  126. }, {
  127. text: '400以上',
  128. value: '400-2000'
  129. }]
  130. };
  131. },
  132. created() {
  133. this.getAllStuNeeds(),
  134. this.getPriceAndTree()
  135. },
  136. methods: {
  137. // 树形结构的课程和价格表
  138. async getPriceAndTree() {
  139. const {
  140. data: result
  141. } = await uni.$http.get('/education/course-price/treeAndPrice')
  142. // console.log(result)
  143. this.courseTree = result.data.treeCourse
  144. },
  145. submit() {
  146. this.$refs.showRight.close();
  147. if (this.queryObj.subject !== '1-1') {
  148. // 课程科目
  149. for (let x = 0; x < this.courseTree.length; x++) {
  150. for (let y = 0; y < this.courseTree[x].children.length; y++) {
  151. if (this.courseTree[x].children[y].value === this.queryObj.subject) {
  152. this.queryObj.subjectBig = this.courseTree[x].value
  153. }
  154. }
  155. }
  156. }
  157. this.stuNeeds = []
  158. this.getAllStuNeeds()
  159. // console.log(this.queryObj)
  160. },
  161. closeDrawer() {
  162. this.$refs.showRight.close();
  163. this.queryObj.sex = ''
  164. this.queryObj.time = ''
  165. this.queryObj.money = ''
  166. this.queryObj.subject = '1-1'
  167. this.queryObj.subjectBig = ''
  168. this.stuNeeds = []
  169. this.getAllStuNeeds()
  170. },
  171. fabClick() {
  172. this.$refs.showRight.open();
  173. },
  174. async getAllStuNeeds(cb) {
  175. // 打开节流阀
  176. this.isloading = true
  177. // 发起请求
  178. const {
  179. data: result
  180. } = await uni.$http.get('/education/student-requirements/getAllRequirements', this.queryObj)
  181. // 关闭节流阀
  182. this.isloading = false
  183. // 只要数据请求完毕,就立即按需调用 cb 回调函数
  184. cb && cb()
  185. for (let i = 0; i < result.data.list.length; i++) {
  186. let arr = result.data.list[i].locationAl.split(",")
  187. let kil = this.space(arr[0], arr[1], this.location.latitude, this.location.longitude)
  188. result.data.list[i].kil = kil
  189. }
  190. // 新旧拼接
  191. this.stuNeeds = [...this.stuNeeds, ...result.data.list]
  192. this.total = result.data.total
  193. // console.log(result)
  194. },
  195. // 下拉刷新
  196. onPullDownRefresh() {
  197. if (this.isloading) return
  198. this.queryObj.pageNum = 1
  199. this.total = 0
  200. this.stuNeeds = []
  201. this.isloading = false
  202. this.getAllStuNeeds(() => uni.stopPullDownRefresh())
  203. },
  204. // 触底事件
  205. onReachBottom() {
  206. // 判断是否有下一页
  207. if (this.queryObj.pageNum * this.queryObj.pageSize >= this.total)
  208. return uni.$showMsg('数据加载完毕!')
  209. // 判断是否正在请求数据
  210. if (this.isloading) return
  211. this.queryObj.pageNum += 1
  212. this.getAllStuNeeds()
  213. },
  214. space(lat1, lng1, lat2, lng2) {
  215. // console.log(lat1, lng1, lat2, lng2)
  216. var radLat1 = lat1 * Math.PI / 180.0;
  217. var radLat2 = lat2 * Math.PI / 180.0;
  218. var a = radLat1 - radLat2;
  219. var b = lng1 * Math.PI / 180.0 - lng2 * Math.PI / 180.0;
  220. var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
  221. Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
  222. s = s * 6378.137;
  223. s = Math.round(s * 10000) / 10000; // 单位千米
  224. return s.toFixed(2) // 保留两位小数
  225. },
  226. goDetail(item) {
  227. uni.navigateTo({
  228. url: '/subpkg/all_stu_require_detail/all_stu_require_detail?item=' + encodeURIComponent(JSON.stringify(item))
  229. })
  230. }
  231. }
  232. }
  233. </script>
  234. <style lang="scss" scoped>
  235. .button-group {
  236. display: flex;
  237. justify-content: space-between;
  238. }
  239. .studentWrapper {
  240. height: 100%;
  241. background-color: #E2F0D9;
  242. padding: 20rpx;
  243. }
  244. .studentList {
  245. display: flex;
  246. position: relative;
  247. /* border: 1rpx solid gray; */
  248. border-radius: 20rpx;
  249. background-color: #FFF2CC;
  250. margin-bottom: 20rpx;
  251. }
  252. // .studentList:first-child {
  253. // margin-top: 30rpx;
  254. // }
  255. /* 左侧部分 */
  256. .studentLeft {
  257. padding: 10rpx;
  258. font-weight: bold;
  259. font-size: 30rpx;
  260. }
  261. .studentLeftTitle,
  262. .studentExpect,
  263. .studentNeedCourse {
  264. padding: 6rpx 0;
  265. }
  266. /* 科目 */
  267. .studentNeedCourse {
  268. display: flex;
  269. }
  270. /* 期望目标 */
  271. .studentExpect {
  272. display: flex;
  273. font-weight: 400;
  274. font-size: 26rpx;
  275. }
  276. /* 期望目标和需求科目详情 */
  277. .needCourse,
  278. .expect {
  279. margin-left: 10rpx;
  280. width: 240rpx;
  281. display: block;
  282. white-space: nowrap;
  283. overflow: hidden;
  284. text-overflow: ellipsis;
  285. }
  286. /* 右侧部分定位 */
  287. .studentRight {
  288. position: absolute;
  289. left: 65%;
  290. color: #FF0000;
  291. font-size: 32rpx;
  292. }
  293. .studentRight,
  294. .studentSex {
  295. padding: 10rpx 0;
  296. }
  297. /* 设置性别的字体 */
  298. .studentSex {
  299. font-weight: bold;
  300. color: #00B050;
  301. }
  302. .search-input {
  303. margin-bottom: 40rpx;
  304. }
  305. </style>