92 lines
1.5 KiB
Vue
92 lines
1.5 KiB
Vue
<template>
|
|
<view class="qrcode-page">
|
|
<view v-if="qrcodeUrl" class="qrcode-card">
|
|
<text class="qrcode-title">客服二维码</text>
|
|
<image class="qrcode-image" :src="qrcodeUrl" mode="aspectFit" @click="previewImage"></image>
|
|
<text class="qrcode-tip">长按识别二维码联系客服</text>
|
|
</view>
|
|
<view v-else class="empty-tip">
|
|
<text>暂无客服二维码</text>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import { getQrcode } from '../../utils/api'
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
qrcodeUrl: ''
|
|
}
|
|
},
|
|
onLoad() {
|
|
this.loadQrcode()
|
|
},
|
|
methods: {
|
|
/** 加载客服二维码 */
|
|
async loadQrcode() {
|
|
try {
|
|
const res = await getQrcode()
|
|
this.qrcodeUrl = res?.value || res?.url || ''
|
|
} catch (e) {
|
|
// 静默处理
|
|
}
|
|
},
|
|
/** 预览图片 */
|
|
previewImage() {
|
|
if (!this.qrcodeUrl) return
|
|
uni.previewImage({ urls: [this.qrcodeUrl] })
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.qrcode-page {
|
|
min-height: 100vh;
|
|
background-color: #f5f5f5;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 40rpx;
|
|
}
|
|
|
|
.qrcode-card {
|
|
background-color: #ffffff;
|
|
border-radius: 20rpx;
|
|
padding: 60rpx 40rpx;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
width: 100%;
|
|
}
|
|
|
|
.qrcode-title {
|
|
font-size: 34rpx;
|
|
color: #333333;
|
|
font-weight: bold;
|
|
margin-bottom: 40rpx;
|
|
}
|
|
|
|
.qrcode-image {
|
|
width: 400rpx;
|
|
height: 400rpx;
|
|
margin-bottom: 30rpx;
|
|
}
|
|
|
|
.qrcode-tip {
|
|
font-size: 26rpx;
|
|
color: #999999;
|
|
}
|
|
|
|
.empty-tip {
|
|
text-align: center;
|
|
}
|
|
|
|
.empty-tip text {
|
|
font-size: 28rpx;
|
|
color: #999999;
|
|
}
|
|
</style>
|