searchitem.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. <template>
  2. <view class="page" >
  3. <scroll-view class="scroll" :style="'height:'+scrollheight+';top:'+top" lower-threshold='50' scroll-y="true" @scrolltolower="scrolltolower">
  4. <block v-if="user.length>0">
  5. <view class="more" style="text-align: left;padding-left: 10px;" v-if="type=='all'">人</view>
  6. <view v-for="(item, index) in user" :key="index" class="lines" @tap="user_detail(item)">
  7. <view class="avatar">
  8. <image :src="image_cache(item.avatar)"></image>
  9. </view>
  10. <view class="showname">
  11. <view>
  12. <rich-text :nodes="item.nickname" style="display: inline-block;"></rich-text>
  13. <span class='id'>(Id:{{item.id}}) </span>
  14. </view>
  15. <view>
  16. <image src="../static/img/vip1.png" class="icon" v-if="item.vip>0"></image>
  17. <view v-if="item.iskefu==1" class="btn_green">客服</view>
  18. <view v-if="item.iskefu==2" class="btn_blue">官方</view>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="more" v-if="user.length>=3 && type=='all'" @tap="showmore('user')">查看更多</view>
  23. </block>
  24. <block v-if="group.length>0">
  25. <view class="more" style="text-align: left;padding-left: 10px;" v-if="type=='all'">群组</view>
  26. <view v-for="(item, index) in group" :key="index" class="lines" @tap="group_detail(item)">
  27. <view class="avatar">
  28. <image :src="image_cache(item.avatar)"></image>
  29. </view>
  30. <view class="showname">
  31. <view>
  32. <rich-text :nodes="item.name" style="display: inline-block;"></rich-text>
  33. <span class='id'>(ID:{{item.id}}) </span>
  34. </view>
  35. <view>
  36. <uni-icons type='person' style="font-size: 16px;font-weight: 700;"></uni-icons>
  37. {{item.people_count}}/{{item.people_max}}人
  38. </view>
  39. </view>
  40. </view>
  41. <view class="more" v-if="group.length>=3 && type=='all'" @tap="showmore('group')">查看更多群组</view>
  42. </block>
  43. <view class="loading" v-if="loading==true" >
  44. <view class="spinner">
  45. <view class="rect1"></view>
  46. <view class="rect2"></view>
  47. <view class="rect3"></view>
  48. <view class="rect4"></view>
  49. <view class="rect5"></view>
  50. </view>
  51. </view>
  52. </scroll-view>
  53. </view>
  54. </template>
  55. <script>
  56. import uniIcons from '../components/uni-icons/uni-icons.vue'
  57. var windowHeight= uni.getSystemInfoSync().windowHeight;
  58. var statusBarHeight = uni.getSystemInfoSync().statusBarHeight ;
  59. var top=statusBarHeight+50;
  60. var scrollheight=windowHeight - top ;
  61. // #ifndef APP-PLUS
  62. scrollheight=scrollheight - 50;
  63. // #endif
  64. export default {
  65. components:{
  66. uniIcons
  67. },
  68. props: {
  69. data: {
  70. },
  71. type:{
  72. default:'all'
  73. },
  74. keyword:{
  75. default:''
  76. },
  77. loading:{
  78. default:false
  79. }
  80. },
  81. data() {
  82. return {
  83. user:[],
  84. plan:[],
  85. group:[],
  86. plan_status:['未开始','进行中','已完结'],
  87. scrollheight:scrollheight+'px',
  88. top:top+'px'
  89. };
  90. },
  91. watch:{
  92. data(val){
  93. this.init();
  94. }
  95. },
  96. mounted() {
  97. this.init();
  98. uni.$once('onReachBottom',function(data){
  99. console.log('触底了!');
  100. })
  101. },
  102. methods:{
  103. init(){
  104. this.user=this.data.user;
  105. for(var i=0;i<this.user.length;i++){
  106. this.user[i].nickname=this.user[i].nickname.replace(this.keyword,'<span style="color: #ff0000">'+this.keyword+'</span>');
  107. }
  108. this.plan=this.data.plan;
  109. for(var i=0;i<this.plan.length;i++){
  110. this.plan[i].title=this.plan[i].title.replace(this.keyword,'<span style="color: #ff0000">'+this.keyword+'</span>');
  111. }
  112. this.group=this.data.group;
  113. for(var i=0;i<this.group.length;i++){
  114. this.group[i].name=this.group[i].name.replace(this.keyword,'<span style="color: #ff0000">'+this.keyword+'</span>');
  115. }
  116. },
  117. showmore(type){
  118. this.$emit('showmore',type);
  119. },
  120. user_detail(item){
  121. this.$jump('friend.detail',{id:item.id});
  122. },
  123. plan_detail(item){
  124. this.$jump('plan.detail',{id:item.id});
  125. },
  126. group_detail(m){
  127. this.$jump('group.detail', {
  128. id: m.id,
  129. from:'search'
  130. });
  131. },
  132. scrolltolower() {
  133. console.log(this.type,1)
  134. if(this.type!='all'){
  135. this.$emit('getnext',this.type);
  136. }
  137. },
  138. }
  139. }
  140. </script>
  141. <style lang="scss">
  142. .page{
  143. font-size: 14px;
  144. background-color: #FAFAFA;
  145. }
  146. .page .scroll{
  147. position: fixed;
  148. left: 0px;
  149. width: 100%;
  150. z-index: 1;
  151. }
  152. .lines{
  153. padding: 5px 0px;
  154. height: 50px;
  155. line-height: 50px;
  156. display: table;
  157. table-layout: fixed;
  158. width: calc(100% - 0px);
  159. background-color: #fff;
  160. margin-bottom: 10px;
  161. font-size: 14px;
  162. }
  163. .lines .avatar{
  164. display: table-cell;
  165. width: 70px;
  166. text-align: center;
  167. }
  168. .lines .avatar > image{
  169. height: 50px;
  170. width: 50px;
  171. border-radius: 5px;;
  172. vertical-align: middle;
  173. }
  174. .lines .showname {
  175. text-align:left;
  176. display: table-cell;
  177. font-size: 14px;
  178. color: #333;
  179. line-height: 25px;;
  180. vertical-align: middle;
  181. margin: 0px 0px;
  182. padding: 0px 0px;
  183. }
  184. .lines .id{
  185. font-size: 12px;
  186. color: #666;
  187. margin-left: 5px;
  188. }
  189. .lines .icon{
  190. margin: 0px 2px;
  191. height: 20px;
  192. width: 20px;
  193. display: inline-block;
  194. }
  195. .btn_yellow{
  196. background-color: yellow;
  197. color: #000;
  198. font-size: 12px;
  199. display: inline-block;
  200. height:18px;
  201. line-height: 18px;
  202. padding: 0px 5px;
  203. border-radius: 5px;
  204. text-align: center;
  205. margin: 0px 2px;
  206. }
  207. .btn_green{
  208. background-color: #0aad6c;
  209. color: #fff;font-size: 12px;
  210. display: inline-block;
  211. height: 18px;
  212. line-height: 18px;
  213. padding: 0px 5px;
  214. border-radius: 5px;
  215. text-align: center;
  216. margin: 0px 2px;
  217. }
  218. .btn_blue{
  219. background-color: #2319dc;
  220. color: #fff;font-size: 12px;
  221. display: inline-block;
  222. height: 18px;
  223. line-height: 18px;
  224. padding: 0px 5px;
  225. border-radius: 5px;
  226. text-align: center;
  227. margin: 0px 2px;
  228. }
  229. .btn_grey{
  230. background-color: #ddd;
  231. color: #000;font-size: 12px;
  232. display: inline-block;
  233. height: 18px;
  234. line-height: 18px;
  235. padding: 0px 5px;
  236. border-radius: 5px;
  237. text-align: center;
  238. margin: 0px 2px;
  239. }
  240. .nodata{
  241. height: 35px;
  242. line-height: 35px;
  243. color: #666;
  244. font-size: 12px;
  245. text-align: center;
  246. }
  247. .more{
  248. height: 25px;
  249. line-height: 25px;
  250. color: #333;
  251. font-size: 14px;
  252. text-align: center;
  253. }
  254. .color-0{
  255. color: #666;
  256. }
  257. .color-1{
  258. color: #0aad6c;
  259. }
  260. .color-2{
  261. color:#ff6600;
  262. }
  263. .loading {
  264. //loading动画
  265. display: flex;
  266. justify-content: center;
  267. padding-bottom: 20px;
  268. @keyframes stretchdelay {
  269. 0%,
  270. 40%,
  271. 100% {
  272. transform: scaleY(0.6);
  273. }
  274. 20% {
  275. transform: scaleY(1.0);
  276. }
  277. }
  278. .spinner {
  279. margin: 20upx 0;
  280. width: 60upx;
  281. height: 25px;
  282. display: flex;
  283. align-items: center;
  284. justify-content: space-between;
  285. view {
  286. background-color: #ff9800;
  287. height: 25px;
  288. width: 3px;
  289. border-radius: 3px;
  290. animation: stretchdelay 1.2s infinite ease-in-out;
  291. }
  292. .rect2 {
  293. animation-delay: -1.1s;
  294. }
  295. .rect3 {
  296. animation-delay: -1.0s;
  297. }
  298. .rect4 {
  299. animation-delay: -0.9s;
  300. }
  301. .rect5 {
  302. animation-delay: -0.8s;
  303. }
  304. }
  305. }
  306. </style>