jdd.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  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/img/radio_buttons_0.png" mode="widthFix"></image>
  21. </view>
  22. <view v-else>
  23. <image class="select" style="border-radius: 0;" v-if="!item2.select" src="/static/img/rcheck.png" mode="widthFix"></image>
  24. <image class="select" style="border-radius: 0;" v-else src="/static/img/rcheck-btn.png" mode="widthFix"></image>
  25. </view>
  26. <image :src="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;border-radius: 50%;}
  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','txbagenum']),
  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. this.noData = JSON.parse(decodeURIComponent(options.notData));
  106. },
  107. onShow() {
  108. },
  109. methods: {
  110. ...mapMutations(['checkUserLogin','setSys']),
  111. /**
  112. *
  113. */
  114. initView:function(){
  115. this
  116. .request
  117. .post("chatGroupUserAll",{groupId : this.groupId})
  118. .then(res=>{
  119. if(res.code == 200) {
  120. for(var i in res.data){
  121. res.data[i].select = false;
  122. res.data[i].isDisable = false;
  123. for(var j in this.noData) {
  124. if(this.noData[j] == res.data[i].uid) {
  125. res.data[i].isDisable = true;
  126. }
  127. }
  128. }
  129. this.dataAr = res.data;
  130. this.letterView();
  131. } else {
  132. this.utils.showModal(res.msg);
  133. }
  134. });
  135. },
  136. /**
  137. * 检索关键词
  138. */
  139. tapKeyWord:function(ev){
  140. this.keyword = ev.detail.value;
  141. this.letterView();
  142. },
  143. //字母
  144. letterView:function(){
  145. var tAr = {};
  146. for(var i in LetterList) {
  147. var letter = LetterList[i];
  148. for(var j in this.dataAr) {
  149. var jAr = this.dataAr[j];
  150. if(jAr.letter == letter && (jAr.nickname.indexOf(this.keyword) >= 0 || jAr.remark.indexOf(this.keyword) >= 0 )) {
  151. if(tAr[letter] != null) {
  152. tAr[letter].data.push(jAr);
  153. } else {
  154. tAr[letter] = {'letter':letter,'data':[jAr]};
  155. }
  156. }
  157. }
  158. }
  159. var count = 0;
  160. var nAr = [];
  161. for(var j in tAr) {
  162. nAr.push(tAr[j]);
  163. count += tAr[j].data.length;
  164. }
  165. this.letter = nAr;
  166. this.count = count;
  167. },
  168. tapSelect:function(index,index2){
  169. if(this.letter[index].data[index2].isDisable)return;
  170. var bool = this.letter[index].data[index2].select;
  171. this.$set(this.letter[index].data[index2],'select',!bool);
  172. },
  173. inAr:function(){
  174. var count = 0;
  175. for(var i in this.letter) {
  176. for(var j in this.letter[i].data) {
  177. if(this.letter[i].data[j].select) {
  178. count += 1;
  179. }
  180. }
  181. }
  182. return count > 0 ? ("(" + count+ ")") : "";
  183. },
  184. /**
  185. * 遍历字符串
  186. */
  187. getRanValue:function(str) {
  188. let value = str;
  189. if (value.indexOf(this.keyword)!==-1) {
  190. let reg = new RegExp(this.keyword, 'gi')
  191. return value.replace(reg, `<font style="color:#2fbec0">${this.keyword}</font>`)
  192. } else {
  193. return value
  194. }
  195. },
  196. /**
  197. * 打开字母
  198. */
  199. tapOpenLetter:function(item){
  200. this.isChoice = true;
  201. this.choice = item;
  202. setTimeout(()=>{this.isChoice = false;},500);
  203. this.toView = "letter_" + item;
  204. },
  205. /**
  206. * 打开
  207. * @param {Object} ev
  208. */
  209. tapOpen: function(ev) {
  210. let url = ev.currentTarget.dataset.url;
  211. this.utils.navigateTo(url);
  212. },
  213. /**
  214. * 提交创建
  215. */
  216. tapSubmit:function(){
  217. var idsAr = [];
  218. for(var i in this.letter) {
  219. for(var j in this.letter[i].data) {
  220. if(this.letter[i].data[j].select) {
  221. idsAr.push(this.letter[i].data[j].uid);
  222. }
  223. }
  224. }
  225. if(idsAr.length < 0) {
  226. return this.utils.Tip("请选择操作的人");
  227. }
  228. uni.showLoading({ title:"提交中.." });
  229. this
  230. .request
  231. .post("GroupJdd",{groupId:this.groupId,usercodes:idsAr.join(",")})
  232. .then(res=>{
  233. uni.hideLoading();
  234. if(res.code == 200) {
  235. this.utils.Tip("操作成功");
  236. setTimeout(()=>{uni.navigateBack();},200);
  237. } else {
  238. uni.showModal({title: '系统提示',content: res.msg,showCancel: false});
  239. }
  240. })
  241. .catch(err=>{
  242. console.log(err);
  243. uni.hideLoading();
  244. uni.showModal({title: '系统提示',content: '加载失败,返回在尝试',showCancel: false});
  245. });
  246. }
  247. }
  248. }
  249. </script>
  250. <style>
  251. .app{width: 100vw;height: 100vh;}
  252. /* #ifdef H5 */
  253. .app{height: calc(100vh - 95px);}
  254. /* #endif */
  255. .app-run .text{font-size: 24px;font-weight: bold;color: #737373;}
  256. .choice {
  257. width: 110rpx;
  258. height: 110rpx;
  259. position: fixed;
  260. top: 40%;
  261. left: 50%;
  262. transform: translate(-50%,-50%);
  263. background: rgba(0,0,0,0.3);
  264. color: #fff;
  265. border-radius: 20rpx;
  266. text-align: center;
  267. line-height: 110rpx;
  268. font-size: 45rpx;
  269. z-index: 2;
  270. }
  271. </style>