groupDetail.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <view class="content">
  3. <u-navbar
  4. :is-back="true"
  5. :title="'群聊天信息(' + members.length + ')'"
  6. :background="{ background: '#F6F7F8' }"
  7. title-color="#404133"
  8. :border-bottom="false"
  9. z-index="1001"
  10. ></u-navbar>
  11. <view style="background-color: #FFFFFF;padding-left: 30rpx;">
  12. <u-grid :col="6" :border="false">
  13. <u-grid-item v-for="(item, index) in members" :index="index" :key="item.id" v-if="index<=10" @tap="linkToCard(item.id)">
  14. <img-cache :src="item.avatar"></img-cache>
  15. <view class="grid-text">{{ item.groupNickName||item.nickName }}</view>
  16. </u-grid-item>
  17. <u-grid-item @click="hanldleLinkMore">
  18. <view style="padding-bottom: 40rpx;">
  19. <u-icon name="plus" size="40"></u-icon>
  20. </view>
  21. </u-grid-item>
  22. </u-grid>
  23. <view @tap="linkToMore" v-if="members.length>10" style="text-align: center;color: #404133;padding-bottom: 10rpx;">查看更多成员</view>
  24. </view>
  25. <view style="height: 10rpx;"></view>
  26. <u-cell-group>
  27. <u-cell-item title="群名称" @click="showUpdate(group.id, group.groupName, 1)" :value="group.groupName" :title-style="{ marginLeft: '10rpx' }"></u-cell-item>
  28. </u-cell-group>
  29. <u-cell-group>
  30. <u-cell-item title="群二维码" :title-style="{ marginLeft: '10rpx' }"><u-avatar :src="src1" size="50"></u-avatar></u-cell-item>
  31. </u-cell-group>
  32. <u-cell-group>
  33. <u-cell-item title="群公告" @click="showUpdate(group.id, context, 2)" :value="context ? context : '暂无公告'" :title-style="{ marginLeft: '10rpx' }"></u-cell-item>
  34. </u-cell-group>
  35. <view style="height: 10rpx;"></view>
  36. <u-cell-group>
  37. <u-cell-item
  38. title="群昵称"
  39. @click="showUpdate(group.id, mine.groupNickName || userData.user.realname, 3)"
  40. :value="mine.groupNickName || userData.user.realname"
  41. :title-style="{ marginLeft: '10rpx' }"
  42. ></u-cell-item>
  43. </u-cell-group>
  44. <u-cell-group>
  45. <u-cell-item title="显示昵称" :title-style="{ marginLeft: '10rpx' }" :arrow="false">
  46. <u-switch active-color="rgb(25, 190, 107)" v-model="isShowNickName" v-on:change="swichShowNickName"></u-switch>
  47. </u-cell-item>
  48. </u-cell-group>
  49. <u-cell-group>
  50. <u-cell-item title="全体禁言" :title-style="{ marginLeft: '10rpx' }" :arrow="false">
  51. <u-switch active-color="rgb(25, 190, 107)" v-model="anyDisnable"></u-switch>
  52. </u-cell-item>
  53. </u-cell-group>
  54. <view style="height: 10rpx;"></view>
  55. <u-cell-group><u-cell-item title="查看聊天内容" @click="showSearch" :title-style="{ marginLeft: '10rpx' }"></u-cell-item></u-cell-group>
  56. <u-cell-group><u-cell-item title="设置聊天背景" :title-style="{ marginLeft: '10rpx' }" @click="chooseImg"></u-cell-item></u-cell-group>
  57. <view style="height: 10rpx;"></view>
  58. <u-cell-group>
  59. <u-cell-item :title-style="{ marginLeft: '10rpx' }" @click="clearGroupMsg" :arrow="false">
  60. <view style="text-align: center; color: red;">清空聊天记录</view>
  61. </u-cell-item>
  62. </u-cell-group>
  63. <u-cell-group>
  64. <u-cell-item :title-style="{ marginLeft: '10rpx' }" @click="removeGroupUser" :arrow="false"><view style="text-align: center; color: red;">删除并退出</view></u-cell-item>
  65. </u-cell-group>
  66. </view>
  67. </template>
  68. <script>
  69. import ImgCache from '@/components/img-cache/img-cache.vue';
  70. export default {
  71. components:{
  72. ImgCache
  73. },
  74. data() {
  75. return {
  76. src1: 'https://taohaoliang.oss-cn-beijing.aliyuncs.com/tmp/qr_code.png',
  77. chatId: '',
  78. chatName: '',
  79. members: [],
  80. group: {
  81. groupName:''
  82. },
  83. context: '',
  84. mine: '',
  85. isShowNickName: false,
  86. anyDisnable:false,
  87. $url:''
  88. };
  89. },
  90. methods: {
  91. linkToMore(){
  92. this.$u.route({
  93. url: 'pageC/chat/moreMem'
  94. })
  95. },
  96. linkToCard(id){
  97. this.$u.route({
  98. url: 'pageC/businessCard/businessCard',
  99. params:{ id: id, source: 1}
  100. })
  101. },
  102. showSearch() {
  103. this.$u.route({
  104. url:"pageD/search/search",
  105. params: {searchType: 4, chatId: this.chatObj.chatId}
  106. })
  107. },
  108. hanldleLinkMore(){
  109. if (this.userData.user.username != this.group.operUser) {
  110. uni.showModal({
  111. title: '无权限修改',
  112. showCancel: false
  113. });
  114. return;
  115. }
  116. this.$u.route({
  117. url: 'pageC/chat/addGroupUser'
  118. });
  119. },
  120. removeGroupUser() {
  121. this.$socket.removeGroupUser([this.userData.user.operId], this.chatObj.chatId, res => {
  122. if (res.success) {
  123. this.$u.route({
  124. url: 'pages/home/home',
  125. type: 'switchTab'
  126. });
  127. }
  128. });
  129. },
  130. showUpdate(groupId, context, type) {
  131. if (this.userData.user.username != this.group.operUser && 3 != type) {
  132. uni.showModal({
  133. title: '无权限修改',
  134. showCancel: false
  135. });
  136. return;
  137. }
  138. this.$u.route({
  139. url: 'pageC/chat/updateGroupInfo',
  140. params: { groupId, context, type }
  141. });
  142. },
  143. clearGroupMsg() {
  144. this.$socket.clearGroupMsg(this.userData.user.operId, this.chatObj.chatId, res => {
  145. console.log(res);
  146. if (res.success) {
  147. uni.showModal({
  148. title: '成功',
  149. showCancel: false
  150. });
  151. } else {
  152. uni.showModal({
  153. title: '失败',
  154. showCancel: false
  155. });
  156. }
  157. });
  158. },
  159. chooseImg() {
  160. this.$u.route({
  161. url: 'components/u-avatar-cropper/u-avatar-cropper',
  162. params: {
  163. destWidth: uni.upx2px(750),
  164. rectWidth: uni.upx2px(500),
  165. fileType: 'jpg'
  166. }
  167. });
  168. },
  169. swichShowNickName(status) {
  170. this.isShowNickName = status;
  171. let storeKey = 'isShowNickName' + this.userData.user.operId + '_' + this.chatObj.chatId;
  172. uni.setStorageSync(storeKey, this.isShowNickName);
  173. },
  174. getShowNickName() {
  175. let storeKey = 'isShowNickName' + this.userData.user.operId + '_' + this.chatObj.chatId;
  176. this.isShowNickName = uni.getStorageSync(storeKey)? uni.getStorageSync(storeKey): false;
  177. },
  178. queryGroupUser() {
  179. this.$socket.queryMembers(this.chatObj.chatId, this.userData.user.operId, res => {
  180. if (res.success) {
  181. this.members = res.members;
  182. this.$u.vuex('_membersNoneIndex',res.members)
  183. this.mine = res.groupUser;
  184. this.group = res.group;
  185. this.getShowNickName();
  186. } else {
  187. uni.showModal({
  188. title: '获取数据失败',
  189. showCancel: false
  190. });
  191. }
  192. });
  193. this.$socket.queryNotice(this.userData.user.operId, this.chatObj.chatId, res => {
  194. if (res.success) {
  195. this.context = res.context;
  196. } else {
  197. uni.showModal({
  198. title: '获取数据失败',
  199. showCancel: false
  200. });
  201. }
  202. });
  203. }
  204. },
  205. onLoad(option) {
  206. },
  207. onShow() {
  208. },
  209. onReady() {
  210. this.queryGroupUser();
  211. }
  212. };
  213. </script>
  214. <style>
  215. .grid-text {
  216. width: 80rpx;
  217. height: 40rpx;
  218. overflow: hidden;
  219. text-align: center;
  220. color: #000000;
  221. }
  222. .img-cache{
  223. width: 80rpx;
  224. height: 80rpx;
  225. }
  226. </style>