promotion.vue 4.7 KB
Newer Older
王建威's avatar
王建威 committed
1
<template>
王建威's avatar
王建威 committed
2
	<view class="promo_content" :style="[style_setting.bg_show ? {'background-image': 'url('+style_setting.bg_url+')'} : null, {'background-color': style_setting.bg_color}]">
王建威's avatar
王建威 committed
3 4 5 6
		<view class="flex">
			<view>
				<i v-if="style_setting.icon_show" class="promo_icon" :style="{'background-image': 'url('+style_setting.icon_url+')'}"></i>
				<text class="promo_title" :style="{'color': style_setting.title_color, 'font-size': style_setting.title_font*2+'rpx'}">{{style_setting.title}}</text>
王建威's avatar
王建威 committed
7
				<text class="du_start" v-if="this.style_setting.is_not_start">距开始:</text>
王建威's avatar
王建威 committed
8
				<text class="countdown" v-if="style_setting.count_down_show">
王建威's avatar
王建威 committed
9
					<uni-countdown :day="day" :hour="hour" :minute="minute" :second="second" :show-day="day > 0" backgroundColor="#000" color="#fff"></uni-countdown>
王建威's avatar
王建威 committed
10
				</text>
王建威's avatar
王建威 committed
11
			</view>
王建威's avatar
王建威 committed
12
			<text class="check_more" @click="$jump(style_setting.more_link)">{{style_setting.more_title}}
王建威's avatar
王建威 committed
13
				<svg viewBox="64 64 896 896" class="svg" data-icon="right" width="1em" height="1em" fill="currentColor" aria-hidden="true" focusable="false"><path d="M765.7 486.8L314.9 134.7A7.97 7.97 0 0 0 302 141v77.3c0 4.9 2.3 9.6 6.1 12.6l360 281.1-360 281.1c-3.9 3-6.1 7.7-6.1 12.6V883c0 6.7 7.7 10.4 12.9 6.3l450.8-352.1a31.96 31.96 0 0 0 0-50.4z"></path></svg>
王建威's avatar
王建威 committed
14 15
			</text>
		</view>
王建威's avatar
王建威 committed
16
		<view class="promo_goods_content">
郑秀明's avatar
郑秀明 committed
17 18 19 20 21
			<view class="promo_goods_item" v-for="(item,key) in list" :key="key" @click="$jumpGoodDetail(item.goods_id)">
				<view class='img_box'>
					<image :src="item.default_image || $noGoodsImg"></image>
					<view v-if="item.stock<=0" class="stock_title">已售罄</view>
				</view>
王建威's avatar
王建威 committed
22 23 24 25 26
				<view  v-if="isLogin">
					<text class="pro_price">{{item.pro_price}}</text>
					<text class="price">{{item.price}}</text>
				</view>
				<view v-else class="unshow_price">登录显示价格</view>
王建威's avatar
王建威 committed
27
			</view>
王建威's avatar
王建威 committed
28
			<view v-if="spaceArray.length" v-for="(item, key) in spaceArray" :key="key+65535" class="promo_goods_item"></view>
王建威's avatar
王建威 committed
29 30 31 32 33
		</view>
	</view>
</template>

<script>
王建威's avatar
王建威 committed
34 35
	import uniCountdown from "@/components/uni-countdown/uni-countdown.vue";
	import moment from 'moment';
王建威's avatar
王建威 committed
36 37 38 39
	export default {
		props: {
			wrapper_props: {
				type: Object
王建威's avatar
王建威 committed
40 41 42 43
			},
			isLogin: {
				type: Number,
				default: 0
王建威's avatar
王建威 committed
44 45 46 47 48 49
			}
		},
		data() {
			return {
				style_setting: this.wrapper_props.style_setting,
				list: this.wrapper_props.goods_list,
王建威's avatar
王建威 committed
50
				day: 0,
王建威's avatar
王建威 committed
51 52 53 54
				hour:0,
				minute: 0,
				second: 0,
				spaceArray: []
王建威's avatar
王建威 committed
55 56 57
			}
		},
		mounted() {
王建威's avatar
王建威 committed
58 59 60 61 62 63
			const t = this.style_setting.is_not_start ? this.style_setting.count_down_time : (this.style_setting.count_down_type === 1 ? this.wrapper_props.first_end_time : this.style_setting.count_down_time);
			const now = moment(new Date(), 'YYYY-MM-DD HH:mm:ss'),
				  end = moment(t, 'YYYY-MM-DD HH:mm:ss'),
				  du = moment.duration(end-now, 'ms');
			this.day = end.diff(now, 'day');
			this.hour = du.hours();
王建威's avatar
王建威 committed
64 65
			this.minute = du.minutes();
			this.second = du.seconds();
王建威's avatar
王建威 committed
66 67 68
			const space = 4 - this.list.length % 4;
			if(space !== 4) {
				this.spaceArray = new Array(space)
王建威's avatar
王建威 committed
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
			}
		},
		components:{
			uniCountdown
		}
	}
</script>

<style lang="less" scoped>
	.promo_content {
		width: 702rpx;
		border-radius: 16rpx;
		background-repeat: no-repeat;
		background-size: 100% 100%;
		margin: 0 auto;
		padding: 0 24rpx 0 28rpx;
		box-sizing: border-box;
王建威's avatar
王建威 committed
86
		border-radius: 16rpx;
王建威's avatar
王建威 committed
87 88 89 90 91 92 93
	}
	.flex {
		display: flex;
		justify-content: space-between;
		align-items: center;
		height: 88rpx;
	}
王建威's avatar
王建威 committed
94 95 96 97
	.countdown {
		display: inline-block;
		vertical-align: middle;
	}
王建威's avatar
王建威 committed
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
	.promo_icon {
		display: inline-block;
		width: 48rpx;
		height: 48rpx;
		background-size: 100% 100%;
		background-repeat: no-repeat;
		vertical-align: middle;
	}
	.promo_title {
		font-weight: 500;
		vertical-align: middle;
		margin: 0 12rpx;
	}
	.check_more {
		font-size: 22rpx;
		color: rgb(33, 33, 33);
	}
	.promo_goods_content {
王建威's avatar
王建威 committed
116
		padding: 12rpx 0;
王建威's avatar
王建威 committed
117 118 119 120 121 122 123 124 125 126 127
		display: flex;
		justify-content: space-between;
		flex-wrap: wrap;
	}
	.promo_goods_content_after:after {
		content: '';
		flex: auto;
	}
	.promo_goods_item {
		width: 140rpx;
		text-align: center;
王建威's avatar
王建威 committed
128
		margin-bottom: 14rpx;
郑秀明's avatar
郑秀明 committed
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
		.img_box{
			position: relative;
			width: 140rpx;
			height: 140rpx;
			.stock_title{
				position: absolute;
				bottom: 0;
				width: 100%;
				background-color: rgba(0,0,0,0.5);
				height: 30rpx;
				color: #fff;
				font-size: 22rpx;
				line-height: 30rpx;
			}
		}
王建威's avatar
王建威 committed
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
		image {
			width:140rpx;
			height: 140rpx;
		}
		.pro_price {
			color: #c3a070;
			font-size: 24rpx;
			width: 140rpx;
			display: block;
		}
		.price {
			color: #aeaeae;
			font-size: 24rpx;
			text-decoration: line-through;
			width: 140rpx;
			display: block;
		}
王建威's avatar
王建威 committed
161 162 163
		.unshow_price {
			font-size: 20rpx;
		}
王建威's avatar
王建威 committed
164
	}
王建威's avatar
王建威 committed
165 166 167 168 169 170 171 172 173
	.du_start {
		font-size: 20rpx;
		vertical-align: middle;
		margin-right: 4rpx;
	}
	.svg {
		position: relative;
		top: 4rpx;
	}
王建威's avatar
王建威 committed
174
</style>