You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

580 lines
14 KiB

<template>
5 years ago
<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="[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 }">
5 years ago
<view @click="goGoodSearch()" class="search acea-row row-middle">
<text class="iconfont icon-xiazai5"></text>
搜索商品
</view>
<view class="qr" @click="startQr()">
<image src="@/static/images/qr.png" />
</view>
5 years ago
</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>
5 years ago
</view>
</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>
5 years ago
<view class="wrapper hot" v-if="bastList.length > 0">
<image class="bg" src="../../static/images/index-bg.png" mode="widthFix"></image>
<view class="title no-border acea-row row-between-wrapper">
<div class="text line1">
<span class="iconfont icon-remen"></span>
<span class="label">热门榜单</span>
</div>
- (2020/04/12) [+] 小程序首页 热门榜单 首发新品 标题有遮挡 - (2020/04/12) [+] 首页榜单进去提示登陆,页面空白:,还有这种总数操作也会就跳转到授权页面,应该是又问题的这快 - (2020/04/12) [+] 全部商品,右边有错误截图如下 - (2020/04/12) [+] 秒杀列表数据不显示;公众号15点的就有数据,但是小程序没有 - (2020/04/12) [+] 7、砍价可以改下,看下最新H5代码,首次进来不自动砍价,自己点击才砍价一次,而且里面详情是乱的 - (2020/04/12) [+] 为啥我也没退出,就取截个图,再进来,点击商品详情,又让登陆,登陆失效怎么这么快,mpvue小程序就没这个问题,这个问题非常严重,一会让让跳转到授权页面登陆!! - (2020/04/12) [+] 1、商品购买选择规格,这个开始进去点可以,点到后面花色的规格点不动了 - (2020/04/12) [+] 2、拼团客服隐藏掉,下面按钮太那个了,把商品详情那个收藏功能放进来,他们收藏功能都是一样的 - (2020/04/12) [+] 商品详情海报一直海报生成中 - (2020/04/12) [+] 砍价弹窗修改 - (2020/04/11) [+] 1、购买选择规格属性点不了 - (2020/04/11) [+] 12、拼团详情客服功能隐藏去掉,其他地方有客服功能的都去掉 - (2020/04/11) [+] 11、分类点击 会分类Tab页分类一级比一级低 - (2020/04/11) [+] 10、我的推广,里面样式有问题,点击海报里面空白 - (2020/04/11) [+] 9、小程序订单核销没上 你那边先根据路径判断隐藏下 - (2020/04/11) [+] 8、订单点击评价没反应 - (2020/04/11) [+] 6、个人中心我的余额点进去点击账单记录一直正在加载中,点击下全部就出来了,应该你没带默认参数 - (2020/04/11) [+] 5、添加地址选择地区无效 - (2020/04/11) [+] 4、待收货 列表查看物流点击没反应,详情查看物流可以点 - (2020/04/11) [+] 3、下单点击积分抵扣没反应 - (2020/04/11) [+] 2、购物车列表点击管理 点击收藏功能去掉
5 years ago
<view @click="goHotNewGoods(2)" class="more">
5 years ago
更多
<text class="iconfont icon-jiantou"></text>
</view>
</view>
<view class="newProducts">
<scroll-view :show-scrollbar="false" scroll-y="false" scroll-x="true">
5 years ago
<view class="newProductsScroll">
<view @click="goGoodsCon(item)" class="newProductsItem" v-for="(item, likeInfoIndex) in likeInfo" :key="likeInfoIndex">
<view class="img-box">
<image :src="item.image" />
</view>
- (2020/04/12) [+] 小程序首页 热门榜单 首发新品 标题有遮挡 - (2020/04/12) [+] 首页榜单进去提示登陆,页面空白:,还有这种总数操作也会就跳转到授权页面,应该是又问题的这快 - (2020/04/12) [+] 全部商品,右边有错误截图如下 - (2020/04/12) [+] 秒杀列表数据不显示;公众号15点的就有数据,但是小程序没有 - (2020/04/12) [+] 7、砍价可以改下,看下最新H5代码,首次进来不自动砍价,自己点击才砍价一次,而且里面详情是乱的 - (2020/04/12) [+] 为啥我也没退出,就取截个图,再进来,点击商品详情,又让登陆,登陆失效怎么这么快,mpvue小程序就没这个问题,这个问题非常严重,一会让让跳转到授权页面登陆!! - (2020/04/12) [+] 1、商品购买选择规格,这个开始进去点可以,点到后面花色的规格点不动了 - (2020/04/12) [+] 2、拼团客服隐藏掉,下面按钮太那个了,把商品详情那个收藏功能放进来,他们收藏功能都是一样的 - (2020/04/12) [+] 商品详情海报一直海报生成中 - (2020/04/12) [+] 砍价弹窗修改 - (2020/04/11) [+] 1、购买选择规格属性点不了 - (2020/04/11) [+] 12、拼团详情客服功能隐藏去掉,其他地方有客服功能的都去掉 - (2020/04/11) [+] 11、分类点击 会分类Tab页分类一级比一级低 - (2020/04/11) [+] 10、我的推广,里面样式有问题,点击海报里面空白 - (2020/04/11) [+] 9、小程序订单核销没上 你那边先根据路径判断隐藏下 - (2020/04/11) [+] 8、订单点击评价没反应 - (2020/04/11) [+] 6、个人中心我的余额点进去点击账单记录一直正在加载中,点击下全部就出来了,应该你没带默认参数 - (2020/04/11) [+] 5、添加地址选择地区无效 - (2020/04/11) [+] 4、待收货 列表查看物流点击没反应,详情查看物流可以点 - (2020/04/11) [+] 3、下单点击积分抵扣没反应 - (2020/04/11) [+] 2、购物车列表点击管理 点击收藏功能去掉
5 years ago
<view class="pro-info line1"><text>{{ item.storeName }}</text></view>
<view class="money font-color-red"><text>{{ item.price }}</text></view>
5 years ago
</view>
</view>
</scroll-view>
</view>
</view>
<view class="wrapper" v-if="bastList.length > 0">
<view class="title no-border acea-row row-between-wrapper">
<view class="text">
<div class="name line1">
<span class="iconfont icon-jingpintuijian"></span>
<span class="label">精品推荐</span>
</div>
</view>
5 years ago
<view @click="goHotNewGoods(1)" class="more">
更多
<text class="iconfont icon-jiantou"></text>
</view>
</view>
<Good-list :good-list="bastList" :is-sort="false"></Good-list>
</view>
5 years ago
<view class="wrapper" v-if="firstList.length > 0">
<view class="title acea-row row-between-wrapper">
<view class="text">
<view class="name line1">
<span class="iconfont icon-xinpin"></span>
<span class="label">首发新品</span>
5 years ago
</view>
</view>
<view @click="goHotNewGoods(3)" class="more">
更多
<text class="iconfont icon-jiantou"></text>
</view>
</view>
<view class="newProducts">
<scroll-view :show-scrollbar="false" scroll-y="false" scroll-x="true">
5 years ago
<view class="newProductsScroll">
<view @click="goGoodsCon(item)" class="newProductsItem" v-for="(item, firstListIndex) in firstList" :key="firstListIndex">
<view class="img-box">
<image :src="item.image" />
</view>
5 years ago
<view class="pro-info line1">{{ item.storeName }}</view>
<view class="money font-color-red">{{ item.price }}</view>
</view>
</view>
</scroll-view>
</view>
</view>
<view class="wrapper" v-if="benefit.length > 0">
5 years ago
<view class="title acea-row row-center">
<view class="text text-center">
<div class="name line1 new-name">
<span class="iconfont icon-shoucang"></span>
<span class="txt">猜你喜欢</span>
</div>
</view>
5 years ago
<!-- <view @click="goGoodsPromotion(4)" class="more">
5 years ago
更多
<text class="iconfont icon-jiantou"></text>
5 years ago
</view> -->
5 years ago
</view>
</view>
<PromotionGood :benefit="benefit"></PromotionGood>
<Coupon-window :coupon-list="couponList" v-if="showCoupon" @checked="couponClose" @close="couponClose"></Coupon-window>
</view>
</template>
<script>
import colorThief from 'miniapp-color-thief';
// import { swiper, swiperSlide } from "vue-awesome-swiper";
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 {
getHomeData,
getShare
} from '@/api/public';
import cookie from '@/utils/store/cookie';
import {
isWeixin,
handleUrlParam
} from '@/utils/index';
const HAS_COUPON_WINDOW = 'has_coupon_window';
export default {
name: 'Index',
components: {
// swiper,
// swiperSlide,
5 years ago
uniNoticeBar,
GoodList,
PromotionGood,
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: [],
menus: [],
roll: [],
activity: [],
activityOne: {},
bastList: [],
firstList: [],
info: {
fastList: [],
bastBanner: [],
bastList: []
5 years ago
},
likeInfo: [],
lovely: [],
benefit: [],
couponList: [],
swiperOption: {
pagination: {
el: '.swiper-pagination',
clickable: true
},
autoplay: {
disableOnInteraction: false,
delay: 2000
},
loop: true,
speed: 1000,
observer: true,
observeParents: true
5 years ago
},
swiperRoll: {
direction: 'vertical',
autoplay: {
disableOnInteraction: false,
delay: 2000
},
loop: true,
speed: 1000,
observer: true,
observeParents: true
5 years ago
},
swiperScroll: {
freeMode: true,
freeModeMomentum: false,
slidesPerView: 'auto',
observer: true,
observeParents: true
5 years ago
},
swiperBoutique: {
pagination: {
el: '.swiper-pagination',
clickable: true
},
autoplay: {
disableOnInteraction: false,
delay: 2000
},
loop: true,
speed: 1000,
observer: true,
observeParents: true
5 years ago
},
swiperProducts: {
freeMode: true,
freeModeMomentum: false,
slidesPerView: 'auto',
observer: true,
observeParents: true
}
};
5 years ago
},
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()
let that = this;
uni.showLoading({
title: '加载中'
5 years ago
});
getHomeData().then(res => {
that.logoUrl = res.data.logoUrl;
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, 'lovely', res.data.lovely);
that.$set(that, 'benefit', res.data.benefit);
that.$set(that, 'couponList', res.data.couponList);
uni.hideLoading();
that.setOpenShare();
that.doColorThief()
5 years ago
});
},
methods: {
...mapActions(["getLocation"]),
goRoll(item) {
if (item.uniapp_url) {
this.$yrouter.push(item.uniapp_url)
}
},
goGoodSearch() {
// this.$yrouter.push('/pages/shop/GoodsEvaluate/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',
query: {
type
}
});
},
goGoodsCon(item) {
this.$yrouter.push({
path: '/pages/shop/GoodsCon/index',
query: {
id: item.id
}
});
},
goGoodsPromotion() {
this.$yrouter.push('/pages/shop/GoodsPromotion/index');
},
setOpenShare: function() {
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
};
this.openShareAll(configAppMessage);
})
}
},
startQr: function() {
uni.scanCode({
success: (res) => {
let option = handleUrlParam(res.result)
switch (option.pageType) {
case 'good':
// 跳转商品详情
this.$yrouter.push({
path: '/pages/shop/GoodsCon/index',
query: {
q: res.result
}
});
break;
case 'group':
// 跳转团购
this.$yrouter.push({
path: '/pages/activity/GroupRule/index',
query: {
q: res.result
}
});
break;
case 'dargain':
// 跳转砍价
this.$yrouter.push({
path: '/pages/activity/DargainDetails/index',
query: {
q: res.result
}
});
break;
default:
// 跳转分销
this.$yrouter.push({
path: '/pages/Loading/index',
query: {
}
});
break;
}
}
});
},
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">
.index {
background-color: #fff;
}
.swiper-item {
height: 100%;
}
.fixed-header {
position: fixed;
z-index: 99;
// #ifdef H5
top: 88rpx;
// #endif
// #ifndef H5
top: 0;
// #endif
left: 0;
right: 0;
background: #fff;
box-shadow: 0 0 20rpx -10rpx #aaa;
&+.fixed-header-box {
height: 98rpx
}
}
.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>