index.vue 4.9 KB

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