|
@@ -8,7 +8,12 @@ const router: Router = createRouter({
|
|
|
|
|
|
router.beforeEach(async (_to, _from, next) => {
|
|
router.beforeEach(async (_to, _from, next) => {
|
|
console.log('_to', _to);
|
|
console.log('_to', _to);
|
|
- let wxOpenId = useCookies().get('wxOpenId');
|
|
|
|
|
|
+ const wxOpenId = useCookies().get('wxOpenId');
|
|
|
|
+ if (_to.name == 'feedback' || _to.name == 'feedbacksuccess') {
|
|
|
|
+ document.title = t('feedback.title');
|
|
|
|
+ } else {
|
|
|
|
+ document.title = '四维时代售后';
|
|
|
|
+ }
|
|
if (wxOpenId || _to.name == 'feedback' || _to.name == 'feedbacksuccess' || getUrlKey('code')) {
|
|
if (wxOpenId || _to.name == 'feedback' || _to.name == 'feedbacksuccess' || getUrlKey('code')) {
|
|
next();
|
|
next();
|
|
} else {
|
|
} else {
|
|
@@ -19,19 +24,18 @@ router.beforeEach(async (_to, _from, next) => {
|
|
function getUrlKey(name) {
|
|
function getUrlKey(name) {
|
|
//获取url 参数
|
|
//获取url 参数
|
|
return (
|
|
return (
|
|
- decodeURIComponent(
|
|
|
|
- (new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ''])[1].replace(/\+/g, '%20'),
|
|
|
|
- ) || null
|
|
|
|
|
|
+ decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ''])[1].replace(/\+/g, '%20')) ||
|
|
|
|
+ null
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
function getCodeApi(state) {
|
|
function getCodeApi(state) {
|
|
//获取code
|
|
//获取code
|
|
console.log('getCodeApi');
|
|
console.log('getCodeApi');
|
|
- let urlNow = encodeURIComponent(window.location.href);
|
|
|
|
- let scope = 'snsapi_base'; //snsapi_userinfo //静默授权 用户无感知
|
|
|
|
- let appid = 'wxac3d59ea82d9b82a';
|
|
|
|
- let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${urlNow}&response_type=code&scope=${scope}&state=${state}#wechat_redirect`;
|
|
|
|
|
|
+ const urlNow = encodeURIComponent(window.location.href);
|
|
|
|
+ const scope = 'snsapi_base'; //snsapi_userinfo //静默授权 用户无感知
|
|
|
|
+ const appid = 'wxac3d59ea82d9b82a';
|
|
|
|
+ const url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${urlNow}&response_type=code&scope=${scope}&state=${state}#wechat_redirect`;
|
|
window.location.replace(url);
|
|
window.location.replace(url);
|
|
}
|
|
}
|
|
export default router;
|
|
export default router;
|