student.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <view class="studentWrapper">
  3. <view v-for="(item,index) in stuNeeds" :key="index" >
  4. <view class="studentList" @click="goDetail(item)">
  5. <view class="studentLeft">
  6. <view class="studentLeftTitle">
  7. <text>{{item.name}}<text style="font-weight: 400; margin-left: 4px">学员</text></text>
  8. </view>
  9. <view class="studentNeedCourse">
  10. <text>科目:</text>
  11. <text class="needCourse">{{item.subjectBig}}/{{item.subjectSmall}}</text>
  12. </view>
  13. <view class="studentExpect">
  14. <text>期望目标:</text>
  15. <text class="expect">{{item.goal}}</text>
  16. </view>
  17. </view>
  18. <view class="studentRight">
  19. <view class="studentRightTitle">
  20. <text>{{item.salary}}/小时</text>
  21. </view>
  22. <view class="studentSex">
  23. <text>{{item.sex}}</text>
  24. </view>
  25. <view class="studentRightTitle">
  26. <text>{{item.kil}}km</text>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import { mapState } from 'vuex'
  35. export default {
  36. computed: {
  37. ...mapState('m_user', ['location'])
  38. },
  39. data() {
  40. return {
  41. stuNeeds: [],
  42. queryObj: {
  43. pageNum: 1,
  44. pageSize: 8
  45. },
  46. total: 0,
  47. isloading: false
  48. };
  49. },
  50. created() {
  51. this.getAllStuNeeds()
  52. },
  53. methods: {
  54. async getAllStuNeeds(cb) {
  55. // 打开节流阀
  56. this.isloading = true
  57. // 发起请求
  58. const { data: result } = await uni.$http.get('/education/student-requirements/getAllRequirements', this.queryObj)
  59. // 关闭节流阀
  60. this.isloading = false
  61. // 只要数据请求完毕,就立即按需调用 cb 回调函数
  62. cb && cb()
  63. for (let i = 0; i < result.data.list.length; i++) {
  64. let arr = result.data.list[i].locationAl.split(",")
  65. let kil = this.space(arr[0], arr[1], this.location.latitude, this.location.longitude)
  66. result.data.list[i].kil = kil
  67. }
  68. // 新旧拼接
  69. this.stuNeeds = [...this.stuNeeds, ...result.data.list]
  70. this.total = result.data.total
  71. // console.log(result)
  72. },
  73. // 下拉刷新
  74. onPullDownRefresh() {
  75. if (this.isloading) return
  76. this.queryObj.pageNum = 1
  77. this.total = 0
  78. this.stuNeeds = []
  79. this.isloading = false
  80. this.getAllStuNeeds( () => uni.stopPullDownRefresh())
  81. },
  82. // 触底事件
  83. onReachBottom() {
  84. // 判断是否有下一页
  85. if (this.queryObj.pageNum * this.queryObj.pageSize >= this.total)
  86. return uni.$showMsg('数据加载完毕!')
  87. // 判断是否正在请求数据
  88. if (this.isloading) return
  89. this.queryObj.pageNum += 1
  90. this.getAllStuNeeds()
  91. },
  92. space(lat1, lng1, lat2, lng2) {
  93. // console.log(lat1, lng1, lat2, lng2)
  94. var radLat1 = lat1 * Math.PI / 180.0;
  95. var radLat2 = lat2 * Math.PI / 180.0;
  96. var a = radLat1 - radLat2;
  97. var b = lng1 * Math.PI / 180.0 - lng2 * Math.PI / 180.0;
  98. var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
  99. Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
  100. s = s * 6378.137;
  101. s = Math.round(s * 10000) / 10000; // 单位千米
  102. return s.toFixed(2) // 保留两位小数
  103. },
  104. goDetail(item) {
  105. uni.navigateTo({
  106. url: '/subpkg/all_stu_require_detail/all_stu_require_detail?item=' + encodeURIComponent(JSON.stringify(item))
  107. })
  108. }
  109. }
  110. }
  111. </script>
  112. <style lang="scss">
  113. .studentWrapper{
  114. height: 100%;
  115. background-color: #E2F0D9;
  116. padding: 20rpx;
  117. }
  118. .studentList{
  119. display: flex;
  120. position: relative;
  121. /* border: 1rpx solid gray; */
  122. border-radius: 20rpx;
  123. background-color: #FFF2CC;
  124. margin-bottom: 20rpx;
  125. }
  126. /* 左侧部分 */
  127. .studentLeft{
  128. padding: 10rpx;
  129. font-weight: bold;
  130. font-size: 30rpx;
  131. }
  132. .studentLeftTitle,
  133. .studentExpect,
  134. .studentNeedCourse{
  135. padding: 6rpx 0;
  136. }
  137. /* 科目 */
  138. .studentNeedCourse{
  139. display: flex;
  140. }
  141. /* 期望目标 */
  142. .studentExpect{
  143. display: flex;
  144. font-weight: 400;
  145. font-size: 26rpx;
  146. }
  147. /* 期望目标和需求科目详情 */
  148. .needCourse,
  149. .expect{
  150. margin-left: 10rpx;
  151. width: 240rpx;
  152. display: block;
  153. white-space: nowrap;
  154. overflow: hidden;
  155. text-overflow: ellipsis;
  156. }
  157. /* 右侧部分定位 */
  158. .studentRight{
  159. position: absolute;
  160. left: 65%;
  161. color: #FF0000;
  162. font-size: 32rpx;
  163. }
  164. .studentRight,
  165. .studentSex{
  166. padding: 10rpx 0;
  167. }
  168. /* 设置性别的字体 */
  169. .studentSex{
  170. font-weight: bold;
  171. color: #00B050;
  172. }
  173. </style>