transfer.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <view class="app">
  3. <view class="top" id="app-top">
  4. <view class="search-view fx-h fx-bc fx-ac">
  5. <u--input
  6. placeholder="搜索联系人"
  7. prefixIcon="search"
  8. clearable
  9. border="none"
  10. prefixIconStyle="font-size: 22px;color: #909399"
  11. v-model="popKeyword"
  12. @input="tapPopKeyWord"
  13. ></u--input>
  14. </view>
  15. </view>
  16. <view class="pop-win-scroll">
  17. <view class="item fx-r fx-bc" @tap="tapItem(item.uid)" v-for="(item,index) in data">
  18. <image :src="item.avatar == '' ? '/static/chat/user-avatar.png' : item.avatar" mode="aspectFill"></image>
  19. <view class="info fx-h fx-ac">
  20. <rich-text class="nickname" :nodes="getRanValue(item.nickname)"></rich-text>
  21. <view class="manager" v-if="item.is_manager">群主</view>
  22. <view class="admin" v-else-if="item.is_admin">管理</view>
  23. </view>
  24. </view>
  25. <view class="loading fx-r fx-ac fx-bc" v-if="page.isFrite && !page.isFoot">
  26. <image src="/static/chat/xloading.png"></image>
  27. <text>正在载入更多...</text>
  28. </view>
  29. <view class="loading complete" :hidden="!page.isFoot">已加载全部</view>
  30. </view>
  31. </view>
  32. </template>
  33. <style lang="scss">
  34. .top{background: #F8F6F6;position: fixed;z-index: 99;width: 100%;}
  35. .search-view{background: #fff;margin-top: 1px;padding: 10px;margin: 10px;border-radius: 6px;}
  36. .search-view .u-input{width: 100%;}
  37. .pop-win-scroll{ padding-top: 60px;}
  38. .pop-win-scroll .item{background: #fff;padding:10px 10px;position: relative;}
  39. .pop-win-scroll .item:active{background: #f1f1f1;}
  40. .pop-win-scroll .item image{width: 40px;height: 40px;border-radius: 50%;}
  41. .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;}
  42. .pop-win-scroll .item .info .title{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;}
  43. .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;}
  44. .pop-win-scroll .item:last-child .info{border-bottom: 0;}
  45. .pop-win-scroll .letter{padding: 10px;background: #F8F6F6;}
  46. .manager{border: 1px solid #faac06;border-radius: 6px;font-size: 10px;padding:0px 6px;color: #faac06;background: #fff;width: 30px;text-align: center;}
  47. .admin{border: 1px solid #2fbec0;border-radius: 6px;font-size: 10px;padding:0px 6px;color: #2fbec0;background: #fff;width: 30px;text-align: center;}
  48. </style>
  49. <script>
  50. import {mapState,mapMutations} from 'vuex';
  51. export default {
  52. computed: mapState(['user','sysData']),
  53. data() {
  54. return {
  55. data : [],
  56. groupId : 0,
  57. mbAr : {},
  58. popKeyword:"",
  59. page:{
  60. isFirst:false,
  61. isLoad:false,
  62. isFoot:false,
  63. page:1
  64. }
  65. }
  66. },
  67. onLoad(options) {
  68. this.groupId = options.groupId;
  69. this.checkUserLogin({
  70. page:this,isLogin:true,fn:this.initView
  71. });
  72. this.getData();
  73. },
  74. onReachBottom() {
  75. if(this.page.isFoot || this.page.isLoad) {
  76. return;
  77. }
  78. this.page.page ++;
  79. this.getData();
  80. },
  81. methods: {
  82. ...mapMutations(['checkUserLogin','setSys']),
  83. tapPopKeyWord:function(ev){
  84. this.page = {page:1,isLoad:false,isFoot:false};
  85. if(this.mbAr[this.popKeyword] != null) {
  86. this.data = this.mbAr[this.popKeyword];
  87. } else {
  88. this.getData(true);
  89. }
  90. },
  91. getData:function(isPull = false){
  92. this
  93. .request
  94. .post("chatGroupUser",{groupId : this.groupId,page : this.page.page,keyword : this.popKeyword})
  95. .then(res=>{
  96. if(res.code == 200) {
  97. this.page.isFrite = true;
  98. this.page.isLoad = false;
  99. if(isPull) {
  100. this.data = res.data.list;
  101. } else {
  102. this.data = this.data.concat(res.data.list);
  103. }
  104. //是否到底
  105. if(res.data.list.length != res.data.pageSize) {
  106. this.page.isFoot = true;
  107. }
  108. if(this.page.page == 1 && this.popKeyword != ''){
  109. this.mbAr[this.popKeyword] = res.data.list;
  110. }
  111. //this.tapPopKeyWord();
  112. } else {
  113. uni.showModal({title: '系统提示',content:res.msg,showCancel: false});
  114. }
  115. });
  116. },
  117. /**
  118. * 提交创建
  119. */
  120. tapItem:function(usercode){
  121. if(usercode == this.user.id) {
  122. return;
  123. }
  124. this.utils.showModal("你确定要转让群主吗?", ()=>{
  125. uni.showLoading({ title:"提交数据中..." });
  126. this
  127. .request
  128. .post("GroupTransfer",{groupId:this.groupId,usercode:usercode})
  129. .then(res=>{
  130. uni.hideLoading();
  131. if(res.code == 200) {
  132. this.utils.Tip("转让成功");
  133. setTimeout(()=>{
  134. uni.navigateBack();
  135. },200);
  136. } else {
  137. this.utils.Tip(res.msg);
  138. }
  139. })
  140. .catch(err=>{
  141. uni.hideLoading();
  142. this.utils.Tip("加载失败,请重新尝试");
  143. });
  144. });
  145. },
  146. /**
  147. * 遍历字符串
  148. */
  149. getRanValue:function(str) {
  150. let value = str;
  151. if (value.indexOf(this.popKeyword)!==-1) {
  152. let reg = new RegExp(this.popKeyword, 'gi')
  153. return value.replace(reg, `<font style="color:#2fbec0">${this.popKeyword}</font>`)
  154. } else {
  155. return value
  156. }
  157. },
  158. }
  159. }
  160. </script>