refactor(signature): 优化签名面板功能和界面
- 移除了不必要的弹窗和屏幕方向检测功能 - 调整了签名面板的布局和样式 -优化了签名提交流程,直接跳转到支付页面 - 修复了外部链接页面的标题和安全问题 - 改进了支付页面的加载提示
This commit is contained in:
parent
c8899348a4
commit
d885680be1
@ -1,11 +1,9 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import {VueSignaturePad} from 'vue-signature-pad';
|
import {VueSignaturePad} from 'vue-signature-pad';
|
||||||
import { showToast } from 'vant';
|
import { showToast } from 'vant';
|
||||||
import { onMounted } from 'vue';
|
|
||||||
import {codeAuthStore} from "~/stores-collect-code/auth/index.js";
|
import {codeAuthStore} from "~/stores-collect-code/auth/index.js";
|
||||||
import {signOffline} from "~/api/goods/index.js";
|
import {signOffline} from "~/api/goods/index.js";
|
||||||
import {useI18n} from "vue-i18n";
|
import {useI18n} from "vue-i18n";
|
||||||
|
|
||||||
const {t} = useI18n();
|
const {t} = useI18n();
|
||||||
const {formData,number}=codeAuthStore()
|
const {formData,number}=codeAuthStore()
|
||||||
const signaturePad = ref(null);
|
const signaturePad = ref(null);
|
||||||
@ -14,11 +12,10 @@ definePageMeta({
|
|||||||
});
|
});
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const imgUrl = ref('');
|
const imgUrl = ref('');
|
||||||
const show = ref(false);
|
|
||||||
const goBack = () => {
|
const goBack = () => {
|
||||||
router.back()
|
router.back()
|
||||||
};
|
};
|
||||||
|
|
||||||
const submitSignature = () => {
|
const submitSignature = () => {
|
||||||
if (signaturePad.value?.isEmpty()) {
|
if (signaturePad.value?.isEmpty()) {
|
||||||
showToast(t('collectCode.signature.pleaseSign'));
|
showToast(t('collectCode.signature.pleaseSign'));
|
||||||
@ -26,7 +23,7 @@ const submitSignature = () => {
|
|||||||
}
|
}
|
||||||
const { data } = signaturePad.value?.saveSignature();
|
const { data } = signaturePad.value?.saveSignature();
|
||||||
imgUrl.value = data;
|
imgUrl.value = data;
|
||||||
show.value = true;
|
confirm()
|
||||||
};
|
};
|
||||||
|
|
||||||
const clearSignature = () => {
|
const clearSignature = () => {
|
||||||
@ -67,9 +64,6 @@ const confirm=async ()=>{
|
|||||||
{{ $t('collectCode.signature.confirm') }}
|
{{ $t('collectCode.signature.confirm') }}
|
||||||
</van-button>
|
</van-button>
|
||||||
</div>
|
</div>
|
||||||
<van-dialog v-model:show="show" show-cancel-button @confirm="confirm">
|
|
||||||
<img class="w-300px h-200px" :src="imgUrl" />
|
|
||||||
</van-dialog>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -1,15 +1,19 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
definePageMeta({
|
definePageMeta({
|
||||||
layout: 'default',
|
layout: 'default',
|
||||||
i18n: 'menu.profile',
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const url=route.query.url??''
|
const url=route.query.url??''
|
||||||
|
useHead({
|
||||||
|
title: route.query.title
|
||||||
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<iframe :src="url"></iframe>
|
<iframe sandbox="allow-same-origin allow-scripts allow-forms" :src="url"></iframe>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ const confirmPay=async ()=>{
|
|||||||
message: t('payment.loading'),
|
message: t('payment.loading'),
|
||||||
forbidClick: true,
|
forbidClick: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const res=await createBuyOrder({
|
const res=await createBuyOrder({
|
||||||
buyUid:payment.value.buyUid,
|
buyUid:payment.value.buyUid,
|
||||||
price:payStatus.value===0?payment.value.leftPrice:amount.value,
|
price:payStatus.value===0?payment.value.leftPrice:amount.value,
|
||||||
@ -38,12 +39,6 @@ const confirmPay=async ()=>{
|
|||||||
testReturnEndPoint:'/payment/result'
|
testReturnEndPoint:'/payment/result'
|
||||||
})
|
})
|
||||||
if (res.status===0){
|
if (res.status===0){
|
||||||
/* router.push({
|
|
||||||
path:'/externallinks',
|
|
||||||
query:{
|
|
||||||
url:res.data.checkoutSessionUrl
|
|
||||||
}
|
|
||||||
})*/
|
|
||||||
window.location.href=res.data.checkoutSessionUrl
|
window.location.href=res.data.checkoutSessionUrl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import {showToast} from 'vant';
|
import {showToast,showLoadingToast } from 'vant';
|
||||||
import {onMounted, onUnmounted, ref} from 'vue';
|
import {onMounted, onUnmounted, ref} from 'vue';
|
||||||
import {signOffline, signOnline} from "~/api/goods/index.js";
|
import {signOffline, signOnline} from "~/api/goods/index.js";
|
||||||
import {VueSignaturePad} from "vue-signature-pad";
|
import {VueSignaturePad} from "vue-signature-pad";
|
||||||
@ -10,44 +10,22 @@ const {t:$t} = useI18n()
|
|||||||
definePageMeta({
|
definePageMeta({
|
||||||
layout: ''
|
layout: ''
|
||||||
})
|
})
|
||||||
const { userInfo ,payment} = authStore()
|
const { payment} = authStore()
|
||||||
const signaturePad = ref(null);
|
const signaturePad = ref(null);
|
||||||
const isLandscapeMode = ref(false);
|
|
||||||
|
|
||||||
const checkScreenOrientation = () => {
|
|
||||||
|
|
||||||
const orientation = screen.orientation?.type || window.orientation;
|
|
||||||
if (orientation === 'landscape-primary' || orientation === 'landscape-secondary' ||
|
|
||||||
orientation === 90 || orientation === -90) {
|
|
||||||
isLandscapeMode.value = true;
|
|
||||||
} else {
|
|
||||||
isLandscapeMode.value = false;
|
|
||||||
showToast($t('signature.tips.landscape'));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
|
|
||||||
nextTick(() => {
|
|
||||||
checkScreenOrientation();
|
|
||||||
});
|
|
||||||
window.addEventListener('orientationchange', checkScreenOrientation);
|
|
||||||
screen.orientation?.addEventListener('change', checkScreenOrientation);
|
|
||||||
});
|
|
||||||
onUnmounted(() => {
|
|
||||||
window.removeEventListener('orientationchange', checkScreenOrientation);
|
|
||||||
screen.orientation?.removeEventListener('change', checkScreenOrientation);
|
|
||||||
});
|
|
||||||
const imgUrl = ref('')
|
const imgUrl = ref('')
|
||||||
const show = ref(false)
|
|
||||||
const clearSignature = () => {
|
const clearSignature = () => {
|
||||||
signaturePad.value?.clearSignature();
|
signaturePad.value?.clearSignature();
|
||||||
};
|
};
|
||||||
|
const toast=ref(false)
|
||||||
const submitSignature = () => {
|
const submitSignature = () => {
|
||||||
if (signaturePad.value?.isEmpty()) {
|
if (signaturePad.value?.isEmpty()) {
|
||||||
showToast($t('signature.pleaseSign'));
|
showToast($t('signature.pleaseSign'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
toast.value=showLoadingToast({
|
||||||
|
message: '加载中...',
|
||||||
|
forbidClick: true,
|
||||||
|
});
|
||||||
const { data } = signaturePad.value?.saveSignature(); // 返回 base64 格式的图片数据
|
const { data } = signaturePad.value?.saveSignature(); // 返回 base64 格式的图片数据
|
||||||
imgUrl.value = data;
|
imgUrl.value = data;
|
||||||
confirm()
|
confirm()
|
||||||
@ -59,7 +37,8 @@ const confirm = async () => {
|
|||||||
signImgFileData: imgUrl.value
|
signImgFileData: imgUrl.value
|
||||||
})
|
})
|
||||||
if (res.status===0){
|
if (res.status===0){
|
||||||
router.push('/payment')
|
await router.push('/payment')
|
||||||
|
toast.value?.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const goBack = () => {
|
const goBack = () => {
|
||||||
@ -68,50 +47,28 @@ router.back()
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="signature-container bg-gray ">
|
<div class="signature-container">
|
||||||
<template v-if="isLandscapeMode">
|
<div class="flex flex-col h-100vh px-20px py-20px bg-gray w-100vw">
|
||||||
<div class="signature-content px-10px py-10px">
|
<client-only>
|
||||||
<VueSignaturePad
|
<VueSignaturePad
|
||||||
width="100%"
|
width="100%"
|
||||||
|
height="93%"
|
||||||
class="signature bg-#fff rounded-10px mb-10px"
|
class="signature bg-#fff rounded-10px mb-10px"
|
||||||
ref="signaturePad"
|
ref="signaturePad"
|
||||||
/>
|
/>
|
||||||
<div class="control-buttons justify-evenly">
|
</client-only>
|
||||||
<van-button
|
<div class="flex justify-evenly">
|
||||||
class="control-button"
|
<van-button class="!h-40px mr-15px" type="primary" @click="goBack">
|
||||||
size="mini"
|
{{ $t('collectCode.signature.back') }}
|
||||||
type="primary"
|
</van-button>
|
||||||
@click="goBack"
|
<van-button class="!h-40px" type="warning" @click="clearSignature">
|
||||||
>
|
{{ $t('collectCode.signature.clear') }}
|
||||||
{{ $t('signature.action.back') }}
|
</van-button>
|
||||||
</van-button>
|
<van-button class="!h-40px" type="primary" @click="submitSignature">
|
||||||
<van-button
|
{{ $t('collectCode.signature.confirm') }}
|
||||||
class="control-button"
|
</van-button>
|
||||||
size="mini"
|
|
||||||
type="warning"
|
|
||||||
@click="clearSignature"
|
|
||||||
>
|
|
||||||
{{ $t('signature.action.clear') }}
|
|
||||||
</van-button>
|
|
||||||
<van-button
|
|
||||||
class="control-button"
|
|
||||||
size="mini"
|
|
||||||
type="primary"
|
|
||||||
@click="submitSignature"
|
|
||||||
>
|
|
||||||
{{ $t('signature.action.confirm') }}
|
|
||||||
</van-button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</div>
|
||||||
<template v-else>
|
|
||||||
<div class="orientation-hint">
|
|
||||||
<p>{{$t('signature.tips.landscape')}}</p>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<van-dialog v-model:show="show" class="signature-dialog" show-cancel-button @confirm="confirm">
|
|
||||||
<img class="h-100px" :src="imgUrl"/>
|
|
||||||
</van-dialog>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user