修改页面样式

This commit is contained in:
Gaoxs
2020-09-01 17:55:08 +08:00
parent 12238a98d6
commit eefed9b9a0
13 changed files with 689 additions and 83 deletions

View File

@ -1,6 +1,19 @@
<template>
<view class="index">
<view class="header fixed-header acea-row row-center-wrapper">
<!-- 导航栏 -->
<view class="head_box " :style="{ background: bgcolor }" :class="{ active: bgcolor }">
<view class="cu-custom" :style="[{height:CustomBar+ 'px',}]">
<view class="cu-bar fixed" :style="customStyle" :class="[bgImage!=''?'none-bg text-white bg-img':'',bgColor]">
<view class="action">
<text class="nav-title shopro-selector-rect">{{ info.name || '商城' }}</text>
</view>
<view class="content" :style="[{top:StatusBar + 'px'}]">
</view>
</view>
</view>
</view>
<view class="header header-search acea-row row-center-wrapper" :style="{ background: bgcolor }">
<view @click="goGoodSearch()" class="search acea-row row-middle">
<text class="iconfont icon-xiazai5"></text>
搜索商品
@ -9,48 +22,22 @@
<image src="@/static/images/qr.png" />
</view>
</view>
<view class="fixed-header-box"></view>
<view class="slider-banner banner">
<swiper indicatorDots="true" v-if="banner.length > 0" autoplay circular>
<block v-for="(item, bannerIndex) in banner" :key="bannerIndex">
<swiper-item>
<view @click="goRoll(item)" class="swiper-item">
<image :src="item.pic" />
</view>
</swiper-item>
</block>
</swiper>
</view>
<view class="nav acea-row">
<view @click="goWxappUrl(item)" class="item" v-for="(item, menusIndex) in menus" :key="menusIndex">
<view class="pictrue">
<image :src="item.pic" />
</view>
<view>{{ item.name }}</view>
<view class="banner-swiper-box mb10" v-if="banner.length>0">
<canvas canvas-id="colorThief" class="hide-canvas"></canvas>
<swiper class="banner-carousel shopro-selector-rect" circular @change="swiperChange" :autoplay="true">
<swiper-item v-for="(item, index) in banner" :key="index" class="carousel-item " @tap="routerTo(item.path)">
<image class="swiper-image " :src="item.pic" @click="goRoll(item)" mode="widthFix" lazy-load></image>
</swiper-item>
</swiper>
<view class="banner-swiper-dots">
<text :class="swiperCurrent === index ? 'banner-dot-active' : 'banner-dot'" v-for="(dot, index) in banner.length"
:key="index"></text>
</view>
</view>
<!-- <view class="news acea-row ">
<view class="pictrue" v-if="$VUE_APP_RESOURCES_URL">
<image src="@/static/images/news.png" />
</view>
<view class="swiper-no-swiping new-banner">
<swiper class="swiper-wrapper" v-if="roll.length > 0" :indicator-dots="false" autoplay circular vertical>
<block v-for="(item, rollIndex) in roll" :key="rollIndex">
<swiper-item class="swiper-slide">
<view @click="goRoll(item)" class="swiper-item acea-row row-between-wrapper">
<view class="text acea-row row-between-wrapper">
<view class="label" v-if="item.show === '是'">最新</view>
<view class="newsTitle line1">{{ item.info }}</view>
</view>
<view class="iconfont icon-xiangyou"></view>
</view>
</swiper-item>
</block>
</swiper>
</view>
</view> -->
<!-- <view class="wrapper hot" v-if="likeInfo.length > 0"> -->
</view>
<Menu :list="menus"></Menu>
<uni-notice-bar scrollable="true" @click="goRoll(singNew)" single="true" :speed="10" showIcon="true" :text="singNew.info"></uni-notice-bar>
<view class="wrapper hot" v-if="bastList.length > 0">
<image class="bg" src="../../static/images/index-bg.png" mode="widthFix"></image>
@ -140,6 +127,8 @@
</view>
</template>
<script>
import colorThief from 'miniapp-color-thief';
// import { swiper, swiperSlide } from "vue-awesome-swiper";
import {
mapState,
@ -148,8 +137,9 @@
} from 'vuex';
import GoodList from '@/components/GoodList';
import PromotionGood from '@/components/PromotionGood';
import CouponWindow from '@/components/CouponWindow';
import uniNoticeBar from '@/components/uni-notice-bar/uni-notice-bar.vue'
import CouponWindow from '@/components/CouponWindow';
import Menu from '@/components/Menu';
import uniNoticeBar from '@/components/uni-notice-bar/uni-notice-bar'
import {
getHomeData,
getShare
@ -170,11 +160,21 @@
uniNoticeBar,
GoodList,
PromotionGood,
CouponWindow
CouponWindow,
Menu
},
props: {},
data: function() {
return {
CustomBar: this.CustomBar,
StatusBar: this.StatusBar,
formatMenus: [],
bgcolorAry: [],
categoryCurrent: 0,
menuNum: 5,
bgcolor: '',
swiperCurrent: 0, //轮播下标
webviewId: 0,
showCoupon: false,
logoUrl: '',
banner: [],
@ -252,7 +252,17 @@
computed: {
singNew() {
return this.roll.length > 0 ? this.roll[0] : "你还没添加通知哦!";
}
},
customStyle() {
var bgImage = this.bgImage;
// var style = `height:${this.CustomBar}px;padding-top:${0}px;background: ${this.bgcolor}`;
var style = `height:${this.CustomBar}px;padding-top:${this.StatusBar}px;background: ${this.bgcolor}`;
if (this.bgImage) {
style = `${style}background-image:url(${bgImage});`;
}
return style
},
},
onShow: function() {
this.getLocation()
@ -274,6 +284,7 @@
that.$set(that, 'couponList', res.data.couponList);
uni.hideLoading();
that.setOpenShare();
that.doColorThief()
});
},
methods: {
@ -327,11 +338,6 @@
uni.scanCode({
success: (res) => {
let option = handleUrlParam(res.result)
console.log(option)
// {productId: "19", spread: "21", codeType: "routine"}
// {productId: "19", spread: "21", pageType: "good", codeType: "routine"}
switch (option.pageType) {
case 'good':
// 跳转商品详情
@ -374,8 +380,55 @@
}
});
}
}
},
async doColorThief() {
let that = this;
let bannerItem = this.banner[this.swiperCurrent]
let bgcolorItem = this.bgcolorAry[this.swiperCurrent]
if (!bgcolorItem) {
let ctx = uni.createCanvasContext('colorThief', that);
if (0 === that.webviewId || ctx.webviewId === that.webviewId) {
that.webviewId = ctx.webviewId;
uni.getImageInfo({
src: bannerItem.pic,
success: function(image) {
ctx.drawImage(image.path, 0, 0, image.width, image.height);
ctx.draw(true, function(e) {
uni.canvasGetImageData({
canvasId: 'colorThief',
x: 0,
y: 0,
width: parseInt(image.width),
height: parseInt(image.height),
success(res) {
let bgcolor = colorThief(res.data).color().getHex();
that.bgcolorAry[that.swiperCurrent] = bgcolor
that.getbgcolor(bgcolor)
}
}, );
});
}
});
}
} else {
this.getbgcolor(bgcolorItem)
}
},
swiperChange(e) {
this.swiperCurrent = e.detail.current;
this.doColorThief();
let bgcolor = this.bgcolorAry[this.swiperCurrent];
this.getbgcolor(bgcolor)
},
getbgcolor(e) {
this.bgcolor = e;
},
},
created: async function() {
await this.doColorThief();
},
};
</script>
<style scoped lang="less">
@ -390,7 +443,13 @@
.fixed-header {
position: fixed;
z-index: 99;
// #ifdef H5
top: 88rpx;
// #endif
// #ifndef H5
top: 0;
// #endif
left: 0;
right: 0;
background: #fff;
@ -400,4 +459,121 @@
height: 98rpx
}
}
</style>
.head_box {
position: relative;
z-index: 10;
width: 100%;
// background: #fff;
transition: all linear 0.3s;
/deep/.cuIcon-back {
display: none;
}
.nav-title {
font-size: 38rpx;
font-family: PingFang SC;
font-weight: 500;
color: #fff;
}
}
.hide-canvas {
position: fixed !important;
top: -99999upx;
left: -99999upx;
z-index: -99999;
}
// 轮播
.banner-swiper-box {
background: #fff;
}
.banner-swiper-box,
.banner-carousel {
width: 750rpx;
height: 350upx;
position: relative;
.carousel-item {
width: 100%;
height: 100%;
// padding: 0 28upx;
overflow: hidden;
}
.swiper-image {
width: 100%;
height: 100%;
// border-radius: 10upx;
// background: #ccc;
}
}
.banner-swiper-dots {
display: flex;
position: absolute;
left: 50%;
transform: translateX(-50%);
bottom: 20rpx;
z-index: 66;
.banner-dot {
width: 14rpx;
height: 14rpx;
background: rgba(255, 255, 255, 1);
border-radius: 50%;
margin-right: 10rpx;
}
.banner-dot-active {
width: 14rpx;
height: 14rpx;
background: #a8700d;
border-radius: 50%;
margin-right: 10rpx;
}
}
.cu-bar.fixed {
position: fixed;
width: 100%;
top: 0;
z-index: 1024;
// box-shadow: 0 1upx 6upx rgba(0, 0, 0, 0.1);
}
.cu-bar {
box-sizing: border-box;
.index .header {
height: 64rpx;
// width: 100%;
// padding: 0 30rpx;
// box-sizing: border-box;
}
}
.header-search {
transition: all linear 0.3s;
}
.cu-bar .action {
display: -webkit-box;
display: -webkit-flex;
display: flex;
align-items: center;
height: 100%;
max-height: 100%;
&:first-child {
margin-left: 15px;
font-size: 15px;
}
}
</style>