homepage_room.php 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
  6. <title>群主页</title>
  7. <link type="text/css" rel="stylesheet"
  8. href="<?php echo RESOURCE_SITE_URL; ?>/mobile/talk/css/weui.css?<?php echo bonus_version(); ?>"/>
  9. <link rel="stylesheet"
  10. href="https://cdn.bootcss.com/jquery-weui/1.2.0/css/jquery-weui.min.css?<?php echo bonus_version(); ?>">
  11. <link type="text/css" rel="stylesheet"
  12. href="<?php echo RESOURCE_SITE_URL; ?>/mobile/talk/css/homepage.css?<?php echo bonus_version(); ?>"/>
  13. </head>
  14. <body>
  15. <?php $output['tpl']->show_cover(); ?>
  16. <div class="group_top">
  17. <div class="group_info">
  18. <?php $output['tpl']->show_group_header(); ?>
  19. <?php $output['tpl']->show_qrcode_btn(); ?>
  20. </div>
  21. <?php $output['tpl']->show_group_notice(); ?>
  22. <div class="group_handle weui-flex">
  23. <?php $output['tpl']->show_group_activity(); ?>
  24. </div>
  25. <div class="group_members weui-flex">
  26. <?php $output['tpl']->show_members(); ?>
  27. </div>
  28. <div id="callback"></div>
  29. </div>
  30. <?php $output['tpl']->show_group_body(); ?>
  31. <?php $output['tpl']->show_personal_settings(); ?>
  32. <?php $output['tpl']->show_group_footer(); ?>
  33. <?php $output['tpl']->show_footer_btn(); ?>
  34. <div class="pop">
  35. <?php $output['tpl']->show_qrcode()?>
  36. </div>
  37. <script src="https://cdn.bootcss.com/jquery/1.11.0/jquery.min.js?<?php echo bonus_version(); ?>"></script>
  38. <script src="https://cdn.bootcss.com/jquery-weui/1.2.0/js/jquery-weui.min.js?<?php echo bonus_version(); ?>"></script>
  39. <script type="text/javascript"
  40. src="<?php echo RESOURCE_SITE_URL; ?>/mobile/comm/new_bridge.js?<?php echo bonus_version(); ?>"></script>
  41. <script type="text/javascript"
  42. src="<?php echo RESOURCE_SITE_URL; ?>/js/ajaxfileupload/ajaxfileupload.js?<?php echo bonus_version(); ?>"></script>
  43. <script type="text/javascript">
  44. $(function () {
  45. var talk_type = "<?php echo $output['param']['talk_type']; ?>";
  46. var talk_id = "<?php echo $output['param']['talk_id']; ?>";
  47. var cur_mid ="<?php echo $output['param']['member_id']; ?>";
  48. var jsBridge = new Bridge();
  49. if($('#add_group_pwd').length > 0 || $('#add_group_apply').length > 0 || $('#add_group').length > 0) {
  50. $('html').css({"min-height":"100%",background:"#ffffff"})
  51. }
  52. var ajaxFileUpload = function () {
  53. $.showLoading();
  54. $.ajaxFileUpload({
  55. url: '/upfile.php',
  56. secureuri: false,
  57. type: 'post',
  58. fileElementId: 'uploader',
  59. dataType: 'json',
  60. data: {
  61. room_id: talk_id
  62. },
  63. success: function (res) {
  64. if (res.code != 200) {
  65. $.hideLoading();
  66. $.alert(res.message);
  67. } else {
  68. var room_avatar = res.datas.file_path;
  69. console.log(room_avatar);
  70. if (room_avatar) {
  71. const update = update_room_avatar(room_avatar);
  72. if (update) {
  73. $.hideLoading();
  74. } else {
  75. $.alert("网络错误");
  76. }
  77. } else {
  78. }
  79. }
  80. },
  81. error: function (data, status, e) {
  82. }
  83. });
  84. $('#uploader').on('change', function () {
  85. ajaxFileUpload();
  86. });
  87. };
  88. $('#uploader').on('change', function () {
  89. ajaxFileUpload();
  90. });
  91. var update_room_avatar = function (room_avatar) {
  92. $.post('/mobile/index.php?act=member_talk&op=change_room_avatar',
  93. {
  94. room_id: talk_id,
  95. file_path: room_avatar,
  96. client_type: 'ajax'
  97. }, function (res) {
  98. console.log(res);
  99. var result = JSON.parse(res);
  100. if (result.code != 200) {
  101. $.alert(result.message);
  102. return false;
  103. } else {
  104. console.log(result.datas.avatar);
  105. $(".g_avatar").attr("src", result.datas.avatar);
  106. $.toast('修改成功',1000);
  107. }
  108. });
  109. return true;
  110. };
  111. var getTalkInfo = function () {
  112. var jsonobject = {
  113. action: "talk_info",
  114. params: {
  115. talk_id: talk_id,
  116. talk_type: talk_type,//room和chatwo两个类型
  117. }
  118. };
  119. jsBridge.call_native_handler('on_native_click', JSON.stringify(jsonobject), function (res) {
  120. var datas = JSON.parse(res);
  121. if (datas.talk_info.stick) {
  122. $('#talk_top').attr('checked', true);
  123. }
  124. if (datas.talk_info.forbid) {
  125. $('#no_disturb').attr('checked', true);
  126. }
  127. });
  128. };
  129. getTalkInfo();
  130. $('#add_member').on('click', function () {
  131. var jsonobject = {
  132. action: "friend_add",
  133. params: {
  134. room_id: talk_id
  135. }
  136. };
  137. $.showLoading();
  138. jsBridge.call_native_handler('on_native_click', JSON.stringify(jsonobject), function (res) {
  139. $.hideLoading();
  140. var datas = JSON.parse(res);
  141. if (datas.friends.length <= 0 || datas.friends == null) return;
  142. var add_friends = datas.friends.join(',');
  143. $.showLoading();
  144. $.get('/mobile/index.php?act=member_talk&op=invite',
  145. {
  146. invitees: add_friends,
  147. room_id: talk_id,
  148. client_type: 'ajax'
  149. },
  150. function (res) {
  151. $.hideLoading();
  152. var datas = JSON.parse(res);
  153. if (datas.code != 200) {
  154. $.alert(datas.message);
  155. return;
  156. }
  157. var html = '';
  158. if (datas.datas.invitees && datas.datas.invitees.length > 0) {
  159. for (var i = 0; i < datas.datas.invitees.length; i++) {
  160. html += '<div class="weui-flex__item" data-member-id="' + datas.datas.invitees[i].member_id + '">' +
  161. '<img src="' + datas.datas.invitees[i].avatar + '" alt="">' +
  162. '<p>' + datas.datas.invitees[i].nickname + '</p>\n' +
  163. '</div>'
  164. }
  165. $('div[data-last="true"]').after(html);
  166. $.toast('添加成功',1000);
  167. }
  168. });
  169. });
  170. });
  171. $('#del_member').on('click', function () {
  172. var jsonobject = {
  173. action: "friend_del",
  174. params: {
  175. room_id: talk_id
  176. }
  177. };
  178. $.showLoading();
  179. jsBridge.call_native_handler('on_native_click', JSON.stringify(jsonobject), function (res) {
  180. $.hideLoading();
  181. var datas = JSON.parse(res);
  182. if (datas.friends.length <= 0 || datas.friends == null) return;
  183. var del_friends = datas.friends.join(',');
  184. $.showLoading();
  185. $.get('/mobile/index.php?act=member_talk&op=kickout', {
  186. users: del_friends,
  187. room_id: talk_id,
  188. client_type: 'ajax'
  189. }, function (res) {
  190. $.hideLoading();
  191. var result = JSON.parse(res);
  192. if (result.code != 200) {
  193. $.alert(result.message);
  194. return;
  195. }
  196. var del_users = result.datas.users;
  197. var num = del_users.length;
  198. if(num > 0)
  199. {
  200. for (var i = 0; i < del_users.length; i++) {
  201. $('div[data-member-id=' + datas.friends[i] + ']').remove();
  202. }
  203. $.toast('删除成功',1000);
  204. }else
  205. {
  206. $.alert("请先移交管理员权限后,再离开聊天");
  207. return;
  208. }
  209. });
  210. });
  211. });
  212. $('#change_owner').on('click', function () {
  213. var jsonobject = {
  214. action: "talk_manager",
  215. params: {
  216. room_id: talk_id
  217. }
  218. };
  219. $.showLoading();
  220. jsBridge.call_native_handler('on_native_click', JSON.stringify(jsonobject), function (res) {
  221. $.hideLoading();
  222. var datas = JSON.parse(res);
  223. if (datas.friends.length <= 0 || datas.friends == null) return;
  224. var new_owner = datas.friends.join(',');
  225. $.showLoading();
  226. $.get('/mobile/index.php?act=member_talk&op=change_room_owner',
  227. {
  228. room_owner:new_owner,
  229. room_id: talk_id,
  230. client_type: 'ajax'
  231. }, function (res) {
  232. $.hideLoading();
  233. var result = JSON.parse(res);
  234. console.log(result);
  235. if (result.code != 200) {
  236. $.alert(result.message);
  237. return;
  238. }
  239. $.toast('转让成功',1000);
  240. setTimeout(function () {
  241. window.location.reload();
  242. },1000);
  243. });
  244. });
  245. });
  246. $('#talk_top').on('change', function () {
  247. var _selfVal = $(this).is(':checked');
  248. var jsonobject;
  249. if (_selfVal) {
  250. jsonobject = {
  251. action: "talk_stick",
  252. params: {
  253. talk_id: talk_id,
  254. talk_type: talk_type,
  255. stick: true
  256. }
  257. };
  258. }
  259. else {
  260. jsonobject = {
  261. action: "talk_stick",
  262. params: {
  263. talk_id: talk_id,
  264. talk_type: talk_type,
  265. stick: false
  266. }
  267. };
  268. }
  269. jsBridge.call_native_handler('on_native_click', JSON.stringify(jsonobject));
  270. });
  271. $('#no_disturb').on('change', function () {
  272. var _selfVal = $(this).is(':checked');
  273. var jsonobject;
  274. if (_selfVal) {
  275. jsonobject = {
  276. action: "talk_forbid",
  277. params: {
  278. talk_id: talk_id,
  279. talk_type: talk_type,
  280. forbid: true
  281. }
  282. };
  283. }
  284. else {
  285. jsonobject = {
  286. action: "talk_forbid",
  287. params: {
  288. talk_id: talk_id,
  289. talk_type: talk_type,
  290. forbid: false
  291. }
  292. };
  293. }
  294. jsBridge.call_native_handler('on_native_click', JSON.stringify(jsonobject));
  295. });
  296. $('#edit_group_name').on('click', function () {
  297. $.prompt({
  298. title: '修改群名称',
  299. text: '请输入群名称(不得超过15字)',
  300. empty: false, // 是否允许为空
  301. onOK: function (input) {
  302. if (input && input.trim().length <= 15) {
  303. //点击确认
  304. $.showLoading();
  305. $.get('/mobile/index.php?act=member_talk&op=room_edit',
  306. {
  307. room_name: input,
  308. room_id: talk_id,
  309. client_type: 'ajax'
  310. }, function (res) {
  311. $.hideLoading();
  312. var result = JSON.parse(res);
  313. if (result.code != 200) {
  314. $.alert(result.message);
  315. return;
  316. }
  317. var new_group_name = input.trim();
  318. $('#edit_group_name .weui-cell__ft').text(new_group_name);
  319. $('.group_name h3').text(new_group_name);
  320. $.toast('修改成功',1000);
  321. });
  322. }
  323. else {
  324. $.alert('群名称不得超过15字');
  325. }
  326. },
  327. onCancel: function () {
  328. //点击取消
  329. }
  330. });
  331. });
  332. $('#edit_nickname').on('click',function(){
  333. $.prompt({
  334. title: '修改我的昵称',
  335. text: '请输入您的昵称(不得超过15字)',
  336. empty: false, // 是否允许为空
  337. onOK: function (input) {
  338. if (input && input.trim().length <= 15) {
  339. //点击确认
  340. $.showLoading();
  341. $.get('/mobile/index.php?act=member_talk&op=change_membernick',
  342. {
  343. member_nick: input,
  344. room_id: talk_id,
  345. client_type: 'ajax'
  346. }, function (res) {
  347. $.hideLoading();
  348. var result = JSON.parse(res);
  349. if (result.code != 200) {
  350. $.alert(result.message);
  351. return;
  352. }
  353. var new_group_name = input.trim();
  354. $('.weui-flex__item[data-member-id="'+cur_mid+'"] p').text(new_group_name);
  355. $('.group-nickname').text(new_group_name);
  356. $.toast('修改成功',1000);
  357. });
  358. }
  359. else {
  360. $.alert('群名称不得超过15字');
  361. }
  362. },
  363. onCancel: function () {
  364. //点击取消
  365. }
  366. });
  367. });
  368. $('#edit_room_notice').on('click',function(){
  369. $.prompt({
  370. title: '修改群公告',
  371. input: '请输入公告信息',
  372. empty: false, // 是否允许为空
  373. onOK: function (input) {
  374. if (input && input.trim().length <= 120) {
  375. //点击确认
  376. $.showLoading();
  377. $.get('/mobile/index.php?act=member_talk&op=change_room_notice',
  378. {
  379. room_notice: input,
  380. room_id: talk_id,
  381. client_type: 'ajax'
  382. }, function (res) {
  383. $.hideLoading();
  384. var result = JSON.parse(res);
  385. if (result.code != 200) {
  386. $.alert(result.message);
  387. return;
  388. }
  389. var new_notice = "【公告】"+ input.trim();
  390. $('.group_notice_board p').text(new_notice);
  391. $('#room-notice-btn').text("已设置");
  392. $('.group_notice_board').show();
  393. $.toast('修改成功',1000);
  394. });
  395. }
  396. else {
  397. $.alert('群公告不得超过120字');
  398. }
  399. },
  400. onCancel: function () {
  401. //点击取消
  402. }
  403. });
  404. $("#weui-prompt-input").remove(); //去除原始输入框
  405. $(".weui-dialog__bd").append('<textarea rows="8" style="height:110px;" class="weui_input weui-prompt-input" id="weui-prompt-input" value=""></textarea>');
  406. });
  407. $('#edit_room_desc').on('click',function(){
  408. $.prompt({
  409. title: '修改群介绍',
  410. text: '请输入群的简介(65个字符以内)',
  411. empty: false, // 是否允许为空
  412. onOK: function (input) {
  413. if (input && input.trim().length <= 65) {
  414. //点击确认
  415. $.showLoading();
  416. $.get('/mobile/index.php?act=member_talk&op=room_edit',
  417. {
  418. room_desc: input,
  419. room_id: talk_id,
  420. client_type: 'ajax'
  421. }, function (res) {
  422. $.hideLoading();
  423. var result = JSON.parse(res);
  424. if (result.code != 200) {
  425. $.alert(result.message);
  426. return;
  427. }
  428. var room_desc = input.trim();
  429. $('.group_name p').text(room_desc);
  430. $('#room-desc-btn').text("已设置");
  431. $.toast('修改成功',1000);
  432. });
  433. }
  434. else {
  435. $.alert('群介绍不得超过65字');
  436. }
  437. },
  438. onCancel: function () {
  439. //点击取消
  440. }
  441. });
  442. });
  443. $('#quit_group').on('click',function(){
  444. $.confirm({
  445. title: '确认退出',
  446. text: '您确认退出该群吗?',
  447. onOK: function () {
  448. $.showLoading();
  449. $.get('/mobile/index.php?act=member_talk&op=leave',{
  450. room_id:talk_id,
  451. client_type:'ajax'
  452. },function(res){
  453. var datas = JSON.parse(res);
  454. if(datas.code != 200) {
  455. $.alert(datas.message);
  456. $.hideLoading();
  457. return;
  458. }
  459. var jsonobject = {
  460. action: "talk_quit",
  461. params: {
  462. talk_id: talk_id,
  463. talk_type: talk_type
  464. }
  465. };
  466. jsBridge.call_native_handler('on_native_click', JSON.stringify(jsonobject),function(){
  467. $.hideLoading();
  468. });
  469. });
  470. },
  471. onCancel: function () {
  472. }
  473. });
  474. });
  475. $('#hide_msg').on('click', function () {
  476. $.confirm({
  477. title: '确认清空',
  478. text: '您确认清空聊天记录吗?',
  479. onOK: function () {
  480. $.showLoading();
  481. $.get('/mobile/index.php?act=member_talk&op=hide_msg',
  482. {
  483. room_id: talk_id,
  484. client_type: 'ajax'
  485. }, function (res) {
  486. $.hideLoading();
  487. var result = JSON.parse(res);
  488. console.log(result);
  489. if (result.code != 200) {
  490. $.alert(result.message);
  491. return;
  492. }
  493. var jsonobject = {
  494. action: "talk_clear",
  495. params: {
  496. talk_id: talk_id,
  497. talk_type: talk_type
  498. }
  499. };
  500. jsBridge.call_native_handler('on_native_click', JSON.stringify(jsonobject));
  501. $.toast('清除成功',1000);
  502. });
  503. },
  504. onCancel: function () {
  505. }
  506. })
  507. });
  508. $('#add_group').on('click', function () {
  509. $.showLoading();
  510. $.get('/mobile/index.php?act=member_talk&op=send_apply',
  511. {
  512. room_id: talk_id,
  513. client_type: 'ajax'
  514. }, function (res) {
  515. $.hideLoading();
  516. var result = JSON.parse(res);
  517. console.log(result);
  518. if (result.code != 200) {
  519. $.alert(result.message);
  520. return;
  521. }
  522. $.toast('进入成功',1000);
  523. });
  524. });
  525. $('#add_group_pwd').on('click', function () {
  526. $.prompt({
  527. title: '密码进群',
  528. text: '请输入密码(最长8位)',
  529. empty: false, // 是否允许为空
  530. onOK: function (input) {
  531. if (input && input.trim().length <= 8) {
  532. $.showLoading();
  533. $.get('/mobile/index.php?act=member_talk&op=send_apply',
  534. {
  535. passwd :input,
  536. room_id: talk_id,
  537. client_type: 'ajax'
  538. }, function (res) {
  539. $.hideLoading();
  540. var result = JSON.parse(res);
  541. console.log(result);
  542. if (result.code != 200) {
  543. $.alert(result.message);
  544. return;
  545. }
  546. $.toast('进入成功',1000);
  547. });
  548. }
  549. else {
  550. $.alert('密码最长为8位,可以由英文字母和数字任意组成,不区分大小写');
  551. }
  552. },
  553. onCancel: function () {
  554. //点击取消
  555. }
  556. });
  557. });
  558. $('#add_group_apply').on('click', function () {
  559. $.prompt({
  560. title: '申请入群',
  561. text: '请输入自我介绍(30字符以内)',
  562. empty: false,
  563. onOK: function (input) {
  564. if (input && input.trim().length <= 30) {
  565. $.showLoading();
  566. $.get('/mobile/index.php?act=member_talk&op=send_apply',
  567. {
  568. apply:1,
  569. msg :input,
  570. room_id: talk_id,
  571. client_type: 'ajax'
  572. }, function (res) {
  573. $.hideLoading();
  574. var result = JSON.parse(res);
  575. console.log(result);
  576. if (result.code != 200) {
  577. $.alert(result.message);
  578. return;
  579. }
  580. $.toast('申请成功',1000);
  581. });
  582. }
  583. else {
  584. $.alert('入群申请最长不得超过30字符');
  585. }
  586. },
  587. onCancel: function () {
  588. //点击取消
  589. }
  590. });
  591. });
  592. $('.group_notice_board p').on('click',function(){
  593. $(this).toggleClass('text_overflow');
  594. if($(this).hasClass('text_overflow')) {
  595. $('.group_notice_board').removeAttr('style');
  596. }
  597. else {
  598. $('.group_notice_board').css('max-height','999px');
  599. }
  600. });
  601. $('.qrcode_btn').on('click',function(){
  602. $('.pop').show(200);
  603. });
  604. $('.close_btn').on('click',function(){
  605. $('.pop').hide();
  606. });
  607. $('.pop').on('touchmove',function(e){
  608. e.preventDefault();
  609. });
  610. $('#group_pwd').on('click',function(e){
  611. if(!$(this).is(':checked')) {
  612. e.preventDefault();
  613. $.showLoading();
  614. $.get('/mobile/index.php?act=member_talk&op=change_passwd',
  615. {
  616. room_id: talk_id,
  617. client_type: 'ajax',
  618. use_pass:0
  619. }, function (res) {
  620. $.hideLoading();
  621. var result = JSON.parse(res);
  622. if (result.code != 200) {
  623. $.alert(result.message);
  624. return;
  625. }
  626. $('#group_pwd').removeAttr('checked');
  627. });
  628. }
  629. else {
  630. $.prompt({
  631. title: '修改群密码',
  632. text: '请设置4-8位群密码',
  633. empty: false,
  634. onOK: function (input) {
  635. if (input && (input.trim().length <= 8 && input.trim().length >= 4)) {
  636. //点击确认
  637. $.showLoading();
  638. $.get('/mobile/index.php?act=member_talk&op=change_passwd',
  639. {
  640. passwd: input,
  641. room_id: talk_id,
  642. client_type: 'ajax',
  643. use_pass:1
  644. }, function (res) {
  645. $.hideLoading();
  646. var result = JSON.parse(res);
  647. if (result.code != 200) {
  648. $.alert(result.message);
  649. $('#group_pwd').removeAttr('checked');
  650. return;
  651. }
  652. $('#group_pwd').attr('checked',true);
  653. $.toast('群密码设置成功',1000);
  654. });
  655. }
  656. else {
  657. $('#group_pwd').removeAttr('checked');
  658. $.alert('群密码设置错误,请重试');
  659. }
  660. },
  661. onCancel: function () {
  662. $('#group_pwd').removeAttr('checked');
  663. }
  664. });
  665. }
  666. });
  667. }
  668. );
  669. </script>
  670. </body>
  671. </html>