guest.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  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. wxMapSdk.calculateDistance({
  202. mode:'straight',
  203. from:{
  204. latitude: this.$store.state.latitude,
  205. longitude: this.$store.state.longitude
  206. },
  207. to:arr,
  208. success:dists=>{
  209. if(dists.message==="query ok"){
  210. for(let j=0;j<dists.result.elements.length;j++){
  211. 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`)
  212. }
  213. }
  214. },fail:err=>{
  215. console.log(err)
  216. }
  217. });
  218. })
  219. },
  220. toDetail(id){
  221. uni.showLoading({})
  222. let user=JSON.parse(uni.getStorageSync('user'));
  223. this.$api.public.userDetail({getAlbum:true,completeUser:user,uponUserId:id}).then(res=>{
  224. if(res.data.sex===user.sex){
  225. uni.showToast({
  226. title:'同性用户不能查看主页',
  227. icon:'none'
  228. })
  229. }
  230. else{
  231. this.otherInfo=res.data;
  232. uni.setStorageSync('otherInfo',JSON.stringify(res.data));
  233. uni.hideLoading();
  234. uni.navigateTo({
  235. url:`/pages/friends/user?id=${id}`
  236. })
  237. }
  238. })
  239. },
  240. }
  241. }
  242. </script>
  243. <style lang="scss" scoped>
  244. .container{
  245. width: 100vw;
  246. height: 100vh;
  247. background-color: $bgcolor1;
  248. position: relative;
  249. overflow: hidden;
  250. .topnav {
  251. padding: 0 10rpx;
  252. position: fixed;
  253. top: 0;
  254. left: 0;
  255. width: 100vw;
  256. z-index: 100;
  257. background-color: $bgcolor1;
  258. .nav-item{
  259. width: 40rpx;
  260. height: 40rpx;
  261. margin-left: 16rpx;
  262. .nav-img{
  263. width: 40rpx;
  264. height: 40rpx;
  265. }
  266. }
  267. .nav-text{
  268. flex: 1;
  269. color: $fontcolor5;
  270. height: 40rpx;
  271. text-align: center;
  272. }
  273. }
  274. .list-item{
  275. flex-wrap: wrap;
  276. padding: 40rpx 32rpx;
  277. .list-head-box{
  278. width: 136rpx;
  279. height: 136rpx;
  280. position: relative;
  281. .list-head-img{
  282. width: 136rpx;
  283. height: 136rpx;
  284. background-color: #ffffff;
  285. border-radius: 136rpx;
  286. }
  287. .list-head-dot{
  288. width: 24rpx;
  289. height: 24rpx;
  290. border-radius: 24rpx;
  291. position: absolute;
  292. background-color: aqua;
  293. bottom: 2rpx;
  294. right: 2rpx;
  295. border: 2rpx solid $bgcolor2;
  296. }
  297. }
  298. .list-info-box{
  299. box-sizing: border-box;
  300. width: 544rpx;
  301. padding-left: 32rpx;
  302. height: 136rpx;
  303. flex-direction: column;
  304. display: flex;
  305. justify-content: flex-start;
  306. align-items: flex-start;
  307. .name-box{
  308. width: 100%;
  309. .name{
  310. .name-text{
  311. color: $fontcolor5;
  312. }
  313. .name-img{
  314. width: 68rpx;
  315. height: 32rpx;
  316. margin-left: 8rpx;
  317. }
  318. .name-img-godness{
  319. width: 76rpx;
  320. height: 40rpx;
  321. margin-left: 8rpx;
  322. transform: translateY(-5rpx);
  323. }
  324. }
  325. .distance{
  326. color: $fontcolor3;
  327. }
  328. }
  329. .sex-box{
  330. width: 74rpx;
  331. height: 32rpx;
  332. background: rgba(226, 53, 104, 0.2);
  333. border-radius: 25rpx;
  334. margin-top: 12rpx;
  335. .sex-img{
  336. width: 24rpx;
  337. height: 24rpx;
  338. }
  339. .sex-text{
  340. color:#E23568 ;
  341. }
  342. }
  343. .tip-box{
  344. color: $fontcolor3;
  345. width: 100%;
  346. margin-top: 10rpx;
  347. }
  348. }
  349. .img-box{
  350. width: 544rpx;
  351. height: 168rpx;
  352. margin-left: 168rpx;
  353. margin-top: 24rpx;
  354. .ib1{
  355. width: 168rpx;
  356. height: 168rpx;
  357. border-radius: 16rpx 0rpx 0rpx 16rpx;
  358. background: $fontcolor5;
  359. }
  360. .ib2{
  361. width: 168rpx;
  362. height: 168rpx;
  363. background: $fontcolor5;
  364. }
  365. .ib3{
  366. width: 168rpx;
  367. height: 168rpx;
  368. border-radius: 0rpx 16rpx 16rpx 0rpx;
  369. background: $fontcolor5;
  370. }
  371. }
  372. }
  373. }
  374. </style>