main
Wayne Hsu 3 years ago
parent 42da7a4330
commit 8ae0a40805

@ -2,17 +2,17 @@ NODE_ENV = production
VUE_ENV = slash VUE_ENV = slash
VUE_APP_BASE_URL = https://card.h888.fun VUE_APP_BASE_URL = https://card.slash1000.com
VUE_APP_SEND_URL = https://liff.line.me/1657876696-564NGMxy VUE_APP_SEND_URL = https://liff.line.me/1657876696-564NGMxy
VUE_APP_API_URL = https://card.h888.fun/appapi/v1 VUE_APP_API_URL = https://card.slash1000.com/appapi/v1
VUE_APP_SSO_URL = https://sso.h888.fun/api/v1 VUE_APP_SSO_URL = https://sso.slash1000.com/api/v1
VUE_APP_IMAGE_URL = https://card.h888.fun/storage VUE_APP_IMAGE_URL = https://card.slash1000.com/storage
VUE_APP_DOMAIN = h888.fun VUE_APP_DOMAIN = slash1000.com
VUE_APP_LINE_CLINE_ID = 1657876696 VUE_APP_LINE_CLINE_ID = 1657876696

@ -24,6 +24,9 @@ export default {
var res = await getUserInfo(); var res = await getUserInfo();
if (res.code === 200) { if (res.code === 200) {
context.commit("setUserInfo", res.data); context.commit("setUserInfo", res.data);
return true;
}else{
return false;
} }
}, },
async setUserTpl(context, payload) { async setUserTpl(context, payload) {

@ -1,7 +1,7 @@
<template> <template>
<div> <div>
<van-nav-bar <van-nav-bar
title="自製名片" title="商務卡片"
right-text="關閉" right-text="關閉"
@click-right="$router.push('/')" @click-right="$router.push('/')"
/> />

@ -224,8 +224,9 @@ const showNfcQrcode = ref(false);
const imageUrl = ref(process.env.VUE_APP_IMAGE_URL); const imageUrl = ref(process.env.VUE_APP_IMAGE_URL);
const userLevel = { const userLevel = {
0: "未付費", 0: "未付費會員",
1: "已付費", 1: "付費會員",
2: "試用用戶"
}; };
const is_due = ref(false); const is_due = ref(false);
@ -234,7 +235,10 @@ const showPwaInstall = ref(false);
const deferredPrompt = ref(null); const deferredPrompt = ref(null);
onBeforeMount(async () => { onBeforeMount(async () => {
store.dispatch("user/getUserInfo"); let res = await store.dispatch("user/getUserInfo");
if(!res){
router.push('/login')
}
}); });
onMounted(() => { onMounted(() => {
@ -315,7 +319,7 @@ const handleLogout = () => {
}; };
const goShop = () => { const goShop = () => {
window.open("https://shop."+store.state.sso_domain+"/", "_blank"); window.open("https://shop."+store.state.sso_domain+"/m/card", "_blank");
}; };
const handlePwaInstall = () => { const handlePwaInstall = () => {

@ -1,58 +1,75 @@
<template> <template></template>
</template>
<script setup> <script setup>
import axios from 'axios' import axios from "axios";
import Cookies from 'js-cookie' import Cookies from "js-cookie";
import { useRoute , useRouter } from 'vue-router' import { useRoute, useRouter } from "vue-router";
import { useStore } from 'vuex' import { useStore } from "vuex";
import { linelogin } from '@/api/index' import { linelogin } from "@/api/index";
import { Toast } from 'vant' import { Toast } from "vant";
const route = useRoute() const route = useRoute();
const router = useRouter() const router = useRouter();
const store = useStore() const store = useStore();
const code = route.query.code const code = route.query.code;
if (!code) { if (!code) {
router.replace('/login') router.replace("/login");
} else {
const client_id = process.env.VUE_APP_LINE_CLINE_ID;
//domainlocalhost
let redirect_uri = "";
if (store.state.domain.includes("localhost")) {
redirect_uri = "http://" + store.state.domain + ":8080/home/linelogin";
} else { } else {
const client_id = process.env.VUE_APP_LINE_CLINE_ID redirect_uri = "https://" + 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', axios
.post(
"https://api.line.me/oauth2/v2.1/token",
new URLSearchParams({
grant_type: "authorization_code",
code: code, code: code,
redirect_uri: redirect_uri, redirect_uri: redirect_uri,
client_id: client_id, client_id: client_id,
client_secret: '2a7930d6143a00ff421812b942cde200' client_secret: "2a7930d6143a00ff421812b942cde200",
}),{ }),
{
headers: { headers: {
'content-type': 'application/x-www-form-urlencoded' "content-type": "application/x-www-form-urlencoded",
},
} }
}).then(async (response) => { )
let res = await linelogin({token:response.data.id_token}) .then(async (response) => {
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.sso_domain}) Cookies.set("token", res.data.token, {
Cookies.set('uid', res.data.uid,{ expires: 365 ,domain: store.state.sso_domain}) expires: 365,
Toast('登入成功') domain: store.state.sso_domain,
});
Cookies.set("uid", res.data.uid, {
expires: 365,
domain: store.state.sso_domain,
});
Toast("登入成功");
router.push('/') router.push("/");
} else if (res.code == 201) { } else if (res.code == 201) {
sessionStorage.setItem('reg',JSON.stringify(response.data)) sessionStorage.setItem("reg", JSON.stringify(response.data));
router.push('/register') router.push("/register");
} }
}) })
.catch(error =>{ .catch((error) => {
Toast('登入失敗') Toast("登入失敗");
router.push('/login') router.push("/login");
}) });
// let res = await lineLogin(code) // let res = await lineLogin(code)
} }
</script> </script>

@ -185,7 +185,14 @@ 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://' + domain.value + "/home/linelogin";
//domainlocalhost
let redirect_uri = '';
if(domain.value.includes('localhost')){
redirect_uri = 'http://' + domain.value + ":8080/home/linelogin";
}else{
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";

@ -115,7 +115,8 @@ const validatorUrl = (val) => {
}; };
const leaveReg = () => { const leaveReg = () => {
window.location.replace("/error.html"); // window.location.replace("/error.html");
router.push('/login')
}; };
const onCrop = () => { const onCrop = () => {

@ -5,7 +5,7 @@
<van-tabs :lazy-render="true" v-model:active="activeName"> <van-tabs :lazy-render="true" v-model:active="activeName">
<van-tab title="我的名片" name="0"> <van-tab title="我的名片" name="0">
</van-tab> </van-tab>
<van-tab :title="state.card_title" name="1"> <van-tab :title="state.card_title" name="1" v-if="state.showCusCard">
</van-tab> </van-tab>
<van-tab :title="card.title" :name="card.id.toString()" v-for="card of state.vip_card" :key="card.id"> <van-tab :title="card.title" :name="card.id.toString()" v-for="card of state.vip_card" :key="card.id">
</van-tab> </van-tab>
@ -86,7 +86,7 @@ const userInfo = computed(() => {
onMounted(async () => { onMounted(async () => {
await liff.init({ liffId: process.env.VUE_APP_LINE_LIFF_ID }); await liff.init({ liffId: process.env.VUE_APP_LINE_LIFF_ID });
if (userInfo.value.level > 1) { if (userInfo.value.level > 0) {
let vipCardRes = await getVipCard({ userid: Cookies.get('uid') }) let vipCardRes = await getVipCard({ userid: Cookies.get('uid') })
state.value.vip_card = vipCardRes.data state.value.vip_card = vipCardRes.data
} else { } else {
@ -105,6 +105,7 @@ watch(() => userInfo.value.cus_card, function (newVal, oldVal) {
if (userInfo.value.level > 0 && newVal.length > 0) { if (userInfo.value.level > 0 && newVal.length > 0) {
state.value.showCusCard = true state.value.showCusCard = true
} }
}, { immediate: true }) }, { immediate: true })
watch(() => userInfo.value.nc_template, function (newVal, oldVal) { watch(() => userInfo.value.nc_template, function (newVal, oldVal) {
@ -164,6 +165,12 @@ async function showFlex(id) {
} }
} }
const sendEcard = async () => { const sendEcard = async () => {
//user level0
if (userInfo.value.level === 0) {
Toast.fail('請先升級付費會員')
return
}
let isMo = isMobile().any let isMo = isMobile().any
// window.location.href = 'https://liff.line.me/1657876696-564NGMxy?userid=sc63e7880cd0b65&cardid=1' // window.location.href = 'https://liff.line.me/1657876696-564NGMxy?userid=sc63e7880cd0b65&cardid=1'
if(isMo){ if(isMo){

Loading…
Cancel
Save