chatList.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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="pwa-guide" id="btnPwa" style="display:none">
  13. <span>{{$t('public.installPwa')}}</span>
  14. <div class="btn-close">
  15. <i class="el-icon-close" @click.stop="closePwaGuide()"></i>
  16. </div>
  17. </div>
  18. <div class="chat-list pub-scroll-box">
  19. <template v-if="!isSearch">
  20. <session-item
  21. v-for="(item, index) in sessionList"
  22. :key="index"
  23. :item="item">
  24. </session-item>
  25. </template>
  26. <template v-else>
  27. <session-item
  28. v-for="(item, index) in searchList"
  29. :key="index"
  30. :item="item">
  31. </session-item>
  32. </template>
  33. </div>
  34. </div>
  35. </template>
  36. <script>
  37. import { mapState, mapMutations } from 'vuex'
  38. import sessionItem from '@/components/panel/sessionItem'
  39. import { searchUserMixin } from '@/mixins'
  40. export default {
  41. name: 'chatList',
  42. mixins: [searchUserMixin],
  43. components: {
  44. sessionItem
  45. },
  46. data () {
  47. return {
  48. searchShow: false
  49. }
  50. },
  51. computed: {
  52. ...mapState({
  53. sessionList: state => state.chat.sessionList,
  54. userInfo: state => state.userInfo
  55. })
  56. },
  57. methods: {
  58. ...mapMutations(['clearHash']),
  59. handleBlur (e) {
  60. let val = e.target.value
  61. if (!val) {
  62. this.searchShow = false
  63. }
  64. },
  65. toSearch () {
  66. this.$router.push({ path: `/search` })
  67. },
  68. closePwaGuide () {
  69. let btnPwa = document.getElementById('btnPwa')
  70. btnPwa.style.display = 'none'
  71. }
  72. },
  73. created () {
  74. this.$store.dispatch('getSessionList')
  75. if (this.userInfo && this.userInfo.user_id) this.$store.dispatch('getUserInfo')
  76. this.$store.commit('setUserId', localStorage.getItem('user_id'))
  77. },
  78. mounted () {
  79. this.clearHash()
  80. }
  81. }
  82. </script>
  83. <style lang="scss" scoped>
  84. .chat-list{
  85. background-color: #ffffff;
  86. overflow-x: hidden;
  87. }
  88. .top-search{
  89. height: px2rem(88);
  90. background-color: #f2f2f2;
  91. display: flex;
  92. align-items: center;
  93. > i{
  94. margin: 0 px2rem(20);
  95. }
  96. .search-wrap{
  97. flex: 1;
  98. background-color: #ffffff;
  99. border-radius: 4px;
  100. border: 1px solid #eeeeee;
  101. height: px2rem(60);
  102. line-height: px2rem(60);
  103. box-sizing: border-box;
  104. font-size: px2rem(28);
  105. }
  106. input{
  107. padding-left: px2rem(10);
  108. font-size: px2rem(28);
  109. color: #666666;
  110. }
  111. }
  112. .pwa-guide{
  113. position: relative;
  114. height: px2rem(81);
  115. line-height: px2rem(81);
  116. color: #438aff;
  117. font-size: px2rem(30);
  118. text-align: center;
  119. &::after{
  120. content: "";
  121. position: absolute;
  122. bottom: 0;
  123. left: 0;
  124. right: 0;
  125. border-bottom: 1px solid #d8d8d8;
  126. transform: scaleY(0.5);
  127. }
  128. .btn-close{
  129. position: absolute;
  130. top: 0;
  131. right: 0;
  132. width: px2rem(75);
  133. height: 100%;
  134. color: #999;
  135. }
  136. }
  137. .meechat-icon{
  138. display: inline-block;
  139. margin: 0 px2rem(20);
  140. background: url('../../../assets/h5/meechat-logo.png') 0 0 / 100% no-repeat;
  141. width: px2rem(42);
  142. height: px2rem(39);
  143. }
  144. .add-icon{
  145. background: url('../../../assets/more-icon.png');
  146. width: px2rem(42);
  147. height: px2rem(42);
  148. margin: 0 px2rem(20);
  149. background-size: 100%;
  150. }
  151. .search-tips{
  152. color: #8e8e93;
  153. i{
  154. display: inline-block;
  155. vertical-align: middle;
  156. margin: 0 px2rem(6) 0 px2rem(27);
  157. font-size: px2rem(26);
  158. }
  159. }
  160. </style>