panel.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <div class="c-panel">
  3. <div class="c-panel-header">
  4. <div class="avatar-wrap" @click="$showUserInfo" v-if="userInfo">
  5. <img v-if="userInfo.cover_photo" :src="userInfo.cover_photo" alt="">
  6. <div v-else class="user-avatar"
  7. :class="'avatar_bg' + userInfo.user_id % 9"
  8. :data-name="userInfo.nick_name && userInfo.nick_name.slice(0,2).toUpperCase()"></div>
  9. </div>
  10. <ul class="panel-ctrls">
  11. <li class="current">
  12. <i class="mee-icon-chat"></i>
  13. </li>
  14. </ul>
  15. <div class="panel-nav-icon" @click.stop="toggleLoginOut()">
  16. <ul :class="['menu',{'active':isShowLoginOut}]">
  17. <li class="item" @click.stop="handleLoginOut">
  18. <i class="exit-icon"></i>退出
  19. </li>
  20. </ul>
  21. </div>
  22. </div>
  23. <div class="c-panel-nav">
  24. <div class="panel-searbar">
  25. <div class="input-con">
  26. <i class="el-icon-search"></i>
  27. <input type="text" @input="searchUser($event, sessionList)" placeholder="搜索">
  28. </div>
  29. <i class="el-icon-plus" @click="$showInvite(1)"></i>
  30. </div>
  31. <!-- <div class="group-recommand">
  32. <i class="group-icon"></i>
  33. <p class="title">熱門群組推薦<i class="el-icon-arrow-right"></i></p>
  34. </div> -->
  35. <div class="chat-list pub-scroll-box">
  36. <template v-if="!isSearch">
  37. <session-item
  38. v-for="(item, index) in sessionList"
  39. :key="index"
  40. :item="item">
  41. </session-item>
  42. </template>
  43. <template v-else>
  44. <session-item
  45. v-for="(item, index) in searchList"
  46. :key="index"
  47. :item="item">
  48. </session-item>
  49. </template>
  50. </div>
  51. </div>
  52. </div>
  53. </template>
  54. <script>
  55. import { mapState } from 'vuex'
  56. import sessionItem from './sessionItem'
  57. import { searchUserMixin } from '@/mixins'
  58. export default {
  59. name: 'panel',
  60. mixins: [searchUserMixin],
  61. data () {
  62. return {
  63. isShowLoginOut: false
  64. }
  65. },
  66. computed: {
  67. ...mapState({
  68. sessionList: state => state.chat.sessionList,
  69. userInfo: state => state.userInfo
  70. })
  71. },
  72. components: {
  73. sessionItem
  74. },
  75. methods: {
  76. toggleLoginOut (flag = true) {
  77. if (flag) this.isShowLoginOut = !this.isShowLoginOut
  78. else this.isShowLoginOut = false
  79. },
  80. handleLoginOut () {
  81. this.$store.dispatch('doScatterLogout')
  82. this.$store.commit('chatAppLogin', false)
  83. this.$store.commit('toApp', false)
  84. }
  85. },
  86. async created () {
  87. this.$store.dispatch('getSessionList')
  88. await this.$store.dispatch('getUserInfo')
  89. if (location.hash.match('user')) {
  90. this.$showUserInfo()
  91. }
  92. },
  93. mounted () {
  94. document.addEventListener('click', () => {
  95. this.toggleLoginOut(false)
  96. })
  97. }
  98. }
  99. </script>
  100. <style lang="scss" scoped>
  101. @import './panel.scss';
  102. </style>