index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <view class="center">
  3. <!-- 顶部logo and 搜索 start-->
  4. <view class="top-search flex">
  5. <view class="top-logo">
  6. <image src="../../static/icon/sh-log.png" mode=""></image>
  7. </view>
  8. <view class="search-box flex" @click="clickSearch()">
  9. <image class="search" src="../../static/icon/search-h.png" mode=""></image>
  10. <view class="search-font">输入关键词搜索</view>
  11. </view>
  12. </view>
  13. <!-- 顶部logo and 搜索 end-->
  14. <view class="jg"></view>
  15. <!-- 轮播图 start -->
  16. <swiper class="top-swiper" autoplay="true" duration="400" interval="5000" @change="swiperChange">
  17. <swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item"
  18. @click="bannerNavToUrl(item)">
  19. <image src="../../static/img/bargainBg.jpg" />
  20. </swiper-item>
  21. </swiper>
  22. <!-- 轮播图 end -->
  23. <view class="swiper-btm flex">
  24. <view class="btm-item flex">
  25. <image src="../../static/icon/index-gou.png" mode=""></image>
  26. <view class="">自用购物返利</view>
  27. </view>
  28. <view class="btm-item flex">
  29. <image src="../../static/icon/index-gou.png" mode=""></image>
  30. <view class="">分享好友赚钱</view>
  31. </view>
  32. <view class="btm-item flex">
  33. <image src="../../static/icon/index-gou.png" mode=""></image>
  34. <view class="">超值正品优惠</view>
  35. </view>
  36. </view>
  37. <!-- 商品列表 -->
  38. </view>
  39. </template>
  40. <script>
  41. import {
  42. tabbar1
  43. } from '@/utils/tabbar.js';
  44. import {
  45. loadIndexs
  46. } from '@/api/index.js';
  47. import uniCountdowns from '@/components/uni-countdown/uni-countdowns.vue';
  48. export default {
  49. components: {
  50. uniCountdowns
  51. },
  52. data() {
  53. return {
  54. current: 0,
  55. tabbar: tabbar1,
  56. titleNViewBackground: '',
  57. swiperCurrent: 0,
  58. swiperLength: 0,
  59. dataList: '',
  60. carouselList: [], //轮播图列表
  61. text: ['恭喜黑白灰用户拼团成功¥353元!', '恭喜黑白灰用户拼团成功¥353元!'],
  62. stopTime: {
  63. stopTimeH: 0,
  64. stopTimeM: 24,
  65. stopTimeS: 59
  66. },
  67. bzb: 30
  68. };
  69. },
  70. onLoad() {
  71. this.loadData();
  72. },
  73. methods: {
  74. loadData() {
  75. loadIndexs({})
  76. .then(({
  77. data
  78. }) => {
  79. let goods = data.info;
  80. this.dataList = goods.bastList; //精品推荐
  81. this.carouselList = data.banner;
  82. })
  83. .catch(e => {});
  84. },
  85. goDetails(e) {
  86. console.log(e, '123456');
  87. uni.navigateTo({
  88. url: '/pages/index/messageInfo'
  89. });
  90. },
  91. nav(url) {
  92. uni.navigateTo({
  93. url,
  94. fail() {
  95. uni.switchTab({
  96. url
  97. });
  98. }
  99. });
  100. },
  101. //轮播图切换修改背景色
  102. swiperChange(e) {
  103. const index = e.detail.current;
  104. this.swiperCurrent = index;
  105. this.titleNViewBackground = this.carouselList[index].background;
  106. },
  107. // 點擊搜索框
  108. clickSearch() {
  109. uni.navigateTo({
  110. url: '/pages/product/search'
  111. });
  112. },
  113. //详情页
  114. navToDetailPage(item) {
  115. let id = item.id;
  116. uni.navigateTo({
  117. url: '/pages/product/product?id=' + id
  118. });
  119. }
  120. }
  121. };
  122. </script>
  123. <style lang="scss">
  124. page,
  125. .center {
  126. min-height: 100%;
  127. height: auto;
  128. background: #ededed;
  129. }
  130. // 顶部搜索
  131. .top-search {
  132. height: 80rpx;
  133. padding: 0 20rpx;
  134. background-color: #fff;
  135. .top-logo {
  136. width: 50rpx;
  137. height: 50rpx;
  138. margin-right: 10rpx;
  139. image {
  140. width: 50rpx;
  141. height: 50rpx;
  142. }
  143. }
  144. .search-box {
  145. justify-content: center;
  146. width: 698rpx;
  147. height: 60rpx;
  148. background: #EEEEEE;
  149. // box-shadow: 0px 10rpx 20rpx 0px rgba(4, 114, 69, 0.22);
  150. border-radius: 30rpx;
  151. .search {
  152. width: 34rpx;
  153. height: 34rpx;
  154. }
  155. .search-font {
  156. margin-left: 14rpx;
  157. font-size: 28rpx;
  158. font-family: PingFang SC;
  159. font-weight: 500;
  160. color: #CBCBCB;
  161. }
  162. }
  163. }
  164. // 顶部轮播图
  165. .top-swiper {
  166. width: 750rpx;
  167. height: 360rpx;
  168. // margin: 20rpx 0 0;
  169. image {
  170. width: 750rpx;
  171. height: 360rpx;
  172. }
  173. }
  174. .swiper-btm {
  175. height: 60rpx;
  176. width: 750rpx;
  177. background-color: #fff;
  178. margin-bottom: 20rpx;
  179. font-size: 21rpx;
  180. font-weight: 500;
  181. color: #333333;
  182. .btm-item {
  183. flex-grow: 1;
  184. justify-content: center;
  185. image {
  186. width: 25rpx;
  187. height: 25rpx;
  188. margin-right: 14rpx;
  189. }
  190. }
  191. }
  192. .jg {
  193. height: 20rpx;
  194. background-color: #fff;
  195. }
  196. </style>