jddNo.vue 8.7 KB

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