| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- <template>
- <view class="public_dialog">
- <view class="code_inner">
- <image class="code_img_out" :src="iconUrl.icon_whiteClose" @click="codeHide"></image>
- <image class="code_img" :src="iconUrl.icon_codeBgTop"></image>
- <view class="code_tit">{{ codeInfo.codeInfo }}</view>
- <view class="code_con">
- <image class="qr_code" :src="qrCodeImage"></image>
- </view>
- <view class="code_tip">
- <text class="colorCustom">{{ seconds }}</text>秒后自动刷新二维码
- </view>
- </view>
- </view>
- </template>
- <script lang="ts" setup>
- import { ref, watch, onUnmounted } from 'vue';
- import { REQUEST_CONFIG } from '@/config';
- import { common } from '@/utils';
- import icon from '@/utils/icon';
- const props = defineProps({
- /**二维码信息 */
- codeInfo: {
- type: Object,
- default: () => ({})
- }
- });
- const emit = defineEmits(['codeHide']);
- const iconUrl = ref(icon)
- const seconds = ref(59);
- const qrCodeImage = ref('');
- let timer: any = null;
- const setCode = (data: any) => {
- qrCodeImage.value = `${REQUEST_CONFIG.BASE_URL}api/340/340/createQrCode.do?content=${data}`;
-
- if (timer) {
- clearInterval(timer);
- timer = null;
- }
-
- timer = setInterval(() => {
- if (seconds.value <= 0) {
- seconds.value = 59;
- } else {
- seconds.value--;
- }
- }, 1000);
- };
- const codeHide = () => {
- emit('codeHide');
- };
- watch(
- () => props.codeInfo,
- (newVal) => {
- seconds.value = 59;
- if (timer) {
- clearInterval(timer);
- timer = null;
- }
- if (!common.isEmpty(newVal)) {
- uni.showLoading({
- title: '',
- mask: true
- });
- setCode(newVal.CardNo);
- uni.hideLoading();
- }
- },
- { deep: true, immediate: true }
- );
- onUnmounted(() => {
- if (timer) {
- clearInterval(timer);
- timer = null;
- }
- });
- </script>
- <style lang="scss" scoped>
- .public_dialog {
- background-color: rgba(1, 1, 1, 0.6);
- position: fixed;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- z-index: 2;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .code_inner {
- width: 600upx;
- border-radius: 24upx;
- position: relative;
- background-color: #fff;
- padding-bottom: 50upx;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- }
- .code_img_out {
- width: 24upx;
- height: 24upx;
- position: absolute;
- right: 30upx;
- top: 30upx;
- z-index: 1;
- }
- .code_img {
- width: 100%;
- height: 200upx;
- position: absolute;
- top: 0;
- left: 0;
- }
- .code_tit {
- font-size: 40upx;
- font-weight: 500;
- height: 200upx;
- line-height: 210upx;
- position: relative;
- color: #fff;
- }
- .code_card {
- font-size: 28upx;
- font-family: Arial;
- font-weight: 400;
- color: rgba(255, 255, 255, 1);
- margin: 23upx 0 107upx;
- position: relative;
- }
- .code_subtit {
- font-size: 28upx;
- }
- .code_con {
- margin: 37upx 0 30upx;
- width: 340upx;
- height: 340upx;
- }
- .code_tip {
- font-size: 26upx;
- color: #58AB56;
- }
- .qr_code {
- box-sizing: content-box;
- width: 340upx;
- height: 340upx;
- padding: 10upx 0;
- }
- </style>
|