newFriend.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <view class="content">
  3. <view v-for="(value, index) in list">
  4. <view class="item u-border-bottom" hover-class="message-hover-class">
  5. <img-cache :src="value.avatar || value.imgUrl"></img-cache>
  6. <view class="right title-wrap">
  7. <view class="right_top">
  8. <view class="right_top_name u-line-1">{{ value.nickName }}</view>
  9. <view class="right_top_time ">{{value.lastOperTime | format}}</view>
  10. </view>
  11. <view class="right_btm">
  12. <view class="u-line-1" v-show="value.status==0">
  13. <u-button @click="handleOn(value.id)" type="success" size="mini">同意</u-button>
  14. </view>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. components: {
  24. },
  25. data() {
  26. return {
  27. list: [],
  28. $url:''
  29. };
  30. },
  31. onLoad() {
  32. },
  33. onShow() {
  34. this.getNewFriend(false)
  35. },
  36. onPullDownRefresh() {
  37. this.getNewFriend(true)
  38. },
  39. methods: {
  40. handleOn(fid){
  41. console.log("点击同意")
  42. this.$socket.AcceptFriendRequest(fid,this.userData.user.operId,res=>{
  43. uni.showToast({
  44. title: '添加好友',
  45. duration: 2000
  46. });
  47. })
  48. },
  49. getNewFriend(freshFlag) {
  50. this.$socket.queryFriendRequestList(this.userData.user.operId, res => {
  51. this.list = res.userList;
  52. if(freshFlag){
  53. uni.stopPullDownRefresh();
  54. }
  55. });
  56. }
  57. },
  58. filters: {
  59. format: function (e) {
  60. // 获取js 时间戳
  61. let time = new Date().getTime();
  62. // 去掉 js 时间戳后三位
  63. time = parseInt((time - e) / 1000);
  64. // 存储转换值
  65. let s;
  66. if (time < 60 * 10) {
  67. // 十分钟内
  68. return '刚刚';
  69. } else if (time < 60 * 60 && time >= 60 * 10) {
  70. // 超过十分钟少于1小时
  71. s = Math.floor(time / 60);
  72. return s + '分钟前';
  73. } else if (time < 60 * 60 * 24 && time >= 60 * 60) {
  74. // 超过1小时少于24小时
  75. s = Math.floor(time / 60 / 60);
  76. return s + '小时前';
  77. } else if (time < 60 * 60 * 24 * 3 && time >= 60 * 60 * 24) {
  78. // 超过1天少于3天内
  79. s = Math.floor(time / 60 / 60 / 24);
  80. return s + '天前';
  81. } else {
  82. // 超过3天
  83. var date = new Date(e);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
  84. var Y = date.getFullYear() + '-';
  85. var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
  86. var D = date.getDate() + ' ';
  87. var h = date.getHours() + ':';
  88. var m = date.getMinutes() + ':';
  89. var ss = date.getSeconds();
  90. return h+m+ss;
  91. }
  92. }
  93. },
  94. };
  95. </script>
  96. <style lang="scss">
  97. .content{
  98. background-color: #fff;
  99. .item {
  100. width: 750rpx;
  101. height: 140rpx;
  102. display: flex;
  103. align-items: center;
  104. image {
  105. width: 96rpx;
  106. height: 96rpx;
  107. margin: 20rpx;
  108. border-radius: 12rpx;
  109. flex: 0 0 96rpx;
  110. }
  111. .right {
  112. overflow: hidden;
  113. flex: 1 0;
  114. padding: 20rpx 20rpx 40rpx 0;
  115. &_top {
  116. display: flex;
  117. justify-content: space-between;
  118. &_name {
  119. font-size: 28rpx;
  120. font-weight: 800;
  121. color: $u-main-color;
  122. flex: 0 0 450rpx;
  123. overflow: hidden;
  124. }
  125. &_time {
  126. font-size: 22rpx;
  127. color: $u-light-color;
  128. }
  129. }
  130. &_btm {
  131. display: flex;
  132. justify-content: space-between;
  133. align-items: center;
  134. font-size: 22rpx;
  135. color: $u-tips-color;
  136. }
  137. }
  138. }
  139. .bg_view {
  140. background-color: #fafafa;
  141. }
  142. .slot-wrap {
  143. display: flex;
  144. align-items: center;
  145. padding: 0 30rpx;
  146. }
  147. }
  148. </style>