blacklist.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  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,index)" >
  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. this.computedScollviewHeight();
  120. this.getGuestData();
  121. },
  122. methods:{
  123. back(){
  124. uni.navigateBack({
  125. delta:1
  126. })
  127. },
  128. /**
  129. * 计算scroll高度
  130. */
  131. computedScollviewHeight() {
  132. let query = uni.createSelectorQuery().in(this);
  133. let heightLeaf =0;
  134. query.select('#topnav').boundingClientRect(data => {
  135. this.topNavHeight=data.height;
  136. heightLeaf += data.height;
  137. }).exec(() => {
  138. let sysInfo = uni.getSystemInfoSync();
  139. this.scrollHeight = sysInfo.windowHeight - heightLeaf;
  140. });
  141. },
  142. /**
  143. * 推荐下拉刷新、加载更多
  144. */
  145. scrollRefresh(){
  146. if (this.scrollRefreshing)
  147. {
  148. return;
  149. }
  150. this.scrollRefreshing = true;
  151. setTimeout(() => {
  152. this.scrollTriggered = false;
  153. this.scrollRefreshing = false;
  154. }, 1000)
  155. this.getOptions={
  156. index:1,
  157. size:20,
  158. sortValues:[]
  159. }
  160. this.getGuestData();
  161. },
  162. scrollPulling(e) {},
  163. scrollRestore() {this.scrollTriggered = true;},
  164. scrollAbort() {},
  165. scrollToBottom(){
  166. if(this.listData.length>=this.scrollTotal){return;}
  167. this.getOptions.index++;
  168. this.getGuestData();
  169. },
  170. getGuestData(){
  171. let user=JSON.parse(uni.getStorageSync('user'));
  172. this.$api.public.guestor({
  173. completeUser:user,
  174. listType:'Black',
  175. page:this.getOptions,
  176. prefer:{
  177. nick:null,
  178. onlineIn24Hour:false
  179. },
  180. uponUserId:user.id
  181. }).then(res=>{
  182. if(res.data.users&&res.data.users.length===0){this.showNoData=true;}
  183. if(this.getOptions.index>1){
  184. this.listData=[...this.listData,...res.data.users];
  185. }
  186. else{
  187. this.listData=res.data.users;
  188. }
  189. this.scrollTotal=res.data.page.recordCount;
  190. let arr=[],obj={latitude:0,longitude:0};
  191. for(let i=0;i<this.listData.length;i++){
  192. this.listData[i].lastActiveTime=this.$moment(new Date()).diff(this.listData[i].lastActive,'minutes');
  193. obj={latitude:0,longitude:0};
  194. obj.latitude=this.listData[i].geo.lat;
  195. obj.longitude=this.listData[i].geo.lon;
  196. arr.push(obj)
  197. }
  198. wxMapSdk.calculateDistance({
  199. mode:'straight',
  200. from:{
  201. latitude: this.$store.state.latitude,
  202. longitude: this.$store.state.longitude
  203. },
  204. to:arr,
  205. success:dists=>{
  206. if(dists.message==="query ok"){
  207. for(let j=0;j<dists.result.elements.length;j++){
  208. 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`)
  209. }
  210. }
  211. },fail:err=>{
  212. console.log(err)
  213. }
  214. });
  215. })
  216. },
  217. toDetail(id,index){
  218. const that=this;
  219. uni.showActionSheet({
  220. itemList: ['取消拉黑', '查看主页'],
  221. success:res=>{
  222. if(res.tapIndex===0){
  223. let user=JSON.parse(uni.getStorageSync('user'));
  224. that.$api.public.operUponUser({
  225. completeUser:user,
  226. direction:'Cancel',
  227. operType:'Hate',
  228. uponUserId:id
  229. }).then(res=>{
  230. if(res.data.succ){
  231. uni.showToast({
  232. title:'操作成功'
  233. });
  234. that.listData.splice(index,1);
  235. that.scrollRefresh()
  236. }
  237. else{
  238. uni.showToast({
  239. icon:'none',
  240. title:res.data.msg
  241. });
  242. uni.navigateBack();
  243. }
  244. })
  245. }
  246. if(res.tapIndex===1){
  247. uni.showLoading({})
  248. let user=JSON.parse(uni.getStorageSync('user'));
  249. this.$api.public.userDetail({getAlbum:true,completeUser:user,uponUserId:id}).then(res=>{
  250. if(res.data.sex===user.sex){
  251. uni.showToast({
  252. title:'同性用户不能查看主页',
  253. icon:'none'
  254. })
  255. }
  256. else{
  257. this.otherInfo=res.data;
  258. uni.setStorageSync('otherInfo',JSON.stringify(res.data));
  259. uni.hideLoading();
  260. uni.navigateTo({
  261. url:`/pages/friends/user?id=${id}`
  262. })
  263. }
  264. })
  265. }
  266. }
  267. })
  268. },
  269. }
  270. }
  271. </script>
  272. <style lang="scss" scoped>
  273. .container{
  274. width: 100vw;
  275. height: 100vh;
  276. background-color: $bgcolor1;
  277. position: relative;
  278. overflow: hidden;
  279. .topnav {
  280. padding: 0 10rpx;
  281. position: fixed;
  282. top: 0;
  283. left: 0;
  284. width: 100vw;
  285. z-index: 100;
  286. background-color: $bgcolor1;
  287. .nav-item{
  288. width: 40rpx;
  289. height: 40rpx;
  290. margin-left: 16rpx;
  291. .nav-img{
  292. width: 40rpx;
  293. height: 40rpx;
  294. }
  295. }
  296. .nav-text{
  297. flex: 1;
  298. color: $fontcolor5;
  299. height: 40rpx;
  300. text-align: center;
  301. }
  302. }
  303. .list-item{
  304. flex-wrap: wrap;
  305. padding: 40rpx 32rpx;
  306. .list-head-box{
  307. width: 136rpx;
  308. height: 136rpx;
  309. position: relative;
  310. .list-head-img{
  311. width: 136rpx;
  312. height: 136rpx;
  313. background-color: #ffffff;
  314. border-radius: 136rpx;
  315. }
  316. .list-head-dot{
  317. width: 24rpx;
  318. height: 24rpx;
  319. border-radius: 24rpx;
  320. position: absolute;
  321. background-color: aqua;
  322. bottom: 2rpx;
  323. right: 2rpx;
  324. border: 2rpx solid $bgcolor2;
  325. }
  326. }
  327. .list-info-box{
  328. box-sizing: border-box;
  329. width: 544rpx;
  330. padding-left: 32rpx;
  331. height: 136rpx;
  332. flex-direction: column;
  333. display: flex;
  334. justify-content: flex-start;
  335. align-items: flex-start;
  336. .name-box{
  337. width: 100%;
  338. .name{
  339. .name-text{
  340. color: $fontcolor5;
  341. }
  342. .name-img{
  343. width: 68rpx;
  344. height: 32rpx;
  345. margin-left: 8rpx;
  346. }
  347. .name-img-godness{
  348. width: 76rpx;
  349. height: 40rpx;
  350. margin-left: 8rpx;
  351. transform: translateY(-5rpx);
  352. }
  353. }
  354. .distance{
  355. color: $fontcolor3;
  356. }
  357. }
  358. .sex-box{
  359. width: 74rpx;
  360. height: 32rpx;
  361. background: rgba(226, 53, 104, 0.2);
  362. border-radius: 25rpx;
  363. margin-top: 12rpx;
  364. .sex-img{
  365. width: 24rpx;
  366. height: 24rpx;
  367. }
  368. .sex-text{
  369. color:#E23568 ;
  370. }
  371. }
  372. .tip-box{
  373. color: $fontcolor3;
  374. width: 100%;
  375. margin-top: 10rpx;
  376. }
  377. }
  378. .img-box{
  379. width: 544rpx;
  380. height: 168rpx;
  381. margin-left: 168rpx;
  382. margin-top: 24rpx;
  383. .ib1{
  384. width: 168rpx;
  385. height: 168rpx;
  386. border-radius: 16rpx 0rpx 0rpx 16rpx;
  387. background: $fontcolor5;
  388. }
  389. .ib2{
  390. width: 168rpx;
  391. height: 168rpx;
  392. background: $fontcolor5;
  393. }
  394. .ib3{
  395. width: 168rpx;
  396. height: 168rpx;
  397. border-radius: 0rpx 16rpx 16rpx 0rpx;
  398. background: $fontcolor5;
  399. }
  400. }
  401. }
  402. }
  403. </style>