Files
2026-09-01 22:15:50 +08:00

76 lines
1.4 KiB
Vue

<template>
<view class="container">
<view v-if="base64" class="cate-img">
<image class="image" mode="scaleToFill" :src="base64"></image>
</view>
<empty v-else :tips="tip" :isLoading="isLoading" />
</view>
</template>
<script>
import * as OrderApi from '@/api/order'
import Empty from '@/components/empty'
export default {
components: {
Empty
},
data() {
return {
// 二维码base64编码
base64: '',
// 正在加载中
isLoading: true,
// 空布局
tip: '未获取到核销码'
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
let id = options.id ? options.id : ''
if(id){
// 获取支付二维码
this.getQrCode(id)
}
},
methods: {
/**
* 获取二维码的base64编码
* @param {string} id
*/
getQrCode(id) {
const app = this
app.isLoading = true
OrderApi.qrCodeImg({orderGoodsId: id})
.then(result => {
app.base64 = result.data.base64
})
.finally(() => app.isLoading = false)
},
}
}
</script>
<style lang="scss" scoped>
.cate-img {
position: relative;
width: 100%;
padding-top: 100%;
.image {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
border-radius: 10rpx;
}
}
</style>