index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. <template>
  2. <view class="page page--divider">
  3. <headerline shownav=true @tapnav="tapnav" :isback="true" :navstyle="navstyle" :navitem="navitem" :navselect="navselect" :statusbarheight='statusBarHeight'
  4. issearch="false" @clicksearch="clicksearch" :showsearch="showsearch" searchtips='请输入关键字'></headerline>
  5. <view class="lotterybox" >
  6. <view class="grouplist" v-if="!onseach">
  7. <block v-for="(m,index) in groupData" :key='index'>
  8. <li @tap="gochat(m)" >
  9. <div class="avatar">
  10. <image :src="imgshow(m.avatar)"></image>
  11. </div>
  12. <div class="info">
  13. <div class="title">
  14. {{m.name}}
  15. </div>
  16. <div>
  17. <uni-icons type='person' style="font-size: 16px;font-weight: 700;"></uni-icons>
  18. {{m.people_count}}/{{m.people_max}}人</div>
  19. <div class="tag">{{m.tags}}</div>
  20. </div></li>
  21. </block>
  22. <view class="loading" v-if="loading && loadstatus=='loading'" >
  23. <view class="spinner">
  24. <view class="rect1"></view>
  25. <view class="rect2"></view>
  26. <view class="rect3"></view>
  27. <view class="rect4"></view>
  28. <view class="rect5"></view>
  29. </view>
  30. </view>
  31. <view v-if="loading && loadstatus=='nomore'" style="text-align: center;height: 30px;line-height: 30px;" >
  32. 亲爱的到底了
  33. </view>
  34. </view>
  35. <view class="grouplist" v-else>
  36. <block v-if="searchData.length>0">
  37. <block v-for="(m,index) in searchData" :key='index'>
  38. <li @tap="gochat(m)" >
  39. <div class="avatar">
  40. <image :src="imgshow(m.avatar)"></image>
  41. </div>
  42. <div class="info">
  43. <div class="title">
  44. <rich-text :nodes="m.name"></rich-text>
  45. </div>
  46. <div>
  47. <uni-icons type='person' style="font-size: 16px;font-weight: 700;"></uni-icons>
  48. {{m.people_count}}/{{m.people_max}}人</div>
  49. <div class="tag">
  50. <rich-text :nodes="m.tags"></rich-text>
  51. </div>
  52. </div></li>
  53. </block>
  54. </block>
  55. <view v-else-if="subsearch" style="text-align: center;height: 30px;line-height: 30px;margin-top: 10px;color: #666;" >
  56. 没有搜索到任何相关群组
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </template>
  62. <script>
  63. import api from "../../library/index.js"
  64. import headerline from '../../components/header.vue'
  65. import http from "../../library/http.js"
  66. import uniIcons from '../../components/uni-icons/uni-icons.vue'
  67. import tabbar from '../../components/tabbar.vue'
  68. var windowHeight= uni.getSystemInfoSync().windowHeight;
  69. var statusBarHeight = uni.getSystemInfoSync().statusBarHeight ;
  70. var contenttop=statusBarHeight+45;
  71. var conentheight=windowHeight-contenttop;
  72. var lottHeight= conentheight;
  73. export default {
  74. components: {
  75. uniIcons,
  76. headerline,
  77. tabbar
  78. },
  79. data() {
  80. return {
  81. statusBarHeight: statusBarHeight+ 'px',
  82. contenttop:contenttop+'px',
  83. contentheight:conentheight+'px',
  84. lottHeight:lottHeight+'px',
  85. newfriendNotify: false,
  86. showMenu: false,
  87. initializing: true,
  88. groupData: uni.getStorageSync('groups_top'),
  89. searchData:[],
  90. subsearch:false,
  91. navitem:['推荐','最新'],
  92. navselect:0,
  93. navstyle:"width:50%;left:25%",
  94. userid:uni.getStorageSync('access_token'),
  95. page:1,
  96. act:'top',
  97. loading:true,
  98. loadstatus:'loading',
  99. onseach:false,
  100. showsearch:false,
  101. }
  102. },
  103. methods: {
  104. tapnav(num){
  105. this.navselect=num;
  106. if(num==0) this.act='top';
  107. else this.act='new'
  108. this.page=1;
  109. this.getGroupList();
  110. },
  111. getGroupList() {
  112. var postdata={act:this.act,page:this.page};
  113. var that=this;
  114. that.loading=true;
  115. that.loadstatus='loading';
  116. http.setWait(false).post('group.php?act=group_list',postdata).then(res=>{
  117. if(res.code==200){
  118. that.loading=false;
  119. if(that.page==1){
  120. this.groupData=res.data;
  121. uni.setStorageSync('groups_'+that.act,res.data);
  122. }
  123. else{
  124. for(var i=0;i<res.data.length;i++){
  125. this.groupData.push(res.data[i]);
  126. }
  127. if(res.data.length<10) {
  128. that.loading=true;
  129. that.loadstatus='nomore';
  130. }
  131. }
  132. }else{
  133. uni.showToast({
  134. title:'网络错误,请稍后再试',
  135. icon:'none'
  136. })
  137. }
  138. })
  139. },
  140. imgshow(image_url){
  141. if(image_url.indexOf('http')<=-1) image_url=config.imgUri+image_url;
  142. return this.image_cache(image_url)
  143. },
  144. gochat(m){
  145. this.$jump('group.detail', {
  146. id: m.id,
  147. from:'index'
  148. });
  149. }
  150. ,
  151. gamenextpage(){
  152. if(!this.onseach){
  153. this.page++;
  154. this.getGroupList();
  155. }
  156. },
  157. clicksearch(e){
  158. this.onseach=e;
  159. this.showsearch=e;
  160. },
  161. go_search(e){
  162. var postdata={keyword:e};
  163. var that=this;
  164. that.loading=true;
  165. that.loadstatus='loading';
  166. that.subsearch=false;
  167. http.setWait(false).post('group.php?act=group_search',postdata).then(res=>{
  168. if(res.code==200){
  169. that.subsearch=true;
  170. that.loading=false;
  171. that.searchData=[];
  172. for(var i=0;i<res.data.length;i++){
  173. var item=res.data[i];
  174. item.name=item.name.replace(e,'<span style="color: #ff0000">'+e+'</span>');
  175. item.tags=item.tags.replace(e,'<span style="color: #ff0000">'+e+'</span>');
  176. that.searchData.push(item);
  177. }
  178. }else{
  179. uni.showToast({
  180. title:'网络错误,请稍后再试',
  181. icon:'none'
  182. })
  183. }
  184. })
  185. console.log(e);
  186. },
  187. },
  188. onReachBottom() {
  189. this.gamenextpage();
  190. },
  191. onShow() {
  192. var userid=parseInt(uni.getStorageSync('access_token'));
  193. if(userid>0) {
  194. this.getGroupList();
  195. this.$action.setStatusTips();
  196. }else{
  197. uni.setStorageSync('gourl','/pages/group/index');
  198. this.$jump('login.index');
  199. }
  200. },
  201. onLoad(opts) {
  202. if(opts.method>0) this.navselect=opts.method;
  203. }
  204. }
  205. </script>
  206. <style lang="scss" scoped>
  207. @import "@/static/css/group.css";
  208. .item {
  209. height: 100upx;
  210. border-bottom: 1px solid #F0F0F0;
  211. overflow: hidden;
  212. padding: $uni-spacing-col-lg 30upx;
  213. display: flex;
  214. flex-direction: row;
  215. justify-content: flex-start;
  216. align-items: center;
  217. background-color: #ffffff;
  218. border-radius: 20upx;
  219. }
  220. .leftImg {
  221. width: 100upx;
  222. height: 100upx;
  223. margin-right: $uni-spacing-row-base;
  224. border-radius: $uni-border-radius-base;
  225. display: flex;
  226. flex-flow: wrap;
  227. justify-content: center;
  228. background-color: #eee;
  229. align-items: center;
  230. &:not(image) {
  231. padding: 1upx;
  232. }
  233. view,
  234. image {
  235. width: (76upx-2upx*4)/3;
  236. height: (76upx-2upx*4)/3;
  237. margin: 1upx;
  238. }
  239. }
  240. .rightContent {
  241. flex: 1;
  242. }
  243. .rightContent,
  244. .topCont {
  245. overflow: hidden;
  246. line-height: 1.25;
  247. }
  248. .topCont {
  249. display: flex;
  250. flex-direction: row;
  251. justify-content: space-between;
  252. align-items: center;
  253. }
  254. .userName {
  255. color: $uni-text-color;
  256. font-size: 38upx;
  257. }
  258. .time {
  259. color: #999999;
  260. font-size: 30upx;
  261. }
  262. .bottomCont {
  263. width: 100%;
  264. font-size: 24upx;
  265. color: #999999;
  266. display: flex;
  267. align-items: center;
  268. justify-content: space-between;
  269. }
  270. .content {
  271. font-size: 28upx;
  272. overflow: hidden;
  273. text-overflow: ellipsis;
  274. white-space: nowrap;
  275. }
  276. .badge {
  277. background-color: red;
  278. color: #fff;
  279. border-radius: 40upx;
  280. line-height: 40upx;
  281. width: 40upx;
  282. height: 40upx;
  283. font-size: 24upx;
  284. text-align: center;
  285. flex-shrink: 0;
  286. }
  287. .loading {
  288. //loading动画
  289. display: flex;
  290. justify-content: center;
  291. padding-bottom: 20px;
  292. @keyframes stretchdelay {
  293. 0%,
  294. 40%,
  295. 100% {
  296. transform: scaleY(0.6);
  297. }
  298. 20% {
  299. transform: scaleY(1.0);
  300. }
  301. }
  302. .spinner {
  303. margin: 20upx 0;
  304. width: 60upx;
  305. height: 25px;
  306. display: flex;
  307. align-items: center;
  308. justify-content: space-between;
  309. view {
  310. background-color: #ff9800;
  311. height: 25px;
  312. width: 3px;
  313. border-radius: 3px;
  314. animation: stretchdelay 1.2s infinite ease-in-out;
  315. }
  316. .rect2 {
  317. animation-delay: -1.1s;
  318. }
  319. .rect3 {
  320. animation-delay: -1.0s;
  321. }
  322. .rect4 {
  323. animation-delay: -0.9s;
  324. }
  325. .rect5 {
  326. animation-delay: -0.8s;
  327. }
  328. }
  329. }
  330. .lotterybox {
  331. -webkit-overflow-scrolling: touch;
  332. overflow-x: hidden;
  333. display: inline-block;
  334. transition: all .3s;
  335. transform: translate(0,0);
  336. width: 100%;
  337. }
  338. </style>