addressBook.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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>
  26. <view class="list-cell-name">{{user.nickName}}</view>
  27. <u-tag v-if="user.traderFlag == 1" style="margin-left: 10px;font-weight: 500;" text="粮商" size ="mini"type="info" mode="plain"/>
  28. <u-tag v-if="user.farmerFlag == 1" style="margin-left: 10px;font-weight: 500;" text="粮农" size ="mini"type="info" mode="plain"/>
  29. <u-tag v-if="user.driverFlag == 1" style="margin-left: 10px;font-weight: 500;" text="物流" size ="mini"type="info" mode="plain"/>
  30. </view>
  31. </view>
  32. </view>
  33. </u-index-list>
  34. </view>
  35. </template>
  36. <script>
  37. import ImgCache from '@/components/img-cache/img-cache.vue';
  38. export default {
  39. name:'u-addressBook',
  40. components:{ ImgCache },
  41. props:{
  42. list:{
  43. type:Array,
  44. default () {
  45. return [];
  46. }
  47. },
  48. isShowMenu:{
  49. type: Boolean,
  50. default () {
  51. return false;
  52. }
  53. },
  54. isSearch:{
  55. type: Boolean,
  56. default () {
  57. return false;
  58. }
  59. },
  60. scrollTop:{
  61. type:Number,
  62. default: 0
  63. }
  64. },
  65. watch:{
  66. keyword:function(val){
  67. let arr = this.tList;
  68. if(val!=''){
  69. this.list = arr.filter(v => {
  70. let flag = false
  71. if(v.members.length>0){
  72. v.members.forEach(m=>{
  73. if(m.groupNickName.includes(val)){
  74. flag = true
  75. }
  76. })
  77. }
  78. return flag
  79. })
  80. }else {
  81. this.list = this.tList
  82. }
  83. }
  84. },
  85. data() {
  86. return {
  87. tList: this.list,
  88. keyword:'',
  89. // url1:require('@/static/image/friend_1.png'),
  90. // url2:require('@/static/image/group_1.png'),
  91. $url:'',
  92. indexList: ['#', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
  93. };
  94. },
  95. methods:{
  96. linkToCard(user){
  97. console.log("点击了用户")
  98. console.log(user)
  99. this.$emit('linkTo',user);
  100. },
  101. linkToNewFriend(){
  102. this.$u.route({
  103. url: 'pageA/newFriend/newFriend'
  104. });
  105. },
  106. linkToGroupItem(){
  107. this.$u.route({
  108. url: 'pageD/groupItem/groupItem'
  109. });
  110. }
  111. }
  112. }
  113. </script>
  114. <style lang="scss">
  115. .list-cell {
  116. display: flex;
  117. box-sizing: border-box;
  118. width: 100%;
  119. padding: 10px 24rpx;
  120. overflow: hidden;
  121. color: #323233;
  122. font-size: 28rpx;
  123. font-weight: 800;
  124. line-height: 48rpx;
  125. background-color: #fff;
  126. border-bottom: solid 3rpx #eeeeee;
  127. align-items: center;
  128. image {
  129. width: 76rpx;
  130. height: 76rpx;
  131. border-radius: 12rpx;
  132. flex: 0 0 76rpx;
  133. }
  134. &-name{
  135. padding-left: 20rpx;
  136. }
  137. }
  138. </style>