diff --git a/demo.js b/demo.js new file mode 100644 index 0000000..5ccae8f --- /dev/null +++ b/demo.js @@ -0,0 +1,42 @@ +const url = 'https://gateway.dev.cdlsxd.cn/h5/?param=activity-swtest#/' + +function getUrlPathName() { + // const url = window.location.href + let code = 'activity' + if (url.indexOf('#/') !== -1) { + let strR = '' + const str = + url.indexOf('#/') !== -1 ? url.split('#/')[1] : url.split('/')[url.split('/').length - 1] + if (str.indexOf('/') === -1) { + strR = str || '' + } else { + strR = str.split('/')[0] + } + if (strR.indexOf('-') === -1) { + code = 'activity' + } else { + code = strR.split('-')[0] + strR = strR.split('-')[1] + } + return { codeS: code, activity_code: strR } + } else if (url.indexOf('?') !== -1) { + let strR = '' + strR = url.split('=')[1] + code = strR.split('-')[0] + return { codeS: code, activity_code: strR.split('-')[1] } + } else { + const str = url.split('/') + const strP = str[str.length - 1] + let strR = '' + if (strP.indexOf('-') === -1) { + strR = strP + code = 'activity' + } else { + code = strP.split('-')[0] + strR = strP.split('-')[1] + } + return { codeS: code, activity_code: strR } + } +} + +console.log(getUrlPathName(url)) diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index aedd831..2f76592 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -49,6 +49,7 @@ const srcList = reactive({ title: '', }) const { MODE } = useEnv() +console.log('----mode', MODE) const urlPath: any = MODE === 'production' ? getUrlPathNameProd() : getUrlPathName() console.log('.....urlPath', urlPath) activityCode.value = urlPath.activity_code