student.vue 7.7 KB

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