student_require_my_collect.vue 3.8 KB

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