groupindex.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. <template>
  2. <view class="page page--divider">
  3. <view class="menu" :style="{top:menutop}">
  4. <block v-if='showsearch'>
  5. <view class="seacrchitem" >
  6. <span class="back" @tap="showsearch=!showsearch">
  7. <uni-icons type='arrowleft' color="#000" style="font-weight: 600;" size="28" class="icons"></uni-icons>
  8. </span>
  9. <span><input class="input1" id="keyword" :placeholder="searchtips" v-model="keyword" /> </span>
  10. <span @tap="go_search();">
  11. <div class="btn"><uni-icons style="font-size: 16px;color:#fff;margin-right:2px;font-weight: 600;" type="search"></uni-icons>搜索</div>
  12. </span>
  13. </view>
  14. </block>
  15. <block v-else>
  16. <li v-for="(m,index) in navitem" :key='index' :class="{'active':navselect==index}" @tap="tapnav(index)" >
  17. {{m}}
  18. </li>
  19. </block>
  20. </view>
  21. <scroll-view class="lotterybox" :style="{height:lottHeight,top:contenttop}" scroll-y="true" lower-threshold='80' @scrolltolower="gamenextpage()">
  22. <view class="grouplist" v-if="!showsearch">
  23. <block v-for="(m,index) in groupData" :key='index'>
  24. <li @tap="gochat(m)" >
  25. <div class="avatar">
  26. <image :src="imgshow(m.avatar)"></image>
  27. </div>
  28. <div class="info">
  29. <div class="title">
  30. {{m.name}}
  31. </div>
  32. <div>
  33. <uni-icons type='person' style="font-size: 16px;font-weight: 700;"></uni-icons>
  34. {{m.people_count}}/{{m.people_max}}人</div>
  35. <div class="tag">{{m.tags}}</div>
  36. </div></li>
  37. </block>
  38. <view class="loading" v-if="loading && loadstatus=='loading'" >
  39. <view class="spinner">
  40. <view class="rect1"></view>
  41. <view class="rect2"></view>
  42. <view class="rect3"></view>
  43. <view class="rect4"></view>
  44. <view class="rect5"></view>
  45. </view>
  46. </view>
  47. <view v-if="loading && loadstatus=='nomore'" style="text-align: center;height: 30px;line-height: 30px;" >
  48. 亲爱的到底了
  49. </view>
  50. </view>
  51. <view class="grouplist" v-else>
  52. <block v-if="searchData.length>0">
  53. <block v-for="(m,index) in searchData" :key='index'>
  54. <li @tap="gochat(m)" >
  55. <div class="avatar">
  56. <image :src="imgshow(m.avatar)"></image>
  57. </div>
  58. <div class="info">
  59. <div class="title">
  60. <rich-text :nodes="m.name"></rich-text>
  61. </div>
  62. <div>
  63. <uni-icons type='person' style="font-size: 16px;font-weight: 700;"></uni-icons>
  64. {{m.people_count}}/{{m.people_max}}人</div>
  65. <div class="tag">
  66. <rich-text :nodes="m.tags"></rich-text>
  67. </div>
  68. </div></li>
  69. </block>
  70. </block>
  71. <view v-else-if="subsearch" style="text-align: center;height: 30px;line-height: 30px;margin-top: 10px;color: #666;" >
  72. 没有搜索到任何相关聊天室
  73. </view>
  74. </view>
  75. <!-- #ifdef H5 -->
  76. <view style="height: 10px;"></view>
  77. <!-- #endif -->
  78. </scroll-view>
  79. </view>
  80. </template>
  81. <script>
  82. import api from "../library/index.js"
  83. import http from "../library/http.js"
  84. import uniIcons from '../components/uni-icons/uni-icons.vue'
  85. var windowHeight= uni.getSystemInfoSync().windowHeight;
  86. var statusBarHeight = uni.getSystemInfoSync().statusBarHeight ;
  87. var menutop=statusBarHeight+45;
  88. var contenttop=menutop+41;
  89. var conentheight=windowHeight-contenttop;
  90. // #ifndef APP-PLUS
  91. var conentheight=conentheight - 50;
  92. // #endif
  93. var lottHeight= conentheight;
  94. export default {
  95. components: {
  96. uniIcons,
  97. },
  98. data() {
  99. return {
  100. statusBarHeight: statusBarHeight+ 'px',
  101. menutop:menutop+'px',
  102. contenttop:contenttop+'px',
  103. contentheight:conentheight+'px',
  104. lottHeight:lottHeight+'px',
  105. newfriendNotify: false,
  106. showMenu: false,
  107. initializing: true,
  108. groupData: uni.getStorageSync('groups_top'),
  109. searchData:[],
  110. subsearch:false,
  111. navitem:['推荐','最新'],
  112. navselect:0,
  113. navstyle:"width:50%;left:25%",
  114. userid:uni.getStorageSync('access_token'),
  115. page:1,
  116. act:'top',
  117. loading:true,
  118. loadstatus:'loading',
  119. onseach:false,
  120. showsearch:false,
  121. searchtips:'请输入要搜索的群组名称',
  122. keyword:''
  123. }
  124. },
  125. mounted() {
  126. this.tapnav(0)
  127. },
  128. methods: {
  129. tapnav(num){
  130. this.navselect=num;
  131. if(num==0) this.act='top';
  132. else this.act='new'
  133. this.page=1;
  134. this.getGroupList();
  135. },
  136. getGroupList() {
  137. var postdata={act:this.act,page:this.page};
  138. var that=this;
  139. that.loading=true;
  140. that.loadstatus='loading';
  141. http.setWait(false).post('group.php?act=group_list',postdata).then(res=>{
  142. if(res.code==200){
  143. that.loading=false;
  144. if(that.page==1){
  145. this.groupData=res.data;
  146. uni.setStorageSync('groups_'+that.act,res.data);
  147. }
  148. else{
  149. for(var i=0;i<res.data.length;i++){
  150. this.groupData.push(res.data[i]);
  151. }
  152. if(res.data.length<10) {
  153. that.loading=true;
  154. that.loadstatus='nomore';
  155. }
  156. }
  157. }else{
  158. uni.showToast({
  159. title:'网络错误,请稍后再试',
  160. icon:'none'
  161. })
  162. }
  163. })
  164. },
  165. imgshow(image_url){
  166. if(image_url.indexOf('http')<=-1) image_url=config.imgUri+image_url;
  167. return this.image_cache(image_url)
  168. },
  169. gochat(m){
  170. this.$jump('group.detail', {
  171. id: m.id,
  172. from:'index'
  173. });
  174. }
  175. ,
  176. gamenextpage(){
  177. if(!this.onseach){
  178. this.page++;
  179. this.getGroupList();
  180. }
  181. },
  182. go_search(){
  183. var e=this.keyword;
  184. if(e==''){
  185. uni.showToast({
  186. title:"请输入群组关键",
  187. icon:'none'
  188. })
  189. this.searchData=[];
  190. return false;
  191. }
  192. var postdata={keyword:this.keyword};
  193. var that=this;
  194. that.loading=true;
  195. that.loadstatus='loading';
  196. that.subsearch=false;
  197. http.setWait(false).post('group.php?act=group_search',postdata).then(res=>{
  198. if(res.code==200){
  199. that.subsearch=true;
  200. that.loading=false;
  201. that.searchData=[];
  202. for(var i=0;i<res.data.length;i++){
  203. var item=res.data[i];
  204. item.name=item.name.replace(e,'<span style="color: #ff0000">'+e+'</span>');
  205. item.tags=item.tags.replace(e,'<span style="color: #ff0000">'+e+'</span>');
  206. that.searchData.push(item);
  207. }
  208. }else{
  209. uni.showToast({
  210. title:'网络错误,请稍后再试',
  211. icon:'none'
  212. })
  213. }
  214. })
  215. console.log(e);
  216. },
  217. },
  218. onShow() {
  219. var userid=parseInt(uni.getStorageSync('access_token'));
  220. if(userid>0) {
  221. this.getGroupList();
  222. this.$action.setStatusTips();
  223. }else{
  224. uni.setStorageSync('gourl','/pages/group/index');
  225. this.$jump('login.index');
  226. }
  227. },
  228. onLoad(opts) {
  229. if(opts.method>0) this.navselect=opts.method;
  230. }
  231. }
  232. </script>
  233. <style lang="scss" scoped>
  234. @import "@/static/css/group.css";
  235. .menu{
  236. position: fixed;
  237. left: 0px;
  238. width: 100%;
  239. height: 30px;
  240. padding: 5px 0px;
  241. background-color: #fff;
  242. text-align: center;
  243. border-bottom: 1px solid #eee;
  244. }
  245. .menu li{
  246. display: inline-block;
  247. height: 28px;
  248. line-height: 28px;
  249. margin: 0px 10px;
  250. border:1px #666 solid;
  251. border-radius: 5px;
  252. width: 80px;
  253. text-align: center;
  254. color:#000000;
  255. }
  256. .menu li.active{
  257. background-color: #2319DC;
  258. border:1px #2319dc solid;
  259. color: #fff;
  260. font-weight: 600;
  261. }
  262. .menu .right{
  263. position: absolute;
  264. right: 0px;
  265. padding-right:5px;
  266. top:0px;
  267. padding-top: 5px;;
  268. }
  269. .item {
  270. height: 100upx;
  271. border-bottom: 1px solid #F0F0F0;
  272. overflow: hidden;
  273. padding: $uni-spacing-col-lg 30upx;
  274. display: flex;
  275. flex-direction: row;
  276. justify-content: flex-start;
  277. align-items: center;
  278. background-color: #ffffff;
  279. border-radius: 20upx;
  280. }
  281. .leftImg {
  282. width: 100upx;
  283. height: 100upx;
  284. margin-right: $uni-spacing-row-base;
  285. border-radius: $uni-border-radius-base;
  286. display: flex;
  287. flex-flow: wrap;
  288. justify-content: center;
  289. background-color: #eee;
  290. align-items: center;
  291. &:not(image) {
  292. padding: 1upx;
  293. }
  294. view,
  295. image {
  296. width: (76upx-2upx*4)/3;
  297. height: (76upx-2upx*4)/3;
  298. margin: 1upx;
  299. }
  300. }
  301. .rightContent {
  302. flex: 1;
  303. }
  304. .rightContent,
  305. .topCont {
  306. overflow: hidden;
  307. line-height: 1.25;
  308. }
  309. .topCont {
  310. display: flex;
  311. flex-direction: row;
  312. justify-content: space-between;
  313. align-items: center;
  314. }
  315. .userName {
  316. color: $uni-text-color;
  317. font-size: 38upx;
  318. }
  319. .time {
  320. color: #999999;
  321. font-size: 30upx;
  322. }
  323. .bottomCont {
  324. width: 100%;
  325. font-size: 24upx;
  326. color: #999999;
  327. display: flex;
  328. align-items: center;
  329. justify-content: space-between;
  330. }
  331. .content {
  332. font-size: 28upx;
  333. overflow: hidden;
  334. text-overflow: ellipsis;
  335. white-space: nowrap;
  336. }
  337. .badge {
  338. background-color: red;
  339. color: #fff;
  340. border-radius: 40upx;
  341. line-height: 40upx;
  342. width: 40upx;
  343. height: 40upx;
  344. font-size: 24upx;
  345. text-align: center;
  346. flex-shrink: 0;
  347. }
  348. .loading {
  349. //loading动画
  350. display: flex;
  351. justify-content: center;
  352. padding-bottom: 20px;
  353. @keyframes stretchdelay {
  354. 0%,
  355. 40%,
  356. 100% {
  357. transform: scaleY(0.6);
  358. }
  359. 20% {
  360. transform: scaleY(1.0);
  361. }
  362. }
  363. .spinner {
  364. margin: 20upx 0;
  365. width: 60upx;
  366. height: 25px;
  367. display: flex;
  368. align-items: center;
  369. justify-content: space-between;
  370. view {
  371. background-color: #ff9800;
  372. height: 25px;
  373. width: 3px;
  374. border-radius: 3px;
  375. animation: stretchdelay 1.2s infinite ease-in-out;
  376. }
  377. .rect2 {
  378. animation-delay: -1.1s;
  379. }
  380. .rect3 {
  381. animation-delay: -1.0s;
  382. }
  383. .rect4 {
  384. animation-delay: -0.9s;
  385. }
  386. .rect5 {
  387. animation-delay: -0.8s;
  388. }
  389. }
  390. }
  391. .lotterybox {
  392. position: fixed;
  393. left: 0px;
  394. width: 100%;
  395. overflow-y: scroll;
  396. -webkit-overflow-scrolling: touch;
  397. overflow-x: hidden;
  398. display: inline-block;
  399. transition: all .3s;
  400. transform: translate(0,0);
  401. }
  402. .seacrchitem{
  403. width: 100%;
  404. height: 30px;
  405. line-height: 30px;
  406. text-align: center;
  407. display: table;
  408. padding-top:0px;
  409. table-layout: fixed;
  410. }
  411. .seacrchitem > span{
  412. display: table-cell;
  413. text-align: center;
  414. vertical-align: top;
  415. }
  416. .seacrchitem > span:first-child{
  417. width: 50px;
  418. padding-top:3px;
  419. }
  420. .seacrchitem > span:nth-child(2){
  421. width: calc(100% - 108px) !important;
  422. text-align: right;
  423. }
  424. .seacrchitem > span:last-child{
  425. width: 68px;
  426. padding-right: 10px;
  427. text-align: left;
  428. }
  429. .seacrchitem > span .input1{
  430. width:calc(100% - 12px);
  431. height: 28px;
  432. line-height: 28px;
  433. padding: 0px 5px;
  434. font-size: 14px;
  435. color: #222;
  436. border-bottom:1px solid #ccc;
  437. border-right: 0px;
  438. text-align: left;
  439. vertical-align: top;
  440. }
  441. .seacrchitem > span .input1::placeholder{
  442. color:#999;
  443. font-size: 12px;
  444. }
  445. .seacrchitem > span .btn{
  446. background: -webkit-linear-gradient(left top, #3388ff , #2319dc);
  447. background: -o-linear-gradient(bottom right, #3388ff, #2319dc);
  448. background: -moz-linear-gradient(bottom right, #3388ff, #2319dc);
  449. background: linear-gradient(to bottom right, #3388ff , #2319dc);
  450. height: 30px;line-height: 30px;
  451. width: 100%;
  452. text-align: center;
  453. padding: 0px 0px;
  454. display: inline-block;
  455. color: #fff;
  456. border: 0px;
  457. cursor: pointer;
  458. vertical-align: top;
  459. }
  460. </style>