promotion.vue 4.01 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="countdown" v-if="style_setting.count_down_show">
王建威's avatar
王建威 committed
8 9
					<uni-countdown :hour="hour" :minute="minute" :second="second" :showDay="false" backgroundColor="#000" color="#fff"></uni-countdown>
				</text>
王建威's avatar
王建威 committed
10
			</view>
王建威's avatar
王建威 committed
11
			<text class="check_more" @click="$jump(style_setting.more_link)">{{style_setting.more_title}}
王建威's avatar
王建威 committed
12 13 14
				<svg viewBox="64 64 896 896" class="" 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>
			</text>
		</view>
王建威's avatar
王建威 committed
15
		<view class="promo_goods_content">
王建威's avatar
王建威 committed
16 17
			<view class="promo_goods_item" v-for="(item,key) in list" :key="key" @click="$jumpGoodDetail(item.goods_id)"> 
				<image :src="item.default_image || $noGoodsImg"></image>
王建威's avatar
王建威 committed
18 19 20 21 22
				<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
23
			</view>
王建威's avatar
王建威 committed
24
			<view v-if="spaceArray.length" v-for="(item, key) in spaceArray" :key="key+65535" class="promo_goods_item"></view>
王建威's avatar
王建威 committed
25 26 27 28 29
		</view>
	</view>
</template>

<script>
王建威's avatar
王建威 committed
30 31
	import uniCountdown from "@/components/uni-countdown/uni-countdown.vue";
	import moment from 'moment';
王建威's avatar
王建威 committed
32 33 34 35
	export default {
		props: {
			wrapper_props: {
				type: Object
王建威's avatar
王建威 committed
36 37 38 39
			},
			isLogin: {
				type: Number,
				default: 0
王建威's avatar
王建威 committed
40 41 42 43 44 45
			}
		},
		data() {
			return {
				style_setting: this.wrapper_props.style_setting,
				list: this.wrapper_props.goods_list,
王建威's avatar
王建威 committed
46 47 48 49
				hour:0,
				minute: 0,
				second: 0,
				spaceArray: []
王建威's avatar
王建威 committed
50 51 52
			}
		},
		mounted() {
王建威's avatar
王建威 committed
53
			const t = this.style_setting.count_down_type === 1 ? this.wrapper_props.first_end_time : this.style_setting.count_down_time;
王建威's avatar
王建威 committed
54 55
			const now = moment(new Date(), 'YYYY-MM-DD HH:mm:ss').format('x')-0,
				  end = moment(t, 'YYYY-MM-DD HH:mm:ss').format('x')-0,
王建威's avatar
王建威 committed
56 57
				  du = moment.duration(end-now);
			this.hour = du.days()*24+du.hours();
王建威's avatar
王建威 committed
58 59
			this.minute = du.minutes();
			this.second = du.seconds();
王建威's avatar
王建威 committed
60 61 62
			const space = 4 - this.list.length % 4;
			if(space !== 4) {
				this.spaceArray = new Array(space)
王建威's avatar
王建威 committed
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
			}
		},
		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
80
		border-radius: 16rpx;
王建威's avatar
王建威 committed
81 82 83 84 85 86 87
	}
	.flex {
		display: flex;
		justify-content: space-between;
		align-items: center;
		height: 88rpx;
	}
王建威's avatar
王建威 committed
88 89 90 91
	.countdown {
		display: inline-block;
		vertical-align: middle;
	}
王建威's avatar
王建威 committed
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
	.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
110
		padding: 12rpx 0;
王建威's avatar
王建威 committed
111 112 113 114 115 116 117 118 119 120 121
		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
122
		margin-bottom: 14rpx;
王建威's avatar
王建威 committed
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
		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
140 141 142
		.unshow_price {
			font-size: 20rpx;
		}
王建威's avatar
王建威 committed
143 144
	}
</style>