101 lines
1.9 KiB
Vue
101 lines
1.9 KiB
Vue
<template>
|
|
<view class="popup-mask" v-if="visible" @click.self="close">
|
|
<view class="popup-content">
|
|
<view class="popup-title">优惠券二维码</view>
|
|
<view class="qrcode-area">
|
|
<tki-qrcode
|
|
ref="qrcode"
|
|
:val="code"
|
|
:size="400"
|
|
unit="upx"
|
|
:load-make="false"
|
|
:onval="false"
|
|
background="#ffffff"
|
|
foreground="#333333"
|
|
/>
|
|
<text class="coupon-code">{{ code }}</text>
|
|
</view>
|
|
<view class="popup-tip">请将二维码出示给商户扫码核销</view>
|
|
<button class="btn-close" @click="close">关闭</button>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import tkiQrcode from 'tki-qrcode'
|
|
|
|
export default {
|
|
name: 'QrcodePopup',
|
|
components: { tkiQrcode },
|
|
props: {
|
|
visible: { type: Boolean, default: false },
|
|
code: { type: String, default: '' }
|
|
},
|
|
emits: ['close'],
|
|
watch: {
|
|
visible(val) {
|
|
if (val && this.code) {
|
|
this.$nextTick(() => {
|
|
setTimeout(() => {
|
|
this.$refs.qrcode && this.$refs.qrcode._makeCode()
|
|
}, 200)
|
|
})
|
|
}
|
|
}
|
|
},
|
|
methods: {
|
|
close() {
|
|
this.$emit('close')
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.popup-mask {
|
|
position: fixed;
|
|
top: 0; left: 0; right: 0; bottom: 0;
|
|
background: rgba(0, 0, 0, 0.5);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
z-index: 999;
|
|
}
|
|
.popup-content {
|
|
background: #fff;
|
|
border-radius: 24rpx;
|
|
padding: 40rpx;
|
|
width: 560rpx;
|
|
text-align: center;
|
|
}
|
|
.popup-title {
|
|
font-size: 34rpx;
|
|
font-weight: bold;
|
|
color: #333;
|
|
margin-bottom: 30rpx;
|
|
}
|
|
.qrcode-area {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
margin-bottom: 20rpx;
|
|
}
|
|
.coupon-code {
|
|
font-size: 28rpx;
|
|
color: #666;
|
|
margin-top: 16rpx;
|
|
letter-spacing: 4rpx;
|
|
}
|
|
.popup-tip {
|
|
font-size: 24rpx;
|
|
color: #999;
|
|
margin-bottom: 30rpx;
|
|
}
|
|
.btn-close {
|
|
background: #f5f5f5;
|
|
color: #666;
|
|
border-radius: 8rpx;
|
|
font-size: 28rpx;
|
|
}
|
|
</style>
|