main
Wayne 2 years ago
parent 605cdb30d7
commit be6f1aee23

@ -3,3 +3,8 @@ import ajax from "./ajax";
export const getCardData = async () =>
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) =>
ajax(`/UserCate/updateUserCate`, params, "POST");

@ -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,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 () => {
if (!liff.isLoggedIn()) {
liff.login({ redirectUri: window.location.href })
@ -154,7 +182,6 @@ const sendEcard = async () => {
let content = JSON.parse(JSON.stringify(state.value.flexContent))
// console.log('content', JSON.stringify(state.value.flexContent))
let res
if (activeName.value === '0') {
@ -164,8 +191,16 @@ const sendEcard = async () => {
'text': '名片的文字、數字,都可連結,請多多指教!'
}])
} else {
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') {
let result = await updateSendCount(userInfo.value.user_id)
@ -266,6 +301,16 @@ const changeTpl = async (val) => {
</div>
<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">
<van-button block class="btn-skyBlue m-2" @click="sendEcard">
<h6><i class="fa-solid fa-share-from-square"></i> 分享好友</h6>

Loading…
Cancel
Save