123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- import { ElMessage } from "element-plus";
- let msgBoxInstance: any = null;
- /**
- * [showMessage 统一封装消息]
- *
- * @return {[params]} [return description]
- */
- export const showMessage = (params: {
- type: string;
- message: string;
- icon?: string;
- duration?: number;
- }) => {
- if (msgBoxInstance) {
- msgBoxInstance.close();
- }
- msgBoxInstance = ElMessage(params as any);
- };
- /**
- * [倒计时]
- *
- * @return {[params]} [return description]
- */
- export function startCountdown(
- duration: number,
- onTick?: (args: number) => void,
- onComplete?: () => void
- ) {
- let time = duration;
- const timer = setInterval(() => {
- time--;
- if (typeof onTick === "function") {
- onTick(time);
- }
- if (time <= 0) {
- clearInterval(timer);
- if (typeof onComplete === "function") {
- onComplete();
- }
- }
- }, 1000);
- }
- export const webSiteFlagRelation: Record<string, string> = {
- 'user': '1', // 海外用户
- 'distributor': '2' // 国内分销商
- }
- const webSiteContactRelation: Record<string, string> = {
- 'user': 'email', // 海外用户
- 'distributor': 'mobile' // 国内分销商
- }
- export const webSiteLanguageRelation: Record<string, string> = {
- 'user': 'en', // 海外用户
- 'distributor': 'zh' // 国内分销商
- }
- export const getContactType = () => {
- const config = useRuntimeConfig()
- const contactType = webSiteContactRelation[config.public.appType];
- return contactType;
- }
|