將domain跟sso_domain分開

main
Wayne Hsu 3 years ago
parent c9e2ddd6f8
commit 4de00f1089

@ -69,8 +69,8 @@ instance.interceptors.response.use(
switch (error.response.status) {
case 401:
// 返回 401 清除token資訊並跳轉到登入頁面
Cookies.remove('token',{ domain: store.state.domain})
Cookies.remove('uid',{ domain: store.state.domain})
Cookies.remove('token',{ domain: store.state.sso_domain})
Cookies.remove('uid',{ domain: store.state.sso_domain})
store.commit(types.LOGOUT);
@ -91,7 +91,7 @@ function refreshToken(response) {
let token = response.headers.authorization
if (token) {
console.log('change token')
Cookies.set('token', token , { expires: 365 ,domain: store.state.domain});
Cookies.set('token', token , { expires: 365 ,domain: store.state.sso_domain});
}
}

@ -64,12 +64,12 @@ export default {
const options = [
{ name: '二维码', icon: 'qrcode', key: 'qrcode' },
{ name: '分享連結', icon: 'link', key: 'link' },
{ name: 'Line', icon: 'https://card.'+store.state.domain+'/images/icons/line.png', key: 'line'},
{ name: 'Facebook', icon: 'https://card.'+store.state.domain+'/images/icons/facebook.png', key: 'fb'}
{ name: 'Line', icon: 'https://'+store.state.domain+'/images/icons/line.png', key: 'line'},
{ name: 'Facebook', icon: 'https://'+store.state.domain+'/images/icons/facebook.png', key: 'fb'}
];
const onSelect = (option) => {
let share_url = `https://card.${store.state.domain}/home/?refer=${store.state.user.userInfo.code}`
let share_url = `https://${store.state.domain}/home/?refer=${store.state.user.userInfo.code}`
if (option.key === 'qrcode') {
showShareQrcode.value = true

@ -25,8 +25,11 @@ export default createStore({
setSiteConfig(state, payload) {
state.config = payload;
},
setDomain(state, { domain }){
setDomain(state, domain ){
state.domain = domain
},
setSsoDomain(state, domain){
state.sso_domain = domain
}
},
modules: {

@ -190,7 +190,7 @@ function genCard(vcard) {
contents: [
{
type: "image",
url: "https://card."+store.state.domain+"/images/tpl02_bg.png",
url: "https://"+store.state.domain+"/images/tpl02_bg.png",
size: "full",
aspectMode: "cover",
aspectRatio: "4:3",

@ -180,7 +180,7 @@ function genCard(vcard) {
contents: [
{
type: "image",
url: "https://card."+store.state.domain+"/images/jcibg.png",
url: "https://"+store.state.domain+"/images/jcibg.png",
size: "full",
aspectMode: "fit",
aspectRatio: "4:3",

@ -184,7 +184,7 @@ function genCard(vcard) {
aspectMode: "cover",
aspectRatio: "4:3",
gravity: "top",
url: "https://card."+store.state.domain+"/images/tpl03_bg.png?v=1",
url: "https://"+store.state.domain+"/images/tpl03_bg.png?v=1",
},
{
type: "box",

@ -32,5 +32,6 @@ export async function initStore() {
}else{
domain = hostname;
}
store.commit('setDomain',{domain})
store.commit('setSsoDomain',domain)
store.commit('setDomain',hostname)
}

@ -306,8 +306,8 @@ const bindTggo = () => {
};
const handleLogout = () => {
Cookies.remove("token", { domain: store.state.domain });
Cookies.remove("uid", { domain: store.state.domain });
Cookies.remove("token", { domain: store.state.sso_domain });
Cookies.remove("uid", { domain: store.state.sso_domain });
// if (liff.isLoggedIn()) {
// liff.logout()
// }
@ -315,7 +315,7 @@ const handleLogout = () => {
};
const goShop = () => {
window.open("https://shop."+store.state.domain+"/m/card", "_blank");
window.open("https://"+store.state.domain+"/m/card", "_blank");
};
const handlePwaInstall = () => {

@ -23,7 +23,7 @@ if(!code){
router.replace('/login')
}else{
const client_id = process.env.VUE_APP_LINE_CLINE_ID
const redirect_uri = `https://card.${store.state.domain}/home/linelogin`
const redirect_uri = `https://${store.state.domain}/home/linelogin`
axios.post('https://api.line.me/oauth2/v2.1/token',new URLSearchParams({
grant_type: 'authorization_code',
@ -38,8 +38,8 @@ if(!code){
}).then(async (response) => {
let res = await linelogin({token:response.data.id_token})
if(res.code == 200){
Cookies.set('token', res.data.token,{ expires: 365 ,domain: store.state.domain})
Cookies.set('uid', res.data.uid,{ expires: 365 ,domain: store.state.domain})
Cookies.set('token', res.data.token,{ expires: 365 ,domain: store.state.sso_domain})
Cookies.set('uid', res.data.uid,{ expires: 365 ,domain: store.state.sso_domain})
Toast('登入成功')
router.push('/')

@ -94,6 +94,10 @@ const domain = computed(()=>{
return store.state.domain
});
const sso_domain = computed(()=>{
return store.state.sso_domain
});
const getVerifyMsg = ref("獲取驗證碼");
const showGetVerifyBtn = ref(false);
const countdown = ref(0);
@ -164,14 +168,13 @@ const handleLogin = async () => {
let res = await login(form.value);
if (res.code === 200) {
console.log('login',domain.value)
Cookies.set("token", res.data.token, {
expires: 365,
domain: domain.value,
domain: sso_domain.value,
});
Cookies.set("uid", res.data.uid, {
expires: 365,
domain: domain.value,
domain: sso_domain.value,
});
router.push("/");
}else{
@ -182,7 +185,7 @@ const handleLogin = async () => {
const handleLineLogin = async () => {
// router.push('/')
const client_id = process.env.VUE_APP_LINE_CLINE_ID;
const redirect_uri = 'https://card.' + domain.value + "/home/linelogin";
const redirect_uri = 'https://' + domain.value + "/home/linelogin";
let link = "https://access.line.me/oauth2/v2.1/authorize?";
link = link + "response_type=code";

@ -189,11 +189,11 @@ const onSubmit = async () => {
Toast("註冊成功");
Cookies.set("token", regRes.data.token, {
expires: 365,
domain: store.state.domain,
domain: store.state.sso_domain,
});
Cookies.set("uid", regRes.data.uid, {
expires: 365,
domain: store.state.domain,
domain: store.state.sso_domain,
});
return router.push("/");
} else {

Loading…
Cancel
Save