addressBook.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <view>
  3. <u-index-list :scrollTop="scrollTop" :index-list="indexList" :active-color="'#3CC51F'">
  4. <view v-if="isShowMenu">
  5. <u-index-anchor index="#" />
  6. <view class="list-cell" hover-class="message-hover-class" @tap="linkToNewFriend">
  7. <u-image width="70rpx" height="70rpx" src="/static/image/friend_1.png"></u-image>
  8. <view class="list-cell-name">新的朋友</view>
  9. </view>
  10. <view class="list-cell " hover-class="message-hover-class" @tap="linkToGroupItem">
  11. <u-image width="70rpx" height="70rpx" src="/static/image/group_1.png"></u-image>
  12. <view class="list-cell-name">我的群聊</view>
  13. </view>
  14. </view>
  15. <view v-if="isSearch">
  16. <u-index-anchor index="#" />
  17. <view class="list-cell" hover-class="message-hover-class">
  18. <u-search v-model="keyword" placeholder="搜索" shape="square" :show-action="false" :bg-color="'#ffffff'"></u-search>
  19. </view>
  20. </view>
  21. <view v-for="(item, index) in list" :key="index">
  22. <u-index-anchor :index="item.name" v-if="item.members&&item.members.length"/>
  23. <view v-for="user in item.members" :key="user.id" class="list-cell " @tap="linkToCard(user)" hover-class="message-hover-class">
  24. <img-cache :src="`${$url}/${user.avatar}`"></img-cache>
  25. <view class="list-cell-name">{{user.nickName}}</view>
  26. </view>
  27. </view>
  28. </u-index-list>
  29. </view>
  30. </template>
  31. <script>
  32. import ImgCache from '@/components/img-cache/img-cache.vue';
  33. export default {
  34. name:'u-addressBook',
  35. components:{ ImgCache },
  36. props:{
  37. list:{
  38. type:Array,
  39. default () {
  40. return [];
  41. }
  42. },
  43. isShowMenu:{
  44. type: Boolean,
  45. default () {
  46. return false;
  47. }
  48. },
  49. isSearch:{
  50. type: Boolean,
  51. default () {
  52. return false;
  53. }
  54. },
  55. scrollTop:{
  56. type:Number,
  57. default: 0
  58. }
  59. },
  60. watch:{
  61. keyword:function(val){
  62. let arr = this.tList;
  63. if(val!=''){
  64. this.list = arr.filter(v => {
  65. let flag = false
  66. if(v.members.length>0){
  67. v.members.forEach(m=>{
  68. if(m.groupNickName.includes(val)){
  69. flag = true
  70. }
  71. })
  72. }
  73. return flag
  74. })
  75. }else {
  76. this.list = this.tList
  77. }
  78. }
  79. },
  80. data() {
  81. return {
  82. tList: this.list,
  83. keyword:'',
  84. url1:require('@/static/image/friend_1.png'),
  85. url2:require('@/static/image/group_1.png'),
  86. $url:'',
  87. indexList: ['#', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
  88. };
  89. },
  90. methods:{
  91. linkToCard(user){
  92. this.$emit('linkTo',user);
  93. },
  94. linkToNewFriend(){
  95. this.$u.route({
  96. url: 'pages/newFriend/newFriend'
  97. });
  98. },
  99. linkToGroupItem(){
  100. this.$u.route({
  101. url: 'pages/groupItem/groupItem'
  102. });
  103. }
  104. }
  105. }
  106. </script>
  107. <style lang="scss">
  108. .list-cell {
  109. display: flex;
  110. box-sizing: border-box;
  111. width: 100%;
  112. padding: 10px 24rpx;
  113. overflow: hidden;
  114. color: #323233;
  115. font-size: 28rpx;
  116. font-weight: 800;
  117. line-height: 48rpx;
  118. background-color: #fff;
  119. border-bottom: solid 3rpx #eeeeee;
  120. align-items: center;
  121. image {
  122. width: 76rpx;
  123. height: 76rpx;
  124. border-radius: 12rpx;
  125. flex: 0 0 76rpx;
  126. }
  127. &-name{
  128. padding-left: 20rpx;
  129. }
  130. }
  131. </style>