my_collect_require.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. };
  43. },
  44. created() {
  45. this.getAllStuNeeds()
  46. },
  47. methods: {
  48. async getAllStuNeeds() {
  49. // 发起请求
  50. const { data: result } = await uni.$http.get('/education/my-favorite-needs/findPersonCollectInfo')
  51. // console.log(result)
  52. for (let i = 0; i < result.data.list.length; i++) {
  53. let arr = result.data.list[i].locationAl.split(",")
  54. let kil = this.space(arr[0], arr[1], this.location.latitude, this.location.longitude)
  55. result.data.list[i].kil = kil
  56. }
  57. this.stuNeeds = result.data.list
  58. },
  59. space(lat1, lng1, lat2, lng2) {
  60. // console.log(lat1, lng1, lat2, lng2)
  61. var radLat1 = lat1 * Math.PI / 180.0;
  62. var radLat2 = lat2 * Math.PI / 180.0;
  63. var a = radLat1 - radLat2;
  64. var b = lng1 * Math.PI / 180.0 - lng2 * Math.PI / 180.0;
  65. var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
  66. Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
  67. s = s * 6378.137;
  68. s = Math.round(s * 10000) / 10000; // 单位千米
  69. return s.toFixed(2) // 保留两位小数
  70. },
  71. goDetail(item) {
  72. uni.navigateTo({
  73. url: '/subpkg/all_stu_require_detail/all_stu_require_detail?item=' + encodeURIComponent(JSON.stringify(item))
  74. })
  75. }
  76. }
  77. }
  78. </script>
  79. <style lang="scss">
  80. .studentWrapper{
  81. height: 100%;
  82. background-color: #E2F0D9;
  83. padding: 20rpx;
  84. }
  85. .studentList{
  86. display: flex;
  87. position: relative;
  88. /* border: 1rpx solid gray; */
  89. border-radius: 20rpx;
  90. background-color: #FFF2CC;
  91. margin-bottom: 20rpx;
  92. }
  93. /* 左侧部分 */
  94. .studentLeft{
  95. padding: 10rpx;
  96. font-weight: bold;
  97. font-size: 30rpx;
  98. }
  99. .studentLeftTitle,
  100. .studentExpect,
  101. .studentNeedCourse{
  102. padding: 6rpx 0;
  103. }
  104. /* 科目 */
  105. .studentNeedCourse{
  106. display: flex;
  107. }
  108. /* 期望目标 */
  109. .studentExpect{
  110. display: flex;
  111. font-weight: 400;
  112. font-size: 26rpx;
  113. }
  114. /* 期望目标和需求科目详情 */
  115. .needCourse,
  116. .expect{
  117. margin-left: 10rpx;
  118. width: 240rpx;
  119. display: block;
  120. white-space: nowrap;
  121. overflow: hidden;
  122. text-overflow: ellipsis;
  123. }
  124. /* 右侧部分定位 */
  125. .studentRight{
  126. position: absolute;
  127. left: 65%;
  128. color: #FF0000;
  129. font-size: 32rpx;
  130. }
  131. .studentRight,
  132. .studentSex{
  133. padding: 10rpx 0;
  134. }
  135. /* 设置性别的字体 */
  136. .studentSex{
  137. font-weight: bold;
  138. color: #00B050;
  139. }
  140. </style>