adminJdd.vue 8.2 KB

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