adminJdd.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  1. <template>
  2. <view>
  3. <view id="app-top">
  4. <uni-nav-bar statusBar backgroundColor="transparent" fixed title="移除管理员" left-icon="left"
  5. @clickLeft="utils.navigateBack()">
  6. <view slot="right" @tap="tapSubmit">
  7. <view class="sub-btn">完成{{inAr()}}</view>
  8. </view>
  9. </uni-nav-bar>
  10. <view class="search fx-r fx-bc">
  11. <image src="/static/img/tb-seach.png"></image>
  12. <input @input="tapKeyWord" class="fx-g1" type="text" placeholder="搜索联系人" />
  13. </view>
  14. </view>
  15. <scroll-view class="search-view" :style="'height: calc(100vh - ' + barheight + 'px);'" scroll-y
  16. :scroll-into-view="toView" scroll-with-animation='true' show-scrollbar="false">
  17. <view class="lists">
  18. <view v-for="(item,index) in letter">
  19. <view class="letter" :id="'letter_' + item.letter">{{item.letter}}</view>
  20. <view class="item fx-r fx-bc" @tap="tapSelect(index,index2)" v-for="(item2,index2) in item.data">
  21. <view v-if="item2.isDisable">
  22. <image class="select" src="/static/chat/radio_buttons_0.png" mode="widthFix"></image>
  23. </view>
  24. <view v-else>
  25. <image class="select" v-if="!item2.select" src="/static/chat/check.png" mode="widthFix">
  26. </image>
  27. <image class="select" v-else src="/static/chat/check-btn.png" mode="widthFix"></image>
  28. </view>
  29. <image style="border-radius: 50%;"
  30. :src="item2.avatar == '' ? '/static/chat/user-avatar.png' : item2.avatar" mode="aspectFill">
  31. </image>
  32. <view class="info fx-h fx-ac">
  33. <rich-text class="title" :nodes="getRanValue(item2.remark || item2.nickname)"></rich-text>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="foot-value">{{count}}个朋友</view>
  38. </view>
  39. </scroll-view>
  40. <view class="SideMenu">
  41. <view @tap="tapOpenLetter(item.letter)" v-for="(item, index) in letter"> {{item.letter}} </view>
  42. </view>
  43. <view class="choice" v-if="isChoice">{{choice}}</view>
  44. </view>
  45. </template>
  46. <style lang="scss">
  47. .sub-btn {
  48. color: #fff;
  49. background: $ic-appcolor;
  50. padding: 8px;
  51. border-radius: 4px;
  52. }
  53. .search {
  54. background: #fff;
  55. border-radius: 6px;
  56. margin: 0px 10px;
  57. padding: 10px;
  58. }
  59. .search image {
  60. width: 30px;
  61. height: 30px;
  62. }
  63. .search input {
  64. font-size: 14px;
  65. }
  66. .search-view {
  67. height: calc(100% - 50px)
  68. }
  69. .search-view .lists {
  70. margin-top: 10px;
  71. }
  72. .search-view .lists .item {
  73. background: #fff;
  74. padding: 0 10px;
  75. position: relative;
  76. }
  77. .search-view .lists .item:active {
  78. background: #f1f1f1;
  79. }
  80. .search-view .lists .item image {
  81. width: 40px;
  82. height: 40px;
  83. }
  84. .search-view .lists .item .info {
  85. width: calc(100% - 100px);
  86. margin-left: 10px;
  87. font-size: 14px;
  88. color: #787878;
  89. border-bottom: 1px solid #f1f1f1;
  90. height: 60px;
  91. }
  92. .search-view .lists .item .flg {
  93. background: #ff5857;
  94. width: 20px;
  95. height: 20px;
  96. border-radius: 50%;
  97. font-size: 10px;
  98. text-align: center;
  99. line-height: 20px;
  100. color: #fff;
  101. }
  102. .search-view .lists .item .select {
  103. width: 20px;
  104. height: 20px;
  105. margin-right: 8px;
  106. }
  107. .search-view .lists .item:last-child .info {
  108. border-bottom: 0;
  109. }
  110. .search-view .letter {
  111. padding: 10px;
  112. }
  113. .SideMenu {
  114. position: fixed;
  115. top: 50%;
  116. right: 0;
  117. padding: 20rpx 0rpx;
  118. width: 45rpx;
  119. transform: translate(0, -50%);
  120. z-index: 1;
  121. }
  122. .SideMenu view {
  123. height: 30rpx;
  124. display: block;
  125. padding: 4rpx 0;
  126. wdith: 45rpx;
  127. color: #000;
  128. text-align: center;
  129. font-size: 22rpx;
  130. }
  131. .foot-value {
  132. height: 60px;
  133. line-height: 60px;
  134. font-size: 14px;
  135. text-align: center;
  136. color: #787878;
  137. }
  138. </style>
  139. <script>
  140. import {
  141. mapState,
  142. mapMutations
  143. } from 'vuex';
  144. var LetterList = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
  145. 'U', 'V', 'W', 'X', 'Y', 'Z', '#'
  146. ];
  147. export default {
  148. computed: mapState(['user', 'sysData']),
  149. data() {
  150. return {
  151. dataAr: [],
  152. letter: [],
  153. noData: [],
  154. count: 0,
  155. keyword: "",
  156. isChoice: false,
  157. choice: "",
  158. toView: "",
  159. barheight: 0,
  160. groupId: 0
  161. }
  162. },
  163. onLoad(options) {
  164. this.checkUserLogin({
  165. page: this,
  166. isLogin: true,
  167. fn: this.initView
  168. });
  169. this.$nextTick(() => {
  170. uni.createSelectorQuery().select("#app-top").boundingClientRect(res => {
  171. this.barheight = res.height;
  172. }).exec();
  173. });
  174. this.groupId = options.groupId;
  175. },
  176. onShow() {},
  177. methods: {
  178. ...mapMutations(['checkUserLogin', 'setSys']),
  179. /**
  180. *
  181. */
  182. initView: function() {
  183. uni.showLoading({
  184. title: "加载中..."
  185. });
  186. this
  187. .request
  188. .post("chatGroupAdminuser", {
  189. groupId: this.groupId
  190. })
  191. .then(res => {
  192. uni.hideLoading();
  193. if (res.code == 200) {
  194. this.dataAr = res.data;
  195. this.letterView();
  196. } else {
  197. this.utils.showModal(res.msg);
  198. }
  199. })
  200. .catch(err => {
  201. uni.hideLoading();
  202. uni.showModal({
  203. title: '系统提示',
  204. content: '加载失败,返回在尝试',
  205. showCancel: false
  206. });
  207. });
  208. },
  209. /**
  210. * 检索关键词
  211. */
  212. tapKeyWord: function(ev) {
  213. this.keyword = ev.detail.value;
  214. this.letterView();
  215. },
  216. //字母
  217. letterView: function() {
  218. var tAr = {};
  219. for (var i in LetterList) {
  220. var letter = LetterList[i];
  221. for (var j in this.dataAr) {
  222. var jAr = this.dataAr[j];
  223. if (jAr.letter == letter && (jAr.nickname.indexOf(this.keyword) >= 0 || jAr.remark.indexOf(this
  224. .keyword) >= 0)) {
  225. if (tAr[letter] != null) {
  226. tAr[letter].data.push(jAr);
  227. } else {
  228. tAr[letter] = {
  229. 'letter': letter,
  230. 'data': [jAr]
  231. };
  232. }
  233. }
  234. }
  235. }
  236. var count = 0;
  237. var nAr = [];
  238. for (var j in tAr) {
  239. nAr.push(tAr[j]);
  240. count += tAr[j].data.length;
  241. }
  242. this.letter = nAr;
  243. this.count = count;
  244. },
  245. tapSelect: function(index, index2) {
  246. if (this.letter[index].data[index2].isDisable) return;
  247. var bool = this.letter[index].data[index2].select;
  248. this.$set(this.letter[index].data[index2], 'select', !bool);
  249. },
  250. inAr: function() {
  251. var count = 0;
  252. for (var i in this.letter) {
  253. for (var j in this.letter[i].data) {
  254. if (this.letter[i].data[j].select) {
  255. count += 1;
  256. }
  257. }
  258. }
  259. return count > 0 ? ("(" + count + ")") : "";
  260. },
  261. /**
  262. * 遍历字符串
  263. */
  264. getRanValue: function(str) {
  265. let value = str;
  266. if (value.indexOf(this.keyword) !== -1) {
  267. let reg = new RegExp(this.keyword, 'gi')
  268. return value.replace(reg, `<font style="color:#2fbec0">${this.keyword}</font>`)
  269. } else {
  270. return value
  271. }
  272. },
  273. /**
  274. * 打开字母
  275. */
  276. tapOpenLetter: function(item) {
  277. this.isChoice = true;
  278. this.choice = item;
  279. setTimeout(() => {
  280. this.isChoice = false;
  281. }, 500);
  282. this.toView = "letter_" + item;
  283. },
  284. /**
  285. * 打开
  286. * @param {Object} ev
  287. */
  288. tapOpen: function(ev) {
  289. let url = ev.currentTarget.dataset.url;
  290. this.utils.navigateTo(url);
  291. },
  292. /**
  293. * 提交创建
  294. */
  295. tapSubmit: function() {
  296. var idsAr = [];
  297. for (var i in this.letter) {
  298. for (var j in this.letter[i].data) {
  299. if (this.letter[i].data[j].select) {
  300. idsAr.push(this.letter[i].data[j].uid);
  301. }
  302. }
  303. }
  304. if (idsAr.length < 0) {
  305. return this.utils.Tip("请选择添加的人");
  306. }
  307. uni.showLoading({
  308. title: "提交中.."
  309. });
  310. this
  311. .request
  312. .post("chatGroupAdminJdd", {
  313. groupId: this.groupId,
  314. usercodes: idsAr.join(",")
  315. })
  316. .then(res => {
  317. uni.hideLoading();
  318. if (res.code == 200) {
  319. uni.$emit('groupAdmin', '');
  320. this.utils.Tip("操作成功");
  321. setTimeout(() => {
  322. uni.navigateBack();
  323. }, 200);
  324. } else {
  325. uni.showModal({
  326. title: '系统提示',
  327. content: res.msg,
  328. showCancel: false
  329. });
  330. }
  331. })
  332. .catch(err => {
  333. console.log(err);
  334. uni.hideLoading();
  335. uni.showModal({
  336. title: '系统提示',
  337. content: '加载失败,返回在尝试',
  338. showCancel: false
  339. });
  340. });
  341. }
  342. }
  343. }
  344. </script>
  345. <style>
  346. .app {
  347. width: 100vw;
  348. height: 100vh;
  349. }
  350. /* #ifdef H5 */
  351. .app {
  352. height: calc(100vh - 95px);
  353. }
  354. /* #endif */
  355. .app-run .text {
  356. font-size: 24px;
  357. font-weight: bold;
  358. color: #737373;
  359. }
  360. .choice {
  361. width: 110rpx;
  362. height: 110rpx;
  363. position: fixed;
  364. top: 40%;
  365. left: 50%;
  366. transform: translate(-50%, -50%);
  367. background: rgba(0, 0, 0, 0.3);
  368. color: #fff;
  369. border-radius: 20rpx;
  370. text-align: center;
  371. line-height: 110rpx;
  372. font-size: 45rpx;
  373. z-index: 2;
  374. }
  375. </style>