chatList.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <div class="chat-list">
  3. <div class="top-search">
  4. <i class="meechat-icon"></i>
  5. <input type="text" class="search-wrap" @input="searchUser($event, sessionList)" @blur="handleBlur" v-focus v-if="searchShow">
  6. <div class="search-tips search-wrap" @click="searchShow = true" v-else>
  7. <i class="el-icon-search"></i>搜索
  8. </div>
  9. <i class="add-icon"></i>
  10. </div>
  11. <div class="chat-list pub-scroll-box">
  12. <template v-if="!isSearch">
  13. <session-item
  14. v-for="(item, index) in sessionList"
  15. :key="index"
  16. :item="item"
  17. :isMoblie="true">
  18. </session-item>
  19. </template>
  20. <template v-else>
  21. <session-item
  22. v-for="(item, index) in searchList"
  23. :key="index"
  24. :item="item"
  25. :isMoblie="true">
  26. </session-item>
  27. </template>
  28. </div>
  29. </div>
  30. </template>
  31. <script>
  32. import { mapState } from 'vuex'
  33. import sessionItem from '@/components/panel/sessionItem'
  34. import { searchUserMixin } from '@/mixins'
  35. export default {
  36. name: 'chatList',
  37. mixins: [searchUserMixin],
  38. components: {
  39. sessionItem
  40. },
  41. data () {
  42. return {
  43. searchShow: false
  44. }
  45. },
  46. computed: {
  47. ...mapState({
  48. sessionList: state => state.chat.sessionList,
  49. userInfo: state => state.userInfo
  50. })
  51. },
  52. methods: {
  53. handleBlur (e) {
  54. let val = e.target.value
  55. if (!val) {
  56. this.searchShow = false
  57. }
  58. }
  59. },
  60. created () {
  61. this.$store.dispatch('getSessionList')
  62. this.$store.dispatch('getUserInfo')
  63. }
  64. }
  65. </script>
  66. <style lang="scss" scoped>
  67. .chat-list{
  68. background-color: #ffffff;
  69. overflow-x: hidden;
  70. }
  71. .top-search{
  72. height: px2rem(88);
  73. background-color: #f2f2f2;
  74. display: flex;
  75. align-items: center;
  76. > i{
  77. margin: 0 px2rem(20);
  78. }
  79. .search-wrap{
  80. flex: 1;
  81. background-color: #ffffff;
  82. border-radius: 4px;
  83. border: 1px solid #eeeeee;
  84. height: px2rem(58);
  85. line-height: px2rem(58);
  86. box-sizing: border-box;
  87. font-size: px2rem(28);
  88. }
  89. input{
  90. padding-left: px2rem(10);
  91. font-size: px2rem(28);
  92. color: #666666;
  93. }
  94. }
  95. .meechat-icon{
  96. background: url('../../../assets/h5/meechat-logo.png');
  97. width: px2rem(42);
  98. height: px2rem(51);
  99. background-size: 100%;
  100. }
  101. .add-icon{
  102. background: url('../../../assets/more-icon.png');
  103. width: px2rem(42);
  104. height: px2rem(42);
  105. background-size: 100%;
  106. }
  107. .search-tips{
  108. text-align: center;
  109. color: #8e8e93;
  110. i{
  111. display: inline-block;
  112. vertical-align: middle;
  113. margin-right: 4px;
  114. font-size: px2rem(36);
  115. }
  116. }
  117. </style>