attachment-list.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <template>
  2. <view class="attachment-box">
  3. <view class="attachment-title sys-color-black">附近精选</view>
  4. <view class="attachment-text sys-color-gray-9">每日推送附近优质用户来场高质量社交</view>
  5. <view class="attachment-list">
  6. <view class="attachment-item" :style="{'background-image':'url('+item.img+')'}" v-for="item in list">
  7. <view class="attachment-data">
  8. <view class="data-name sys-color-white sys-weight-600 sys-webkit-box sys-height-44">{{item.name}}</view>
  9. <view class="data-text sys-height-44">
  10. <text class="sys-height-44 sys-color-white text-item">{{item.age}}</text>
  11. <text class="sys-height-44 sys-color-white text-item">/</text>
  12. <text class="sys-height-44 sys-color-white text-item">{{item.sex}}</text>
  13. <text class="sys-height-44 sys-color-white text-item">/</text>
  14. <text class="sys-height-44 sys-color-white text-item">{{item.constellation}}</text>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="attachment-open" v-show="isLock">
  20. <view class="open-data sys-background-yellow sys-radius-200">
  21. <image class="open-img" src="/static/img/common/lock.png" mode="aspectFill"></image>
  22. <view class="open-text sys-color-black sys-weight-500" >立即解锁</view>
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. import {getNearbyList} from "@/api/discovery";
  29. import tools from "@/service/tools";
  30. export default {
  31. name: "attachment-list",
  32. components: {},
  33. props: {
  34. },
  35. data() {
  36. return {
  37. page:1,
  38. total:undefined,
  39. isAjax:false,
  40. list:[],
  41. isLock:false
  42. }
  43. },
  44. watch: {},
  45. mounted() {
  46. this.getAttachmentList()
  47. },
  48. methods: {
  49. async getAttachmentList(){
  50. if(this.isLock && this.page>1 ){
  51. return false
  52. }
  53. if(this.total<=this.list.length){
  54. return false
  55. }
  56. if(this.isAjax){
  57. return false
  58. }
  59. this.isAjax=true
  60. let locationData=await tools.getLocation()
  61. getNearbyList({'pageNo':this.page,'pageSize':20,'longitude':locationData.longitude,'latitude':locationData.latitude}).then((res)=>{
  62. this.isAjax=false
  63. if(res.code===0){
  64. this.page++
  65. this.total=res.total
  66. res.data.data.forEach( (item)=>{
  67. let galleryUrls=item.galleryUrls
  68. let age=tools.getAge(item.dateOfBirth)
  69. if(galleryUrls.length>0){
  70. if(galleryUrls.length>8){
  71. galleryUrls=galleryUrls.slice(0,7)
  72. }
  73. let newdata = {
  74. img: galleryUrls[0],
  75. age: age,
  76. name: item.nickname,
  77. userId: item.userId,
  78. sex: '女',
  79. constellation: '处女座',
  80. }
  81. this.list.push(newdata)
  82. }
  83. })
  84. }
  85. })
  86. }
  87. }
  88. }
  89. </script>
  90. <style scoped lang="scss">
  91. .attachment-box{
  92. .attachment-title{
  93. margin-top: 40rpx;
  94. text-align: center;
  95. font-size: 44rpx;
  96. height: 44rpx;
  97. line-height: 44rpx;
  98. -webkit-background-clip: text;
  99. }
  100. .attachment-text{
  101. text-align: center;
  102. margin-top: 16rpx;
  103. font-size: 32rpx;
  104. height: 44rpx;
  105. line-height: 44rpx;
  106. }
  107. .attachment-list{
  108. padding: 32rpx;
  109. display: flex;
  110. flex-wrap: wrap;
  111. }
  112. .attachment-item{
  113. border-radius: 20rpx;
  114. display: inline-block;
  115. margin-right:18rpx;
  116. width: calc((100vw - 82rpx)/2);
  117. height: 504rpx;
  118. background-repeat: no-repeat;//不平铺
  119. background-position: center center;//居中
  120. background-size: cover;//随容器大小
  121. position: relative;
  122. .attachment-data{
  123. position: absolute;
  124. left: 24rpx;
  125. bottom: 24rpx;
  126. width: calc((100vw - 82rpx)/2 - 48rpx);
  127. .data-name{
  128. font-size: 36rpx;
  129. }
  130. .data-text{
  131. .text-item{
  132. margin-right: 6rpx;
  133. font-size: 24rpx;
  134. }
  135. }
  136. }
  137. }
  138. .attachment-item:nth-of-type(2n+0){
  139. margin-right:0;
  140. }
  141. .attachment-item:nth-of-type(n+3){
  142. margin-top:18rpx;
  143. }
  144. .attachment-open{
  145. position: fixed;
  146. left: 0;
  147. bottom: 80rpx;
  148. width: 100vw;
  149. height: 190rpx;
  150. background: linear-gradient(180deg, rgba(255,255,255,0) 0%, #FFFFFF 100%);
  151. padding: 70rpx 80rpx 30rpx 80rpx;
  152. box-sizing: border-box;
  153. .open-data{
  154. display: flex;
  155. justify-content: center;
  156. height: 88rpx;
  157. padding: 22rpx 0;
  158. box-sizing: border-box;
  159. .open-img{
  160. width: 32rpx;
  161. height: 32rpx;
  162. margin-right: 8rpx;
  163. margin-top: 6rpx;
  164. }
  165. .open-text{
  166. font-size: 32rpx;
  167. //height: 44rpx;
  168. //line-height: 44rpx;
  169. }
  170. }
  171. }
  172. }
  173. </style>