|
|
|
|
@ -2,23 +2,24 @@
|
|
|
|
|
import Footer from "@/components/Footer.vue";
|
|
|
|
|
import FlexView from "@/components/FlexView.vue";
|
|
|
|
|
|
|
|
|
|
import { ref, watch, computed, nextTick } from "vue";
|
|
|
|
|
import { ref, onMounted , watch, computed, nextTick } from "vue";
|
|
|
|
|
|
|
|
|
|
import { useCardStore } from '@/store/card'
|
|
|
|
|
|
|
|
|
|
import { useRouter } from "vue-router";
|
|
|
|
|
import { useRouter,useRoute } from "vue-router";
|
|
|
|
|
|
|
|
|
|
import axios from "axios";
|
|
|
|
|
import _ from "lodash";
|
|
|
|
|
|
|
|
|
|
import { showToast, showLoadingToast, showSuccessToast, showFailToast } from "vant";
|
|
|
|
|
|
|
|
|
|
import { onMounted } from "vue";
|
|
|
|
|
import { getCusCard, updateCusCard } from "@/api";
|
|
|
|
|
|
|
|
|
|
const URL = window.URL || window.webkitURL;
|
|
|
|
|
|
|
|
|
|
const cardStore = useCardStore();
|
|
|
|
|
|
|
|
|
|
const route = useRoute();
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
|
|
|
|
|
const showNfc = ref(false);
|
|
|
|
|
@ -82,11 +83,25 @@ const defaultTheme = {
|
|
|
|
|
isShow: true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const userid = ref(route.query.user_id || null)
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
if (cardStore.cusCard.cus_card && cardStore.cusCard.cus_card.length > 0) {
|
|
|
|
|
form.value = JSON.parse(cardStore.cusCard.cus_card);
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
|
|
|
|
|
// 判斷query參數是否有userid
|
|
|
|
|
if(userid.value){
|
|
|
|
|
let res = await getCusCard( {userid: userid.value} )
|
|
|
|
|
|
|
|
|
|
if(res.code===200){
|
|
|
|
|
if(res.data.cus_card && res.data.cus_card.length>0){
|
|
|
|
|
form.value = JSON.parse(res.data.cus_card)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
if (cardStore.cusCard.cus_card && cardStore.cusCard.cus_card.length > 0) {
|
|
|
|
|
form.value = JSON.parse(cardStore.cusCard.cus_card);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const sizeColumns = ref([
|
|
|
|
|
@ -355,7 +370,13 @@ const onDescSizeConfirm = ({ selectedOptions }) => {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleSubmit = async () => {
|
|
|
|
|
let user_id = sessionStorage.getItem("uid");
|
|
|
|
|
let user_id;
|
|
|
|
|
|
|
|
|
|
if(!userid.value){
|
|
|
|
|
user_id= sessionStorage.getItem("uid");
|
|
|
|
|
}else{
|
|
|
|
|
user_id = userid.value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
showLoadingToast({
|
|
|
|
|
duration: 0,
|
|
|
|
|
@ -367,31 +388,43 @@ const handleSubmit = async () => {
|
|
|
|
|
card_title: form.value.title,
|
|
|
|
|
show_cus: form.value.showNfc,
|
|
|
|
|
cus_card: JSON.stringify(form.value),
|
|
|
|
|
user_id: user_id,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let res = cardStore.updateCusCard(cusCard);
|
|
|
|
|
|
|
|
|
|
if (res) {
|
|
|
|
|
showSuccessToast("建立成功");
|
|
|
|
|
} else {
|
|
|
|
|
showFailToast("建立失敗");
|
|
|
|
|
if(!userid.value){
|
|
|
|
|
let res = cardStore.updateCusCard(cusCard);
|
|
|
|
|
if (res) {
|
|
|
|
|
showSuccessToast("建立成功");
|
|
|
|
|
} else {
|
|
|
|
|
showFailToast("建立失敗");
|
|
|
|
|
}
|
|
|
|
|
router.push("/card");
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
let res = await updateCusCard(cusCard);
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
showSuccessToast("建立成功");
|
|
|
|
|
} else {
|
|
|
|
|
showFailToast("建立失敗");
|
|
|
|
|
}
|
|
|
|
|
router.push("/auth/getauth");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// let res = await updateCusCard(cusCard);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// if (res.code === 200) {
|
|
|
|
|
// cardStore.cusCard = cusCard;
|
|
|
|
|
// showSuccessToast("建立成功");
|
|
|
|
|
// } else {
|
|
|
|
|
// showToast.fail("建立失敗");
|
|
|
|
|
// }
|
|
|
|
|
router.push("/card");
|
|
|
|
|
const goBack = () => {
|
|
|
|
|
if(!userid.value){
|
|
|
|
|
router.push('/')
|
|
|
|
|
}else{
|
|
|
|
|
router.push('/auth/getauth')
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<div class="edit page">
|
|
|
|
|
<van-nav-bar class="bg-skyBlue py-1" left-arrow @click-left="$router.push('/')">
|
|
|
|
|
<van-nav-bar class="bg-skyBlue py-1" left-arrow @click-left="goBack">
|
|
|
|
|
<template #title>
|
|
|
|
|
<h5 class="text-white mb-1"><strong>商務卡片設定</strong></h5>
|
|
|
|
|
</template>
|
|
|
|
|
@ -425,7 +458,7 @@ const handleSubmit = async () => {
|
|
|
|
|
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
|
|
|
|
allowfullscreen></iframe>
|
|
|
|
|
</van-popup>
|
|
|
|
|
|
|
|
|
|
<van-field v-model="userid" label="會員編號" name="" input-align="right" :placeholder="userid" readonly v-if="userid"/>
|
|
|
|
|
<van-field v-model="form.title" label="標題文字" name="" input-align="right" error-message-align="right"
|
|
|
|
|
placeholder="請輸入您在名片切換時顯示的文字" :rules="[{ required: true, message: '標題文字必填' }]" />
|
|
|
|
|
<van-field label="是否顯示於感應名片" class="longText" input-align="right">
|
|
|
|
|
|