|
@@ -7,12 +7,13 @@ import {
|
|
|
processMethod,
|
|
|
registerAccountMethod,
|
|
|
registerFieldsMethod,
|
|
|
- searchAccountMethod,
|
|
|
+ scanAccountMethod, searchAccountMethod,
|
|
|
} from '@/request/api';
|
|
|
|
|
|
import { useVisitor } from '@/stores';
|
|
|
+import { useRouteQuery } from '@vueuse/router';
|
|
|
|
|
|
-import { useCaptcha, useForm, useRequest } from 'alova/client';
|
|
|
+import { useCaptcha, useForm, useRequest, useWatcher } from 'alova/client';
|
|
|
|
|
|
import type { FieldRule, FormInstance, NumberKeyboardProps, PasswordInputProps } from 'vant';
|
|
|
import { RadioGroup as vanRadioGroup } from 'vant';
|
|
@@ -222,6 +223,37 @@ function fix(key: FieldKey) {
|
|
|
if (field.keyboard?.show && field.name !== key ) field.keyboard.show = false;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+const scan = useRouteQuery<string>('scan');
|
|
|
+useWatcher(
|
|
|
+ () => scanAccountMethod(sessionStorage.getItem(`scan_${ scan.value }`)!),
|
|
|
+ [ scan ],
|
|
|
+ {
|
|
|
+ immediate: true,
|
|
|
+ async middleware(_, next) {
|
|
|
+ if ( _.method.config.params?.scanCode ) {
|
|
|
+ let scanToastRef: any;
|
|
|
+ try {
|
|
|
+ scanToastRef = Toast.loading(100, { message: '加载中' });
|
|
|
+ await next();
|
|
|
+ } catch ( error ) {} finally {
|
|
|
+ scanToastRef?.close?.();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ console.log('12->', _);
|
|
|
+ },
|
|
|
+ },
|
|
|
+).onSuccess(({ data }) => {
|
|
|
+ Toast.success('扫码成功');
|
|
|
+ modelRef.value = { ...modelRef.value, ...data };
|
|
|
+});
|
|
|
+
|
|
|
+onBeforeUnmount(() => {
|
|
|
+ for ( let i = 0; i < sessionStorage.length; i++ ) {
|
|
|
+ const key = sessionStorage.key(i);
|
|
|
+ if ( key?.startsWith('scan_') ) sessionStorage.removeItem(key);
|
|
|
+ }
|
|
|
+});
|
|
|
</script>
|
|
|
<template>
|
|
|
<div>
|