deming/components/mine/coupon/index.vue

141 lines
3.2 KiB
Vue
Raw Normal View History

2020-07-08 18:14:41 +08:00
<template>
<view class="c-coupon">
2020-07-18 17:43:37 +08:00
<view class="coupon-usable">
<view class="info-type" :style="{ backgroundImage: 'url(' + '/static/image/mine/30.png' + ')', backgroundSize:'contain', backgroundRepeat: 'no-repeat' }">
2020-07-08 18:14:41 +08:00
<div class="wrap_left_top"></div>
2020-07-17 17:34:42 +08:00
{{ couponInfo.type == 2 ? '店铺优惠券' : '平台优惠券' }}
2020-07-08 18:14:41 +08:00
</view>
<view class="coupon-info">
<view class="info-usable">
2020-07-17 17:34:42 +08:00
<view class="price"><span>{{ couponInfo.vouchertemplate_price }}</span></view>
<view class="condition">{{ couponInfo.vouchertemplate_limit }}使用</view>
2020-07-08 18:14:41 +08:00
</view>
2020-07-18 17:43:37 +08:00
<view class="info-store u-line-1">仅限{{ couponInfo.vouchertemplate_storename }}商品使用</view>
2020-07-17 17:34:42 +08:00
<view class="info-integral">兑换积分{{ couponInfo.vouchertemplate_points }}积分</view>
<view class="info-date">有效期{{ couponInfo.vouchertemplate_startdate }}-{{ couponInfo.vouchertemplate_enddate }}</view>
2020-07-08 18:14:41 +08:00
</view>
<view class="coupon-btn">
2020-07-18 17:43:37 +08:00
<text @click="exchangeCoupon">立即兑换</text>
2020-07-08 18:14:41 +08:00
</view>
</view>
</view>
</template>
<script>
/**
* coupon 优惠券
* @description 优惠券组件
* @property {Object} coupon-info 优惠券信息
* @event {Function} exchange 兑换优惠券
*/
export default {
data() {
return {}
},
props: {
status: Number,
couponInfo: Object,
},
2020-07-17 17:34:42 +08:00
created() {
2020-07-18 17:43:37 +08:00
// console.log(this.couponInfo);
2020-07-17 17:34:42 +08:00
},
2020-07-08 18:14:41 +08:00
methods: {
exchange() {
2020-07-17 17:34:42 +08:00
this.$emit('exchange', this.couponInfo.vouchertemplate_id);
},
exchangeCoupon() {
this.$u.api.getCoupon({ id: this.couponInfo.vouchertemplate_id }).then(res => {
this.$u.toast(res.message);
if(res.errCode == 0) {}
})
2020-07-08 18:14:41 +08:00
},
},
};
</script>
<style lang="scss" scoped>
.c-coupon {
position: relative;
z-index: 9;
@mixin coupon-image($url) {
width: 690rpx;
height: 194rpx;
background: url($url) no-repeat left top / contain;
color: #FFFFFF;
.info-type {
width: 150rpx;
height: 30rpx;
line-height: 30rpx;
font-size: 20rpx;
border-radius: 10rpx 0rpx 10rpx 0rpx;
padding-left: 25rpx;
margin-bottom: 6rpx;
}
.coupon-info {
z-index: 10;
position: absolute;
top: 36rpx;
left: 0;
font-weight: 500;
padding-left: 20rpx;
width: 360rpx;
.info-usable{
margin-bottom: 6rpx;
display: flex;
align-items: center;
.price {
margin-right: 16rpx;
font-size: 40rpx;
> span {
font-size: 50rpx;
}
}
.condition {
font-size: 24rpx;
}
}
.info-store{
margin-bottom: 10rpx;
font-size: 22rpx;
}
.info-integral{
margin-bottom: 10rpx;
font-size: 22rpx;
}
.info-date{
font-size: 20rpx;
}
}
.coupon-btn {
z-index: 10;
position: absolute;
right: 60rpx;
top: 50%;
transform: translate(0, -50%);
> text {
font-size: 32rpx;
font-weight: 500;
color: rgba(255,255,255,1);
2020-07-18 17:43:37 +08:00
position: relative;
// 增大按钮点击范围
&::after {
content:"";
position: absolute;
top: -30rpx;
left: -40rpx;
width: 200rpx;
height: 100rpx;
}
2020-07-08 18:14:41 +08:00
}
> image {
width: 122rpx;
height: 122rpx;
}
}
}
.coupon-usable {
@include coupon-image('/static/image/mine/26.png');
}
.coupon-unable {
@include coupon-image('/static/image/mine/27.png');
}
}
</style>