index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. <template>
  2. <view>
  3. <!-- 骨架屏 -->
  4. <kz-skeleton v-if="showSkeleton" :showSkeleton="showSkeleton" backgroundColor="#fafafa" borderRadius="10rpx"></kz-skeleton>
  5. <!-- 添加小程序提示组件 -->
  6. <!-- #ifdef MP-WEIXIN -->
  7. <add-tip :tip="focusOnTip" :duration="1" />
  8. <!-- #endif -->
  9. <!-- banner -->
  10. <view class="tn-margin"><!-- :style="{paddingTop: vuex_custom_bar_height + 'px'}" -->
  11. <tn-swiper :list="banners" :height="350" :effect3d="false" mode="dot"></tn-swiper>
  12. </view>
  13. <!-- 公告 -->
  14. <view class="tui-rolling-news" v-if="headlines">
  15. <tui-icon name="news-fill" :size='22' color='#5677fc' class="margin-right-xs"></tui-icon>
  16. <swiper vertical autoplay circular interval="3000" class="tui-swiper">
  17. <swiper-item v-for="(notice,index) in notices" :key="index" class="tui-swiper-item" @click="clickNotice(notice.id)">
  18. <view class="tui-news-item">{{notice.name}}</view>
  19. </swiper-item>
  20. </swiper>
  21. </view>
  22. <!-- 首页简约风格组件 -->
  23. <kz-page-index-simple :banners="banners" v-if="pageStyle == 'simple'"></kz-page-index-simple>
  24. <!-- 首页多彩列表风格组件 -->
  25. <kz-page-index-color :banners="banners" :papers="papers" :rooms="rooms" v-else-if="pageStyle == 'color'"></kz-page-index-color>
  26. <!-- 悬浮组件 -->
  27. <tui-scroll-top :scrollTop="scrollTop" :isIndex="false" :isHideAd="showAdBtn" :isShare="showShareBtn" :customShare="false" @hideAd="() => {showAd = !showAd}" @goNotice="goNoticeList"></tui-scroll-top>
  28. <!-- 流量主组件 -->
  29. <!-- #ifdef MP-WEIXIN -->
  30. <view v-show="showAd">
  31. <kz-ad ref="adIndex" kind="BANNER" :config="ad" field="index_banner"></kz-ad>
  32. <kz-ad ref="adIndex" kind="VIDEO" :config="ad" field="index_video"></kz-ad>
  33. <kz-ad ref="adIndex" kind="VIDEO_PATCH" :config="ad" field="index_video_patch"></kz-ad>
  34. </view>
  35. <!-- #endif -->
  36. <!-- 登录组件 -->
  37. <login ref="login"></login>
  38. <!-- 底部导航栏组件 -->
  39. <tabbar :theme="tabbarStyle"></tabbar>
  40. <view class="margin-bottom-xl">
  41. <tn-load-more class="tn-margin-top" status="nomore" dot></tn-load-more>
  42. </view>
  43. </view>
  44. </template>
  45. <script>
  46. // import HeadLine from '@/components/headline/headline.vue'
  47. import AddTip from '@/components/struggler-uniapp-add-tip/struggler-uniapp-add-tip.vue';
  48. var interstitialAd = null;
  49. export default {
  50. components: {
  51. // HeadLine,
  52. AddTip
  53. },
  54. data() {
  55. return {
  56. focusOnTip: '点击「添加小程序」,下次访问更便捷',
  57. imgUrl: this.imgUrl,
  58. banners: [],
  59. system: null,
  60. ad: null,
  61. showAd: true,
  62. showSkeleton: true,
  63. headlines: [],
  64. notices: [],
  65. scrollTop: 0,
  66. showAdBtn: false,
  67. showShareBtn: false,
  68. hideTop: false,
  69. pageStyle: 'color',
  70. papers: [],
  71. rooms: [],
  72. tabbarStyle: '',
  73. }
  74. },
  75. onLoad(e) {
  76. this.getSetting()
  77. },
  78. onPageScroll(e) {
  79. if (!this.hideTop) {
  80. this.scrollTop = e.scrollTop;
  81. }
  82. },
  83. methods: {
  84. getSetting() {
  85. this.http('common/index', '', 'get').then(res => {
  86. if (!res.code) {
  87. uni.showToast({
  88. title: '获取数据失败,请刷新重试',
  89. icon: 'error'
  90. })
  91. return
  92. }
  93. // 公告
  94. this.headlines = res.data.notice
  95. this.notices = res.data.notices
  96. // 考卷
  97. this.papers = res.data.papers
  98. // 考场
  99. this.rooms = res.data.rooms
  100. // 系统配置数据
  101. let system = res.data.system
  102. if (system) {
  103. this.system = system
  104. uni.setStorageSync('system', system)
  105. // 轮播图
  106. if (system.banner) {
  107. let banners = []
  108. for (let bannerImage of (system.banner.split(','))) {
  109. console.log('bannerImage', bannerImage, bannerImage.indexOf('http'))
  110. if (bannerImage.indexOf('http') < 0) {
  111. bannerImage = this.imgUrl + bannerImage
  112. }
  113. banners.push({
  114. image: bannerImage
  115. })
  116. }
  117. this.banners = banners
  118. console.log('banners', this.banners)
  119. // 延迟加载:v-if导致组件未完全渲染
  120. // setTimeout(() => {
  121. // this.banners = system.banner.split(',')
  122. // console.log('banners', this.banners)
  123. // }, 200)
  124. }
  125. }
  126. // 页面配置数据
  127. let page = res.data.page
  128. if (page) {
  129. this.page = page
  130. uni.setStorageSync('page', page)
  131. // 页面风格
  132. this.pageStyle = 'color'
  133. // this.pageStyle = page.page_index_style ? page.page_index_style : 'simple'
  134. // 底部栏风格
  135. this.tabbarStyle = page.page_tabbar_style ? page.page_tabbar_style : 'simple'
  136. // 悬浮按钮
  137. this.showAdBtn = parseInt(page.page_index_ad_btn) == 1
  138. this.showShareBtn = parseInt(page.page_index_share_btn) == 1
  139. }
  140. // #ifdef MP-WEIXIN
  141. // 流量主数据
  142. let ad = res.data.ad;
  143. if (ad) {
  144. this.ad = ad
  145. uni.setStorageSync('ad', ad);
  146. // 插屏广告
  147. if (this.ad.index_cp_open == 1) {
  148. this.adUtils.interstitial.load(this.ad.index_cp)
  149. this.adUtils.interstitial.show()
  150. }
  151. // // 激励广告
  152. // this.adUtils.rewarded.load('adunit-69d6a49d4c5999c5', () => {
  153. // //这里写你的任意奖励事件
  154. // });
  155. // this.adUtils.rewarded.show();
  156. }
  157. // #endif
  158. // 隐藏骨架屏
  159. this.showSkeleton = false
  160. this.$forceUpdate()
  161. })
  162. },
  163. // 点击悬浮按钮
  164. clickFabItem(e) {
  165. console.log('clickFabItem', e)
  166. },
  167. // 跳转公告列表
  168. goNoticeList() {
  169. this.utils.goto('notice-list')
  170. },
  171. // 点击公告,跳转公告详情
  172. clickNotice(id) {
  173. this.utils.goto('notice-detail?id=' + id)
  174. },
  175. }
  176. }
  177. </script>
  178. <style>
  179. page {
  180. background-color: #fff;
  181. }
  182. .nav-list {
  183. display: flex;
  184. flex-wrap: wrap;
  185. padding: 0px 40 upx 0px;
  186. justify-content: space-between;
  187. }
  188. .nav-li {
  189. padding: 30 upx;
  190. border-radius: 12 upx;
  191. width: 45%;
  192. margin: 0 2.5% 40 upx;
  193. background-image: url(https://cdn.nlark.com/yuque/0/2019/png/280374/1552996358352-assets/web-upload/cc3b1807-c684-4b83-8f80-80e5b8a6b975.png);
  194. background-size: cover;
  195. background-position: center;
  196. position: relative;
  197. z-index: 1;
  198. }
  199. .nav-li::after {
  200. content: "";
  201. position: absolute;
  202. z-index: -1;
  203. background-color: inherit;
  204. width: 100%;
  205. height: 100%;
  206. left: 0;
  207. bottom: -10%;
  208. border-radius: 10 upx;
  209. opacity: 0.2;
  210. transform: scale(0.9, 0.9);
  211. }
  212. .nav-li.cur {
  213. color: #fff;
  214. background: rgb(94, 185, 94);
  215. box-shadow: 4 upx 4 upx 6 upx rgba(94, 185, 94, 0.4);
  216. }
  217. .nav-title {
  218. font-size: 32 upx;
  219. font-weight: 300;
  220. }
  221. .nav-title::first-letter {
  222. font-size: 40 upx;
  223. margin-right: 4 upx;
  224. }
  225. .nav-name {
  226. font-size: 28 upx;
  227. text-transform: Capitalize;
  228. margin-top: 20 upx;
  229. position: relative;
  230. }
  231. .nav-name::before {
  232. content: "";
  233. position: absolute;
  234. display: block;
  235. width: 40 upx;
  236. height: 6 upx;
  237. background: #fff;
  238. bottom: 0;
  239. right: 0;
  240. opacity: 0.5;
  241. }
  242. .nav-name::after {
  243. content: "";
  244. position: absolute;
  245. display: block;
  246. width: 100 upx;
  247. height: 1px;
  248. background: #fff;
  249. bottom: 0;
  250. right: 40 upx;
  251. opacity: 0.3;
  252. }
  253. .nav-name::first-letter {
  254. font-weight: bold;
  255. font-size: 36 upx;
  256. margin-right: 1px;
  257. }
  258. .nav-li text {
  259. position: absolute;
  260. right: 30 upx;
  261. top: 30 upx;
  262. font-size: 52 upx;
  263. width: 60 upx;
  264. height: 60 upx;
  265. text-align: center;
  266. line-height: 60 upx;
  267. }
  268. .text-light {
  269. font-weight: 300;
  270. }
  271. @keyframes show {
  272. 0% {
  273. transform: translateY(-50px);
  274. }
  275. 60% {
  276. transform: translateY(40 upx);
  277. }
  278. 100% {
  279. transform: translateY(0px);
  280. }
  281. }
  282. @-webkit-keyframes show {
  283. 0% {
  284. transform: translateY(-50px);
  285. }
  286. 60% {
  287. transform: translateY(40 upx);
  288. }
  289. 100% {
  290. transform: translateY(0px);
  291. }
  292. }
  293. /*banner*/
  294. .tui-banner-box {
  295. width: 100%;
  296. padding-top: 20rpx;
  297. box-sizing: border-box;
  298. background: #fff;
  299. }
  300. .tui-banner-swiper {
  301. width: 100%;
  302. height: 320rpx;
  303. }
  304. .tui-banner-item {
  305. padding: 0 16rpx;
  306. box-sizing: border-box;
  307. }
  308. .tui-slide-image {
  309. width: 100%;
  310. height: 320rpx;
  311. display: block;
  312. border-radius: 12rpx;
  313. /* transition: all 0.1s linear; */
  314. }
  315. .tui-banner-scale {
  316. transform: scaleY(0.9);
  317. transform-origin: center center;
  318. }
  319. /* #ifdef MP-WEIXIN */
  320. .tui-banner-swiper .wx-swiper-dot {
  321. width: 8rpx;
  322. height: 8rpx;
  323. display: inline-flex;
  324. background: none;
  325. justify-content: space-between;
  326. }
  327. .tui-banner-swiper .wx-swiper-dot::before {
  328. content: '';
  329. flex-grow: 1;
  330. background: rgba(255, 255, 255, 0.8);
  331. border-radius: 16rpx;
  332. overflow: hidden;
  333. }
  334. .tui-banner-swiper .wx-swiper-dot-active::before {
  335. background: #fff;
  336. }
  337. .tui-banner-swiper .wx-swiper-dot.wx-swiper-dot-active {
  338. width: 16rpx;
  339. }
  340. /* #endif */
  341. /*banner*/
  342. /*公告*/
  343. .tui-rolling-news {
  344. width: 100%;
  345. padding: 12rpx 30rpx;
  346. box-sizing: border-box;
  347. display: flex;
  348. align-items: center;
  349. justify-content: center;
  350. flex-wrap: nowrap;
  351. background: #fff;
  352. }
  353. .tui-swiper {
  354. font-size: 28rpx;
  355. height: 50rpx;
  356. flex: 1;
  357. }
  358. .tui-swiper-item {
  359. display: flex;
  360. align-items: center
  361. }
  362. .tui-news-item {
  363. line-height: 24rpx;
  364. white-space: nowrap;
  365. overflow: hidden;
  366. text-overflow: ellipsis;
  367. }
  368. /*公告*/
  369. </style>