Compare commits

...

3 Commits

Author SHA1 Message Date
Wayne 39b5bd0ab5 Merge branch 'sta'
2 years ago
Wayne eafd24ff65 0001247
2 years ago
Wayne be6f1aee23 0001246
2 years ago

@ -3,3 +3,8 @@ import ajax from "./ajax";
export const getCardData = async () => export const getCardData = async () =>
ajax(`/Card/getCardData`); ajax(`/Card/getCardData`);
export const updateRemark = async (params) =>
ajax(`/card/updateRemark`, params, "POST");
export const updateIsSend = async (params) =>
ajax(`/card/updateIsSend`, params, "POST");

@ -100,4 +100,3 @@ export const getUserCateList = async () =>
export const updateUserCate = async (params) => export const updateUserCate = async (params) =>
ajax(`/UserCate/updateUserCate`, params, "POST"); ajax(`/UserCate/updateUserCate`, params, "POST");

@ -96,9 +96,9 @@ function genCard1(ctx) {
altText: vcard.altText, altText: vcard.altText,
contents: { contents: {
type: "carousel", type: "carousel",
contents: _.map(vcard.cards, (card, cardIdx) => contents: vcard.cards
renderCard({ ...ctx, card, cardIdx }) .filter(card => card.isSend === true)
), .map((card, cardIdx) => renderCard({ ...ctx, card, cardIdx }))
}, },
}; };
} }

@ -54,6 +54,8 @@ const form = ref({
titleSize: "xl", titleSize: "xl",
cards: [ cards: [
{ {
isSend: false,
aIsSend: false,
bgColor: "#ffffff", bgColor: "#ffffff",
desc: "", desc: "",
descColor: "#000000", descColor: "#000000",
@ -80,7 +82,9 @@ const defaultTheme = {
descSize: "sm", descSize: "sm",
titleColor: "#000000", titleColor: "#000000",
ratio: "4:3", ratio: "4:3",
isShow: true isShow: true,
isSend: false,
aIsSend: false,
} }
const userid = ref(route.query.user_id || null) const userid = ref(route.query.user_id || null)
@ -232,6 +236,15 @@ const moveBtn = (type, index) => {
} }
}; };
const handleChangeIsSend = () => {
// form.json5.cards,isSendtrue10
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) => { const afterRead = async (file, name) => {
crop.value.show = true crop.value.show = true
const ofile = file.file const ofile = file.file
@ -351,6 +364,7 @@ const handleDelete = () => {
}; };
const handlePreview = () => { const handlePreview = () => {
router.push({ router.push({
name: "CardPreview", name: "CardPreview",
state: { content: JSON.stringify(form.value) }, state: { content: JSON.stringify(form.value) },
@ -458,7 +472,8 @@ const goBack = () => {
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen></iframe> allowfullscreen></iframe>
</van-popup> </van-popup>
<van-field v-model="userid" label="會員編號" name="" input-align="right" :placeholder="userid" readonly v-if="userid"/> <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" <van-field v-model="form.title" label="標題文字" name="" input-align="right" error-message-align="right"
placeholder="請輸入您在名片切換時顯示的文字" :rules="[{ required: true, message: '標題文字必填' }]" /> placeholder="請輸入您在名片切換時顯示的文字" :rules="[{ required: true, message: '標題文字必填' }]" />
<van-field label="是否顯示於感應名片" class="longText" input-align="right"> <van-field label="是否顯示於感應名片" class="longText" input-align="right">
@ -476,11 +491,11 @@ const goBack = () => {
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li class="nav-item" v-for="(card, index) in form.json5.cards" :key="index" <li class="nav-item" v-for="(card, index) in form.json5.cards" :key="index"
@click="form.page = index + 1"> @click="form.page = index + 1">
<button type="button" class="nav-link" :class="{ active: form.page === index + 1 }"> <button type="button" class="nav-link" :class="{ active: form.page === index + 1,send: card.isSend === true && form.page !== index + 1 }">
{{ index + 1 }} {{ index + 1 }}
</button> </button>
</li> </li>
<li class="nav-item" @click="addCard" v-if="form.json5.cards.length < 10"> <li class="nav-item" @click="addCard">
<button type="button" class="nav-link"> <button type="button" class="nav-link">
<i class="fa fa-plus-circle"></i> 新增 <i class="fa fa-plus-circle"></i> 新增
</button> </button>
@ -504,6 +519,12 @@ const goBack = () => {
@click="delCard(form.page)"></van-button> @click="delCard(form.page)"></van-button>
</template> </template>
</van-field> </van-field>
<van-field label="是否發送" class="longText" input-align="right">
<template #input>
<van-switch v-model="form.json5.cards[form.page - 1].isSend" size="18px" active-color="#345068"
inactive-color="#888888" @change="handleChangeIsSend" />
</template>
</van-field>
<van-field v-model="form.json5.cards[form.page - 1].bgColor" label="卡片底色" id="vcard-bgColor" <van-field v-model="form.json5.cards[form.page - 1].bgColor" label="卡片底色" id="vcard-bgColor"
input-align="right" placeholder="請輸入卡片底色的色碼,如:#333333" :border="false" input-align="right" placeholder="請輸入卡片底色的色碼,如:#333333" :border="false"
@ -542,12 +563,8 @@ const goBack = () => {
</template> </template>
</van-field> </van-field>
<van-field <van-field label="圖片網址連結" v-model="form.json5.cards[form.page - 1].link" :border="false"
label="圖片網址連結" placeholder="需輸入完整網址,http://..,https://..." />
v-model="form.json5.cards[form.page - 1].link"
:border="false"
placeholder="需輸入完整網址,http://..,https://..."
/>
<van-divider :style="{ <van-divider :style="{
color: '#345068', color: '#345068',
@ -555,14 +572,15 @@ const goBack = () => {
padding: '0 16px', padding: '0 16px',
}"><strong>卡片標題</strong></van-divider> }"><strong>卡片標題</strong></van-divider>
<van-field v-model="form.json5.cards[form.page - 1].title" label="標題文字" id="vcard-title" input-align="right" <van-field v-model="form.json5.cards[form.page - 1].title" label="標題文字" id="vcard-title"
placeholder="請填寫卡片標題文字" :rules="[{ required: true, message: '請填寫卡片標題文字' }]" /> input-align="right" placeholder="請填寫卡片標題文字" :rules="[{ required: true, message: '請填寫卡片標題文字' }]" />
<van-field v-model="form.json5.cards[form.page - 1].titleSize" is-link readonly label="標題文字大小" <van-field v-model="form.json5.cards[form.page - 1].titleSize" is-link readonly label="標題文字大小"
id="vcard-titleSize" input-align="right" placeholder="請輸入標題文字的色碼,如:#333333" id="vcard-titleSize" input-align="right" placeholder="請輸入標題文字的色碼,如:#333333"
@click="showTitleSizePicker = true" /> @click="showTitleSizePicker = true" />
<van-popup v-model:show="showTitleSizePicker" round position="bottom"> <van-popup v-model:show="showTitleSizePicker" round position="bottom">
<van-picker :columns="sizeColumns" @cancel="showTitleSizePicker = false" @confirm="onTitleSizeConfirm" /> <van-picker :columns="sizeColumns" @cancel="showTitleSizePicker = false"
@confirm="onTitleSizeConfirm" />
</van-popup> </van-popup>
<van-field v-model="form.json5.cards[form.page - 1].titleColor" label="標題文字顏色" id="vcard-titleColor" <van-field v-model="form.json5.cards[form.page - 1].titleColor" label="標題文字顏色" id="vcard-titleColor"
@ -591,7 +609,8 @@ const goBack = () => {
</van-popup> </van-popup>
<van-field v-model="form.json5.cards[form.page - 1].descColor" label="說明文字顏色" id="vcard-descColor" <van-field v-model="form.json5.cards[form.page - 1].descColor" label="說明文字顏色" id="vcard-descColor"
input-align="right" placeholder="請輸入說明文字的色碼,如:#333333" :rules="[{ required: true, message: '說明文字色碼必填' }]"> input-align="right" placeholder="請輸入說明文字的色碼,如:#333333"
:rules="[{ required: true, message: '說明文字色碼必填' }]">
<template #button> <template #button>
<input v-model="form.json5.cards[form.page - 1].descColor" type="color" class="form-control-color" /> <input v-model="form.json5.cards[form.page - 1].descColor" type="color" class="form-control-color" />
</template> </template>
@ -620,9 +639,11 @@ const goBack = () => {
<van-field :label="`控制按鈕 ${index + 1}`" :border="false" class="bg-transparent"> <van-field :label="`控制按鈕 ${index + 1}`" :border="false" class="bg-transparent">
<template #button> <template #button>
<van-button size="small" class="bg-transparent border-0" icon="arrow-up" <van-button size="small" class="bg-transparent border-0" icon="arrow-up"
@click="moveBtn(0, index)" v-if="form.json5.cards[form.page - 1].btns.length > 1"></van-button> @click="moveBtn(0, index)"
v-if="form.json5.cards[form.page - 1].btns.length > 1"></van-button>
<van-button size="small" class="bg-transparent border-0" icon="arrow-down" <van-button size="small" class="bg-transparent border-0" icon="arrow-down"
@click="moveBtn(1, index)" v-if="form.json5.cards[form.page - 1].btns.length > 1"></van-button> @click="moveBtn(1, index)"
v-if="form.json5.cards[form.page - 1].btns.length > 1"></van-button>
<van-button size="small" class="bg-transparent border-0" icon="delete-o" <van-button size="small" class="bg-transparent border-0" icon="delete-o"
@click="delBtn(index)"></van-button> @click="delBtn(index)"></van-button>
</template> </template>
@ -692,7 +713,6 @@ const goBack = () => {
</template> </template>
<style lang="less" scoped> <style lang="less" scoped>
.edit { .edit {
:deep(.van-van-field__control--min-height) { :deep(.van-van-field__control--min-height) {
min-height: 100px; min-height: 100px;
@ -742,6 +762,12 @@ const goBack = () => {
background-color: #4a677d; background-color: #4a677d;
border-color: #4a677d #4a677d #4a677d; border-color: #4a677d #4a677d #4a677d;
} }
.nav-link.send {
background-color: #ccc;
border-color: #ccc #ccc #ccc;
}
} }
.previewCnt { .previewCnt {
@ -812,5 +838,4 @@ const goBack = () => {
background-color: #fff; background-color: #fff;
} }
} }
</style> </style>

@ -7,6 +7,8 @@ import { onMounted, ref, computed, watch } from 'vue'
import { getCard, getCusCard, getVipCard, updateSendCount, getFlexcard } from '@/api' import { getCard, getCusCard, getVipCard, updateSendCount, getFlexcard } from '@/api'
import { updateRemark, updateIsSend } from '@/api/card.js'
import { cardFactory } from '@/utils/card' import { cardFactory } from '@/utils/card'
import { genCard1 } from '@/utils/card2' import { genCard1 } from '@/utils/card2'
@ -29,7 +31,10 @@ const state = ref({
flexContent: {}, flexContent: {},
}) })
const activeName = ref('0'); const activeName = ref('0')
const is_send = ref(0)
const remark = ref('')
let flexRef = ref(null) let flexRef = ref(null)
@ -63,6 +68,10 @@ onMounted(async () => {
watch(() => activeName.value, function (newVal, oldVal) { watch(() => activeName.value, function (newVal, oldVal) {
if (newVal !== oldVal) { if (newVal !== oldVal) {
showFlex(newVal) showFlex(newVal)
if(parseInt(newVal) < 2){
is_send.value = 0
remark.value = ''
}
} }
}, { immediate: true }) }, { immediate: true })
@ -133,6 +142,9 @@ async function showFlex(id) {
flexRef.value.innerHTML = '' flexRef.value.innerHTML = ''
flex2html("flex", state.value.flexContent) flex2html("flex", state.value.flexContent)
} }
is_send.value = res.is_send
remark.value = res.remark
// if( card2Res.code === 200){ // if( card2Res.code === 200){
// if(card2Res.data.cus_card){ // if(card2Res.data.cus_card){
// state.flexContent = genCard1(JSON.parse(card2Res.data.cus_card)) // state.flexContent = genCard1(JSON.parse(card2Res.data.cus_card))
@ -147,6 +159,22 @@ 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 () => { const sendEcard = async () => {
if (!liff.isLoggedIn()) { if (!liff.isLoggedIn()) {
liff.login({ redirectUri: window.location.href }) liff.login({ redirectUri: window.location.href })
@ -154,7 +182,6 @@ const sendEcard = async () => {
let content = JSON.parse(JSON.stringify(state.value.flexContent)) let content = JSON.parse(JSON.stringify(state.value.flexContent))
// console.log('content', JSON.stringify(state.value.flexContent))
let res let res
if (activeName.value === '0') { if (activeName.value === '0') {
@ -163,9 +190,17 @@ const sendEcard = async () => {
'type': 'text', 'type': 'text',
'text': '名片的文字、數字,都可連結,請多多指教!' 'text': '名片的文字、數字,都可連結,請多多指教!'
}]) }])
} else {
if(is_send.value === 1){
res = await liff.shareTargetPicker([content,
{
'type': 'text',
'text': remark.value
}])
}else{ }else{
res = await liff.shareTargetPicker([content]) res = await liff.shareTargetPicker([content])
} }
}
if (res.status === 'success') { if (res.status === 'success') {
let result = await updateSendCount(userInfo.value.user_id) let result = await updateSendCount(userInfo.value.user_id)
@ -266,6 +301,16 @@ const changeTpl = async (val) => {
</div> </div>
<van-sticky position="bottom"> <van-sticky position="bottom">
<div v-if="parseInt(activeName) > 1" style="padding-top: 20px;">
<van-cell-group inset>
<van-cell center title="是否發送">
<template #right-icon>
<van-switch :active-value="1" :inactive-value="0" v-model="is_send" @change="handleOnChange"/>
</template>
</van-cell>
<van-field v-model="remark" label="分享內容附帶說明" label-width="120" nplaceholder="" @blur="handleOnBlur"/>
</van-cell-group>
</div>
<div class="bottomBtnCnt d-flex"> <div class="bottomBtnCnt d-flex">
<van-button block class="btn-skyBlue m-2" @click="sendEcard"> <van-button block class="btn-skyBlue m-2" @click="sendEcard">
<h6><i class="fa-solid fa-share-from-square"></i> 分享好友</h6> <h6><i class="fa-solid fa-share-from-square"></i> 分享好友</h6>

Loading…
Cancel
Save