addressBook.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <view style='margin-bottom:120rpx;'>
  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="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. console.log("点击了用户")
  93. console.log(user)
  94. this.$emit('linkTo',user);
  95. },
  96. linkToNewFriend(){
  97. this.$u.route({
  98. url: 'pageA/newFriend/newFriend'
  99. });
  100. },
  101. linkToGroupItem(){
  102. this.$u.route({
  103. url: 'pageD/groupItem/groupItem'
  104. });
  105. }
  106. }
  107. }
  108. </script>
  109. <style lang="scss">
  110. .list-cell {
  111. display: flex;
  112. box-sizing: border-box;
  113. width: 100%;
  114. padding: 10px 24rpx;
  115. overflow: hidden;
  116. color: #323233;
  117. font-size: 28rpx;
  118. font-weight: 800;
  119. line-height: 48rpx;
  120. background-color: #fff;
  121. border-bottom: solid 3rpx #eeeeee;
  122. align-items: center;
  123. image {
  124. width: 76rpx;
  125. height: 76rpx;
  126. border-radius: 12rpx;
  127. flex: 0 0 76rpx;
  128. }
  129. &-name{
  130. padding-left: 20rpx;
  131. }
  132. }
  133. </style>