diff --git a/src/App.vue b/src/App.vue index 3fe423d..c7828ad 100644 --- a/src/App.vue +++ b/src/App.vue @@ -5,6 +5,7 @@ import { nextTick, onMounted, ref } from 'vue' import { WechatAuth } from '@/utils/wechat' import LoginModal from './components/LoginModal.vue' import loginService from './services/loginService' +import { LOCAL_URL_CFROM,LOCAL_URL_CITY_ID } from './constants/common'; // 获取当前URL参数 const urlParams = new URLSearchParams(window.location.search); @@ -12,6 +13,16 @@ const urlParams = new URLSearchParams(window.location.search); const friend_account_id = urlParams.get('friend_account_id'); const accountId = urlParams.get('accountId'); const loginModal = ref(null) // 创建 ref +const cfrom = urlParams.get('from'); +const cityId = urlParams.get('cityId'); +if(cfrom){ + localStorage.setItem(LOCAL_URL_CFROM, cfrom); +} +if(cityId){ + localStorage.setItem(LOCAL_URL_CITY_ID, cityId); +} + + //微信环境 if(WechatAuth.isWechatBrowser()){ diff --git a/src/components/LoginModal.vue b/src/components/LoginModal.vue index 8ce0723..0fb9793 100644 --- a/src/components/LoginModal.vue +++ b/src/components/LoginModal.vue @@ -42,6 +42,7 @@ import api from '../utils/api.js' import { showToast } from 'vant' // 导入Toast组件 import { getBasicConfig } from '@/utils/basicSetting' import PopContent from '@/components/PopContent.vue' // 导入PopContent组件 +import { LOCAL_APP_TOKEN, LOCAL_URL_CFROM } from '../constants/common' // 响应式数据 const isVisible = ref(false) @@ -131,9 +132,10 @@ const handleLogin = async () => { const response = await api.post('/auto/login/mobile', { mobile: mobile.value, code: code.value, + cfrom: localStorage.getItem(LOCAL_URL_CFROM) }) if (response.code === 200 && response.data.Authorization) { - localStorage.setItem('token', response.data.Authorization) + localStorage.setItem(LOCAL_APP_TOKEN, response.data.Authorization) closeModal() if (callback.value) { callback.value() diff --git a/src/constants/common.ts b/src/constants/common.ts new file mode 100644 index 0000000..02a64f5 --- /dev/null +++ b/src/constants/common.ts @@ -0,0 +1,7 @@ +/** + * 公共常量 + */ +// 本地存储 +export const LOCAL_APP_TOKEN = 'token' //系统token +export const LOCAL_URL_CFROM = 'url_cfrom' //跳转来源 +export const LOCAL_URL_CITY_ID = 'url_cityId' //来源城市ID \ No newline at end of file