Browse Source

uniapp端首页标题栏、搜过索背景色不能调用后端提交的背景色的问题

master
Gao xiaosong 4 years ago
parent
commit
acf6b7af07
  1. 229
      pages/home/index.vue

229
pages/home/index.vue

@ -14,14 +14,21 @@
<!-- </view>-->
<!-- </view>-->
<view class="head_box " :style="{ background: bgcolor }" :class="{ active: bgcolor }">
<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>
<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
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>
搜索商品
@ -30,8 +37,19 @@
<image src="@/static/images/qr.png" />
</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>
<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>
<view class="content_box home_content_box">
<!-- 菜单 -->
<Menu :list="menus"></Menu>
@ -56,44 +74,39 @@
<!-- 为您推荐 -->
<PromotionGood :benefit="benefit"></PromotionGood>
</view>
<Coupon-window :coupon-list="couponList" v-if="showCoupon" @checked="couponClose" @close="couponClose">
<Coupon-window
:coupon-list="couponList"
v-if="showCoupon"
@checked="couponClose"
@close="couponClose"
>
</Coupon-window>
</view>
</template>
<script>
import {
mapState,
mapMutations,
mapActions
} from 'vuex';
import GoodList from '@/components/GoodList';
import PromotionGood from '@/components/PromotionGood';
import CouponWindow from '@/components/CouponWindow';
import Menu from '@/components/Menu';
import UniNoticeBar from '@/components/uni-notice-bar/uni-notice-bar'
import Adv from '@/components/sh-adv'
import Groupon from '@/components/sh-groupon.vue'
import { mapState, mapMutations, mapActions } from "vuex";
import GoodList from "@/components/GoodList";
import PromotionGood from "@/components/PromotionGood";
import CouponWindow from "@/components/CouponWindow";
import Menu from "@/components/Menu";
import UniNoticeBar from "@/components/uni-notice-bar/uni-notice-bar";
import Adv from "@/components/sh-adv";
import Groupon from "@/components/sh-groupon.vue";
import Banner from './components/Banner';
import HotCommodity from './components/HotCommodity';
import FirstNewProduct from './components/FirstNewProduct';
import ProductsRecommended from './components/ProductsRecommended';
import Live from './components/Live';
import Banner from "./components/Banner";
import HotCommodity from "./components/HotCommodity";
import FirstNewProduct from "./components/FirstNewProduct";
import ProductsRecommended from "./components/ProductsRecommended";
import Live from "./components/Live";
import {
getHomeData,
getShare
} from '@/api/public';
import cookie from '@/utils/store/cookie';
import {
isWeixin,
handleUrlParam
} from '@/utils/index';
import { getHomeData, getShare } from "@/api/public";
import cookie from "@/utils/store/cookie";
import { isWeixin, handleUrlParam } from "@/utils/index";
const HAS_COUPON_WINDOW = 'has_coupon_window';
const HAS_COUPON_WINDOW = "has_coupon_window";
export default {
name: 'Index',
name: "Index",
components: {
// swiper,
// swiperSlide,
@ -108,7 +121,7 @@
HotCommodity,
FirstNewProduct,
ProductsRecommended,
Live
Live,
},
props: {},
data: function () {
@ -118,12 +131,12 @@
formatMenus: [],
categoryCurrent: 0,
menuNum: 4,
bgcolor: '',
bgColor: '',
bgcolor: "",
bgColor: "",
swiperCurrent: 0, //
webviewId: 0,
showCoupon: false,
logoUrl: '',
logoUrl: "",
banner: [],
menus: [],
combinationList: [],
@ -136,7 +149,7 @@
fastList: [],
bastBanner: [],
bastList: []
bastList: [],
},
likeInfo: [],
live: [],
@ -145,58 +158,58 @@
couponList: [],
swiperOption: {
pagination: {
el: '.swiper-pagination',
clickable: true
el: ".swiper-pagination",
clickable: true,
},
autoplay: {
disableOnInteraction: false,
delay: 2000
delay: 2000,
},
loop: true,
speed: 1000,
observer: true,
observeParents: true
observeParents: true,
},
swiperRoll: {
direction: 'vertical',
direction: "vertical",
autoplay: {
disableOnInteraction: false,
delay: 2000
delay: 2000,
},
loop: true,
speed: 1000,
observer: true,
observeParents: true
observeParents: true,
},
swiperScroll: {
freeMode: true,
freeModeMomentum: false,
slidesPerView: 'auto',
slidesPerView: "auto",
observer: true,
observeParents: true
observeParents: true,
},
swiperBoutique: {
pagination: {
el: '.swiper-pagination',
clickable: true
el: ".swiper-pagination",
clickable: true,
},
autoplay: {
disableOnInteraction: false,
delay: 2000
delay: 2000,
},
loop: true,
speed: 1000,
observer: true,
observeParents: true
observeParents: true,
},
swiperProducts: {
freeMode: true,
freeModeMomentum: false,
slidesPerView: 'auto',
slidesPerView: "auto",
observer: true,
observeParents: true
observeParents: true,
},
bgImage: ''
bgImage: "",
};
},
computed: {
@ -210,31 +223,30 @@
if (this.bgImage) {
style = `${style}background-image:url(${bgImage});`;
}
return style
return style;
},
},
onLoad: function () {
this.getLocation()
this.getLocation();
let that = this;
uni.showLoading({
title: '加载中'
title: "加载中",
});
getHomeData().then(res => {
getHomeData().then((res) => {
that.logoUrl = res.data.logoUrl;
res.data.banner.map(item => item.bgcolor = '')
that.$set(that, 'banner', res.data.banner);
that.$set(that, 'menus', res.data.menus);
that.$set(that, 'roll', res.data.roll);
that.$set(that, 'info', res.data.info);
that.$set(that, 'firstList', res.data.firstList);
that.$set(that, 'bastList', res.data.bastList);
that.$set(that, 'likeInfo', res.data.likeInfo);
that.$set(that, 'live', res.data.liveList);
that.$set(that, 'lovely', res.data.lovely);
that.$set(that, 'benefit', res.data.benefit);
that.$set(that, 'couponList', res.data.couponList);
that.$set(that, 'combinationList', res.data.combinationList);
res.data.banner.map((item) => (item.bgcolor = item.color || ""));
that.$set(that, "banner", res.data.banner);
that.$set(that, "menus", res.data.menus);
that.$set(that, "roll", res.data.roll);
that.$set(that, "info", res.data.info);
that.$set(that, "firstList", res.data.firstList);
that.$set(that, "bastList", res.data.bastList);
that.$set(that, "likeInfo", res.data.likeInfo);
that.$set(that, "live", res.data.liveList);
that.$set(that, "lovely", res.data.lovely);
that.$set(that, "benefit", res.data.benefit);
that.$set(that, "couponList", res.data.couponList);
that.$set(that, "combinationList", res.data.combinationList);
uni.hideLoading();
that.setOpenShare();
// that.doColorThief()
@ -246,104 +258,102 @@
return {
title: this.miniHomeRemark,
imageUrl: this.miniHomeImg,
path: "pages/home/index?spread=" + uni.getStorageSync("uid")
}
path: "pages/home/index?spread=" + uni.getStorageSync("uid"),
};
},
onShareAppMessage: function () {
return {
title: this.miniHomeRemark,
imageUrl: this.miniHomeImg,
path: "pages/home/index?spread=" + uni.getStorageSync("uid")
}
path: "pages/home/index?spread=" + uni.getStorageSync("uid"),
};
},
goRoll(item) {
if (item.uniapp_url) {
this.$yrouter.push(item.uniapp_url)
this.$yrouter.push(item.uniapp_url);
}
},
goGoodSearch() {
// this.$yrouter.push('/pages/shop/GoodsEvaluate/index');
this.$yrouter.push('/pages/shop/GoodSearch/index');
this.$yrouter.push("/pages/shop/GoodSearch/index");
},
goWxappUrl(item) {
this.$yrouter.push(item.uniapp_url);
},
goHotNewGoods(type) {
this.$yrouter.push({
path: '/pages/shop/HotNewGoods/index',
path: "/pages/shop/HotNewGoods/index",
query: {
type
}
type,
},
});
},
goGoodsCon(item) {
this.$yrouter.push({
path: '/pages/shop/GoodsCon/index',
path: "/pages/shop/GoodsCon/index",
query: {
id: item.id
}
id: item.id,
},
});
},
goGoodsPromotion() {
this.$yrouter.push('/pages/shop/GoodsPromotion/index');
this.$yrouter.push("/pages/shop/GoodsPromotion/index");
},
setOpenShare: function () {
if (this.$deviceType == 'weixin') {
getShare().then(res => {
if (this.$deviceType == "weixin") {
getShare().then((res) => {
var data = res.data.data;
var configAppMessage = {
desc: data.synopsis,
title: data.title,
link: location.href,
imgUrl: data.img
imgUrl: data.img,
};
this.openShareAll(configAppMessage);
})
});
}
},
startQr: function () {
uni.scanCode({
success: (res) => {
let option = handleUrlParam(res.result)
let option = handleUrlParam(res.result);
switch (option.pageType) {
case 'good':
case "good":
//
this.$yrouter.push({
path: '/pages/shop/GoodsCon/index',
path: "/pages/shop/GoodsCon/index",
query: {
q: res.result
}
q: res.result,
},
});
break;
case 'group':
case "group":
//
this.$yrouter.push({
path: '/pages/activity/GroupRule/index',
path: "/pages/activity/GroupRule/index",
query: {
q: res.result
}
q: res.result,
},
});
break;
case 'dargain':
case "dargain":
//
this.$yrouter.push({
path: '/pages/activity/DargainDetails/index',
path: "/pages/activity/DargainDetails/index",
query: {
q: res.result
}
q: res.result,
},
});
break;
default:
//
this.$yrouter.push({
path: '/pages/Loading/index',
query: {
}
path: "/pages/Loading/index",
query: {},
});
break;
}
}
},
});
},
getbgcolor(e) {
@ -384,7 +394,7 @@
box-shadow: 0 0 20rpx -10rpx #aaa;
& + .fixed-header-box {
height: 98rpx
height: 98rpx;
}
}
@ -421,7 +431,6 @@
// width: 100%;
// padding: 0 30rpx;
// box-sizing: border-box;
}
}

Loading…
Cancel
Save