index.vue 9.5 KB

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