index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <view class="contact_container">
  3. <uv-index-list :index-list="indexList">
  4. <!-- <template v-slot:header>
  5. <view class="top">
  6. <uni-list>
  7. <uni-list-item :clickable="true" @click="clickTop" :to="'./group/index'">
  8. <template v-slot:body>
  9. <view class="top_slot_container">
  10. <uni-row>
  11. <uni-col :xs="5" :sm="4">
  12. <uni-icons color="#ffffff" type="staff" size="50"></uni-icons>
  13. </uni-col>
  14. <uni-col :xs="17" :sm="18">
  15. <view class="top_text">部门</view>
  16. </uni-col>
  17. </uni-row>
  18. </view>
  19. </template>
  20. </uni-list-item>
  21. </uni-list>
  22. </view>
  23. </template> -->
  24. <template v-for="(items, index) in itemArr" :key="index">
  25. <uv-index-item>
  26. <uv-index-anchor :text="indexList[index]" size="16"></uv-index-anchor>
  27. <view class="chat_list">
  28. <uni-list :border="true">
  29. <uni-list-chat v-for="(item, index) in items" @click="clickChat(item)" :title="item.name"
  30. :avatar="item.avatar || headImg" :note="item.desktop_phone" :clickable="true" :avatar-circle="true" :key="index">
  31. <view class="chat-custom-right">
  32. <text class="chat-custom-text" v-text="item.dept"></text>
  33. </view>
  34. </uni-list-chat>
  35. </uni-list>
  36. </view>
  37. </uv-index-item>
  38. </template>
  39. </uv-index-list>
  40. </view>
  41. </template>
  42. <script setup lang="ts">
  43. import { onMounted, ref } from 'vue'
  44. import headImg from "@/static/images/mine/headImg.jpg";
  45. import $tab from '@/plugins/tab.js'
  46. import { getContactAllUser } from '@/api/contacts.js'
  47. onMounted(() => {
  48. const unitId = '47517153919893'
  49. // 获取 通讯录 索引列表
  50. getContactAllUser(unitId).then(res => {
  51. getContactList(res.returnParams)
  52. })
  53. })
  54. // 索引列表
  55. const indexList = ref([])
  56. const itemArr = ref([])
  57. function getContactList(data) {
  58. // console.log('data', data);
  59. for(let key in data) {
  60. // hasOwnProperty 排除 __proto__等数据
  61. if (data.hasOwnProperty(key)) {
  62. // 过滤 userState 为 0 的 User
  63. data[key] = data[key].filter(user => user.userState !== '0')
  64. } else {
  65. continue
  66. }
  67. // 删除 过滤后 数据为0的 索引
  68. if (data[key].length === 0) delete data[key]
  69. }
  70. // 获取索引
  71. indexList.value = Object.keys(data)
  72. // 获取索引数据
  73. itemArr.value = Object.values(data)
  74. }
  75. function clickTop() {
  76. console.log('clickTop');
  77. }
  78. // 点击通讯录列表
  79. function clickChat(e) {
  80. $tab.navigateTo('/pages/mine/personal_message/personal_message?id=' + e.useId + '&name=' + e.name)
  81. }
  82. </script>
  83. <style lang="scss">
  84. .contact_container {
  85. .top {
  86. .top_slot_container {
  87. height: 100%;
  88. width: 100%;
  89. ::v-deep .uni-icons {
  90. background-color: #468bf0;
  91. border-radius: 50%;
  92. }
  93. .top_text {
  94. font-size: 24px;
  95. }
  96. }
  97. }
  98. .chat_list {
  99. .chat-custom-right {
  100. .chat-custom-text {
  101. margin-right: 10px;
  102. }
  103. }
  104. }
  105. }
  106. </style>