Browse Source

优化模块名称

zyh
Gaoxs 4 years ago
parent
commit
99fcfdbc5b
  1. 132
      components/colorui/components/cu-custom.vue
  2. 58
      pages/home/components/Banner.vue
  3. 91
      pages/home/index.vue

132
components/colorui/components/cu-custom.vue

@ -1,65 +1,71 @@
<template>
<view>
<view class="cu-custom" :style="[{height:CustomBar + 'px'}]">
<view class="cu-bar fixed" :style="style" :class="[bgImage!=''?'none-bg text-white bg-img':'',bgColor]">
<view class="action" @tap="BackPage" v-if="isBack">
<text class="cuIcon-back"></text>
<slot name="backText"></slot>
</view>
<view class="content" :style="[{top:StatusBar + 'px'}]">
<slot name="content"></slot>
</view>
<slot name="right"></slot>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
StatusBar: this.StatusBar,
CustomBar: this.CustomBar
};
},
name: 'cu-custom',
computed: {
<template>
<view class="cu-custom" :style="[{height:CustomBar + 'px'}]">
<view class="cu-bar fixed" :style="style" :class="[bgImage!=''?'none-bg text-white bg-img':'',bgColor]">
<view class="action" @tap="BackPage" v-if="isBack">
<text class="cuIcon-back"></text>
<slot name="backText"></slot>
</view>
<view class="content" :style="[{top:StatusBar + 'px'}]">
<slot name="content"></slot>
</view>
<slot name="right"></slot>
</view>
</view>
</template>
<script>
export default {
data() {
return {
StatusBar: this.StatusBar,
CustomBar: this.CustomBar
};
},
name: 'cu-custom',
computed: {
style() {
var StatusBar= this.StatusBar;
var CustomBar= this.CustomBar;
var bgImage = this.bgImage;
var style = `height:${CustomBar}px;padding-top:${StatusBar}px;`;
if (this.bgImage) {
style = `${style}background-image:url(${bgImage});`;
}
return style
}
},
props: {
bgColor: {
type: String,
default: ''
},
isBack: {
type: [Boolean, String],
default: false
},
bgImage: {
type: String,
default: ''
},
},
methods: {
BackPage() {
uni.navigateBack({
delta: 1
});
}
}
}
</script>
<style>
console.log(this)
var StatusBar = this.StatusBar;
var CustomBar = this.CustomBar;
var bgImage = this.bgImage;
var style = `height:${CustomBar}px;padding-top:${StatusBar}px;background:${this.bgColor} ;`;
if (this.bgImage) {
style = `${style}background-image:url(${bgImage});`;
}
return style
}
},
props: {
bgColor: {
type: String,
default: ''
},
isBack: {
type: [Boolean, String],
default: false
},
bgImage: {
type: String,
default: ''
},
},
methods: {
BackPage() {
uni.navigateBack({
delta: 1
});
}
}
}
</script>
<style>
.fixed{
position: fixed;
top:0;
left:0;
right:0;
z-index: 99;
}
</style>

58
pages/home/components/Banner.vue

@ -43,34 +43,36 @@
let bgcolor = item.bgcolor;
//
if (bgcolor === '') {
let ctx = uni.createCanvasContext('colorThief', that);
if (0 === that.webviewId || ctx.webviewId === that.webviewId) {
that.webviewId = ctx.webviewId;
uni.getImageInfo({
src: item.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.$set(item, 'bgcolor', bgcolor);
that.$emit('getbgcolor', bgcolor);
}
},
that
);
});
}
});
}
// let ctx = uni.createCanvasContext('colorThief', that);
// if (0 === that.webviewId || ctx.webviewId === that.webviewId) {
// that.webviewId = ctx.webviewId;
// uni.getImageInfo({
// src: item.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.$set(item, 'bgcolor', bgcolor);
// that.$emit('getbgcolor', bgcolor);
// }
// },
// that
// );
// });
// }
// });
// }
that.$set(item, 'bgcolor', '#c40414');
that.$emit('getbgcolor', '#c40414');
} else {
that.$set(item, 'bgcolor', bgcolor);
that.$emit('getbgcolor', bgcolor);

91
pages/home/index.vue

@ -1,26 +1,26 @@
<template>
<view class="index">
<!-- 导航栏 -->
<!-- <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="[bgcolor]">-->
<!-- <view class="action">-->
<!-- <text class="nav-title Shop-selector-rect">{{ 'yshop商城' }}</text>-->
<!-- </view>-->
<!-- <view class="content" :style="[{top:StatusBar + 'px'}]">-->
<!-- <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="[bgcolor]">-->
<!-- <view class="action">-->
<!-- <text class="nav-title Shop-selector-rect">{{ 'yshop商城' }}</text>-->
<!-- </view>-->
<!-- <view class="content" :style="[{top:StatusBar + 'px'}]">-->
<!-- </view>-->
<!-- </view>-->
<!-- </view>-->
<!-- </view>-->
<!-- </view>-->
<!-- </view>-->
<!-- </view>-->
<!-- </view>-->
<view class="head_box " :style="{ background: bgcolor }" :class="{ active: bgcolor }">
<cu-custom :isBack="true" >
<block slot="backText">
<text class="nav-title shopro-selector-rect">{{ 'YSHOP商城' }}</text>
</block>
</cu-custom>
</view>
<view class="head_box " :style="{ background: bgcolor }" :class="{ active: bgcolor }">
<cu-custom :isBack="true" :bgColor="bgcolor">
<block slot="backText">
<text class="nav-title shopro-selector-rect">{{ 'YSHOP商城' }}</text>
</block>
</cu-custom>
</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>
@ -31,8 +31,7 @@
</view>
</view>
<Banner :detail="banner" v-if="banner.length>0" @getbgcolor="getbgcolor"></Banner>
<uni-notice-bar scrollable="true" @click="goRoll(singNew)" single="true" :speed="10" showIcon="true"
:text="singNew.info"></uni-notice-bar>
<uni-notice-bar scrollable="true" @click="goRoll(singNew)" single="true" :speed="10" showIcon="true" :text="singNew.info"></uni-notice-bar>
<view class="content_box home_content_box">
<!-- 菜单 -->
<Menu :list="menus"></Menu>
@ -112,7 +111,7 @@
Live
},
props: {},
data: function () {
data: function() {
return {
CustomBar: this.CustomBar,
StatusBar: this.StatusBar,
@ -215,7 +214,7 @@
},
},
onShow: function () {
onShow: function() {
this.getLocation()
let that = this;
uni.showLoading({
@ -243,14 +242,14 @@
},
methods: {
...mapActions(["getLocation"]),
onShareTimeline: function () {
onShareTimeline: function() {
return {
title: this.miniHomeRemark,
imageUrl: this.miniHomeImg,
path: "pages/home/index?spread=" + uni.getStorageSync("uid")
}
},
onShareAppMessage: function () {
onShareAppMessage: function() {
return {
title: this.miniHomeRemark,
imageUrl: this.miniHomeImg,
@ -288,7 +287,7 @@
goGoodsPromotion() {
this.$yrouter.push('/pages/shop/GoodsPromotion/index');
},
setOpenShare: function () {
setOpenShare: function() {
if (this.$deviceType == 'weixin') {
getShare().then(res => {
var data = res.data.data;
@ -302,7 +301,7 @@
})
}
},
startQr: function () {
startQr: function() {
uni.scanCode({
success: (res) => {
let option = handleUrlParam(res.result)
@ -351,7 +350,7 @@
this.bgcolor = e;
},
},
created: async function () {
created: async function() {
// await this.doColorThief();
},
};
@ -389,22 +388,22 @@
}
}
.head_box {
width: 750rpx;
// background: #fff;
transition: all linear 0.3s;
.head_box {
width: 750rpx;
// background: #fff;
transition: all linear 0.3s;
/deep/.cuIcon-back {
display: none;
}
/deep/.cuIcon-back {
display: none;
}
.nav-title {
font-size: 38rpx;
font-family: PingFang SC;
font-weight: 500;
color: #fff;
}
}
.nav-title {
font-size: 38rpx;
font-family: PingFang SC;
font-weight: 500;
color: #fff;
}
}
.cu-bar.fixed {
position: fixed;
@ -447,4 +446,12 @@
.home_content_box {
margin-top: -10rpx;
}
</style>
.head_box {
}
.nav-title {
margin-left: 20rpx;
line-height: 40px;
}
</style>

Loading…
Cancel
Save