index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <view class="contacts-v">
  3. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :sticky="true"
  4. :down="downOption" :up="upOption" :bottombar="false">
  5. <view class="search-box search-box_sticky">
  6. <u-search :placeholder="$t('app.apply.pleaseKeyword')" v-model="keyword" height="72"
  7. :show-action="false" @change="search" bg-color="#f0f2f6" shape="square">
  8. </u-search>
  9. </view>
  10. <view class="list-cell u-p-l-20 u-p-r-20" v-for="(item, i) in list" :key="i" @click="detail(item.id)">
  11. <view class="u-border-bottom list-item u-font-28 u-flex">
  12. <u-avatar :src="baseURL+item.headIcon"></u-avatar>
  13. <view class="list-cell-txt">
  14. <view class="u-font-30 u-m-b-4" style="color: #303133;font-size: 28rpx;">
  15. {{item.realName}}/{{item.account}}
  16. </view>
  17. <view class="u-font-24 department u-m-t-4">{{item.department}}</view>
  18. </view>
  19. </view>
  20. </view>
  21. </mescroll-body>
  22. </view>
  23. </template>
  24. <script>
  25. import {
  26. getImUser
  27. } from '@/api/common.js'
  28. import resources from '@/libs/resources.js'
  29. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  30. export default {
  31. mixins: [MescrollMixin],
  32. data() {
  33. return {
  34. downOption: {
  35. use: true,
  36. auto: true
  37. },
  38. upOption: {
  39. page: {
  40. num: 0,
  41. size: 20,
  42. time: null
  43. },
  44. empty: {
  45. use: true,
  46. icon: resources.message.nodata,
  47. tip: this.$t('common.noData'),
  48. fixed: true,
  49. top: "300rpx",
  50. },
  51. textNoMore: this.$t('app.apply.noMoreData'),
  52. },
  53. keyword: '',
  54. list: []
  55. }
  56. },
  57. computed: {
  58. baseURL() {
  59. return this.define.baseURL
  60. }
  61. },
  62. methods: {
  63. upCallback(page) {
  64. let query = {
  65. currentPage: page.num,
  66. pageSize: page.size,
  67. keyword: this.keyword
  68. }
  69. getImUser(query, {
  70. load: page.num == 1
  71. }).then(res => {
  72. this.mescroll.endSuccess(res.data.list.length);
  73. if (page.num == 1) this.list = [];
  74. const list = res.data.list;
  75. this.list = this.list.concat(list);
  76. }).catch(() => {
  77. this.mescroll.endErr();
  78. })
  79. },
  80. search() {
  81. // 节流,避免输入过快多次请求
  82. this.searchTimer && clearTimeout(this.searchTimer)
  83. this.searchTimer = setTimeout(() => {
  84. this.list = [];
  85. this.mescroll.resetUpScroll();
  86. }, 300)
  87. },
  88. detail(id) {
  89. uni.navigateTo({
  90. url: '/pages/message/userDetail/index?userId=' + id,
  91. })
  92. }
  93. }
  94. }
  95. </script>
  96. <style lang="scss">
  97. page {
  98. background-color: #eef0f4;
  99. }
  100. .contacts-v {
  101. .list-cell {
  102. width: 100%;
  103. background-color: #fff;
  104. .list-item {
  105. box-sizing: border-box;
  106. overflow: hidden;
  107. color: $u-content-color;
  108. height: 136rpx;
  109. .list-cell-txt {
  110. margin-left: 20rpx;
  111. .department {
  112. color: #909399;
  113. font-size: 24rpx;
  114. }
  115. }
  116. }
  117. }
  118. }
  119. </style>