Dining_Hall/pages/code/index.vue

134 lines
2.9 KiB
Vue

<template>
<page-meta :page-font-size="fontValue+'px'" :root-font-size="fontValue+'px'"></page-meta>
<view class="work-container">
<view class="card-box">
<!-- 标题 -->
<view class="title">出示二维码支付</view>
<!-- 副标题 -->
<view class="subtitle">{{custName}}</view>
<view style="border: 1px dashed #e9a765;width: 90%;margin: 0 auto;"></view>
<!-- 二维码 -->
<ikun-qrcode
class="qr-code"
width="500"
height="500"
unit="rpx"
color="#000000"
:data="qrCodeUrl"
></ikun-qrcode>
<!-- 有效期 -->
<!-- <view class="valid-time">有效时间15分钟</view> -->
<view class="refresh-button">
<button @click="refreshQrCode" class="login-btn cu-btn block bg-blue lg round" style="width: 70%;">刷新二维码</button>
</view>
</view>
</view>
</template>
<script>
import { getOrderQRCodeAPI } from '../../api/index/index'
export default {
data() {
return {
timer:null,
fontValue:uni.getStorageSync('fontSize') || 8,
custName:uni.getStorageSync('custName'),
qrCodeUrl:`xnzn{\"s\":1,\"y\":3,\"p\":\"${uni.getStorageSync('custId')}\",\"t\":\"${uni.getStorageSync('codeTime')}\"}`// 替换为实际的二维码URL
};
},
onLoad() {
this.timer = setInterval(() => {
console.log("codeTime")
this.getOrderQRCodeData()
}, 4000)
},
onUnload() {
clearInterval(this.timer)
this.timer = null;
uni.navigateBack()
},
methods: {
// 获取二维码
async getOrderQRCodeData() {
const res = await getOrderQRCodeAPI({ "custId":uni.getStorageSync('custId') })
uni.setStorageSync("codeTime",res);
this.qrCodeUrl = `xnzn{\"s\":1,\"y\":3,\"p\":\"${uni.getStorageSync('custId')}\",\"t\":\"${uni.getStorageSync('codeTime')}\"}`
// console.log(res, '二维码信息--')
},
refreshQrCode() {
// 模拟刷新二维码
this.getOrderQRCodeData()
}
}
};
</script>
<style scoped>
page {
display: flex;
flex-direction: column;
box-sizing: border-box;
background-color: #F9FBFF;
min-height: 100%;
height: auto;
}
.work-container {
background-color: #FFFFFF;
text-align: center;
height: 94vh;
}
.card-box{
margin: 40rpx;
/* border: 1px solid #000; */
border-radius: 10rpx;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
padding-top: 20rpx;
padding-bottom: 40rpx;
}
.title {
font-size: 44rpx;
color: #333;
margin-bottom: 10px;
font-weight: 600;
}
.subtitle {
font-size: 32rpx;
color: #999;
margin-bottom: 20px;
/* font-weight: 600; */
}
.qr-code {
margin: 0 auto;
margin-bottom: 10px;
padding-top: 20rpx;
}
.valid-time {
font-size: 32rpx;
color: #666;
margin-bottom: 20px;
}
.refresh-button {
width: 100%;
height: auto;
display: flex;
justify-content: center;
}
.login-btn {
width: 100%;
height: 35px;
margin: 0 auto;
margin-left: 30rpx;
margin-right: 30rpx;
background-color: #e97c3d;
}
</style>