group_member.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791
  1. <template>
  2. <view class="page">
  3. <view class="list-footer" v-if="data.type == 1">
  4. <view class="searchOut">
  5. <uni-search-bar ref="searchBar" placeholder="搜索" bgColor="#F7F7F7" :show="false" @confirm="search"
  6. @search="search">
  7. </uni-search-bar>
  8. </view>
  9. <view class="member-list">
  10. <view class="member-item" v-for="(val,index) in show_men" :key="index" @tap="goDetails(val.user_id)" v-if="isShow">
  11. <view class="item-left">
  12. <view class="item-left-img">
  13. <image :src="photo(val.photo+'')" :lazy-load="true" :data-index="index" @erro="imageError">
  14. </image>
  15. </view>
  16. <view class="item-text">
  17. <text>{{val.show_name}}</text>
  18. <text class="tag-admin" v-show="val.is_admin == 2">群主</text>
  19. <text class="tag-admin" v-show="val.is_admin == 1">管理员</text>
  20. </view>
  21. </view>
  22. <view class="item-right">
  23. <!-- <view class="item-right-img">
  24. <image src="/static/theme/default/qunzhu.png" v-show="val.is_admin == 2"></image>
  25. <image src="/static/theme/default/guanliyuan.png" v-show="val.is_admin == 1"></image>
  26. </view> -->
  27. <view class="item-right-text">
  28. {{val.is_online == 1 ? '在线' : '离线'}}
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="yaoqing-menber">
  34. <view class="group-member-btn-box">
  35. <view class="group-member-btn" @tap="add">
  36. +
  37. </view>
  38. <text class="tip">添加</text>
  39. </view>
  40. <view class="group-member-btn-box">
  41. <view class="group-member-btn" @tap="reduce">
  42. -
  43. </view>
  44. <text class="tip">删除</text>
  45. </view>
  46. </view>
  47. </view>
  48. <!-- <view class="doButton" v-show="!data.is_action && data.type == 1" >
  49. <button class="group-button" type="button" @tap="liveGroup">离开群聊</button>
  50. </view> -->
  51. </view>
  52. </template>
  53. <script>
  54. import _hook from '../../../common/_hook';
  55. import _data from '../../../common/_data';
  56. import _get from '../../../common/_get';
  57. import _page from '../../../common/common';
  58. import uniSearchBar from '@/components/mehaotian-search/mehaotian-search.vue';
  59. export default {
  60. components: {
  61. uniSearchBar
  62. },
  63. data() {
  64. return {
  65. show_men: [],
  66. isShow: true,
  67. data: {
  68. chat_msg: '55',
  69. member: [],
  70. group: {
  71. is_photo: 'default_group_photo/90.jpg',
  72. },
  73. is_action: 0,
  74. type: 1,
  75. },
  76. list_id: 0,
  77. user_id: 0
  78. };
  79. },
  80. computed: {
  81. staticPhoto() {
  82. return _data.staticPhoto();
  83. },
  84. isAction() {
  85. if (this.data.group.main_id == _data.data('user_info').id) {
  86. return true;
  87. }
  88. return false;
  89. },
  90. showKefu() {
  91. return this.my_data.id != 5880
  92. }
  93. },
  94. onShow() {
  95. _hook.routeSonHook();
  96. let _this = this;
  97. _this.$httpSend({
  98. path: '/im/message/getChatDetails',
  99. data: {
  100. list_id: _this.list_id,
  101. },
  102. success(data) {
  103. _this.data = data;
  104. _this.show_men = data.member;
  105. console.log(_this.show_men,'_this.show_men');
  106. if (data.type == 1) {
  107. uni.setNavigationBarTitle({
  108. title: `全部成员(${data.member.length}人)`,
  109. });
  110. }
  111. let cache_data = _data.data('cache');
  112. if (data.type == 1 && !('group_photo_' + _this.list_id in cache_data)) {
  113. uni.downloadFile({
  114. url: _data.staticPhoto() + data.group.is_photo,
  115. success: (res) => {
  116. if (res.statusCode === 200) {
  117. cache_data['group_photo_' + _this.list_id] = res.tempFilePath;
  118. _data.data('cache', cache_data);
  119. }
  120. }
  121. });
  122. }
  123. }
  124. });
  125. },
  126. methods: {
  127. search(chat_msg) {
  128. chat_msg = chat_msg.trim();
  129. this.isShow = false
  130. console.log('chat_msg',chat_msg);
  131. let arr = []
  132. if(chat_msg == '' || chat_msg === undefined) {
  133. this.show_men = this.data.member
  134. this.isShow = true
  135. }else {
  136. this.data.member.forEach(item => {
  137. if(item.show_name.indexOf(chat_msg) != -1) {
  138. arr.push(item)
  139. }
  140. })
  141. this.$set(this,'show_men',arr)
  142. this.isShow = true
  143. }
  144. // this.show_men = arr
  145. console.log(this.show_men,'this.show_men');
  146. },
  147. goKefu() {
  148. this.$httpSend({
  149. path: '/im/get/kefu',
  150. success(data) {
  151. console.log('客服数据', data)
  152. uni.navigateTo({
  153. 'url': '/pages/chat/message?list_id=' + data
  154. })
  155. }
  156. });
  157. },
  158. groupNickname(val) {
  159. console.log(val)
  160. uni.navigateTo({
  161. url: 'group_nickname?' + _page.pageParam({
  162. list_id: this.list_id,
  163. nickname: val
  164. })
  165. })
  166. },
  167. disturb(e) {
  168. //消息免打扰
  169. let value = e.detail.value ? 1 : 0;
  170. let _this = this;
  171. this.$httpSend({
  172. path: '/im/message/msgDisturb',
  173. data: {
  174. list_id: this.list_id,
  175. value: value
  176. },
  177. success(data) {
  178. _data.localData('DISTURB:' + _this.list_id, value)
  179. }
  180. });
  181. },
  182. liveGroup() {
  183. //离开群聊
  184. let _this = this;
  185. uni.showModal({
  186. title: '重要提示',
  187. content: '确定要离开群聊吗?',
  188. confirmText: '离开',
  189. cancelText: '再看看',
  190. confirmColor: 'red',
  191. cancelColor: '#353535',
  192. success: function(res) {
  193. if (res.confirm) {
  194. _this.$httpSend({
  195. path: '/im/message/liveGroup',
  196. data: {
  197. list_id: _this.list_id
  198. },
  199. success(data) {
  200. console.log(data)
  201. uni.switchTab({
  202. url: '../index'
  203. });
  204. }
  205. });
  206. }
  207. }
  208. });
  209. },
  210. imageError(e) {
  211. console.log("图片加载失败!", e.detail);
  212. let index = e.currentTarget.dataset.index
  213. console.log(e.currentTarget.dataset.index)
  214. //替换index对应的图片
  215. console.log(this.data.member[index].photo)
  216. this.data.member[index].photo = '/default_photo_path.png';
  217. },
  218. removeGroup() {
  219. let _this = this;
  220. uni.showModal({
  221. title: '重要提示',
  222. content: '此操作数据不可恢复,确定要解散该群吗?',
  223. confirmText: '不解散',
  224. cancelText: '解散',
  225. confirmColor: '#353535',
  226. cancelColor: 'red',
  227. success: function(res) {
  228. if (!res.confirm) {
  229. _this.$httpSend({
  230. path: '/im/message/removeGroup',
  231. data: {
  232. list_id: _this.list_id,
  233. },
  234. success(data) {
  235. uni.switchTab({
  236. url: '../index'
  237. });
  238. }
  239. });
  240. }
  241. }
  242. });
  243. },
  244. photo(path) {
  245. return this.staticPhoto + path + '?_=' + Math.random();
  246. },
  247. msgChange(e) {
  248. let value = e.detail.value ? 1 : 0;
  249. if (this.data.is_action != 2) {
  250. uni.showModal({
  251. content: '没有权限设置',
  252. showCancel: false,
  253. });
  254. return;
  255. }
  256. this.$httpSend({
  257. path: '/im/message/groupIsMsg',
  258. data: {
  259. list_id: this.list_id,
  260. value,
  261. },
  262. success(data) {
  263. return;
  264. uni.showToast({
  265. title: '设置成功',
  266. duration: 1500
  267. });
  268. }
  269. });
  270. },
  271. nimingChange(e) {
  272. let value = e.detail.value ? 1 : 0;
  273. if (!this.data.is_action && this.data.is_action != 2) {
  274. uni.showModal({
  275. content: '没有权限设置',
  276. showCancel: false,
  277. });
  278. return;
  279. }
  280. this.$httpSend({
  281. path: '/im/message/nimingChange',
  282. data: {
  283. list_id: this.list_id,
  284. value,
  285. },
  286. success(data) {
  287. return;
  288. uni.showToast({
  289. title: '设置成功',
  290. duration: 1500
  291. });
  292. }
  293. });
  294. },
  295. msgTop(e) {
  296. let _this = this,
  297. value = e.detail.value ? 1 : 0;
  298. this.$httpSend({
  299. path: '/im/message/chatTop',
  300. data: {
  301. list_id: this.list_id,
  302. value,
  303. },
  304. success(data) {
  305. /** 更新对话列表数据 */
  306. for (let i = 0, local_chat_list = _data.localData('chat_list'), j = local_chat_list
  307. .length; i < j; i++) {
  308. if (local_chat_list[i].list_id == _this.list_id) {
  309. let action_list_data = local_chat_list[i];
  310. local_chat_list.splice(i, 1);
  311. local_chat_list.unshift(action_list_data);
  312. _data.localData('chat_list', local_chat_list);
  313. uni.$emit('data_chat_list', local_chat_list);
  314. break;
  315. }
  316. }
  317. return;
  318. uni.showToast({
  319. title: '设置成功',
  320. duration: 1500
  321. });
  322. }
  323. });
  324. },
  325. switch1Change(e) {
  326. let _this = this,
  327. value = e.detail.value ? 1 : 0;
  328. this.$httpSend({
  329. path: '/im/message/speekChecked',
  330. data: {
  331. list_id: this.list_id,
  332. value: value,
  333. },
  334. success(data) {
  335. /** 更新对话列表数据 */
  336. for (let i = 0, local_chat_list = _data.localData('chat_list'), j = local_chat_list
  337. .length; i < j; i++) {
  338. if (local_chat_list[i].list_id == _this.list_id) {
  339. let action_list_data = local_chat_list[i];
  340. local_chat_list.splice(i, 1);
  341. local_chat_list.unshift(action_list_data);
  342. _data.localData('chat_list', local_chat_list);
  343. uni.$emit('data_chat_list', local_chat_list);
  344. break;
  345. }
  346. }
  347. }
  348. });
  349. },
  350. editChange(e) {
  351. let _this = this,
  352. value = e.detail.value ? 1 : 0;
  353. this.$httpSend({
  354. path: '/im/vendor/editChange',
  355. data: {
  356. list_id: this.list_id,
  357. value: value,
  358. },
  359. success(data) {
  360. }
  361. });
  362. },
  363. goGroupQrcode() {
  364. uni.navigateTo({
  365. url: ('./group_qrcode?list_id=' + this.list_id),
  366. animationType: 'slide-in-bottom',
  367. });
  368. },
  369. goSetGroupPhoto() {
  370. if (this.data.is_action != 2 && !this.data.group.edit_photo) {
  371. uni.showToast({
  372. title: '没有权限设置',
  373. icon: 'none',
  374. duration: 1000
  375. });
  376. return;
  377. }
  378. uni.navigateTo({
  379. url: ('../../set/group_photo?list_id=' + this.list_id),
  380. animationType: 'slide-in-bottom',
  381. });
  382. },
  383. goSetAdmin(type) {
  384. switch (type) {
  385. case 1:
  386. if (this.data.is_action != 2) {
  387. console.log("this.data.is_action", this.data.is_action)
  388. uni.showToast({
  389. title: '群主才能设置',
  390. icon: 'none',
  391. duration: 1000
  392. });
  393. return;
  394. }
  395. break;
  396. case 2:
  397. if (this.data.is_action != 2) {
  398. uni.showModal({
  399. content: '没有权限设置',
  400. showCancel: false,
  401. });
  402. return;
  403. }
  404. break;
  405. case 3:
  406. if (this.data.is_action != 2) {
  407. uni.showModal({
  408. content: '没有权限设置',
  409. showCancel: false,
  410. });
  411. return;
  412. }
  413. break;
  414. case 4:
  415. if (this.data.is_action != 2) {
  416. uni.showModal({
  417. content: '没有权限设置',
  418. showCancel: false,
  419. });
  420. return;
  421. }
  422. break;
  423. default:
  424. return;
  425. break;
  426. }
  427. let url = '../../set/group_admin?list_id=' + this.list_id + '&type=' + type;
  428. if (type == 3) url = '../../set/group_trans?list_id=' + this.list_id + '&type=' + type;
  429. if (type == 4) url = '../../set/copy_group?list_id=' + this.list_id + '&type=' + type;
  430. uni.navigateTo({
  431. url: url,
  432. animationType: 'slide-in-bottom',
  433. });
  434. },
  435. goSet(type) {
  436. if (this.data.is_action != 2 && !this.data.group.edit_photo) {
  437. uni.showToast({
  438. title: '没有权限设置',
  439. icon: 'none',
  440. duration: 1000
  441. });
  442. return;
  443. }
  444. uni.navigateTo({
  445. url: ('../../set/message_more?list_id=' + this.list_id + '&type=' + type),
  446. animationType: 'slide-in-bottom',
  447. });
  448. },
  449. goDetails(user_id) {
  450. if (this.data.type && this.data.is_action != 2) {
  451. uni.showToast({
  452. title: '没有权限查看',
  453. icon: 'none',
  454. duration: 1000
  455. });
  456. return;
  457. }
  458. uni.navigateTo({
  459. url: ('../../details/index?user_id=' + user_id + '&type=' + this.data.type + '&list_id=' + this
  460. .list_id + "&is_action=" + this.data.is_action),
  461. });
  462. },
  463. add() {
  464. uni.navigateTo({
  465. url: ('../../friend/index_list?list_id=' + this.list_id),
  466. animationType: 'slide-in-bottom',
  467. });
  468. },
  469. reduce() {
  470. uni.navigateTo({
  471. url: ('./reduce?list_id=' + this.list_id),
  472. animationType: 'slide-in-bottom',
  473. });
  474. },
  475. groupCopy(value) {
  476. _page.uniCopy({
  477. content: this.data.group.id,
  478. success: function() {
  479. uni.showToast({
  480. 'title': '复制成功',
  481. duration: 2000
  482. })
  483. }
  484. })
  485. },
  486. replaceStr(str) {
  487. console.log(str)
  488. return str.substr(10)
  489. },
  490. getRedChange(e) {
  491. let _this = this,
  492. value = e.detail.value ? 1 : 0;
  493. this.$httpSend({
  494. path: '/im/vendor/getRedChange',
  495. data: {
  496. list_id: this.list_id,
  497. value: value,
  498. },
  499. success(data) {
  500. }
  501. });
  502. },
  503. goBigRedList() { //todo 长时间未领取红包列表
  504. uni.navigateTo({
  505. url: "../message/red_list?list_id=" + this.list_id
  506. })
  507. },
  508. manarger() {
  509. uni.navigateTo({
  510. url: '../message/qun_manage?list_id=' + this.list_id
  511. })
  512. },
  513. xiaoHui() { //销毁聊天记录
  514. _get.xiaoHui({
  515. type: this.data.type,
  516. list_id: this.list_id
  517. }, function() {
  518. })
  519. }
  520. },
  521. onLoad(option) {
  522. this.list_id = option.list_id;
  523. this.data.type = option.type;
  524. },
  525. }
  526. </script>
  527. <style scoped>
  528. .item-text {
  529. display: flex;
  530. align-items: center;
  531. }
  532. .item-right-text {
  533. color: #80c8a8;
  534. }
  535. .tag-admin {
  536. border: 1px solid #80c8a8;
  537. margin-left: 20rpx;
  538. color: #80c8a8;
  539. height: 30rpx;
  540. font-size: 24rpx;
  541. display: flex;
  542. justify-content: center;
  543. align-items: center;
  544. border-radius: 15rpx;
  545. padding: 0 10rpx;
  546. }
  547. .group-member-btn-box {
  548. display: flex;
  549. flex-direction: column;
  550. align-items: center;
  551. .tip {
  552. font-size: 30rpx;
  553. color: #333;
  554. }
  555. }
  556. .group-member-btn {
  557. width: 100rpx;
  558. height: 100rpx;
  559. border-radius: 50%;
  560. background: #efefef;
  561. margin: 10rpx;
  562. display: flex;
  563. justify-content: center;
  564. align-items: center;
  565. font-size: 40rpx;
  566. color: #b6b6b8;
  567. font-weight: bold;
  568. }
  569. page {
  570. background: #fff;
  571. }
  572. .my-padding {
  573. padding-right: 0 !important;
  574. }
  575. .page {
  576. max-width: 100%;
  577. }
  578. .photos {
  579. background-color: #FFFFFF;
  580. }
  581. .group-button {
  582. width: 92%;
  583. background-color: #5693ee;
  584. color: white;
  585. height: 70upx;
  586. line-height: 70upx !important;
  587. border-radius: 40upx;
  588. font-size: 36upx;
  589. cursor: pointer;
  590. margin-top: 20upx;
  591. }
  592. .photo_main {
  593. margin: 7upx 0 0 40upx;
  594. display: inline-block;
  595. text-align: center;
  596. }
  597. .qun-gonggao {
  598. display: flex;
  599. justify-content: space-between;
  600. width: 95%;
  601. }
  602. .photo {
  603. width: 106upx;
  604. height: 106upx;
  605. border-radius: 7upx;
  606. }
  607. .name_class {
  608. font-size: 12px;
  609. color: black;
  610. max-width: 106upx;
  611. overflow: hidden;
  612. white-space: nowrap;
  613. }
  614. .msg-size {
  615. font-size: 16px !important;
  616. }
  617. .title {
  618. background: #FFFFFF;
  619. padding: 10px 20px 10px 23px;
  620. border-top: 1px solid #e5e5e5;
  621. display: flex;
  622. justify-content: space-between;
  623. }
  624. .title-msg {
  625. display: flex;
  626. justify-content: space-between;
  627. align-items: center;
  628. width: 90%;
  629. color: black !important;
  630. font-size: 16px !important;
  631. }
  632. .title-img {
  633. display: flex;
  634. align-items: center;
  635. }
  636. .title_val {
  637. display: inline-block;
  638. }
  639. .switch_class {
  640. margin-top: 20upx;
  641. }
  642. .show_text {
  643. position: absolute;
  644. right: 30px;
  645. color: #8f8f94;
  646. display: inline-block;
  647. /* width: 320px; */
  648. overflow: hidden;
  649. height: 30px;
  650. }
  651. .photo_qrcode {
  652. width: 52upx;
  653. height: 52upx;
  654. margin-right: 0upx;
  655. }
  656. .uni-list-cell-navigate.uni-navigate-right:after {
  657. font-size: 20px !important;
  658. }
  659. .uni-list-cell {
  660. height: 60px !important
  661. }
  662. .uni-list-cell-pd {
  663. padding: 0px 10px 0 12px !important;
  664. }
  665. .uni-media-list-logo {
  666. margin-right: 0px !important;
  667. }
  668. .qun-id {
  669. display: flex;
  670. justify-content: center;
  671. align-items: center;
  672. word-break: break-all;
  673. }
  674. .item-left-img {
  675. display: flex;
  676. justify-content: center;
  677. align-items: center;
  678. padding: 0 10px 0 25px;
  679. }
  680. .item-right-img {
  681. display: flex;
  682. justify-content: center;
  683. align-items: center;
  684. margin-right: 30px;
  685. }
  686. .item-right-img image {
  687. width: 20px;
  688. height: 20px;
  689. }
  690. .item-left-img image {
  691. width: 45px;
  692. height: 45px;
  693. border-radius: 50%;
  694. }
  695. .member-list {
  696. display: flex;
  697. flex-direction: column;
  698. background-color: #ffffff;
  699. }
  700. .member-item {
  701. display: flex;
  702. flex-direction: row;
  703. justify-content: space-between;
  704. align-items: center;
  705. padding: 20rpx;
  706. border-top: 1px solid #ebebeb;
  707. }
  708. .item-left {
  709. display: flex;
  710. flex-direction: row;
  711. justify-content: center;
  712. align-items: center;
  713. }
  714. .item-right {
  715. display: flex;
  716. flex-direction: row;
  717. justify-content: center;
  718. align-items: center;
  719. padding: 0 30px 0 20px;
  720. color: #435d90;
  721. }
  722. .yaoqing-menber {
  723. display: flex;
  724. align-items: center;
  725. padding: 10px 0 10px 30px;
  726. background-color: #ffffff;
  727. }
  728. .yaoqing {
  729. margin-left: 5px;
  730. }
  731. .list-member-count {
  732. padding: 5px 0 5px 30px;
  733. background-color: #f9f9f9;
  734. }
  735. .doButton {
  736. padding: 10px;
  737. }
  738. </style>