index.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. <template>
  2. <v-header mode="" async ref="header" @fetch="fetch" :title="config.name">
  3. <refresh-view @refresh="refresh">
  4. <view class="container">
  5. <!-- 小程序头部兼容 -->
  6. <!-- #ifdef MP -->
  7. <!-- <view class="mp-search-box"><input class="ser-input" type="text" value="输入关键字搜索" disabled /></view> -->
  8. <!-- #endif -->
  9. <!-- 头部轮播 -->
  10. <view class="carousel-section">
  11. <!-- 标题栏和状态栏占位符 -->
  12. <view class="titleNview-placing"></view>
  13. <swiper class="carousel" circular @change="swiperChange">
  14. <swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item" @click="navToDetailPage({ product_id: item.product_id })">
  15. <v-image mode="aspectFill" class="screen_all" :src="item.image" />
  16. </swiper-item>
  17. </swiper>
  18. </view>
  19. <!-- 新人赠送优惠券 -->
  20. <view v-if="coupon && coupon.id" class="coupon-container center">
  21. <layout-coupon></layout-coupon>
  22. </view>
  23. <!-- 新人赠送优惠券 -->
  24. <!-- 分类 -->
  25. <view class="cate-section">
  26. <view class="cate-item" v-for="(item, index) in menu" :key="index" @click="trigger(item)">
  27. <image :src="item.icon" ></image>
  28. <text>{{item.label}}</text>
  29. </view>
  30. </view>
  31. <!-- 精品推荐-->
  32. <view class="boutique row center">
  33. <image :src="require('./images/decorate-left.png')"></image>
  34. <view class="boutique-title">精品·推荐</view>
  35. <image :src="require('./images/decorate-right.png')"></image>
  36. </view>
  37. <!-- 商品 -->
  38. <view class="shop-container">
  39. <view class="shop-item overflow relative"
  40. v-for="(item,index) in goodsList"
  41. :key="index"
  42. >
  43. <v-image mode="aspectFill" class="screen_all" :src="item.index_bg"></v-image>
  44. <view class="shop-item-info absolute jEnd aCenter" :style="{color:item.font_color}">
  45. <view class="absolute shop-item-header row aCenter">
  46. <image src="/static/images/logo.jpg" class="shop-item-header-logo"></image>
  47. <view class="flex-all-1">
  48. <view class="shop-logo-header-title">{{ config.name }}</view>
  49. <view class="shop-logo-en-title">{{config.enName}}</view>
  50. </view>
  51. </view>
  52. <view class="shop-item-title">{{item.title}}</view>
  53. <text class="shop-item-price-group" v-if="item.id">
  54. <text class="shop-item-price-em">¥</text>
  55. <text class="shop-item-price">{{item.price}}</text>
  56. <text>/1瓶</text>
  57. </text>
  58. <view class="shop-item-buy-button relative center" @click="goShopDetail(item)" v-if="item.id">立即购买</view>
  59. </view>
  60. </view>
  61. </view>
  62. <!-- 查看更多产品 -->
  63. <view class="center">
  64. <view @click="goShopMore" class="shop-button row center">
  65. <text>查看更多商品</text>
  66. <image mode="aspectFill" :src="require('./images/more.png')"></image>
  67. </view>
  68. </view>
  69. </view>
  70. </refresh-view>
  71. </v-header>
  72. </template>
  73. <script>
  74. import uniCountdown from '@/components/uni-countdown/uni-countdown.vue';
  75. import menu from './data/menu';
  76. import layoutCoupon from '@/layout/layout-coupon/index.vue';
  77. import vHeader from '@/components/v-header/main.vue';
  78. import refreshView from '@/components/refresh-view/main.vue';
  79. import vImage from '@/components/v-image/main.vue';
  80. import trigger from '@/mixins/trigger/index';
  81. import shop from '@/utils/controls/shop';
  82. import {
  83. mapState
  84. } from 'vuex';
  85. export default {
  86. components: {uniCountdown,layoutCoupon,vHeader,refreshView,vImage},
  87. mixins:[trigger],
  88. data() {
  89. return {
  90. titleNViewBackground: '',
  91. swiperCurrent: 0,
  92. swiperLength: 0,
  93. carouselList: [{}],
  94. goodsList: [{},{}],
  95. menu:menu,
  96. coupon:{}
  97. };
  98. },
  99. computed:{
  100. ...mapState(['config'])
  101. },
  102. methods: {
  103. fetch(obj){
  104. return Promise.all([
  105. this.$request({
  106. url: '/index/getAdsList',
  107. cache:true
  108. }),
  109. this.$request({
  110. url:'index/getNewCoupon',
  111. token:true
  112. }),
  113. this.$request({
  114. url:'product/getProductList',
  115. cache:true,
  116. data:{
  117. is_recommend:1
  118. }
  119. })
  120. ]).then((data)=>{
  121. // 执行设置
  122. ['setBanner','setCoupon','setProduct'].map((item,index)=>{
  123. return this[item] && this[item](data[index]);
  124. });
  125. this.refreshStop && this.refreshStop();
  126. return obj.success();
  127. }).catch(()=>{
  128. this.refreshStop && this.refreshStop();
  129. obj.fail();
  130. });
  131. },
  132. refresh(stop){
  133. this.refreshStop = stop;
  134. if (this.$refs.header) {
  135. if (this.$refs.header._state!==1) {
  136. return this.$refs.header.reload();
  137. }
  138. } else {
  139. stop();
  140. }
  141. },
  142. setBanner(res){
  143. let carouselList = res.data;
  144. this.swiperLength = carouselList.length;
  145. this.carouselList = carouselList;
  146. },
  147. setCoupon(data){
  148. this.coupon = data.data[0];
  149. },
  150. setProduct(data){
  151. this.goodsList = data.data.map((item)=>{
  152. let price = parseFloat(item.sales_price);
  153. let intPrice = Math.floor(price);
  154. if (price === intPrice) price = intPrice;
  155. item.price = price;
  156. return item;
  157. });
  158. },
  159. goShopDetail(item){
  160. console.log(item);
  161. return shop.goShopDetail(item);
  162. },
  163. goShopMore(){
  164. return this.$router.switchTab('category');
  165. }
  166. },
  167. };
  168. </script>
  169. <style lang="scss">
  170. /* #ifdef MP */
  171. .mp-search-box {
  172. position: absolute;
  173. left: 0;
  174. top: 30upx;
  175. z-index: 9999;
  176. width: 100%;
  177. padding: 0 80upx;
  178. .ser-input {
  179. flex: 1;
  180. height: 56upx;
  181. line-height: 56upx;
  182. text-align: center;
  183. font-size: 28upx;
  184. color: $font-color-base;
  185. border-radius: 20px;
  186. background: rgba(255, 255, 255, 0.6);
  187. }
  188. }
  189. /* #endif */
  190. page {
  191. .carousel-section {
  192. padding: 0;
  193. .titleNview-placing {
  194. padding-top: 0;
  195. height: 0;
  196. }
  197. .carousel {
  198. .carousel-item {
  199. padding: 0;
  200. }
  201. }
  202. .swiper-dots {
  203. left: 45upx;
  204. bottom: 40upx;
  205. }
  206. }
  207. }
  208. page {
  209. background: #f5f5f5;
  210. }
  211. .m-t {
  212. margin-top: 16upx;
  213. }
  214. /* 头部 轮播图 */
  215. .carousel-section {
  216. position: relative;
  217. padding-top: 10px;
  218. .titleNview-placing {
  219. height: var(--status-bar-height);
  220. padding-top: 44px;
  221. box-sizing: content-box;
  222. }
  223. .titleNview-background {
  224. position: absolute;
  225. top: 0;
  226. left: 0;
  227. width: 100%;
  228. height: 426upx;
  229. transition: 0.4s;
  230. }
  231. }
  232. .carousel {
  233. width: 100%;
  234. height: 960upx;
  235. .carousel-item,image {
  236. width: 100%;
  237. height: 100%;
  238. }
  239. }
  240. .swiper-dots {
  241. display: flex;
  242. position: absolute;
  243. left: 60upx;
  244. bottom: 15upx;
  245. width: 72upx;
  246. height: 36upx;
  247. background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAABkCAYAAADDhn8LAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTMyIDc5LjE1OTI4NCwgMjAxNi8wNC8xOS0xMzoxMzo0MCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZ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hYE+AeBAAdPLOcV8HRmWRDAiQVcO7GcV8CLM8uCAE4sQCDAlHcQ7x+ABQEEAggEEAggEEAggEAAgQACASAQQCCAQACBAAIBBAIIBBAIIBBAIABe4e9iAe/xd7EAJxYgEGDeO4j3EODp/cOCAE4sYMyJ5cwCHs4rCwI4sYBxJ5YzC84rCwKcXxArAuthQYDzC2JF0H49LAhwYUGsCFqvx5EF2T07dMaJBetx4cRyaqFtHJ8EIhK0i8OJBQxcECuCVutxJhCRoE0cZwMRyRcFefa/ffZBVPogePihhyCnbBhcfMFFEFM+DD4m+ghSlgmDkwlOgpAl4+BkkJMgZdk4+EgaSCcpVX7bmY9kgXQQU+1TgE0c+QJZUUz1b2T4SBbIKmJW+3iMj2SBVBWz+leVfCQLpIqYbp8b85EskIxyfIOfK5Sf+wiCRJEsllQ+oqEkQfBxmD8BBgA5hVjXyrBNUQAAAABJRU5ErkJggg==);
  248. background-size: 100% 100%;
  249. .num {
  250. width: 36upx;
  251. height: 36upx;
  252. border-radius: 50px;
  253. font-size: 24upx;
  254. color: #fff;
  255. text-align: center;
  256. line-height: 36upx;
  257. }
  258. .sign {
  259. position: absolute;
  260. top: 0;
  261. left: 50%;
  262. line-height: 36upx;
  263. font-size: 12upx;
  264. color: #fff;
  265. transform: translateX(-50%);
  266. }
  267. }
  268. /* 分类 */
  269. .cate-section {
  270. display: flex;
  271. justify-content: space-around;
  272. margin-top: 20upx;
  273. padding: 30upx 22upx;
  274. .cate-item {
  275. display: flex;
  276. flex: 1;
  277. justify-content: center;
  278. align-items: center;
  279. flex-direction: column;
  280. font-size: 26upx;
  281. color: $font-color-dark;
  282. }
  283. /* 原图标颜色太深,不想改图了,所以加了透明度 */
  284. image {
  285. width: 47upx;
  286. height: 47upx;
  287. margin-bottom: 14upx;
  288. }
  289. }
  290. </style>
  291. <style src="./style.scss" lang="scss"></style>