adminAdd.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <view>
  3. <view class="app">
  4. <uni-nav-bar statusBar 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="top">
  10. <view class="search-view fx-h fx-bc fx-ac">
  11. <u--input
  12. placeholder="搜索联系人"
  13. prefixIcon="search"
  14. clearable
  15. border="none"
  16. prefixIconStyle="font-size: 22px;color: #909399"
  17. v-model="popKeyword"
  18. @input="tapPopKeyWord"
  19. ></u--input>
  20. </view>
  21. </view>
  22. <view class="pop-win-scroll">
  23. <view class="item fx-r fx-bc" @tap="tapSelect(index)" v-for="(item,index) in data">
  24. <view v-if="">
  25. <view v-if="item.isDisable || item.is_manager">
  26. <image class="select" src="/static/chat/radio_buttons_0.png" mode="widthFix"></image>
  27. </view>
  28. <view v-else>
  29. <image class="select" v-if="!item.select" src="/static/chat/check.png" mode="widthFix"></image>
  30. <image class="select" v-else src="/static/chat/check-btn.png" mode="widthFix"></image>
  31. </view>
  32. </view>
  33. <view class="fx-r fx-g1 fx-bc">
  34. <image :src="item.avatar == '' ? '/static/chat/user-avatar.png' : item.avatar" mode="aspectFill"></image>
  35. <view class="info fx-h fx-ac">
  36. <rich-text class="nickname" :nodes="getRanValue(item.nickname)"></rich-text>
  37. <view class="manager" v-if="item.is_manager">群主</view>
  38. <view class="admin" v-else-if="item.is_admin">管理</view>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="loading fx-r fx-ac fx-bc" v-if="page.isFrite && !page.isFoot">
  43. <image src="/static/chat/xloading.png"></image>
  44. <text>正在载入更多...</text>
  45. </view>
  46. <view class="loading complete" :hidden="!page.isFoot">已加载全部</view>
  47. </view>
  48. </view>
  49. </view>
  50. </template>
  51. <style lang="scss">
  52. .sub-btn{color: #fff;background:$ic-appcolor;padding: 8px;border-radius: 4px;}
  53. .top{background: #F8F6F6;position: fixed;z-index: 99;width: 100%;}
  54. .search-view{background: #fff;margin-top: 1px;padding: 10px;margin: 10px;border-radius: 6px;}
  55. .search-view .u-input{width: 100%;}
  56. .pop-win-scroll{ padding-top: 60px;}
  57. .pop-win-scroll .item{background: #fff;padding:10px 10px;position: relative;}
  58. .pop-win-scroll .item:active{background: #f1f1f1;}
  59. .pop-win-scroll .item image{width: 40px;height: 40px;border-radius: 50%;}
  60. .pop-win-scroll .item .info{width: calc(100% - 70px);padding: 10px 0;margin-left: 10px;font-size: 14px;color:#787878;border-bottom: 1px solid #f1f1f1;}
  61. .pop-win-scroll .item .info .title{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;}
  62. .pop-win-scroll .item .flg{background: #ff5857;width: 20px;height: 20px;border-radius: 50%;font-size: 10px;text-align: center;line-height: 20px;color: #fff;}
  63. .pop-win-scroll .item:last-child .info{border-bottom: 0;}
  64. .pop-win-scroll .item .select{width: 20px;height: 20px;margin-right: 8px;border-radius: 0;}
  65. .pop-win-scroll .letter{padding: 10px;background: #F8F6F6;}
  66. .manager{border: 1px solid #faac06;border-radius: 6px;font-size: 10px;padding:0px 6px;color: #faac06;background: #fff;width: 30px;text-align: center;}
  67. .admin{border: 1px solid #2fbec0;border-radius: 6px;font-size: 10px;padding:0px 6px;color: #2fbec0;background: #fff;width: 30px;text-align: center;}
  68. </style>
  69. <script>
  70. import {mapState,mapMutations} from 'vuex';
  71. 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','#'];
  72. export default {
  73. computed: mapState(['user','sysData','txbagenum']),
  74. data() {
  75. return {
  76. noData : [],
  77. data : [],
  78. groupId : 0,
  79. mbAr : {},
  80. popKeyword:"",
  81. page :{
  82. isFirst:false,
  83. isLoad:false,
  84. isFoot:false,
  85. page:1
  86. }
  87. }
  88. },
  89. onLoad(options) {
  90. this.checkUserLogin({
  91. page:this,isLogin:true,fn:this.initView
  92. });
  93. this.groupId = options.groupId;
  94. this.noData = JSON.parse(decodeURIComponent(options.notData));
  95. },
  96. onReachBottom() {
  97. if(this.page.isFoot || this.page.isLoad) {
  98. return;
  99. }
  100. this.page.page ++;
  101. this.getData();
  102. },
  103. onShow() {
  104. },
  105. methods: {
  106. ...mapMutations(['checkUserLogin','setSys']),
  107. /**
  108. *
  109. */
  110. initView:function(){
  111. this.getData();
  112. },
  113. tapPopKeyWord:function(ev){
  114. this.page = {page:1,isLoad:false,isFoot:false};
  115. if(this.mbAr[this.popKeyword] != null) {
  116. this.data = this.mbAr[this.popKeyword];
  117. } else {
  118. this.getData(true);
  119. }
  120. },
  121. getData:function(isPull = false){
  122. this
  123. .request
  124. .post("chatGroupUser",{groupId : this.groupId,page : this.page.page,keyword : this.popKeyword})
  125. .then(res=>{
  126. if(res.code == 200) {
  127. this.page.isFrite = true;
  128. this.page.isLoad = false;
  129. console.log(this.notData);
  130. for(var j in this.noData) {
  131. for(var i in res.data.list){
  132. if(this.noData[j] ==res.data.list[i].uid) {
  133. res.data.list[i].isDisable = true;
  134. } else {
  135. res.data.list[i].isDisable = false;
  136. }
  137. }
  138. }
  139. if(isPull) {
  140. this.data = res.data.list;
  141. } else {
  142. this.data = this.data.concat(res.data.list);
  143. }
  144. //是否到底
  145. if(res.data.list.length != res.data.pageSize) {
  146. this.page.isFoot = true;
  147. }
  148. if(this.page.page == 1 && this.popKeyword != ''){
  149. this.mbAr[this.popKeyword] = res.data.list;
  150. }
  151. } else {
  152. uni.showModal({title: '系统提示',content:res.msg,showCancel: false});
  153. }
  154. });
  155. },
  156. /**
  157. * 遍历字符串
  158. */
  159. getRanValue:function(str) {
  160. let value = str;
  161. if (value.indexOf(this.keyword)!==-1) {
  162. let reg = new RegExp(this.keyword, 'gi')
  163. return value.replace(reg, `<font style="color:#2fbec0">${this.keyword}</font>`)
  164. } else {
  165. return value
  166. }
  167. },
  168. /**
  169. * 打开
  170. * @param {Object} ev
  171. */
  172. tapOpen: function(ev) {
  173. let url = ev.currentTarget.dataset.url;
  174. this.utils.navigateTo(url);
  175. },
  176. tapSelect:function(index){
  177. if(this.data[index].isDisable)return;
  178. var bool = this.data[index].select;
  179. this.$set(this.data[index],'select',!bool);
  180. },
  181. /**
  182. * 提交创建
  183. */
  184. tapSubmit:function(){
  185. var idsAr = [];
  186. for(var j in this.data) {
  187. if(this.data[j].select) {
  188. idsAr.push(this.data[j].uid);
  189. }
  190. }
  191. if(idsAr.length < 0) {
  192. return this.utils.Tip("请选择添加的人");
  193. }
  194. uni.showLoading({ title:"提交中.." });
  195. this
  196. .request
  197. .post("chatGroupAdminAdd",{groupId:this.groupId,usercodes:idsAr.join(",")})
  198. .then(res=>{
  199. uni.hideLoading();
  200. if(res.code == 200) {
  201. uni.$emit('groupAdmin','');
  202. this.utils.Tip("操作成功");
  203. setTimeout(()=>{uni.navigateBack();},200);
  204. } else {
  205. uni.showModal({title: '系统提示',content: res.msg,showCancel: false});
  206. }
  207. })
  208. .catch(err=>{
  209. console.log(err);
  210. uni.hideLoading();
  211. uni.showModal({title: '系统提示',content: '加载失败,返回在尝试',showCancel: false});
  212. });
  213. },
  214. inAr:function(){
  215. var count = 0;
  216. for(var j in this.data) {
  217. if(this.data[j].select) {
  218. count += 1;
  219. }
  220. }
  221. return count > 0 ? ("(" + count+ ")") : "";
  222. },
  223. }
  224. }
  225. </script>