index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <div class="r-view-mgr" @click.stop>
  3. <template v-if="!adminShow">
  4. <div class="groudMgr-top">
  5. <i class="el-icon-arrow-left" @click="handleGroudMgr"></i>
  6. <span>{{$t('public.setting')}}</span>
  7. <i class="el-icon-close" @click="handleCloseCharSet"></i>
  8. </div>
  9. <div class="ad-wrap">
  10. <div class="ad-item" @click="adminShow = true">
  11. {{$t('group.adminSetting')}}<i class="el-icon-arrow-right"></i>
  12. </div>
  13. <div class="ad-item" @click="$showInvite(5)">
  14. {{$t('invite.transferGroupOwner')}}<i class="el-icon-arrow-right"></i>
  15. </div>
  16. <div class="ad-item" @click="addGroupAuth">
  17. {{$t('group.groupCertification')}}<i class="el-icon-arrow-right"></i>
  18. </div>
  19. </div>
  20. </template>
  21. <template v-else>
  22. <div class="groudMgr-top">
  23. <i class="el-icon-arrow-left" @click="adminShow = false"></i>
  24. <span>{{$t('group.admin')}}</span>
  25. <i class="el-icon-close" @click="handleCloseCharSet"></i>
  26. </div>
  27. <div class="groudMgr-admins">
  28. <div class="admins-add" @click="$showInvite(4)">
  29. <div class="add-fl">
  30. <i class="el-icon-circle-plus-outline"></i>{{$t('group.add')}}{{$t('group.admin')}}
  31. </div>
  32. <div class="add-fr">
  33. {{adminsList.length}}/{{membersArray.length}}
  34. <i class="el-icon-arrow-right"></i>
  35. </div>
  36. </div>
  37. <ul class="admin-list">
  38. <li class="admin-item" v-for="(item, key) in adminsList" :key="key">
  39. <img class="user-avatar" :src="item.cover_photo" v-if="item.cover_photo">
  40. <div class="user-avatar" v-else :class="`avatar_bg${item.user_id % 9}`" :data-name="item.nick_name.slice(0,2).toUpperCase()">
  41. </div>
  42. <span class="name">{{item.nick_name}}</span>
  43. <el-button @click="removeAdmin(item.user_id,item.nick_name)">{{$t('public.remove')}}</el-button>
  44. </li>
  45. </ul>
  46. </div>
  47. </template>
  48. </div>
  49. </template>
  50. <script>
  51. import Vue from 'vue'
  52. import { Button, MessageBox } from 'element-ui'
  53. import { mapState } from 'vuex'
  54. import API from '@/api'
  55. import { addPanelSessionMixin } from '@/mixins/index'
  56. Vue.component(Button.name, Button)
  57. export default {
  58. name: 'chatGroudMgr',
  59. mixins: [addPanelSessionMixin],
  60. computed: {
  61. ...mapState({
  62. curGroupId: state => state.curSession,
  63. userId: state => state.userId,
  64. membersArray: state => state.group.membersArray,
  65. sessionList: state => state.chat.sessionList
  66. }),
  67. adminsList () {
  68. return this.membersArray.filter(v => {
  69. return v.is_admin == 1
  70. })
  71. }
  72. },
  73. data () {
  74. return {
  75. adminShow: false
  76. }
  77. },
  78. methods: {
  79. handleGroudMgr () {
  80. this.$emit('handleShowGroudMgr', 0)
  81. },
  82. handleCloseCharSet () {
  83. this.$emit('handleShowCharSet', 0)
  84. this.adminShow = false
  85. },
  86. removeAdmin (userId, nick) {
  87. MessageBox.confirm(`${this.$t('public.confirm')}${this.$t('public.remove')}${nick}?`).then(() => {
  88. API.group
  89. .removeAdmin({
  90. admin_id: userId,
  91. group_id: this.curGroupId
  92. })
  93. .then(({ data }) => {
  94. this.$store.dispatch('getGroupInfo')
  95. })
  96. })
  97. .catch(e => {
  98. console.log(e)
  99. })
  100. },
  101. addGroupAuth () {
  102. API.base.groupAuth({
  103. group_id: this.curGroupId
  104. }).then(({ data }) => {
  105. let serverId = data.data.serverId
  106. let sessionId = this.userId > serverId
  107. ? `${serverId}-${this.userId}`
  108. : `${this.userId}-${serverId}`
  109. this.addPanelSession(serverId, sessionId)
  110. this.$store.commit('changeSessionId', sessionId)
  111. this.$router.push({ path: `/pm/${sessionId}` })
  112. })
  113. }
  114. }
  115. }
  116. </script>
  117. <style lang="scss" scoped>
  118. @import "./style.scss";
  119. </style>