將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) { switch (error.response.status) {
case 401: case 401:
// 返回 401 清除token資訊並跳轉到登入頁面 // 返回 401 清除token資訊並跳轉到登入頁面
Cookies.remove('token',{ domain: store.state.domain}) Cookies.remove('token',{ domain: store.state.sso_domain})
Cookies.remove('uid',{ domain: store.state.domain}) Cookies.remove('uid',{ domain: store.state.sso_domain})
store.commit(types.LOGOUT); store.commit(types.LOGOUT);
@ -91,7 +91,7 @@ function refreshToken(response) {
let token = response.headers.authorization let token = response.headers.authorization
if (token) { if (token) {
console.log('change 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 = [ const options = [
{ name: '二维码', icon: 'qrcode', key: 'qrcode' }, { name: '二维码', icon: 'qrcode', key: 'qrcode' },
{ name: '分享連結', icon: 'link', key: 'link' }, { name: '分享連結', icon: 'link', key: 'link' },
{ name: 'Line', icon: 'https://card.'+store.state.domain+'/images/icons/line.png', key: 'line'}, { name: 'Line', icon: 'https://'+store.state.domain+'/images/icons/line.png', key: 'line'},
{ name: 'Facebook', icon: 'https://card.'+store.state.domain+'/images/icons/facebook.png', key: 'fb'} { name: 'Facebook', icon: 'https://'+store.state.domain+'/images/icons/facebook.png', key: 'fb'}
]; ];
const onSelect = (option) => { 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') { if (option.key === 'qrcode') {
showShareQrcode.value = true showShareQrcode.value = true

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

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

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

@ -184,7 +184,7 @@ function genCard(vcard) {
aspectMode: "cover", aspectMode: "cover",
aspectRatio: "4:3", aspectRatio: "4:3",
gravity: "top", 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", type: "box",

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

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

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

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

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

Loading…
Cancel
Save