oil-station/gasStation-uni/pagesHome/QRcode/QRcode.vue

359 lines
7.6 KiB
Vue
Raw Normal View History

2024-08-16 18:26:19 +08:00
<template>
<view class="content">
<view class="container">
2024-09-17 17:43:44 +08:00
<!-- <view class="my-header">
2024-08-16 18:26:19 +08:00
<view class="my-icons" @click="goback"> <uni-icons type="left" color="#ffffff" size="16"></uni-icons>
</view>
<view class="my-text">二维码</view>
<view class="my-icons"></view>
2024-09-17 17:43:44 +08:00
</view> -->
2024-08-16 18:26:19 +08:00
<!-- 顶部区域 -->
2024-09-17 17:43:44 +08:00
<view class="title_">付款码</view>
<view class="size_">结账时请出示</view>
2024-08-16 18:26:19 +08:00
<view class="cen-box">
2024-09-17 17:43:44 +08:00
<!-- <view class="box-top">
2024-08-16 18:26:19 +08:00
请出示此码给加油员
2024-09-17 17:43:44 +08:00
</view> -->
2024-08-16 18:26:19 +08:00
<view class="code-top">
<w-barcode :options="option"></w-barcode>
</view>
<view class="hui-size">
<!-- <text>2023 **** **** 5523</text> -->
<text>{{barCode}}</text>
<text @click="lookNumber">查看数字</text>
</view>
<view class="code-box">
<w-qrcode :options="options"></w-qrcode>
</view>
<view class="dis-size">
2024-09-17 17:43:44 +08:00
<u-icon name="reload" @click="refresh" color="#E02020" size="18"></u-icon>
2024-08-16 18:26:19 +08:00
<!-- <u-count-down :timestamp="timestamp"></u-count-down> -->
<text style="margin-left: 10px;">
2024-09-17 17:43:44 +08:00
{{timestamp}}刷新请勿截屏以免影响正常使用
2024-08-16 18:26:19 +08:00
</text>
</view>
<view class="bottom-box">
2024-09-17 17:43:44 +08:00
<view class="">
<view class="h_siz">储值卡</view>
<view class="">余额42222.00</view>
2024-08-16 18:26:19 +08:00
</view>
2024-09-17 17:43:44 +08:00
<view class="">充值</view>
2024-08-16 18:26:19 +08:00
</view>
</view>
<view class="v-bottom-box">
<u-icon name="warning-fill" size="20px"></u-icon>
<view style="width: 80%;margin-left: 10px;">付款码有效时长60秒切勿截屏使用</view>
</view>
</view>
<u-popup :show="show" :round="10" @close="close" @open="open">
<view class="box-popup">
<view class="popup-top">
<view class="title">请选择用户类型</view>
<view class="hui-size">如果付款失败尝试使用其他方式完成付款</view>
</view>
2024-09-17 17:43:44 +08:00
<view class="bottom-box" v-for="(item,index) in deduction" :key="index"
@click="choosePayMethod(item.value)">
2024-08-16 18:26:19 +08:00
<view style="display: flex;align-items: center;">
<uni-icons type="wallet-filled" color="#2979ff" size="30"></uni-icons>
<view style="margin-left: 10px;">
<view class="">{{item.value}}</view>
<!-- <view style="font-size: 14px; color: #666666;">根据账户自动识别的付款方式</view> -->
</view>
</view>
<view class="">
<u-icon name="arrow-right"></u-icon>
</view>
</view>
<!-- <view class="bottom-box">
<view style="display: flex;align-items: center;">
<uni-icons type="wallet-filled" color="#2979ff" size="30"></uni-icons>
<view style="margin-left: 10px;">
<view class="">囤油卡</view>
<view style="font-size: 14px; color: #666666;">根据账户自动识别的付款方式</view>
</view>
</view>
<view class="">
<u-icon name="arrow-right"></u-icon>
</view>
</view> -->
</view>
</u-popup>
</view>
</template>
<script>
import request from '../../utils/request'
export default {
data() {
return {
timestamp: 60,
title: '',
show: false,
option: {
width: 670, // 宽度 单位rpx
height: 150, // 高度 单位rpx
code: 'E57890543271985', // 生成条形码的值
},
options: {
code: 'https://qm.qq.com/cgi-bin/qm/qr?k=LKqML292dD2WvwQfAJXBUmvgbiB_TZWF&noverify=0', // 生成二维码的值
size: 460, // 460代表生成的二维码的宽高均为460rpx
},
2024-09-17 17:43:44 +08:00
deduction: [{
key: "balance",
value: "储值卡扣款"
},
{
key: "oilStorageCard",
value: "囤油卡扣款"
},
2024-08-16 18:26:19 +08:00
],
2024-09-17 17:43:44 +08:00
value: "储值卡扣款",
barCode: "",
isLook: false,
timer: {},
2024-08-16 18:26:19 +08:00
}
},
onLoad() {
this.getBarCode()
this.getQrCode()
this.countdown()
},
components: {
},
methods: {
// 是否查看数字
2024-09-17 17:43:44 +08:00
lookNumber() {
if (this.isLook) {
this.barCode = this.option.code.slice(0, 4) + " **** **** " + this.option.code.slice(this.option.code
.length - 5, this.option.code.length - 1)
2024-08-16 18:26:19 +08:00
this.isLook = false
2024-09-17 17:43:44 +08:00
} else {
2024-08-16 18:26:19 +08:00
this.barCode = this.option.code.replace(/(.{4})/g, '$1 ')
this.isLook = true
}
},
// 倒计时刷新
2024-09-17 17:43:44 +08:00
countdown() {
2024-08-16 18:26:19 +08:00
let _this = this
_this.timer = setInterval(() => {
2024-09-17 17:43:44 +08:00
// countdown减1
_this.timestamp--;
// 如果倒计时为0清除定时器
if (_this.timestamp === 0) {
2024-08-16 18:26:19 +08:00
_this.getBarCode()
_this.getQrCode()
_this.timestamp = 60
2024-09-17 17:43:44 +08:00
}
2024-08-16 18:26:19 +08:00
}, 1000);
},
// 刷新二维码信息
2024-09-17 17:43:44 +08:00
refresh() {
2024-08-16 18:26:19 +08:00
this.getBarCode()
this.getQrCode()
this.timestamp = 60
},
// 选择扣款方式
2024-09-17 17:43:44 +08:00
choosePayMethod(val) {
2024-08-16 18:26:19 +08:00
this.value = val
this.show = false
},
// 获取条码信息
2024-09-17 17:43:44 +08:00
getBarCode() {
2024-08-16 18:26:19 +08:00
request({
url: 'business/qrCode/createBarCode',
method: 'get',
}).then(res => {
this.option.code = res.data
2024-09-17 17:43:44 +08:00
this.barCode = res.data.slice(0, 4) + " **** **** " + res.data.slice(res.data.length - 5, res
.data.length - 1)
2024-08-16 18:26:19 +08:00
})
},
// 获取二维码信息
2024-09-17 17:43:44 +08:00
getQrCode() {
2024-08-16 18:26:19 +08:00
request({
url: 'business/qrCode/createQrCode',
method: 'get',
}).then(res => {
this.options.code = res.data
})
},
close() {
console.log('弹出层收起');
this.show = false
},
open() {
console.log('弹出层打开');
},
bottomShow() {
this.show = true
},
goback() {
clearInterval(this.timer)
uni.navigateBack()
}
}
}
</script>
<style scoped lang="scss">
.content {
background: #f4f5f6;
}
.container {
width: 100%;
height: 100vh;
box-sizing: border-box;
2024-09-17 17:43:44 +08:00
// padding-top: 88px;
background-color: #ff9655;
2024-08-16 18:26:19 +08:00
}
.my-header {
width: 100%;
height: 88px;
2024-09-17 17:43:44 +08:00
background: #ff9655;
2024-08-16 18:26:19 +08:00
display: flex;
align-items: center;
justify-content: space-between;
color: #ffffff;
box-sizing: border-box;
padding: 0px 15px;
padding-top: 40px;
.my-icons {
width: 20px;
}
position: fixed;
top: 0px;
}
.cen-box {
width: 95%;
background: #ffffff;
box-sizing: border-box;
padding: 15px;
border-radius: 8px;
margin: 10px auto;
}
.box-top {
width: 100%;
box-sizing: border-box;
// padding: 10px 0px;
padding-bottom: 10px;
border-bottom: 1px solid #f4f5f6;
text-align: center;
font-size: 18px;
font-weight: bold;
}
.code-box {
display: flex;
align-items: center;
justify-content: center;
}
.code-top {
margin: 10px auto;
display: flex;
align-items: center;
justify-content: center;
}
.hui-size {
font-size: 14px;
width: 100%;
text-align: center;
color: #666666;
margin-bottom: 20px;
}
.dis-size {
display: flex;
align-items: center;
justify-content: center;
color: #666666;
font-size: 14px;
margin: 20px 0px;
}
.bottom-box {
width: 100%;
border-top: 1px solid #f4f5f6;
box-sizing: border-box;
padding-top: 15px;
display: flex;
align-items: center;
justify-content: space-between;
}
.v-bottom-box {
width: 95%;
border-radius: 8px;
box-sizing: border-box;
padding: 15px 10px;
background: #ffffff;
display: flex;
align-items: center;
justify-content: center;
font-size: 12px;
color: #666666;
margin: 10px auto;
}
.box-popup {
width: 100%;
box-sizing: border-box;
padding: 15px;
background-color: #ffffff;
}
.popup-top {
box-sizing: border-box;
}
.title {
width: 100%;
text-align: center;
font-size: 18px;
font-weight: bold;
color: #000000;
}
.hui-size {
color: #666666;
font-size: 14px;
}
2024-09-17 17:43:44 +08:00
.title_ {
font-size: 16px;
color: #fff;
text-align: center;
}
.size_ {
font-size: 14px;
color: #FFFFFF;
text-align: center;
}
.h_siz {
color: #666666;
}
.x_sz {
font-size: 14px;
color: #333333;
}
2024-08-16 18:26:19 +08:00
</style>