Commit 74a17e5fce674c2609f3a36ca0e1940fc270deb5
1 parent
d305fdd9
优选库——优选主页,添加3D轮播组件~
Showing
8 changed files
with
211 additions
and
17 deletions
package.json
src/components/swiper3dCom/swiper3dCom.less
0 → 100644
| 1 | +@charset "UTF-8"; | |
| 2 | + | |
| 3 | +&.swiper-3d-com { | |
| 4 | + position: relative; | |
| 5 | + .bg-box { | |
| 6 | + width: 100%; | |
| 7 | + height: auto; | |
| 8 | + .bg-img { | |
| 9 | + display: block; | |
| 10 | + width: 100%; | |
| 11 | + height: auto; | |
| 12 | + } | |
| 13 | + } | |
| 14 | + .carousel-3d-box { | |
| 15 | + position: absolute; | |
| 16 | + top: 138px; | |
| 17 | + z-index: 1; | |
| 18 | + width: 100%; | |
| 19 | + height: 100%; | |
| 20 | + /deep/ .carousel-3d-container { | |
| 21 | + width: 100% !important; | |
| 22 | + height: auto !important; | |
| 23 | + .carousel-3d-slider { | |
| 24 | + width: 310px !important; | |
| 25 | + .carousel-3d-slide { | |
| 26 | + background-color: transparent !important; | |
| 27 | + width: 100% !important; | |
| 28 | + height: auto !important; | |
| 29 | + opacity: 0.2 !important; | |
| 30 | + border: none; | |
| 31 | + &.current { | |
| 32 | + opacity: 1 !important; | |
| 33 | + } | |
| 34 | + } | |
| 35 | + } | |
| 36 | + } | |
| 37 | + } | |
| 38 | +} | |
| 0 | 39 | \ No newline at end of file | ... | ... |
src/components/swiper3dCom/swiper3dCom.vue
0 → 100644
| 1 | +<template> | |
| 2 | + <div class="swiper-3d-com" v-if="items && items.length"> | |
| 3 | + | |
| 4 | + <!-- 背景图片 --> | |
| 5 | + <div class="bg-box" v-if="setOptions.bg"> | |
| 6 | + <img :src="setOptions.bg + SIGN.BIG" class="bg-img" /> | |
| 7 | + </div> | |
| 8 | + | |
| 9 | + <!-- 3D轮播 --> | |
| 10 | + <div class="carousel-3d-box"> | |
| 11 | + <carousel-3d :autoplay="setOptions.autoplay" :autoplayTimeout="setOptions.autoplayTimeout" :autoplayHoverPause="setOptions.autoplayHoverPause" :display="setOptions.display" :width="getWidth()" :height="getHeight()" :inverseScaling="1000" :onMainSlideClick="onMainSlideClick"> | |
| 12 | + <slide :index="index" v-for="(item, index) in items" :key="index"> | |
| 13 | + <img :src="item.img" class="img" /> | |
| 14 | + </slide> | |
| 15 | + </carousel-3d> | |
| 16 | + </div> | |
| 17 | + </div> | |
| 18 | +</template> | |
| 19 | + | |
| 20 | +<script> | |
| 21 | + | |
| 22 | + // 引入组件 | |
| 23 | + import { Carousel3d, Slide } from 'vue-carousel-3d'; | |
| 24 | + | |
| 25 | + export default { | |
| 26 | + data: function () { | |
| 27 | + return { | |
| 28 | + setOptions: { | |
| 29 | + bg: null, // 背景图片 | |
| 30 | + display: 3, // 展示数量 | |
| 31 | + autoplay: true, // 自动切换 | |
| 32 | + autoplayTimeout: 5000, // 自动切换时长 | |
| 33 | + autoplayHoverPause: true, // 悬停自动暂停 | |
| 34 | + inverseScaling: 1000 // 反向缩放大小,数字越大缩放比例越大(暂时不使用这个参数,要配合width/height参数共同使用) | |
| 35 | + } | |
| 36 | + } | |
| 37 | + }, | |
| 38 | + props: ["items", "options"], | |
| 39 | + components: { | |
| 40 | + Carousel3d, | |
| 41 | + Slide | |
| 42 | + }, | |
| 43 | + computed: { | |
| 44 | + | |
| 45 | + /** | |
| 46 | + * 计算宽度 | |
| 47 | + */ | |
| 48 | + getWidth() { | |
| 49 | + return () => { | |
| 50 | + return (document.documentElement.clientWidth || document.body.clientWidth) * (760 / 750); | |
| 51 | + } | |
| 52 | + }, | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * 计算高度 | |
| 56 | + */ | |
| 57 | + getHeight() { | |
| 58 | + return () => { | |
| 59 | + return (document.documentElement.clientWidth || document.body.clientWidth) * (290 / 750); | |
| 60 | + } | |
| 61 | + } | |
| 62 | + }, | |
| 63 | + methods: { | |
| 64 | + | |
| 65 | + /** | |
| 66 | + * 合并选项 | |
| 67 | + * @param {Object} options [配置选项] | |
| 68 | + */ | |
| 69 | + mergeOptions(options) { | |
| 70 | + | |
| 71 | + if (typeof options === 'object' && options !== null) { | |
| 72 | + | |
| 73 | + // 合并默认参数 | |
| 74 | + Object.assign(this.setOptions, options); | |
| 75 | + } | |
| 76 | + }, | |
| 77 | + | |
| 78 | + /** | |
| 79 | + * 活动项目点击事件 | |
| 80 | + * @param {Object} item [数据对象] | |
| 81 | + */ | |
| 82 | + onMainSlideClick(item) { | |
| 83 | + this.$emit('onMainSlideClick', item); | |
| 84 | + } | |
| 85 | + }, | |
| 86 | + watch: { | |
| 87 | + | |
| 88 | + /** | |
| 89 | + * 监听options参数变化 | |
| 90 | + */ | |
| 91 | + options(newVal, oldVal) { | |
| 92 | + | |
| 93 | + // 合并选项 | |
| 94 | + this.mergeOptions(newVal); | |
| 95 | + } | |
| 96 | + }, | |
| 97 | + mounted() { | |
| 98 | + | |
| 99 | + this.$nextTick(() => { | |
| 100 | + | |
| 101 | + // 合并选项 | |
| 102 | + this.mergeOptions(this.options); | |
| 103 | + }); | |
| 104 | + } | |
| 105 | + } | |
| 106 | +</script> | |
| 107 | + | |
| 108 | +<!-- Add "scoped" attribute to limit CSS to this component only --> | |
| 109 | +<style rel="stylesheet/less" lang="less" scoped> | |
| 110 | + @import './swiper3dCom'; | |
| 111 | +</style> | ... | ... |
src/pages/optimization2/optimization2.less
src/pages/optimization2/optimization2.vue
| ... | ... | @@ -80,17 +80,16 @@ |
| 80 | 80 | </div> |
| 81 | 81 | </div> |
| 82 | 82 | |
| 83 | - | |
| 84 | - | |
| 85 | 83 | <!-- 热销排行 --> |
| 86 | - <div class="section"> | |
| 84 | + <div class="section hot-box"> | |
| 87 | 85 | |
| 88 | - <!-- 临时,热销排行占位图片 --> | |
| 89 | - <img src="static/img/hot_img.jpg" style="display: block;width: 100%;" /> | |
| 86 | + <!-- 3D轮播 --> | |
| 87 | + <swiper-3d-com @onMainSlideClick="toHotSaleList" | |
| 88 | + :items="swiper3dItems" | |
| 89 | + :options="swiper3dOptions"> | |
| 90 | + </swiper-3d-com> | |
| 90 | 91 | </div> |
| 91 | 92 | |
| 92 | - | |
| 93 | - | |
| 94 | 93 | <!-- 积分商城 --> |
| 95 | 94 | <div class="section shop-list"> |
| 96 | 95 | |
| ... | ... | @@ -155,6 +154,7 @@ |
| 155 | 154 | import countDownCom from "@/components/countDownCom/countDownCom"; |
| 156 | 155 | import goodsItem2 from "@/components/goodsItem_2/goodsItem_2"; |
| 157 | 156 | import iconsCom from "@/components/iconsCom/iconsCom"; |
| 157 | + import swiper3dCom from "@/components/swiper3dCom/swiper3dCom"; | |
| 158 | 158 | import moreCom from "@/components/moreCom/moreCom"; |
| 159 | 159 | import textTitleBox from "@/components/textTitleBox/textTitleBox"; |
| 160 | 160 | import columnListBox from "@/components/columnListBox/columnListBox"; |
| ... | ... | @@ -164,16 +164,15 @@ |
| 164 | 164 | name: 'optimization', |
| 165 | 165 | data () { |
| 166 | 166 | return { |
| 167 | - title: "", // 标题 | |
| 168 | - backs: null, // 后退按钮组 | |
| 169 | - navs: null, // 导航 | |
| 170 | - goodsLists: null, // 折扣专区数据 | |
| 171 | - shopLists: null, // 品质优选 | |
| 172 | - points: null, // 用户积分 | |
| 173 | - likeLists: null, // 猜你喜欢列表 | |
| 174 | - | |
| 175 | - | |
| 176 | - | |
| 167 | + title: "", // 标题 | |
| 168 | + backs: null, // 后退按钮组 | |
| 169 | + navs: null, // 导航 | |
| 170 | + goodsLists: null, // 折扣专区数据 | |
| 171 | + shopLists: null, // 品质优选 | |
| 172 | + swiper3dItems: null, // 3D轮播数据数组 | |
| 173 | + swiper3dOptions: null, // 3D轮播配置选项 | |
| 174 | + points: null, // 用户积分 | |
| 175 | + likeLists: null // 猜你喜欢列表 | |
| 177 | 176 | } |
| 178 | 177 | }, |
| 179 | 178 | components: { |
| ... | ... | @@ -183,6 +182,7 @@ |
| 183 | 182 | countDownCom, |
| 184 | 183 | goodsItem2, |
| 185 | 184 | iconsCom, |
| 185 | + swiper3dCom, | |
| 186 | 186 | moreCom, |
| 187 | 187 | textTitleBox, |
| 188 | 188 | columnListBox, |
| ... | ... | @@ -333,6 +333,24 @@ |
| 333 | 333 | |
| 334 | 334 | |
| 335 | 335 | |
| 336 | + // 临时,3D轮播参数设置 | |
| 337 | + this.$set(this, 'swiper3dItems', [ | |
| 338 | + { | |
| 339 | + img: 'static/img/hot_img_01.png' | |
| 340 | + }, | |
| 341 | + { | |
| 342 | + img: 'static/img/hot_img_01.png' | |
| 343 | + }, | |
| 344 | + { | |
| 345 | + img: 'static/img/hot_img_01.png' | |
| 346 | + } | |
| 347 | + ]); | |
| 348 | + this.$set(this, 'swiper3dOptions', { | |
| 349 | + bg: 'static/img/hot_img_bg.png' | |
| 350 | + }); | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 336 | 354 | // 临时,用户积分数据设置 |
| 337 | 355 | this.$set(this, 'points', { |
| 338 | 356 | key: '我的积分', |
| ... | ... | @@ -574,6 +592,29 @@ |
| 574 | 592 | }, |
| 575 | 593 | |
| 576 | 594 | /** |
| 595 | + * 跳转热销排行列表 | |
| 596 | + * @param {Object} item [通用跳转对象] | |
| 597 | + */ | |
| 598 | + toHotSaleList(item) { | |
| 599 | + | |
| 600 | + | |
| 601 | + console.log('toHotSaleList', item); | |
| 602 | + | |
| 603 | + | |
| 604 | + // 跳转封装 | |
| 605 | + if (typeof this.$parent.navBarJump === 'function') { | |
| 606 | + | |
| 607 | + // 设置跳转参数 | |
| 608 | + let params = { | |
| 609 | + | |
| 610 | + }; | |
| 611 | + | |
| 612 | + // 页面跳转 | |
| 613 | + this.$parent.navBarJump(params); | |
| 614 | + } | |
| 615 | + }, | |
| 616 | + | |
| 617 | + /** | |
| 577 | 618 | * 查看更多积分 |
| 578 | 619 | * @param {Object} item [数据对象] |
| 579 | 620 | */ | ... | ... |
static/img/hot_img.jpg deleted
100644 → 0
37.9 KB
static/img/hot_img_01.png
0 → 100644
79.7 KB
static/img/hot_img_bg.png
0 → 100644
105 KB