chatList.vue 3.0 KB

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