groupInfo.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. <template>
  2. <view>
  3. <uni-nav-bar statusBar backgroundColor="#F8F6F6" fixed title="群聊基本信息" left-icon="left" @clickLeft="utils.navigateBack()" />
  4. <view class="cath-user fx-r">
  5. <view class="item fx-h fx-bc fx-ac" v-for="item in data.chatData" @tap="tapOpen" :data-url="'../userShow?usercode=' + item.uid" >
  6. <image class="avatar" :src="item.avatar == '' ? '/static/chat/user-avatar.png' : item.avatar" mode="aspectFill"></image>
  7. <view class="manager" v-if="item.is_manager">群主</view>
  8. <view class="admin" v-else-if="item.is_admin">管理</view>
  9. <view class="text">{{item.nickname}}</view>
  10. </view>
  11. <view class="item fx-h fx-bc fx-ac" @tap="tapAdd" v-if="data.chat.is_manager || data.chat.is_admin">
  12. <image class="avatar" src="/static/chat/id_chat_add.png" mode="aspectFill"></image>
  13. <view class="text">添加成员</view>
  14. </view>
  15. <view class="item fx-h fx-bc fx-ac" @tap="tapJdd" v-if="data.chat.is_manager || data.chat.is_admin">
  16. <image class="avatar" src="/static/chat/id_chat_reduce.png" mode="aspectFill"></image>
  17. <view class="text">移除成员</view>
  18. </view>
  19. </view>
  20. <view class="chat-more" @tap="tapGroupUser" v-if="data.is_more">查看更多成员</view>
  21. <view class="list-item">
  22. <view class="item fx-r fx-bc fx-ac" @tap="tapUpChatAavatr" v-if="data.chat.is_manager">
  23. <view class="label">群头像</view>
  24. <view class="fx-g1"></view>
  25. <image :src="data.chat.img == '' ? '/static/chat/group_chat.png' : data.chat.img" style="width: 40px;height: 40px;border-radius: 20px;" mode="aspectFill"></image>
  26. <image class="pve" src="/static/chat/ic_next.png" mode="widthFix"></image>
  27. </view>
  28. <view class="item fx-r fx-bc fx-ac" @tap="tapRkname">
  29. <view class="label">群聊名称</view>
  30. <view class="fx-g1"></view>
  31. <view class="name">{{data.name}}</view>
  32. <image class="pve" src="/static/chat/ic_next.png" mode="widthFix"></image>
  33. </view>
  34. <view class="item fx-r fx-bc fx-ac" @tap="tapOpen" :data-url="'groupInfo/qrcode?groupId=' + groupId + '&name=' + data.name + '&img=' + encodeURIComponent(data.img)">
  35. <view class="label">群二维码</view>
  36. <view class="fx-g1"></view>
  37. <image src="/static/chat/id-qrcode.svg" style="width: 20px;height: 20px;"></image>
  38. <image class="pve" src="/static/chat/ic_next.png" mode="widthFix"></image>
  39. </view>
  40. <view class="item fx-r fx-bc fx-ac" @tap="tapOpen" :data-url="'groupInfo/msg?groupId=' + groupId + '&name=' + data.name + '&msg=' + encodeURIComponent(data.msg)">
  41. <view class="label">群公告</view>
  42. <view class="fx-g1"></view>
  43. <view class="name">
  44. {{data.msg}}
  45. </view>
  46. <image class="pve" src="/static/chat/ic_next.png" mode="widthFix"></image>
  47. </view>
  48. <view class="item fx-r fx-bc fx-ac" @tap="tapNotOrder" v-if="data.chat.is_manager || data.chat.is_admin">
  49. <view class="label" style="color: red;">不持单会员</view>
  50. <view class="fx-g1"></view>
  51. <image class="pve" src="/static/chat/ic_next.png" mode="widthFix"></image>
  52. </view>
  53. <view class="item fx-r fx-bc fx-ac" @tap="tapGrouAmin" v-if="data.chat.is_manager">
  54. <view class="label">群管理</view>
  55. <view class="fx-g1"></view>
  56. <image class="pve" src="/static/chat/ic_next.png" mode="widthFix"></image>
  57. </view>
  58. </view>
  59. <view class="list-item">
  60. <view class="item fx-r fx-bc fx-ac" @tap="tapSearch">
  61. <view class="label">聊天记录</view>
  62. <view class="fx-g1"></view>
  63. <image class="pve" src="/static/chat/ic_next.png" mode="widthFix"></image>
  64. </view>
  65. <view class="item fx-r fx-bc fx-ac" @tap="tapGroupUser">
  66. <view class="label">群成员</view>
  67. <view class="fx-g1"></view>
  68. <image class="pve" src="/static/chat/ic_next.png" mode="widthFix"></image>
  69. </view>
  70. <view class="item fx-r fx-bc fx-ac" @tap="tapRemarkName">
  71. <view class="label">我在群里的昵称</view>
  72. <view class="fx-g1"></view>
  73. <view class="tag">{{data.chat.remark_name}}</view>
  74. <image class="pve" src="/static/chat/ic_next.png" mode="widthFix"></image>
  75. </view>
  76. </view>
  77. <view class="list-item">
  78. <view class="item fx-r fx-bc fx-ac">
  79. <view class="label">消息免打扰</view>
  80. <view class="fx-g1"></view>
  81. <image @tap="tapAction('is_disturb','0')" v-if="data.chat.is_disturb == 1" src="/static/chat/select-options-btn.png" class="icon-next"></image>
  82. <image @tap="tapAction('is_disturb','1')" v-else src="/static/chat/select-options.png" class="icon-next"></image>
  83. </view>
  84. <view class="item fx-r fx-bc fx-ac" >
  85. <view class="label">置顶聊天</view>
  86. <view class="fx-g1"></view>
  87. <image @tap="tapAction('is_top','0')" v-if="data.chat.is_top == 1" src="/static/chat/select-options-btn.png" class="icon-next"></image>
  88. <image @tap="tapAction('is_top','1')" v-else src="/static/chat/select-options.png" class="icon-next"></image>
  89. </view>
  90. </view>
  91. <view class="list-item" style="margin-top: 10px;">
  92. <view class="item fx-r fx-bc fx-ac" style="padding: 20px 0;" @tap="tapClerAr">
  93. <view class="label">清空聊天记录</view>
  94. </view>
  95. </view>
  96. <!-- <view class="list-item" style="margin-top: 10px;">
  97. <view class="item fx-r fx-bc fx-ac" style="padding: 20px 0;" @tap="tapDelet">
  98. <view class="label">删除退出</view>
  99. </view>
  100. </view> -->
  101. </view>
  102. </template>
  103. <style lang="scss">
  104. .cath-user{padding: 10px;background: #fff;}
  105. .cath-user .item{width:16.5%;margin-bottom: 10px;position: relative;}
  106. .cath-user .item .avatar{width:40px;height: 40px;border-radius: 6px;}
  107. .cath-user .item .text{font-size: 12px;margin-top: 4px;overflow:hidden;white-space:nowrap; text-overflow:ellipsis;width: 16vw;text-align: center;}
  108. .cath-user .manager{transform:scale(0.5);border: 1px solid #faac06;border-radius: 6px;font-size: 10px;padding:0px 6px;color: #faac06;position: absolute;top: -6px;right: 0;background: #fff;}
  109. .cath-user .admin{transform:scale(0.5);border: 1px solid #2fbec0;border-radius: 6px;font-size: 10px;padding:0px 6px;color: #2fbec0;position: absolute;top: -6px;right: 0;background: #fff;}
  110. .list-item{background: #fff;padding: 0px 20px;margin-top: 10px;}
  111. .list-item .item{padding: 15px 0;border-bottom: 1px solid #f1f1f1;}
  112. .list-item .item:last-child{border-bottom: 0;}
  113. .list-item .item .label{font-size: 16px;color:$ic-default-text;}
  114. .list-item .item .name{color:$ic-default-text;font-size: 14px;max-width: calc(100% - 90px);}
  115. .list-item .item .tag{color:$ic-default-text;font-size: 14px;max-width: calc(100% - 90px);}
  116. .list-item .item .pve{width: 20px;}
  117. .icon-next{width:40px;height: 40px;}
  118. .chat-more{background: #fff;padding: 10px;color: #787878;text-align: center;}
  119. </style>
  120. <script>
  121. import {mapState,mapMutations } from 'vuex';
  122. export default {
  123. data() {
  124. return {
  125. data : {
  126. chat:{}
  127. },
  128. groupId : "",
  129. isPop:false
  130. }
  131. },
  132. onLoad(option){
  133. this.groupId = option.groupId || "";
  134. uni.$on('glRkName',this.glRkName);
  135. },
  136. onUnload() {
  137. uni.$off('glRkName',this.glRkName);
  138. },
  139. onShow() {
  140. this.getData();
  141. },
  142. methods: {
  143. getData:function(){
  144. uni.showLoading({ title: '获取数据中..'});
  145. this
  146. .request
  147. .post("chatChatFindGroup",{groupip:this.groupId})
  148. .then(res => {
  149. uni.hideLoading();
  150. if(res.code == 200) {
  151. this.data = res.data;
  152. } else {
  153. uni.showModal({title: '系统提示',content: res.msg,showCancel: false});
  154. }
  155. })
  156. .catch(res=>{
  157. console.log(res);
  158. uni.hideLoading();
  159. uni.showModal({title: '系统提示',content: '加载失败,重新点击尝试!',showCancel: false});
  160. });
  161. },
  162. tapAdd:function(){
  163. var nAr = [];
  164. for(var i in this.data.chatData){
  165. nAr.push(this.data.chatData[i].uid);
  166. }
  167. uni.navigateTo({
  168. url : "groupInfo/add?groupId=" + this.groupId + "&notData=" + JSON.stringify(nAr)
  169. });
  170. },
  171. /**
  172. * 减少成员
  173. */
  174. tapJdd:function(){
  175. var nAr = [];
  176. for(var i in this.data.chatData){
  177. if(this.data.chat.is_manager) {
  178. if(this.data.chatData[i].is_manager)
  179. nAr.push(this.data.chatData[i].uid);
  180. }
  181. if(!this.data.chat.is_manager && this.data.chat.is_admin) {
  182. if(this.data.chatData[i].is_manager || this.data.chatData[i].is_admin)
  183. nAr.push(this.data.chatData[i].uid);
  184. }
  185. }
  186. uni.navigateTo({
  187. url : "groupInfo/jdd?groupId=" + this.groupId + "&notData=" + JSON.stringify(nAr)
  188. });
  189. },
  190. tapRkname:function(){
  191. if(!this.data.chat.is_manager) {
  192. return this.utils.Tip("你还不是管理人员");
  193. }
  194. uni.navigateTo({
  195. url:"groupInfo/rkname?groupId=" + this.groupId + "&name=" + this.data.name + "&img=" + this.data.img
  196. })
  197. },
  198. /**
  199. * 修改昵称
  200. */
  201. tapRemarkName:function(){
  202. uni.navigateTo({
  203. url:"groupInfo/remark_name?groupId=" + this.groupId + "&name=" + this.data.chat.remark_name + "&img=" + this.data.img
  204. });
  205. },
  206. /**
  207. * 不支持单会员
  208. */
  209. tapNotOrder:function(){
  210. if(!this.data.chat.is_manager) {
  211. return this.utils.Tip("你还不是管理人员");
  212. }
  213. uni.navigateTo({
  214. url:"groupInfo/jddNo?groupId=" + this.groupId
  215. })
  216. },
  217. /**
  218. * 设置数据
  219. * @param {Object} name
  220. * @param {Object} bool
  221. */
  222. tapAction:function(name,bool){
  223. this
  224. .request
  225. .post("chatUpdateChat",{groupId:this.groupId,code:name,val:bool})
  226. .then(res=>{
  227. if(res.code == 200) {
  228. this.$set(this.data.chat,name,bool);
  229. } else {
  230. uni.showModal({title: '系统提示',content: res.msg,showCancel: false});
  231. }
  232. });
  233. },
  234. tapGroupUser:function(){
  235. uni.navigateTo({
  236. url:"groupInfo/user?groupId=" + this.groupId
  237. })
  238. },
  239. /**
  240. * 群管理
  241. */
  242. tapGrouAmin:function(){
  243. uni.navigateTo({
  244. url:"groupInfo/admin?groupId=" + this.groupId
  245. })
  246. },
  247. /**
  248. * open
  249. * @param {Object} ev
  250. */
  251. tapOpen:function(ev){
  252. let url = ev.currentTarget.dataset.url;
  253. this.utils.navigateTo(url);
  254. },
  255. /**
  256. * 聊天记录
  257. */
  258. tapSearch:function(){
  259. uni.navigateTo({
  260. url:"/pages/chat/search?groupId=" + this.groupId + "&type=group_chat"
  261. });
  262. },
  263. /**
  264. * 清理数据
  265. */
  266. tapClerAr:function(){
  267. this.utils.showModal("你确定要清空聊天记录吗?", ()=>{
  268. uni.showLoading({ title:"提交数据中..." });
  269. this
  270. .request
  271. .post("clearChat",{groupId:this.groupId})
  272. .then(res=>{
  273. uni.hideLoading();
  274. if(res.code == 200) {
  275. this.utils.Tip("清理成功");
  276. uni.$emit('chatClear',this.groupId);
  277. setTimeout(()=>{
  278. uni.navigateBack();
  279. },200);
  280. } else {
  281. this.utils.Tip(res.msg);
  282. }
  283. })
  284. .catch(err=>{
  285. uni.hideLoading();
  286. this.utils.Tip("加载失败,请重新尝试");
  287. });
  288. });
  289. },
  290. tapDelet:function(){
  291. this.utils.showModal("你确定要退出群聊吗?", ()=>{
  292. uni.showLoading({ title:"提交数据中..." });
  293. this.request.post("chatGroupRemove",{groupId:this.groupId})
  294. .then(res=>{
  295. uni.hideLoading();
  296. if(res.code == 200) {
  297. this.utils.Tip("退出成功");
  298. uni.$emit('chatDel',this.groupId);
  299. setTimeout(()=>{
  300. uni.navigateBack();
  301. },200);
  302. } else {
  303. this.utils.Tip(res.msg);
  304. }
  305. })
  306. .catch(err=>{
  307. uni.hideLoading();
  308. this.utils.Tip("加载失败,请重新尝试");
  309. });
  310. });
  311. },
  312. glRkName:function(data){
  313. if(this.groupId == data.groupId) {
  314. this.$set(this.data.chat,"remark_name",data.name);
  315. }
  316. },
  317. tapUpChatAavatr:function(){
  318. // #ifdef APP-PLUS
  319. this.$store.dispatch('permission/requestPermissions', 'WRITE_EXTERNAL_STORAGE').then(res => {
  320. console.log(res);
  321. if(res !== 1) return;
  322. this.tapUpChatAavatrS();
  323. });
  324. return;
  325. // #endif
  326. this.tapUpChatAavatrS();
  327. },
  328. /**
  329. * 更换群头像
  330. */
  331. tapUpChatAavatrS:function(){
  332. uni.chooseImage({
  333. count: 1,
  334. sizeType: ['compressed'],
  335. success: (res) => {
  336. let img = res.tempFilePaths[0];
  337. this.utils.loadIng();
  338. this
  339. .request
  340. .uploadFile("chatGroupAvatar",img,"file",{groupId:this.groupId})
  341. .then(res2 => {
  342. uni.hideLoading();
  343. if (res2.code == 200) {
  344. this.data.chat.img = res2.data.img;
  345. this.$forceUpdate();
  346. } else {
  347. this.utils.Tip(res2.msg);
  348. }
  349. })
  350. .catch(err => {
  351. uni.hideLoading();
  352. this.utils.Tip("网络错误,请稍后尝试");
  353. });
  354. }
  355. });
  356. }
  357. }
  358. }
  359. </script>