student_require_my_collect.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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 v-if="item.sex === '女'">
  7. <image class="teachImg" src="/static/girl.png"></image>
  8. </template>
  9. <template v-else>
  10. <image class="teachImg" src="/static/boy.png"></image>
  11. </template>
  12. <view class="hotStudentText">
  13. <view class="studentTitle">{{item.name}}学员</view>
  14. <view class="publicSex">{{item.sex}}</view>
  15. <view class="stuGoal">{{item.goal}}</view>
  16. <view class="studentDistance">
  17. <uni-icons type="location" color="#3ed598" ></uni-icons>
  18. <text>{{item.kil}}</text>km
  19. </view>
  20. </view>
  21. <view class="stuSubject">{{item.subjectBig + "/" + item.subjectSmall}}</view>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. import { mapState } from 'vuex'
  29. import computeDistance from '@/mixins/compute-distance.js'
  30. export default {
  31. mixins: [computeDistance],
  32. computed: {
  33. ...mapState('m_user', ['location'])
  34. },
  35. data() {
  36. return {
  37. stuNeeds: [],
  38. };
  39. },
  40. onShow() {
  41. this.getAllStuNeeds()
  42. },
  43. methods: {
  44. async getAllStuNeeds() {
  45. // 发起请求
  46. const { data: result } = await uni.$http.get('/education/my-favorite-needs/findPersonCollectInfo')
  47. for (let i = 0; i < result.data.list.length; i++) {
  48. let arr = result.data.list[i].locationAl.split(",")
  49. let kil = this.space(arr[0], arr[1], this.location.latitude, this.location.longitude)
  50. result.data.list[i].kil = kil
  51. result.data.list[i].name = result.data.list[i].name.slice(0,1)
  52. }
  53. this.stuNeeds = result.data.list
  54. },
  55. goDetail(id) {
  56. uni.navigateTo({
  57. url: '/subpkg/student/require/student_require_all_detail?requireId=' + encodeURIComponent(id)
  58. })
  59. }
  60. }
  61. }
  62. </script>
  63. <!-- 设置页面背景 -->
  64. <style lang="scss">
  65. page{
  66. height: 100%;
  67. // background-color: #D4F5E9;
  68. }
  69. </style>
  70. <style lang="scss" scoped>
  71. /* 教员、学员头像 */
  72. .teachImg,
  73. .studentImg{
  74. width: 25%;
  75. height: 95%;
  76. border-radius: 20%;
  77. }
  78. .stuSubject{
  79. position: absolute;
  80. left: 200rpx;
  81. top: 60rpx;
  82. border: 0rpx solid gray;
  83. padding: 10rpx 20rpx;
  84. border-radius: 30rpx;
  85. background-color: #3ed598;
  86. color: #ffffff;
  87. font-size: 12px;
  88. }
  89. .studentTitle{
  90. font-size: 14px;
  91. position: absolute;
  92. left: 200rpx;
  93. top: 10rpx;
  94. font-weight: bold;
  95. color: #6d6d6d;
  96. }
  97. /* 距离 */
  98. .studentDistance{
  99. position: absolute;
  100. left: 300rpx;
  101. top: 10rpx;
  102. font-weight: bold;
  103. color: #3ed598;
  104. font-size: 12px;
  105. }
  106. .stuGoal{
  107. margin-top: 10rpx;
  108. border: 2px solid #3ed598;
  109. border-radius: 30rpx;
  110. padding: 0rpx 10rpx;
  111. font-size: 12px;
  112. position: absolute;
  113. left: 200rpx;
  114. top: 125rpx;
  115. color: #3ed598;
  116. display: block;//将文本设置为块元素,否则overflow无效
  117. overflow: hidden;
  118. text-overflow: ellipsis;
  119. display: -webkit-box;
  120. -webkit-box-orient: vertical;//设置对齐模式为垂直对齐
  121. -webkit-line-clamp: 1;//设置要显示的行数
  122. }
  123. /* item */
  124. .publicItem{
  125. margin-left: 20rpx;
  126. margin-right: 20rpx;
  127. margin-top: 10rpx ;
  128. margin-bottom: 10rpx ;
  129. border: 0rpx solid gray;
  130. padding: 10rpx 20rpx;
  131. border-radius: 30rpx;
  132. background-color: #ffffff;
  133. }
  134. .hotStudent{
  135. position: relative;
  136. display: flex;
  137. padding: 10rpx;
  138. height: 170rpx;
  139. align-items: center;
  140. }
  141. /* teachsex */
  142. .publicSex{
  143. position: absolute;
  144. right: 10rpx;
  145. top: 5rpx;
  146. border: 0rpx solid gray;
  147. padding: 5rpx 10rpx;
  148. border-radius: 30rpx;
  149. background-color: #3ed598;
  150. color: #ffffff;
  151. font-size: 12px;
  152. }
  153. </style>