index.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. <template>
  2. <view class="active">
  3. <view class="top">
  4. <u-swiper :list="list1" @change="change" @click="click"></u-swiper>
  5. </view>
  6. <view class="tab">
  7. <view v-for="(item,index) in tab_list" :key='index' :class="current_tab==item.id ? 'active-item' : 'item'"
  8. @click="changTab(item.id)">
  9. <view class="week">
  10. {{item.name}}
  11. </view>
  12. <text class="line" v-if="current_tab==item.id">
  13. </text>
  14. </view>
  15. </view>
  16. <view class="search">
  17. <view class="u-demo-block__content">
  18. <view class="u-page__tag-item">
  19. <u-search placeholder="请输入搜索内容" v-model="searchValue" @search="searchActive()"
  20. @clear="clearActive()" :show-action="false" shape='square'>
  21. </u-search>
  22. </view>
  23. </view>
  24. <view class="search-button" @click="searchActive()">搜索</view>
  25. </view>
  26. <view class="list" v-if="list.length>0">
  27. <view class="list-item" @click="detail(item.id)" v-for="(item,index) in list" :key='index'>
  28. <view class="tips" v-if="item.category_id==2">
  29. <text>已报名人数:</text><text class="sign-num">{{item.sign_up_count}}/{{item.max_sign_up_count}}</text>
  30. </view>
  31. <!-- <view class="image" :style="{backgroundImage:'url('+ (item.cover_resource ? item.cover_resource.url : '../../static/images/avator.png') +')'}">
  32. </view> -->
  33. <image class="image" :src="item.cover_resource ? item.cover_resource.url : '../../static/images/avator.png'" mode="aspectFill">
  34. </image>
  35. <view class="right">
  36. <view class="title">
  37. {{item.title? item.title :'--'}}
  38. </view>
  39. <view class="text" v-if="item.category_id==2">
  40. <text > 活动时间:{{item.data?getTime(item.data.active_time):'--'}}</text>
  41. </view>
  42. <view class="text">
  43. <text v-if="item.category_id==2"> 报名时间:{{item.data? getTime(item.data.star_time):'--'}}&nbsp;~&nbsp;{{item.data?getTime(item.data.end_time):'--'}}</text>
  44. </view>
  45. <view class="time" style="width: 100%;justify-content: space-between;">
  46. <view class="">
  47. <u-icon name="clock-fill"></u-icon>{{getTime(item.created_at)}}
  48. </view>
  49. <view class="">
  50. <u-icon name="eye-fill"></u-icon>{{item.view_count? item.view_count :'--'}}
  51. </view>
  52. <view class="" style="width: 40%;white-space: nowrap;overflow: hidden;text-overflow: ellipsis">
  53. <u-icon name="account-fill"></u-icon>{{item.admin_name? item.admin_name :'--'}}
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. <view class="empty" v-else>
  60. <image src="../../static/empty.png" mode="widthFix"></image>
  61. <view class="empty-text">
  62. 暂无内容
  63. </view>
  64. </view>
  65. <tab-bar :current="3"></tab-bar>
  66. </view>
  67. </template>
  68. <script>
  69. export default {
  70. data() {
  71. return {
  72. list1: [
  73. 'https://cdn.uviewui.com/uview/swiper/swiper1.png',
  74. 'https://cdn.uviewui.com/uview/swiper/swiper2.png',
  75. 'https://cdn.uviewui.com/uview/swiper/swiper3.png',
  76. ],
  77. current_tab: 0,
  78. tab_list: ['学术前沿', '自主活动'],
  79. list: [],
  80. page: 1,
  81. last: false,
  82. value5: '',
  83. searchValue: '', //搜索
  84. }
  85. },
  86. onShow() {
  87. // this.getList()
  88. this.page = 1
  89. this.list = []
  90. this.last = false
  91. this.getTabList()
  92. },
  93. async onLoad() {
  94. if (this.is_weixin()) {
  95. this.navTitle()
  96. }
  97. // await this.getList()
  98. this.get_banner()
  99. },
  100. onReachBottom() {
  101. if (!this.last) {
  102. this.page++
  103. }
  104. console.log(this.page,'oooooooooooooooooo')
  105. this.getList()
  106. },
  107. methods: {
  108. //获取轮播图
  109. get_banner() {
  110. this.list1=[]
  111. this.$u.get('/base/banner',{position:'information'}).then(res => {
  112. let banner=res.data.list
  113. banner.map(item=>{
  114. this.list1.push(item.cover_resource.url)
  115. })
  116. console.log(res, '轮播图')
  117. })
  118. },
  119. change() {},
  120. //截取时间
  121. getTime(time) {
  122. if (!time) return '--'
  123. else return time.split(' ')[0]
  124. },
  125. //判断是否是微信
  126. is_weixin() {
  127. let ua = navigator.userAgent.toLowerCase();
  128. return ua.indexOf('micromessenger') != -1;
  129. },
  130. navTitle() {
  131. let navTitle = document.getElementsByTagName('uni-page-head');
  132. navTitle[0].style.display = 'none'
  133. },
  134. //选择本周还是下周
  135. changTab(id) {
  136. this.list = []
  137. this.current_tab = id
  138. this.page = 1
  139. this.last = false
  140. this.getList()
  141. },
  142. getTabList() {
  143. this.$u.get('/inform/category-user-tree', {
  144. type: 1
  145. }).then(res => {
  146. console.log(res, 'pp')
  147. this.tab_list = res.data
  148. this.current_tab = res.data[0].id
  149. this.getList()
  150. })
  151. },
  152. getList() {
  153. this.$u.get('/inform/information', {
  154. category_id: this.current_tab,
  155. title: this.searchValue,
  156. page: this.page,
  157. per_page: 15
  158. }).then(res => {
  159. console.log(res, 'ppp')
  160. let data = res.data.list
  161. console.log(res, 'course1')
  162. if (this.page > 1 && data.length == 0) {
  163. uni.showToast({
  164. title: '暂无更多',
  165. icon: 'none'
  166. })
  167. this.last = true
  168. } else {
  169. this.list = this.list.concat(data)
  170. }
  171. })
  172. },
  173. detail(id) {
  174. console.log('详情')
  175. uni.navigateTo({
  176. url: './details?id=' + id
  177. })
  178. },
  179. //点击搜索
  180. searchActive() {
  181. this.list = []
  182. this.page = 1
  183. this.last = false
  184. console.log(this.searchValue, '用户点击了搜索')
  185. this.getList()
  186. },
  187. //清空搜索框
  188. clearActive() {
  189. this.list = []
  190. this.page = 1
  191. this.last = false
  192. this.getList()
  193. console.log(this.searchValue, '用户点击了搜索---')
  194. }
  195. }
  196. }
  197. </script>
  198. <style lang="scss">
  199. page {
  200. position: relative;
  201. background-color: #F7F7F7;
  202. padding-bottom: 70px;
  203. }
  204. .add {
  205. position: fixed;
  206. bottom: 75px;
  207. right: 15px;
  208. text-align: center;
  209. z-index: 6;
  210. .add-buttom {
  211. width: 36px;
  212. height: 36px;
  213. background: #6A6A6A;
  214. display: inline-block;
  215. text-align: center;
  216. line-height: 36px;
  217. opacity: 1;
  218. border-radius: 50%;
  219. }
  220. .add-tips {
  221. font-size: 10px;
  222. font-family: PingFang SC;
  223. font-weight: bold;
  224. line-height: 14px;
  225. color: #292929;
  226. opacity: 1;
  227. margin-top: 3px;
  228. }
  229. }
  230. .search {
  231. background-color: #FFFFFF;
  232. padding: 8px 15px;
  233. margin-top: 6px;
  234. display: flex;
  235. justify-items: center;
  236. justify-content: center;
  237. align-items: center;
  238. .search-button {
  239. padding: 0 10px;
  240. color: #138E57;
  241. font-size: 15px;
  242. text-align: center;
  243. }
  244. .u-demo-block__content {
  245. flex: 1;
  246. }
  247. ::v-deep {
  248. .u-action {
  249. color: #138E57 !important;
  250. }
  251. }
  252. }
  253. .active {
  254. position: relative;
  255. overflow: hidden;
  256. height: 100%;
  257. .top {
  258. padding: 15px 15px 0;
  259. background-size: 100%;
  260. background-repeat: no-repeat;
  261. }
  262. .tab {
  263. display: flex;
  264. align-items: center;
  265. width: 80%;
  266. margin: 0 auto;
  267. .item,
  268. .active-item {
  269. margin-top: 17px;
  270. view {
  271. display: block;
  272. }
  273. font-size: 16px;
  274. font-family: PingFang SC;
  275. font-weight: bold;
  276. line-height: 20px;
  277. color: rgba(113, 113, 113, .43);
  278. opacity: 0.43;
  279. opacity: 1;
  280. flex: 1;
  281. text-align: center;
  282. .week {
  283. padding-bottom: 12px;
  284. }
  285. .line {
  286. width: 11px;
  287. height: 4px;
  288. background: #3B7653;
  289. opacity: 1;
  290. border-radius: 2px;
  291. display: block;
  292. margin: 0 auto;
  293. }
  294. }
  295. .active-item {
  296. font-size: 18px;
  297. font-family: PingFang SC;
  298. font-weight: bold;
  299. line-height: 20px;
  300. color: #3B7653;
  301. .week {
  302. padding-bottom: 8px;
  303. }
  304. }
  305. }
  306. .list {
  307. padding: 15px;
  308. .list-item {
  309. background: #FFFFFF;
  310. opacity: 1;
  311. border-radius: 4px;
  312. padding: 16px 15px;
  313. position: relative;
  314. display: flex;
  315. align-items: center;
  316. margin-bottom: 10px;
  317. overflow: hidden;
  318. .tips {
  319. position: absolute;
  320. // width: 52px;
  321. display: inline-block;
  322. padding: 0 7px;
  323. text-align: center;
  324. background: #FFAA1D;
  325. top: 0;
  326. right: 0;
  327. opacity: 1;
  328. border-radius: 0px 4px 0px 4px;
  329. font-size: 8px;
  330. color: #fff;
  331. .sign-num {
  332. font-size: 12px;
  333. font-weight: 600;
  334. }
  335. }
  336. .image {
  337. flex: 0 0 66px;
  338. width: 66px;
  339. height: 66px;
  340. margin-right: 6px;
  341. background-position: center;
  342. background-repeat: no-repeat;
  343. background-size: cover;
  344. }
  345. .right {
  346. flex: 1;
  347. padding-left: 5px;
  348. width: calc(100% - 170px);
  349. view {
  350. height: 19px;
  351. line-height: 19px;
  352. }
  353. .title {
  354. width: 220px;
  355. font-size: 14px;
  356. font-family: PingFang SC;
  357. color: #0C0C0C;
  358. opacity: 1;
  359. white-space: nowrap;
  360. /*设置不换行*/
  361. overflow: hidden;
  362. /*设置隐藏*/
  363. text-overflow: ellipsis;
  364. /*设置隐藏部分为省略号*/
  365. margin-bottom: 3px;
  366. }
  367. .text {
  368. font-size: 12px;
  369. line-height: 16px;
  370. font-family: PingFang SC;
  371. font-weight: 400;
  372. color: #666666;
  373. // margin-top: 3px;
  374. width: 230px;
  375. white-space: nowrap;
  376. /*设置不换行*/
  377. overflow: hidden;
  378. /*设置隐藏*/
  379. text-overflow: ellipsis;
  380. /*设置隐藏部分为省略号*/
  381. // &:first-child{
  382. // margin-top: 3px;
  383. // }
  384. }
  385. .time {
  386. display: flex;
  387. font-size: 10px;
  388. color: #858585;
  389. align-items: center;
  390. view{
  391. display: flex;
  392. align-items: center;
  393. .u-icon{
  394. padding-right: 4rpx;
  395. }
  396. }
  397. }
  398. }
  399. }
  400. }
  401. }
  402. </style>