| | |
| | | import { ref, reactive } from "vue"; |
| | | import { ElMessageBox, ElMessage, ElLoading } from "element-plus"; |
| | | import { checkSnId } from '@/api/user.js'; |
| | | |
| | | export default () => { |
| | | const $message = ElMessage; |
| | |
| | | text: "Loading", |
| | | background: "rgba(0, 0, 0, 0.7)", |
| | | target: document.body, |
| | | zIndex: 9000, |
| | | // 可以添加更多默认配置 |
| | | }; |
| | | |
| | |
| | | // }; |
| | | } |
| | | |
| | | return { $alert, $confirm, $message, $loading }; |
| | | // 确认用户密码后干某事 |
| | | async function $confirmPwdDo(callback) { |
| | | ElMessageBox.prompt('请输入用户密码', '系统提示', { |
| | | inputType: 'password', |
| | | inputPattern: /^.+$/, |
| | | inputErrorMessage: '密码不能为空', |
| | | }) |
| | | .then(async ({ value: pwd }) => { |
| | | console.log('pwd', pwd, '============='); |
| | | |
| | | // 验证密码 |
| | | let res = await checkSnId(pwd); |
| | | let { code, data } = res; |
| | | let res_pwd = code && data; |
| | | |
| | | if (res_pwd) { |
| | | $message({ |
| | | type: 'success', |
| | | message: '密码正确' |
| | | }); |
| | | } else { |
| | | $message({ |
| | | type: 'error', |
| | | message: '密码错误' |
| | | }); |
| | | return false; |
| | | } |
| | | |
| | | if (callback && typeof callback === 'function') { |
| | | callback(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | return { $alert, $confirm, $message, $loading, $confirmPwdDo }; |
| | | }; |