diff --git a/src/api/card.js b/src/api/card.js index 8aadade..c8046e4 100644 --- a/src/api/card.js +++ b/src/api/card.js @@ -2,4 +2,9 @@ import ajax from "./ajax"; export const getCardData = async () => ajax(`/Card/getCardData`); - \ No newline at end of file + +export const updateRemark = async (params) => + ajax(`/card/updateRemark`, params, "POST"); + +export const updateIsSend = async (params) => + ajax(`/card/updateIsSend`, params, "POST"); diff --git a/src/api/index.js b/src/api/index.js index 19a1344..4ddad48 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -100,4 +100,3 @@ export const getUserCateList = async () => export const updateUserCate = async (params) => ajax(`/UserCate/updateUserCate`, params, "POST"); - diff --git a/src/utils/card2.js b/src/utils/card2.js index d61251c..74d93b9 100644 --- a/src/utils/card2.js +++ b/src/utils/card2.js @@ -96,9 +96,9 @@ function genCard1(ctx) { altText: vcard.altText, contents: { type: "carousel", - contents: _.map(vcard.cards, (card, cardIdx) => - renderCard({ ...ctx, card, cardIdx }) - ), + contents: vcard.cards + .filter(card => card.isSend === true) + .map((card, cardIdx) => renderCard({ ...ctx, card, cardIdx })) }, }; } diff --git a/src/views/Card/Edit.vue b/src/views/Card/Edit.vue index cab2447..708f004 100644 --- a/src/views/Card/Edit.vue +++ b/src/views/Card/Edit.vue @@ -2,11 +2,11 @@ import Footer from "@/components/Footer.vue"; import FlexView from "@/components/FlexView.vue"; -import { ref, onMounted , watch, computed, nextTick } from "vue"; +import { ref, onMounted, watch, computed, nextTick } from "vue"; import { useCardStore } from '@/store/card' -import { useRouter,useRoute } from "vue-router"; +import { useRouter, useRoute } from "vue-router"; import axios from "axios"; import _ from "lodash"; @@ -54,6 +54,8 @@ const form = ref({ titleSize: "xl", cards: [ { + isSend: false, + aIsSend: false, bgColor: "#ffffff", desc: "", descColor: "#000000", @@ -80,7 +82,9 @@ const defaultTheme = { descSize: "sm", titleColor: "#000000", ratio: "4:3", - isShow: true + isShow: true, + isSend: false, + aIsSend: false, } const userid = ref(route.query.user_id || null) @@ -88,17 +92,17 @@ const userid = ref(route.query.user_id || null) 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 (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); + form.value = JSON.parse(cardStore.cusCard.cus_card); } } @@ -232,6 +236,15 @@ const moveBtn = (type, index) => { } }; +const handleChangeIsSend = () => { + // 檢查form.json5.cards裏,isSend為true的數量是否大於10 + let isSendCount = form.value.json5.cards.filter(card => card.isSend).length + if (isSendCount > 10) { + showFailToast('最多只能設定10張卡片為發送') + form.value.json5.cards[form.value.page - 1].isSend = false + } +} + const afterRead = async (file, name) => { crop.value.show = true const ofile = file.file @@ -351,6 +364,7 @@ const handleDelete = () => { }; const handlePreview = () => { + router.push({ name: "CardPreview", state: { content: JSON.stringify(form.value) }, @@ -370,13 +384,13 @@ const onDescSizeConfirm = ({ selectedOptions }) => { }; const handleSubmit = async () => { - let user_id; + let user_id; - if(!userid.value){ - user_id= sessionStorage.getItem("uid"); - }else{ - user_id = userid.value; - } + if (!userid.value) { + user_id = sessionStorage.getItem("uid"); + } else { + user_id = userid.value; + } showLoadingToast({ duration: 0, @@ -391,21 +405,21 @@ const handleSubmit = async () => { user_id: user_id, }; - if(!userid.value){ + if (!userid.value) { let res = cardStore.updateCusCard(cusCard); if (res) { - showSuccessToast("建立成功"); + showSuccessToast("建立成功"); } else { - showFailToast("建立失敗"); + showFailToast("建立失敗"); } router.push("/card"); - }else{ + } else { let res = await updateCusCard(cusCard); if (res.code === 200) { - showSuccessToast("建立成功"); + showSuccessToast("建立成功"); } else { - showFailToast("建立失敗"); + showFailToast("建立失敗"); } router.push("/auth/getauth"); } @@ -413,9 +427,9 @@ const handleSubmit = async () => { }; const goBack = () => { - if(!userid.value){ + if (!userid.value) { router.push('/') - }else{ + } else { router.push('/auth/getauth') } }; @@ -444,7 +458,7 @@ const goBack = () => {
卡片設定
+ + + { - + 卡片標題 - + - + { + input-align="right" placeholder="請輸入說明文字的色碼,如:#333333" + :rules="[{ required: true, message: '說明文字色碼必填' }]"> @@ -620,9 +639,11 @@ const goBack = () => { @@ -692,9 +713,8 @@ const goBack = () => { diff --git a/src/views/Send/index.vue b/src/views/Send/index.vue index 7b26fbc..98e81e1 100644 --- a/src/views/Send/index.vue +++ b/src/views/Send/index.vue @@ -7,6 +7,8 @@ import { onMounted, ref, computed, watch } from 'vue' import { getCard, getCusCard, getVipCard, updateSendCount, getFlexcard } from '@/api' +import { updateRemark, updateIsSend } from '@/api/card.js' + import { cardFactory } from '@/utils/card' import { genCard1 } from '@/utils/card2' @@ -29,7 +31,10 @@ const state = ref({ flexContent: {}, }) -const activeName = ref('0'); +const activeName = ref('0') + +const is_send = ref(0) +const remark = ref('') let flexRef = ref(null) @@ -63,6 +68,10 @@ onMounted(async () => { watch(() => activeName.value, function (newVal, oldVal) { if (newVal !== oldVal) { showFlex(newVal) + if(parseInt(newVal) < 2){ + is_send.value = 0 + remark.value = '' + } } }, { immediate: true }) @@ -93,7 +102,7 @@ async function showFlex(id) { let data = res2.data; data.ad_image = imageUrl.value + data.ad_image; state.value.flexContent = genAdCard(JSON.parse(card), data); - }else{ + } else { state.value.flexContent = JSON.parse(card) } } @@ -133,6 +142,9 @@ async function showFlex(id) { flexRef.value.innerHTML = '' flex2html("flex", state.value.flexContent) } + is_send.value = res.is_send + remark.value = res.remark + // if( card2Res.code === 200){ // if(card2Res.data.cus_card){ // state.flexContent = genCard1(JSON.parse(card2Res.data.cus_card)) @@ -147,14 +159,29 @@ async function showFlex(id) { } } +const handleOnChange = async () => { + // 更新 + let res = await updateIsSend({is_send:is_send.value,id:activeName.value}) + if(res.code !== 200){ + showToast('更新失敗') + } +} + +const handleOnBlur = async () => { + // 更新 + let res = await updateRemark({remark:remark.value,id:activeName.value}) + if(res.code !== 200){ + showToast('更新失敗') + } +} + const sendEcard = async () => { if (!liff.isLoggedIn()) { liff.login({ redirectUri: window.location.href }) } - + let content = JSON.parse(JSON.stringify(state.value.flexContent)) - // console.log('content', JSON.stringify(state.value.flexContent)) let res if (activeName.value === '0') { @@ -164,7 +191,15 @@ const sendEcard = async () => { 'text': '名片的文字、數字,都可連結,請多多指教!' }]) } else { - res = await liff.shareTargetPicker([content]) + if(is_send.value === 1){ + res = await liff.shareTargetPicker([content, + { + 'type': 'text', + 'text': remark.value + }]) + }else{ + res = await liff.shareTargetPicker([content]) + } } if (res.status === 'success') { @@ -266,6 +301,16 @@ const changeTpl = async (val) => { +
+ + + + + + +
分享好友