guide.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <template>
  2. <view class="main">
  3. <view class="swiper">
  4. <swiper class="swiper-list" indicator-dots indicator-color="#ffffff" indicator-active-color="rgb(3,160,168)"
  5. interval="5000" :autoplay="autoplay" :duration="duration" @change="swiperChange">
  6. <swiper-item v-for="(item, index) in swiperList" :key="index">
  7. <view class="swiper-item">
  8. <view class="swiper-item-img">
  9. <!-- aspectFill -->
  10. <image :src="item.image" mode="aspectFit"></image>
  11. </view>
  12. </view>
  13. </swiper-item>
  14. </swiper>
  15. <view class="jumpover" @tap="launchFlag()" v-if="swiperCurrent+1 < swiperLength">{{ jumpover }}</view>
  16. <view class="experience" @tap="launchFlag()" v-if="swiperCurrent+1 == swiperLength">{{ experience }}</view>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. import {
  22. getBannerList
  23. } from "@/api/government.js"
  24. export default {
  25. data() {
  26. return {
  27. titleNViewBackground: '',
  28. swiperCurrent: 0,
  29. swiperLength: 0,
  30. // swiperList: [{
  31. // imgUrl: '/static/guide/1-1.jpg',
  32. // bgColor: ''
  33. // },
  34. // {
  35. // imgUrl: '/static/guide/2-2.jpg',
  36. // bgColor: ''
  37. // },
  38. // {
  39. // imgUrl: '/static/guide/3-3.jpg',
  40. // bgColor: ''
  41. // },
  42. // {
  43. // imgUrl: '/static/guide/4-4.jpg',
  44. // bgColor: ''
  45. // }
  46. // ],
  47. swiperList: [],
  48. autoplay: false,
  49. duration: 500,
  50. jumpover: '跳过',
  51. experience: '立即体验'
  52. };
  53. },
  54. onLoad() {
  55. // #ifdef APP-PLUS
  56. if (plus.os.name == 'iOS') {
  57. // 首先获取一次网络状态
  58. uni.getNetworkType({
  59. success: (res) => {
  60. if (res.networkType != 'none') {
  61. this.getList()
  62. }
  63. }
  64. });
  65. // 监听网络变化
  66. uni.onNetworkStatusChange((res) => {
  67. if (res.isConnected) {
  68. this.getList()
  69. }
  70. });
  71. } else {
  72. this.getList()
  73. }
  74. // #endif
  75. // this.titleNViewBackground = this.swiperList[0].bgColor;
  76. },
  77. methods: {
  78. getList() {
  79. getBannerList('ydtgg').then(res => {
  80. this.swiperList = res.data;
  81. this.swiperLength = this.swiperList.length;
  82. }).catch(err => {
  83. })
  84. },
  85. //轮播图切换修改背景色
  86. swiperChange(e) {
  87. const index = e.detail.current;
  88. this.swiperCurrent = index;
  89. this.swiperLength = this.swiperList.length;
  90. // this.titleNViewBackground = this.swiperList[index].bgColor;
  91. },
  92. launchFlag: function() {
  93. /**
  94. * 向本地存储中设置launchFlag的值,即启动标识;
  95. */
  96. uni.setStorage({
  97. key: 'launchFlag',
  98. data: true
  99. });
  100. uni.switchTab({
  101. url: '/pages/home'
  102. });
  103. }
  104. }
  105. };
  106. </script>
  107. <style lang="scss" scoped>
  108. page,
  109. .main {
  110. width: 100%;
  111. height: 100%;
  112. padding: 0;
  113. background-size: 100% auto;
  114. }
  115. .swiper {
  116. flex-direction: column;
  117. width: 100%;
  118. height: 100vh;
  119. background: #fff;
  120. }
  121. .swiper-list {
  122. width: 100%;
  123. height: 100%;
  124. }
  125. .swiper-item {
  126. position: relative;
  127. display: flex;
  128. align-items: center;
  129. flex-direction: column;
  130. width: 100%;
  131. height: 100%;
  132. text-align: center;
  133. }
  134. .swiper-item-img {
  135. justify-content: center;
  136. width: 100%;
  137. height: 100%;
  138. margin: 0 auto;
  139. }
  140. .swiper-item-img image {
  141. width: 100%;
  142. height: 100%;
  143. }
  144. .jumpover,
  145. .experience {
  146. position: absolute;
  147. z-index: 999;
  148. height: 60rpx;
  149. line-height: 56rpx;
  150. padding: 0 40rpx;
  151. font-size: 32rpx;
  152. color: rgb(3, 160, 168);
  153. border: 2rpx solid rgb(3, 160, 168);
  154. border-radius: 30rpx;
  155. }
  156. .jumpover {
  157. right: 30rpx;
  158. top: 90rpx;
  159. }
  160. .experience {
  161. width: 300rpx;
  162. height: 80rpx;
  163. right: 50%;
  164. bottom: 20vh !important;
  165. margin-right: -20%;
  166. padding: 0;
  167. background: rgb(3, 160, 168);
  168. color: #fff;
  169. line-height: 80rpx;
  170. text-align: center;
  171. border-radius: 40rpx;
  172. }
  173. /deep/ uni-swiper .uni-swiper-dot {
  174. border: 1rpx solid rgb(3, 160, 168);
  175. }
  176. /deep/ uni-swiper .uni-swiper-dots-horizontal {
  177. bottom: 10vh !important;
  178. }
  179. </style>