index.vue 4.0 KB

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