index.vue 4.5 KB

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