secondaryGuide.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <view class="main">
  3. <view class="swiper" v-if="!launchFlagStatus">
  4. <swiper class="swiper-list" :indicator-dots="swiperList && swiperList.length > 1" indicator-color="#ffffff"
  5. indicator-active-color="rgb(3,160,168)" interval="5000" :autoplay="autoplay" :duration="duration"
  6. @change="swiperChange">
  7. <swiper-item v-for="(item, index) in swiperList" :key="index">
  8. <view class="swiper-item">
  9. <view class="swiper-item-img">
  10. <!-- aspectFill -->
  11. <image :src="item.image" mode="aspectFit"></image>
  12. </view>
  13. </view>
  14. </swiper-item>
  15. </swiper>
  16. <!-- <view class="jumpover" @tap="launchFlag()" v-if="swiperCurrent+1 < swiperLength">{{ jumpover }}</view> -->
  17. <view class="jumpover">
  18. <div class="jumpover_l">{{ countDown }}s</div>
  19. <div class="jumpover_r" @click="goPage()">跳过</div>
  20. </view>
  21. <!-- <view class="experience" @tap="launchFlag()" v-if="swiperCurrent+1 == swiperLength">{{ experience }}</view> -->
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. import {
  27. getBannerList
  28. } from "@/api/government.js"
  29. export default {
  30. data() {
  31. return {
  32. launchFlagStatus: false,
  33. titleNViewBackground: '',
  34. swiperCurrent: 0,
  35. swiperLength: 0,
  36. swiperList: [
  37. // {
  38. // imgUrl: '/static/guide/1-1.png',
  39. // bgColor: ''
  40. // },
  41. // {
  42. // imgUrl: '/static/guide/2-2.png',
  43. // bgColor: ''
  44. // },
  45. // {
  46. // imgUrl: '/static/guide/3-3.png',
  47. // bgColor: ''
  48. // },
  49. // {
  50. // imgUrl: '/static/guide/4-4.png',
  51. // bgColor: ''
  52. // }
  53. ],
  54. autoplay: false,
  55. duration: 500,
  56. jumpover: '跳过',
  57. experience: '立即体验',
  58. countDown: 3,
  59. countDownInterval: null
  60. };
  61. },
  62. onLoad() {
  63. // try {
  64. // this.launchFlagStatus = uni.getStorageSync('launchFlag');
  65. // } catch (e) {
  66. // //TODO handle the exception
  67. // }
  68. // this.launchFlagStatus = this.launchFlagStatus ? true : false;
  69. console.log('this.launchFlagStatus = ', this.launchFlagStatus)
  70. if (this.launchFlagStatus) {
  71. uni.switchTab({
  72. url: '/pages/home',
  73. success: res => {
  74. // push.navigator.closeSplashscreen();
  75. console.log('111 = res ', res)
  76. },
  77. fail: err => {
  78. // push.navigator.closeSplashscreen();
  79. console.log('111 = err ', err)
  80. }
  81. });
  82. } else {
  83. this.swiperLength = this.swiperList.length;
  84. this.getList();
  85. this.countDown = 3;
  86. this.countDownInterval = setInterval(() => {
  87. this.countDown--;
  88. if (this.countDown <= 0) {
  89. clearInterval(this.countDownInterval)
  90. this.launchFlag();
  91. }
  92. }, 1000)
  93. }
  94. // this.swiperLength = this.swiperList.length;
  95. // this.getList()
  96. // this.titleNViewBackground = this.swiperList[0].bgColor;
  97. },
  98. onUnload() {
  99. try {
  100. clearInterval(this.countDownInterval)
  101. } catch (e) {
  102. //TODO handle the exception
  103. }
  104. },
  105. methods: {
  106. goPage(){
  107. clearInterval(this.countDownInterval)
  108. this.launchFlag();
  109. },
  110. getList() {
  111. getBannerList('guanggaoyd').then(res => {
  112. this.swiperList = res.data
  113. })
  114. },
  115. //轮播图切换修改背景色
  116. swiperChange(e) {
  117. const index = e.detail.current;
  118. this.swiperCurrent = index;
  119. this.swiperLength = this.swiperList.length;
  120. // this.titleNViewBackground = this.swiperList[index].bgColor;
  121. },
  122. launchFlag: function() {
  123. /**
  124. * 向本地存储中设置launchFlag的值,即启动标识;
  125. */
  126. // uni.setStorage({
  127. // key: 'launchFlag',
  128. // data: true
  129. // });
  130. uni.switchTab({
  131. url: '/pages/home'
  132. });
  133. }
  134. }
  135. };
  136. </script>
  137. <style lang="scss" scoped>
  138. page,
  139. .main {
  140. width: 100%;
  141. height: 100%;
  142. padding: 0;
  143. background-size: 100% auto;
  144. }
  145. .swiper {
  146. flex-direction: column;
  147. width: 100%;
  148. height: 100vh;
  149. background: #fff;
  150. }
  151. .swiper-list {
  152. width: 100%;
  153. height: 100%;
  154. }
  155. .swiper-item {
  156. position: relative;
  157. display: flex;
  158. align-items: center;
  159. flex-direction: column;
  160. width: 100%;
  161. height: 100%;
  162. text-align: center;
  163. }
  164. .swiper-item-img {
  165. justify-content: center;
  166. width: 100%;
  167. height: 100%;
  168. margin: 0 auto;
  169. }
  170. .swiper-item-img image {
  171. width: 100%;
  172. height: 100%;
  173. }
  174. .jumpover,
  175. .experience {
  176. position: absolute;
  177. z-index: 999;
  178. height: 60rpx;
  179. line-height: 56rpx;
  180. padding: 0 40rpx;
  181. font-size: 32rpx;
  182. color: rgb(3, 160, 168);
  183. border: 2rpx solid rgb(3, 160, 168);
  184. border-radius: 30rpx;
  185. }
  186. .jumpover {
  187. right: 20rpx;
  188. top: 90rpx;
  189. padding: 0 20rpx;
  190. display: flex;
  191. .jumpover_l{
  192. }
  193. .jumpover_r{
  194. font-size: 28rpx;
  195. margin-left: 20rpx;
  196. // padding-top: 2rpx;
  197. position: relative;
  198. &::before{
  199. content: "";
  200. display: block;
  201. position: absolute;
  202. width: 2rpx;
  203. height: 36rpx;
  204. background: rgb(3, 160, 168);
  205. top: 12rpx;
  206. left: -10rpx;
  207. }
  208. }
  209. }
  210. .experience {
  211. width: 300rpx;
  212. height: 80rpx;
  213. right: 50%;
  214. bottom: 20vh !important;
  215. margin-right: -20%;
  216. padding: 0;
  217. background: rgb(3, 160, 168);
  218. color: #fff;
  219. line-height: 80rpx;
  220. text-align: center;
  221. border-radius: 40rpx;
  222. }
  223. /deep/ uni-swiper .uni-swiper-dot {
  224. border: 1rpx solid rgb(3, 160, 168);
  225. }
  226. /deep/ uni-swiper .uni-swiper-dots-horizontal {
  227. bottom: 10vh !important;
  228. }
  229. </style>