index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  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 (var image of (system.banner.split(','))) {
  109. banners.push({
  110. image: this.imgUrl + image
  111. })
  112. }
  113. this.banners = banners
  114. console.log('banners', this.banners)
  115. // 延迟加载:v-if导致组件未完全渲染
  116. // setTimeout(() => {
  117. // this.banners = system.banner.split(',')
  118. // console.log('banners', this.banners)
  119. // }, 200)
  120. }
  121. }
  122. // 页面配置数据
  123. let page = res.data.page
  124. if (page) {
  125. this.page = page
  126. uni.setStorageSync('page', page)
  127. // 页面风格
  128. this.pageStyle = 'color'
  129. // this.pageStyle = page.page_index_style ? page.page_index_style : 'simple'
  130. // 底部栏风格
  131. this.tabbarStyle = page.page_tabbar_style ? page.page_tabbar_style : 'simple'
  132. // 悬浮按钮
  133. this.showAdBtn = parseInt(page.page_index_ad_btn) == 1
  134. this.showShareBtn = parseInt(page.page_index_share_btn) == 1
  135. }
  136. // #ifdef MP-WEIXIN
  137. // 流量主数据
  138. let ad = res.data.ad;
  139. if (ad) {
  140. this.ad = ad
  141. uni.setStorageSync('ad', ad);
  142. // 插屏广告
  143. if (this.ad.index_cp_open == 1) {
  144. this.adUtils.interstitial.load(this.ad.index_cp)
  145. this.adUtils.interstitial.show()
  146. }
  147. // // 激励广告
  148. // this.adUtils.rewarded.load('adunit-69d6a49d4c5999c5', () => {
  149. // //这里写你的任意奖励事件
  150. // });
  151. // this.adUtils.rewarded.show();
  152. }
  153. // #endif
  154. // 隐藏骨架屏
  155. this.showSkeleton = false
  156. this.$forceUpdate()
  157. })
  158. },
  159. // 点击悬浮按钮
  160. clickFabItem(e) {
  161. console.log('clickFabItem', e)
  162. },
  163. // 跳转公告列表
  164. goNoticeList() {
  165. this.utils.goto('notice-list')
  166. },
  167. // 点击公告,跳转公告详情
  168. clickNotice(id) {
  169. this.utils.goto('notice-detail?id=' + id)
  170. },
  171. }
  172. }
  173. </script>
  174. <style>
  175. page {
  176. background-color: #fff;
  177. }
  178. .nav-list {
  179. display: flex;
  180. flex-wrap: wrap;
  181. padding: 0px 40 upx 0px;
  182. justify-content: space-between;
  183. }
  184. .nav-li {
  185. padding: 30 upx;
  186. border-radius: 12 upx;
  187. width: 45%;
  188. margin: 0 2.5% 40 upx;
  189. background-image: url(https://cdn.nlark.com/yuque/0/2019/png/280374/1552996358352-assets/web-upload/cc3b1807-c684-4b83-8f80-80e5b8a6b975.png);
  190. background-size: cover;
  191. background-position: center;
  192. position: relative;
  193. z-index: 1;
  194. }
  195. .nav-li::after {
  196. content: "";
  197. position: absolute;
  198. z-index: -1;
  199. background-color: inherit;
  200. width: 100%;
  201. height: 100%;
  202. left: 0;
  203. bottom: -10%;
  204. border-radius: 10 upx;
  205. opacity: 0.2;
  206. transform: scale(0.9, 0.9);
  207. }
  208. .nav-li.cur {
  209. color: #fff;
  210. background: rgb(94, 185, 94);
  211. box-shadow: 4 upx 4 upx 6 upx rgba(94, 185, 94, 0.4);
  212. }
  213. .nav-title {
  214. font-size: 32 upx;
  215. font-weight: 300;
  216. }
  217. .nav-title::first-letter {
  218. font-size: 40 upx;
  219. margin-right: 4 upx;
  220. }
  221. .nav-name {
  222. font-size: 28 upx;
  223. text-transform: Capitalize;
  224. margin-top: 20 upx;
  225. position: relative;
  226. }
  227. .nav-name::before {
  228. content: "";
  229. position: absolute;
  230. display: block;
  231. width: 40 upx;
  232. height: 6 upx;
  233. background: #fff;
  234. bottom: 0;
  235. right: 0;
  236. opacity: 0.5;
  237. }
  238. .nav-name::after {
  239. content: "";
  240. position: absolute;
  241. display: block;
  242. width: 100 upx;
  243. height: 1px;
  244. background: #fff;
  245. bottom: 0;
  246. right: 40 upx;
  247. opacity: 0.3;
  248. }
  249. .nav-name::first-letter {
  250. font-weight: bold;
  251. font-size: 36 upx;
  252. margin-right: 1px;
  253. }
  254. .nav-li text {
  255. position: absolute;
  256. right: 30 upx;
  257. top: 30 upx;
  258. font-size: 52 upx;
  259. width: 60 upx;
  260. height: 60 upx;
  261. text-align: center;
  262. line-height: 60 upx;
  263. }
  264. .text-light {
  265. font-weight: 300;
  266. }
  267. @keyframes show {
  268. 0% {
  269. transform: translateY(-50px);
  270. }
  271. 60% {
  272. transform: translateY(40 upx);
  273. }
  274. 100% {
  275. transform: translateY(0px);
  276. }
  277. }
  278. @-webkit-keyframes show {
  279. 0% {
  280. transform: translateY(-50px);
  281. }
  282. 60% {
  283. transform: translateY(40 upx);
  284. }
  285. 100% {
  286. transform: translateY(0px);
  287. }
  288. }
  289. /*banner*/
  290. .tui-banner-box {
  291. width: 100%;
  292. padding-top: 20rpx;
  293. box-sizing: border-box;
  294. background: #fff;
  295. }
  296. .tui-banner-swiper {
  297. width: 100%;
  298. height: 320rpx;
  299. }
  300. .tui-banner-item {
  301. padding: 0 16rpx;
  302. box-sizing: border-box;
  303. }
  304. .tui-slide-image {
  305. width: 100%;
  306. height: 320rpx;
  307. display: block;
  308. border-radius: 12rpx;
  309. /* transition: all 0.1s linear; */
  310. }
  311. .tui-banner-scale {
  312. transform: scaleY(0.9);
  313. transform-origin: center center;
  314. }
  315. /* #ifdef MP-WEIXIN */
  316. .tui-banner-swiper .wx-swiper-dot {
  317. width: 8rpx;
  318. height: 8rpx;
  319. display: inline-flex;
  320. background: none;
  321. justify-content: space-between;
  322. }
  323. .tui-banner-swiper .wx-swiper-dot::before {
  324. content: '';
  325. flex-grow: 1;
  326. background: rgba(255, 255, 255, 0.8);
  327. border-radius: 16rpx;
  328. overflow: hidden;
  329. }
  330. .tui-banner-swiper .wx-swiper-dot-active::before {
  331. background: #fff;
  332. }
  333. .tui-banner-swiper .wx-swiper-dot.wx-swiper-dot-active {
  334. width: 16rpx;
  335. }
  336. /* #endif */
  337. /*banner*/
  338. /*公告*/
  339. .tui-rolling-news {
  340. width: 100%;
  341. padding: 12rpx 30rpx;
  342. box-sizing: border-box;
  343. display: flex;
  344. align-items: center;
  345. justify-content: center;
  346. flex-wrap: nowrap;
  347. background: #fff;
  348. }
  349. .tui-swiper {
  350. font-size: 28rpx;
  351. height: 50rpx;
  352. flex: 1;
  353. }
  354. .tui-swiper-item {
  355. display: flex;
  356. align-items: center
  357. }
  358. .tui-news-item {
  359. line-height: 24rpx;
  360. white-space: nowrap;
  361. overflow: hidden;
  362. text-overflow: ellipsis;
  363. }
  364. /*公告*/
  365. </style>