ykt-wxapp/hooks/useInfoCheck.js

24 lines
683 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { storeToRefs } from 'pinia';
import useAccountStore from "@/store/account.js";
import { confirm } from '@/utils/widget';
export default function useInfoCheck() {
const { doctorInfo } = storeToRefs(useAccountStore());
function withInfo(fn) {
return async (...args) => {
if (!doctorInfo.value || !doctorInfo.value.anotherName) {
try {
await confirm('请先完善您的个人信息方可使用该功能', { cancelText: '再等等', confirmText: '去完善' })
} catch {
return;
}
return uni.navigateTo({ url: '/pages/work/profile' });
}
return fn(...args);
}
}
return { withInfo }
}