guest.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. <template>
  2. <view class="container">
  3. <view id="topnav" class="topnav flex-between" :style="{'height':`${topbarOffsetHeight-statusBarHeight}px`,'padding-top':`${statusBarHeight}px`}">
  4. <view class="nav-item flex-center" @click="back">
  5. <image :src="`${assetsUrl}back.png`" mode="widthFix" class="nav-img"></image>
  6. </view>
  7. <view class="nav-text font32 fw600">
  8. {{pageName}}
  9. </view>
  10. <view class="nav-item"></view>
  11. </view>
  12. <scroll-view
  13. scroll-y="true"
  14. :style="{'height': `${scrollHeight}px`,'padding-top':`${topNavHeight}px`}"
  15. v-if="scrollHeight>0"
  16. lower-threshold="200"
  17. refresher-enabled="true"
  18. :refresher-triggered="scrollTriggered"
  19. :refresher-threshold="45"
  20. refresher-default-style="white"
  21. refresher-background="#151126"
  22. @refresherrefresh="scrollRefresh"
  23. @refresherpulling="scrollPulling"
  24. @refresherrestore="scrollRestore"
  25. @refresherabort="scrollAbort"
  26. @scrolltolower="scrollToBottom"
  27. >
  28. <view class="list-item flex-start" v-for="(item,index) in listData" :key="index" @click="toDetail(item.id)" >
  29. <view class="list-head-box">
  30. <image :src="item.iconThumbnail" mode="aspectFill" class="list-head-img"></image>
  31. <view class="list-head-dot" style="background-color: #38E825;" v-if="item.lastActiveTime<=30"></view>
  32. <view class="list-head-dot" style="background-color: #0ABDEF;" v-else-if="item.lastActiveTime>30&&item.lastActiveTime<=1440"></view>
  33. </view>
  34. <view class="list-info-box">
  35. <view class="name-box flex-between">
  36. <view class="name flex-start">
  37. <view class="name-text font28 fw600">
  38. {{item.nick}}
  39. </view>
  40. <image :src="`${assetsUrl}friends-vip.png`" mode="aspectFill" class="name-img" v-if="item.vip"></image>
  41. <image :src="`${assetsUrl}friends-godness.png`" mode="aspectFill" class="name-img-godness" v-if="item.goddess"></image>
  42. <image :src="`${assetsUrl}friends-real.png`" mode="aspectFill" class="name-img" v-else-if="item.realMan"></image>
  43. </view>
  44. <view class="distance font22 fw400" v-if="item.distance">
  45. {{item.distance}}
  46. </view>
  47. </view>
  48. <view class="sex-box flex-center">
  49. <image :src="`${assetsUrl}friends-female.png`" mode="aspectFill" class="sex-img"></image>
  50. <view class="el font20 fw500 sex-text">
  51. {{item.ageInfo.age}}
  52. </view>
  53. </view>
  54. <view class="tip-box font28 fw400 el" v-if="item.desc">
  55. 签名:{{item.desc}}
  56. </view>
  57. <view class="tip-box font28 fw400 el" v-else>
  58. 签名:暂无介绍
  59. </view>
  60. </view>
  61. <view class="img-box flex-between" v-if="item.lastNews">
  62. <image :src="item.lastNews.mediaUrls[0]" mode="aspectFill" class="ib1"></image>
  63. <image :src="item.lastNews.mediaUrls[1]" mode="aspectFill" class="ib2"></image>
  64. <image :src="item.lastNews.mediaUrls[2]" mode="aspectFill" class="ib3"></image>
  65. </view>
  66. </view>
  67. <Status type="noData" text="暂无数据" v-if="showNoData"></Status>
  68. <view class="no-more font24 fw400" v-if="listData.length!==0&&listData.length>=scrollTotal">没有更多了</view>
  69. </scroll-view>
  70. </view>
  71. </template>
  72. <script>
  73. import wxMap from '@/static/qqmap-wx-jssdk1.2/qqmap-wx-jssdk.min.js';
  74. /**
  75. * 腾讯位置服务,手机账号:18996226740
  76. */
  77. const wxMapSdk=new wxMap({key:'E5SBZ-T2YC3-CBL3F-YGFQQ-26PP2-ERFII'});
  78. import Status from '@/components/Status/Status.vue';
  79. export default {
  80. components: {
  81. Status
  82. },
  83. data() {
  84. return {
  85. assetsUrl:this.$util.assetsUrl,
  86. pageName:'',
  87. scrollHeight:0,
  88. topNavHeight:0,
  89. pageType:'',
  90. getOptions:{
  91. index:1,
  92. size:20,
  93. sortValues:[]
  94. },
  95. listData:[],
  96. scrollTotal:0,
  97. scrollRefreshing:false,
  98. scrollTriggered:true,
  99. showNoData:false,
  100. user:null,
  101. otherInfo:null
  102. };
  103. },
  104. computed: {
  105. statusBarHeight() {
  106. return this.$store.state.statusBarHeight;
  107. },
  108. topbarOffsetHeight() {
  109. return this.$store.state.topbarOffsetHeight;
  110. },
  111. latitude(){
  112. return this.$store.state.latitude;
  113. },
  114. longitude(){
  115. return this.$store.state.longitude;
  116. },
  117. },
  118. onLoad(option) {
  119. console.log(option)
  120. this.pageType=option.pagetype;
  121. this.pageName=option.name;
  122. this.computedScollviewHeight();
  123. this.getGuestData();
  124. },
  125. methods:{
  126. back(){
  127. uni.navigateBack({
  128. delta:1
  129. })
  130. },
  131. /**
  132. * 计算scroll高度
  133. */
  134. computedScollviewHeight() {
  135. let query = uni.createSelectorQuery().in(this);
  136. let heightLeaf =0;
  137. query.select('#topnav').boundingClientRect(data => {
  138. this.topNavHeight=data.height;
  139. heightLeaf += data.height;
  140. }).exec(() => {
  141. let sysInfo = uni.getSystemInfoSync();
  142. this.scrollHeight = sysInfo.windowHeight - heightLeaf;
  143. });
  144. },
  145. /**
  146. * 推荐下拉刷新、加载更多
  147. */
  148. scrollRefresh(){
  149. if (this.scrollRefreshing)
  150. {
  151. return;
  152. }
  153. this.scrollRefreshing = true;
  154. setTimeout(() => {
  155. this.scrollTriggered = false;
  156. this.scrollRefreshing = false;
  157. }, 1000)
  158. this.getOptions={
  159. index:1,
  160. size:20,
  161. sortValues:[]
  162. }
  163. this.getGuestData();
  164. },
  165. scrollPulling(e) {},
  166. scrollRestore() {this.scrollTriggered = true;},
  167. scrollAbort() {},
  168. scrollToBottom(){
  169. if(this.listData.length>=this.scrollTotal){return;}
  170. this.getOptions.index++;
  171. this.getGuestData();
  172. },
  173. getGuestData(){
  174. let user=JSON.parse(uni.getStorageSync('user'));
  175. this.$api.public.guestor({
  176. completeUser:user,
  177. listType:this.pageType,
  178. page:this.getOptions,
  179. prefer:{
  180. nick:null,
  181. onlineIn24Hour:false
  182. },
  183. uponUserId:user.id
  184. }).then(res=>{
  185. if(res.data.users&&res.data.users.length===0){this.showNoData=true;}
  186. if(this.getOptions.index>1){
  187. this.listData=[...this.listData,...res.data.users];
  188. }
  189. else{
  190. this.listData=res.data.users;
  191. }
  192. this.scrollTotal=res.data.page.recordCount;
  193. let arr=[],obj={latitude:0,longitude:0};
  194. for(let i=0;i<this.listData.length;i++){
  195. this.listData[i].lastActiveTime=this.$moment(new Date()).diff(this.listData[i].lastActive,'minutes');
  196. obj={latitude:0,longitude:0};
  197. obj.latitude=this.listData[i].geo.lat;
  198. obj.longitude=this.listData[i].geo.lon;
  199. arr.push(obj)
  200. }
  201. console.log(arr)
  202. wxMapSdk.calculateDistance({
  203. mode:'straight',
  204. from:{
  205. latitude: this.$store.state.latitude,
  206. longitude: this.$store.state.longitude
  207. },
  208. to:arr,
  209. success:dists=>{
  210. if(dists.message==="query ok"){
  211. for(let j=0;j<dists.result.elements.length;j++){
  212. this.listData[j].distance=(dists.result.elements[j].distance>1000?`${Math.floor(dists.result.elements[j].distance/100)/10}km`:`${dists.result.elements[j].distance}m`)
  213. }
  214. console.log(this.listData)
  215. }
  216. },fail:err=>{
  217. console.log(err)
  218. }
  219. });
  220. })
  221. },
  222. toDetail(id){
  223. uni.showLoading({})
  224. let user=JSON.parse(uni.getStorageSync('user'));
  225. this.$api.public.userDetail({getAlbum:true,completeUser:user,uponUserId:id}).then(res=>{
  226. if(res.data.sex===user.sex){
  227. uni.showToast({
  228. title:'同性用户不能查看主页',
  229. icon:'none'
  230. })
  231. }
  232. else{
  233. this.otherInfo=res.data;
  234. uni.hideLoading();
  235. uni.navigateTo({
  236. url:`/pages/friends/user?id=${id}`
  237. })
  238. }
  239. })
  240. },
  241. }
  242. }
  243. </script>
  244. <style lang="scss" scoped>
  245. .container{
  246. width: 100vw;
  247. height: 100vh;
  248. background-color: $bgcolor1;
  249. position: relative;
  250. overflow: hidden;
  251. .topnav {
  252. padding: 0 10rpx;
  253. position: fixed;
  254. top: 0;
  255. left: 0;
  256. width: 100vw;
  257. z-index: 100;
  258. background-color: $bgcolor1;
  259. .nav-item{
  260. width: 40rpx;
  261. height: 40rpx;
  262. margin-left: 16rpx;
  263. .nav-img{
  264. width: 40rpx;
  265. height: 40rpx;
  266. }
  267. }
  268. .nav-text{
  269. flex: 1;
  270. color: $fontcolor5;
  271. height: 40rpx;
  272. text-align: center;
  273. }
  274. }
  275. .list-item{
  276. flex-wrap: wrap;
  277. padding: 40rpx 32rpx;
  278. .list-head-box{
  279. width: 136rpx;
  280. height: 136rpx;
  281. position: relative;
  282. .list-head-img{
  283. width: 136rpx;
  284. height: 136rpx;
  285. background-color: #ffffff;
  286. border-radius: 136rpx;
  287. }
  288. .list-head-dot{
  289. width: 24rpx;
  290. height: 24rpx;
  291. border-radius: 24rpx;
  292. position: absolute;
  293. background-color: aqua;
  294. bottom: 2rpx;
  295. right: 2rpx;
  296. border: 2rpx solid $bgcolor2;
  297. }
  298. }
  299. .list-info-box{
  300. box-sizing: border-box;
  301. width: 544rpx;
  302. padding-left: 32rpx;
  303. height: 136rpx;
  304. flex-direction: column;
  305. display: flex;
  306. justify-content: flex-start;
  307. align-items: flex-start;
  308. .name-box{
  309. width: 100%;
  310. .name{
  311. .name-text{
  312. color: $fontcolor5;
  313. }
  314. .name-img{
  315. width: 68rpx;
  316. height: 32rpx;
  317. margin-left: 8rpx;
  318. }
  319. .name-img-godness{
  320. width: 76rpx;
  321. height: 40rpx;
  322. margin-left: 8rpx;
  323. transform: translateY(-5rpx);
  324. }
  325. }
  326. .distance{
  327. color: $fontcolor3;
  328. }
  329. }
  330. .sex-box{
  331. width: 74rpx;
  332. height: 32rpx;
  333. background: rgba(226, 53, 104, 0.2);
  334. border-radius: 25rpx;
  335. margin-top: 12rpx;
  336. .sex-img{
  337. width: 24rpx;
  338. height: 24rpx;
  339. }
  340. .sex-text{
  341. color:#E23568 ;
  342. }
  343. }
  344. .tip-box{
  345. color: $fontcolor3;
  346. width: 100%;
  347. margin-top: 10rpx;
  348. }
  349. }
  350. .img-box{
  351. width: 544rpx;
  352. height: 168rpx;
  353. margin-left: 168rpx;
  354. margin-top: 24rpx;
  355. .ib1{
  356. width: 168rpx;
  357. height: 168rpx;
  358. border-radius: 16rpx 0rpx 0rpx 16rpx;
  359. background: $fontcolor5;
  360. }
  361. .ib2{
  362. width: 168rpx;
  363. height: 168rpx;
  364. background: $fontcolor5;
  365. }
  366. .ib3{
  367. width: 168rpx;
  368. height: 168rpx;
  369. border-radius: 0rpx 16rpx 16rpx 0rpx;
  370. background: $fontcolor5;
  371. }
  372. }
  373. }
  374. }
  375. </style>