index8.vue 9.0 KB

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