index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <view class="center">
  3. <view class="top">
  4. <view class="vheigh"></view>
  5. <image class="top-bg" src="../../static/img/top-bg.png" mode=""></image>
  6. <view class="top-main flex">
  7. <view class="search-box flex" @click="clickSearch()">
  8. <image class="search" src="../../static/img/search.png" mode=""></image>
  9. <view class="search-font">输入关键词搜索</view>
  10. </view>
  11. </view>
  12. </view>
  13. <swiper class="carousel" autoplay="true" duration="400" interval="5000" @change="swiperChange">
  14. <swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item"
  15. @click="bannerNavToUrl(item)">
  16. <image :src="item.pic" />
  17. </swiper-item>
  18. </swiper>
  19. <view class="tongz flex">
  20. <view>
  21. <view class="tongz-bg">
  22. <image src="../../static/img/tongz-bg.png" mode=""></image>
  23. </view>
  24. <view class="tongz-left flex">
  25. <image class="image-left" src="../../static/img/ling.png" mode=""></image>
  26. <u-notice-bar style="width: 100%;" mode="vertical" type="none" :volume-icon="false"
  27. :more-icon="false" :list="text"></u-notice-bar>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="navbar">
  32. <view class="nav-item" @click="nav('/pages/index/index')">
  33. <image class="nav-img" src="../../static/img/newbanner.png" mode=""></image>
  34. </view>
  35. <view class="nav-item" @click="nav('/pages/navigation/main')">
  36. <image class="nav-img" src="../../static/img/oldbanner.png" mode=""></image>
  37. </view>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. import {
  43. loadIndexs,
  44. store_list
  45. } from '@/api/index.js';
  46. import {
  47. mapState,
  48. mapMutations
  49. } from 'vuex';
  50. export default {
  51. data() {
  52. return {
  53. current: 0,
  54. titleNViewBackground: '',
  55. swiperCurrent: 0,
  56. swiperLength: 0,
  57. carouselList: [], //轮播图列表
  58. text: ['双模式 双系统 开创第三代新零售'],
  59. };
  60. },
  61. onShow() {
  62. this.loadData();
  63. },
  64. methods: {
  65. ...mapMutations(['setLat', 'setLon', 'setChoose']),
  66. loadData() {
  67. loadIndexs({})
  68. .then(({
  69. data
  70. }) => {
  71. let goods = data.info;
  72. this.dataList = goods.bastList; //精品推荐
  73. this.carouselList = data.banner;
  74. })
  75. .catch(e => {});
  76. },
  77. nav(url) {
  78. uni.navigateTo({
  79. url,
  80. fail() {
  81. uni.switchTab({
  82. url
  83. });
  84. }
  85. });
  86. },
  87. //轮播图切换修改背景色
  88. swiperChange(e) {
  89. const index = e.detail.current;
  90. this.swiperCurrent = index;
  91. this.titleNViewBackground = this.carouselList[index].background;
  92. },
  93. // 點擊搜索框
  94. clickSearch() {
  95. uni.navigateTo({
  96. url: '/pages/product/search'
  97. });
  98. },
  99. }
  100. };
  101. </script>
  102. <style lang="scss">
  103. page,
  104. .center {
  105. min-height: 100%;
  106. height: auto;
  107. background: #ffffff;
  108. }
  109. .vheigh {
  110. height: var(--status-bar-height);
  111. background-color: $base-color;
  112. }
  113. .top {
  114. position: relative;
  115. width: 100%;
  116. height: 360rpx;
  117. .top-bg {
  118. position: absolute;
  119. top: 0;
  120. left: 0;
  121. right: 0;
  122. width: 100%;
  123. height: 100%;
  124. }
  125. .top-main {
  126. position: relative;
  127. z-index: 2;
  128. padding: 30rpx;
  129. .search-box {
  130. justify-content: center;
  131. width: 698rpx;
  132. height: 60rpx;
  133. background: rgba(255, 240, 245, 0.4);
  134. box-shadow: 0px 10rpx 20rpx 0px rgba(4, 114, 69, 0.22);
  135. border-radius: 30rpx;
  136. .search {
  137. width: 34rpx;
  138. height: 34rpx;
  139. }
  140. .search-font {
  141. margin-left: 14rpx;
  142. font-size: 28rpx;
  143. font-family: PingFang SC;
  144. font-weight: 500;
  145. color: #ffffff;
  146. }
  147. }
  148. }
  149. }
  150. .carousel {
  151. width: 700rpx;
  152. height: 276rpx;
  153. /* #ifndef APP-PLUS */
  154. margin: -240rpx auto 0;
  155. /* #endif */
  156. /* #ifdef APP-PLUS */
  157. margin: -180rpx auto 0;
  158. /* #endif */
  159. border-radius: 40rpx;
  160. image {
  161. border-radius: 40rpx;
  162. width: 700rpx;
  163. height: 276rpx;
  164. }
  165. }
  166. .tongz {
  167. width: 690rpx;
  168. height: 70rpx;
  169. margin: 32rpx auto 0;
  170. padding: 18rpx 30rpx 18rpx 24rpx;
  171. align-items: center;
  172. position: relative;
  173. .tongz-bg {
  174. position: absolute;
  175. top: 0;
  176. right: 0;
  177. left: 0;
  178. width: 690rpx;
  179. height: 70rpx;
  180. image {
  181. width: 100%;
  182. height: 100%;
  183. }
  184. }
  185. .tongz-left {
  186. width: 640rpx;
  187. .image-left {
  188. width: 28rpx;
  189. height: 34rpx;
  190. }
  191. .tongz-font {
  192. margin-left: 22rpx;
  193. font-size: 28rpx;
  194. font-family: Source Han Sans CN;
  195. font-weight: 400;
  196. color: #0f253a;
  197. }
  198. }
  199. .tongz-right {
  200. position: relative;
  201. z-index: 11;
  202. width: 12rpx;
  203. height: 26rpx;
  204. image {
  205. width: 100%;
  206. height: 100%;
  207. }
  208. }
  209. }
  210. .nav-item {
  211. width: 698rpx;
  212. height: 219rpx;
  213. background: linear-gradient(150deg, #F5BE41 0%, #DF4226 100%);
  214. border-radius: 14rpx;
  215. margin: 40rpx auto 0;
  216. .nav-img {
  217. width: 100%;
  218. height: 100%;
  219. border-radius: 14rpx;
  220. }
  221. }
  222. </style>