qun_manage.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  1. <template>
  2. <view class="page">
  3. <view class="page-content">
  4. <view class="page-list">
  5. <view class="page-item">
  6. <view class="page-item-left">
  7. <view>全员禁言</view>
  8. <view class="page-item-info">开启后仅群主和管理员可以发言</view>
  9. </view>
  10. <view class="page-item-right">
  11. <switch :checked="!!data.group.is_msg" @change="msgChange" />
  12. </view>
  13. </view>
  14. <view class="page-item">
  15. <view class="page-item-left">
  16. <view>允许群成员修改群名称和头像</view>
  17. <view class="page-item-info">关闭后紧群主和管理员可以修改群名称和头像</view>
  18. </view>
  19. <view class="page-item-right">
  20. <switch :checked="!!data.group.edit_photo" @change="editChange" />
  21. </view>
  22. </view>
  23. <view class="page-item">
  24. <view class="page-item-left">
  25. <view>允许群成员领取长时间未领取的红包</view>
  26. <view class="page-item-info">关闭后仅群主和管理员使用</view>
  27. </view>
  28. <view class="page-item-right">
  29. <switch :checked="!!data.group.can_get_bigred" @change="getRedChange" />
  30. </view>
  31. </view>
  32. <view class="page-item">
  33. <view class="page-item-left">
  34. <view>允许群成员上麦</view>
  35. <view class="page-item-info">关闭后仅群主和管理员可以上麦</view>
  36. </view>
  37. <view class="page-item-right">
  38. <switch :checked="!!data.group.can_shangmai" @change="shangmai" />
  39. </view>
  40. </view>
  41. <view class="page-item">
  42. <view class="page-item-left">
  43. <view>群内禁止好友</view>
  44. <view class="page-item-info">关闭后群成员直接可以加好友</view>
  45. </view>
  46. <view class="page-item-right">
  47. <switch checked="!data.group.can_add_friend" @change="switch1Change"/>
  48. </view>
  49. </view>
  50. <view class="page-item">
  51. <view class="page-item-left">
  52. <view>匿名聊天</view>
  53. <view class="page-item-info">开启后用户聊天不显示真实头像</view>
  54. </view>
  55. <view class="page-item-right">
  56. <switch :checked="data.group.can_niming == 1" @change="nimingChange" />
  57. </view>
  58. </view>
  59. <view class="page-item-footer" @tap="goSetAdmin(4)">
  60. <view class="page-item-left">
  61. <view>一键复制新群</view>
  62. </view>
  63. <view class="page-item-right">
  64. <view class="iconfont-im icon-jiantou font-jiantou"></view>
  65. </view>
  66. </view>
  67. <view class="footer-list">
  68. <view class="page-item-footer" @tap="goSetAdmin(1)">
  69. <view class="page-item-left">
  70. <view>设置管理员</view>
  71. </view>
  72. <view class="page-item-right">
  73. <view class="iconfont-im icon-jiantou font-jiantou"></view>
  74. </view>
  75. </view>
  76. <view class="footer-hr"></view>
  77. <view class="page-item-footer" @tap="goSetAdmin(3)">
  78. <view class="page-item-left">
  79. <view>群主管理权转让</view>
  80. </view>
  81. <view class="page-item-right">
  82. <view class="iconfont-im icon-jiantou font-jiantou"></view>
  83. </view>
  84. </view>
  85. <view class="footer-hr"></view>
  86. <view class="page-item-footer" @tap="reduce">
  87. <view class="page-item-left">
  88. <view>踢出群成员</view>
  89. </view>
  90. <view class="page-item-right">
  91. <view class="iconfont-im icon-jiantou font-jiantou"></view>
  92. </view>
  93. </view>
  94. <view class="footer-hr"></view>
  95. <view class="page-item-footer" @tap="goSetAdmin(2)">
  96. <view class="page-item-left">
  97. <view>禁言设置</view>
  98. </view>
  99. <view class="page-item-right">
  100. <view class="iconfont-im icon-jiantou font-jiantou"></view>
  101. </view>
  102. </view>
  103. <view class="footer-hr"></view>
  104. <view class="doButton" v-show="data.is_action == 2" >
  105. <button class="group-button" type="button" @tap="removeGroup">解散该群</button>
  106. </view>
  107. </view>
  108. </view>
  109. </view>
  110. </view>
  111. </template>
  112. <script>
  113. import _hook from '../../../common/_hook';
  114. import _data from '../../../common/_data';
  115. import _page from '../../../common/common';
  116. export default {
  117. data() {
  118. return {
  119. data: {
  120. member: [],
  121. group: {
  122. is_photo: 'default_group_photo/90.jpg',
  123. },
  124. is_action: 0,
  125. type: 1,
  126. },
  127. list_id: 0,
  128. };
  129. },
  130. computed: {
  131. staticPhoto(){
  132. return _data.staticPhoto();
  133. },
  134. isAction(){
  135. if(this.data.group.main_id == _data.data('user_info').id){
  136. return true;
  137. }
  138. return false;
  139. }
  140. },
  141. onShow(){
  142. _hook.routeSonHook();
  143. let _this = this;
  144. _this.$httpSend({
  145. path: '/im/message/getChatDetails',
  146. data: { list_id: _this.list_id, },
  147. success(data) {
  148. _this.data = data;
  149. if(data.type == 1){
  150. uni.setNavigationBarTitle({
  151. title: data.group.name,
  152. });
  153. }
  154. let cache_data = _data.data('cache');
  155. if(data.type == 1 && !('group_photo_' + _this.list_id in cache_data)){
  156. uni.downloadFile({
  157. url: _data.staticPhoto() + data.group.is_photo,
  158. success: (res) => {
  159. if (res.statusCode === 200) {
  160. cache_data['group_photo_' + _this.list_id] = res.tempFilePath;
  161. _data.data('cache',cache_data);
  162. }
  163. }
  164. });
  165. }
  166. }
  167. });
  168. },
  169. methods: {
  170. shangmai(e){
  171. //消息免打扰
  172. let value = e.detail.value ? 1 : 0;
  173. let _this = this;
  174. this.$httpSend({
  175. path: '/im/vendor/setShangmai',
  176. data: {list_id: this.list_id, value: value},
  177. success(data) {
  178. _data.localData('DISTURB:'+_this.list_id,value)
  179. }
  180. });
  181. },
  182. groupNickname(val){
  183. console.log(val)
  184. uni.navigateTo({
  185. url:'group_nickname?'+_page.pageParam({list_id:this.list_id,nickname:val})
  186. })
  187. },
  188. disturb(e){
  189. //消息免打扰
  190. let value = e.detail.value ? 1 : 0;
  191. let _this = this;
  192. this.$httpSend({
  193. path: '/im/message/msgDisturb',
  194. data: {list_id: this.list_id, value: value},
  195. success(data) {
  196. _data.localData('DISTURB:'+_this.list_id,value)
  197. }
  198. });
  199. },
  200. liveGroup(){
  201. //离开群聊
  202. let _this = this;
  203. uni.showModal({
  204. title: '重要提示',
  205. content: '确定要离开群聊吗?',
  206. confirmText: '离开',
  207. cancelText: '再看看',
  208. confirmColor: 'red',
  209. cancelColor: '#353535',
  210. success: function (res) {
  211. if (res.confirm) {
  212. _this.$httpSend({
  213. path: '/im/message/liveGroup',
  214. data: { list_id: _this.list_id },
  215. success(data) {
  216. console.log(data)
  217. uni.switchTab({
  218. url: '../index'
  219. });
  220. }
  221. });
  222. }
  223. }
  224. });
  225. },
  226. imageError(e){
  227. console.log("图片加载失败!",e.detail);
  228. let index = e.currentTarget.dataset.index
  229. console.log(e.currentTarget.dataset.index)
  230. //替换index对应的图片
  231. console.log(this.data.member[index].photo)
  232. this.data.member[index].photo = '/default_photo_path.png';
  233. },
  234. removeGroup(){
  235. let _this = this;
  236. uni.showModal({
  237. title: '重要提示',
  238. content: '此操作数据不可恢复,确定要解散该群吗?',
  239. confirmText: '不解散',
  240. cancelText: '解散',
  241. confirmColor: '#353535',
  242. cancelColor: 'red',
  243. success: function (res) {
  244. if (!res.confirm) {
  245. _this.$httpSend({
  246. path: '/im/message/removeGroup',
  247. data: { list_id: _this.list_id, },
  248. success(data) {
  249. uni.switchTab({
  250. url: '../index'
  251. });
  252. }
  253. });
  254. }
  255. }
  256. });
  257. },
  258. photo(path){
  259. return this.staticPhoto + path + '?_=' + Math.random();
  260. },
  261. msgChange(e){
  262. let value = e.detail.value ? 1 : 0;
  263. if(this.data.is_action != 2){
  264. uni.showModal({
  265. content: '没有权限设置',
  266. showCancel: false,
  267. });
  268. return;
  269. }
  270. this.$httpSend({
  271. path: '/im/message/groupIsMsg',
  272. data: { list_id: this.list_id,value, },
  273. success(data) {
  274. return;
  275. uni.showToast({
  276. title: '设置成功',
  277. duration: 1500
  278. });
  279. }
  280. });
  281. },
  282. nimingChange(e){
  283. let value = e.detail.value ? 1 : 0;
  284. if(!this.data.is_action && this.data.is_action != 2){
  285. uni.showModal({
  286. content: '没有权限设置',
  287. showCancel: false,
  288. });
  289. return;
  290. }
  291. this.$httpSend({
  292. path: '/im/message/nimingChange',
  293. data: { list_id: this.list_id,value, },
  294. success(data) {
  295. return;
  296. uni.showToast({
  297. title: '设置成功',
  298. duration: 1500
  299. });
  300. }
  301. });
  302. },
  303. msgTop(e){
  304. let _this = this,
  305. value = e.detail.value ? 1 : 0;
  306. this.$httpSend({
  307. path: '/im/message/chatTop',
  308. data: { list_id: this.list_id,value, },
  309. success(data) {
  310. /** 更新对话列表数据 */
  311. for(let i = 0,local_chat_list = _data.localData('chat_list'),j = local_chat_list.length;i < j;i ++){
  312. if(local_chat_list[i].list_id == _this.list_id){
  313. let action_list_data = local_chat_list[i];
  314. local_chat_list.splice(i,1);
  315. local_chat_list.unshift(action_list_data);
  316. _data.localData('chat_list',local_chat_list);
  317. uni.$emit('data_chat_list',local_chat_list);
  318. break;
  319. }
  320. }
  321. return;
  322. uni.showToast({
  323. title: '设置成功',
  324. duration: 1500
  325. });
  326. }
  327. });
  328. },
  329. switch1Change(e){
  330. let _this = this, value = e.detail.value ? 1 : 0;
  331. this.$httpSend({
  332. path: '/im/message/speekChecked',
  333. data: { list_id: this.list_id,value:value,},
  334. success(data) {
  335. /** 更新对话列表数据 */
  336. for(let i = 0,local_chat_list = _data.localData('chat_list'),j = local_chat_list.length;i < j;i ++){
  337. if(local_chat_list[i].list_id == _this.list_id){
  338. let action_list_data = local_chat_list[i];
  339. local_chat_list.splice(i,1);
  340. local_chat_list.unshift(action_list_data);
  341. _data.localData('chat_list',local_chat_list);
  342. uni.$emit('data_chat_list',local_chat_list);
  343. break;
  344. }
  345. }
  346. }
  347. });
  348. },
  349. editChange(e){
  350. let _this = this, value = e.detail.value ? 1 : 0;
  351. this.$httpSend({
  352. path: '/im/vendor/editChange',
  353. data: { list_id: this.list_id,value:value,},
  354. success(data) {
  355. }
  356. });
  357. },
  358. goGroupQrcode(){
  359. uni.navigateTo({
  360. url: ('./group_qrcode?list_id=' + this.list_id),
  361. animationType: 'slide-in-bottom',
  362. });
  363. },
  364. goSetGroupPhoto(){
  365. if(this.data.is_action != 2 && !this.data.group.edit_photo){
  366. uni.showToast({
  367. title: '没有权限设置',
  368. icon: 'none',
  369. duration: 1000
  370. });
  371. return;
  372. }
  373. uni.navigateTo({
  374. url: ('../../set/group_photo?list_id=' + this.list_id),
  375. animationType: 'slide-in-bottom',
  376. });
  377. },
  378. goSetAdmin(type){
  379. switch (type){
  380. case 1:
  381. if(this.data.is_action != 2){
  382. console.log("this.data.is_action",this.data.is_action)
  383. uni.showToast({
  384. title: '群主才能设置',
  385. icon: 'none',
  386. duration: 1000
  387. });
  388. return;
  389. }
  390. break;
  391. case 2:
  392. if(this.data.is_action != 2){
  393. uni.showModal({
  394. content: '没有权限设置',
  395. showCancel: false,
  396. });
  397. return;
  398. }
  399. break;
  400. case 3:
  401. if(this.data.is_action != 2){
  402. uni.showModal({
  403. content: '没有权限设置',
  404. showCancel: false,
  405. });
  406. return;
  407. }
  408. break;
  409. case 4:
  410. if(this.data.is_action != 2){
  411. uni.showModal({
  412. content: '没有权限设置',
  413. showCancel: false,
  414. });
  415. return;
  416. }
  417. break;
  418. default:
  419. return;
  420. break;
  421. }
  422. let url = '../../set/group_admin?list_id=' + this.list_id + '&type=' + type;
  423. if(type == 3)url = '../../set/group_trans?list_id=' + this.list_id + '&type=' + type;
  424. if(type == 4)url = '../../set/copy_group?list_id=' + this.list_id + '&type=' + type;
  425. uni.navigateTo({
  426. url: url,
  427. animationType: 'slide-in-bottom',
  428. });
  429. },
  430. goSet(type){
  431. if(this.data.is_action != 2 && !this.data.group.edit_photo){
  432. uni.showToast({
  433. title: '没有权限设置',
  434. icon: 'none',
  435. duration: 1000
  436. });
  437. return;
  438. }
  439. uni.navigateTo({
  440. url: ('../../set/message_more?list_id=' + this.list_id + '&type=' + type),
  441. animationType: 'slide-in-bottom',
  442. });
  443. },
  444. goDetails(user_id){
  445. if(this.data.type&& this.data.is_action != 2){
  446. uni.showToast({
  447. title: '没有权限查看',
  448. icon: 'none',
  449. duration: 1000
  450. });
  451. return;
  452. }
  453. uni.navigateTo({
  454. url: ('../../details/index?user_id=' + user_id+'&type='+this.data.type+'&list_id='+this.list_id+"&is_action="+this.data.is_action),
  455. });
  456. },
  457. add(){
  458. uni.navigateTo({
  459. url: ('../../friend/index_list?list_id=' + this.list_id),
  460. animationType: 'slide-in-bottom',
  461. });
  462. },
  463. reduce(){
  464. uni.navigateTo({
  465. url: ('./reduce?list_id=' + this.list_id),
  466. animationType: 'slide-in-bottom',
  467. });
  468. },
  469. groupCopy(value) {
  470. _page.uniCopy({
  471. content:this.data.group.id,
  472. success:function () {
  473. uni.showToast({'title':'复制成功',duration:2000})
  474. }
  475. })
  476. },
  477. replaceStr(str){
  478. console.log(str)
  479. return str.substr(10)
  480. },
  481. getRedChange(e){
  482. let _this = this, value = e.detail.value ? 1 : 0;
  483. this.$httpSend({
  484. path: '/im/vendor/getRedChange',
  485. data: { list_id: this.list_id,value:value,},
  486. success(data) {
  487. }
  488. });
  489. },
  490. goBigRedList(){ //todo 长时间未领取红包列表
  491. uni.navigateTo({url:"../message/red_list?list_id="+this.list_id})
  492. },
  493. manarger(){
  494. uni.navigateTo({url:'../message/qun_manage?list_id='+this.list_id})
  495. }
  496. },
  497. onLoad(option) {
  498. this.list_id = option.list_id;
  499. this.data.type = option.type;
  500. },
  501. }
  502. </script>
  503. <style>
  504. page{
  505. background-color: #e5e5e5;
  506. }
  507. .page{
  508. height: 100%;
  509. }
  510. .page-content{
  511. display:flex;
  512. justify-content: space-between;
  513. flex-direction: column;
  514. }
  515. .page-list{
  516. display: flex;
  517. flex-direction: column;
  518. justify-content: space-between;
  519. }
  520. .page-item{
  521. display: flex;
  522. justify-content: space-between;
  523. align-items: center;
  524. background-color: #ffffff;
  525. margin-bottom: 10px;
  526. padding: 10px 20px;
  527. }
  528. .page-item-footer{
  529. display: flex;
  530. justify-content: space-between;
  531. align-items: center;
  532. background-color: #ffffff;
  533. padding: 10px 20px;
  534. }
  535. .footer-hr{
  536. height: 1upx;
  537. width: 90%;
  538. background-color: #e1e1e1;
  539. margin: 0 auto;
  540. }
  541. .page-list:first-child{
  542. border-top: 1upx solid #e1e1e1;
  543. }
  544. .page-item-left{
  545. display: flex;
  546. justify-content: center;
  547. flex-direction: column;
  548. }
  549. .footer-list{
  550. background-color: #ffffff;
  551. padding-bottom: 20px;
  552. }
  553. .page-item-info{
  554. color: #bababa;
  555. font-size: 12px;
  556. }
  557. .font-jiantou{
  558. font-size: 12px;
  559. }
  560. .page-item-footer .page-item-right{
  561. margin-right: 20px;
  562. }
  563. .page-item-footer{
  564. margin-bottom: 10px;
  565. }
  566. .doButton{
  567. padding: 10px;
  568. }
  569. .group-button{
  570. width: 92%;
  571. background-color: #5693ee;
  572. color: white;
  573. height: 70upx;
  574. line-height: 70upx !important;
  575. border-radius: 40upx;
  576. font-size: 36upx;
  577. cursor: pointer;
  578. margin-top: 20upx;
  579. }
  580. </style>