diff --git a/api/system.js b/api/system.js index 4ca2c86..64dcd89 100644 --- a/api/system.js +++ b/api/system.js @@ -29,3 +29,19 @@ export const getShareReward = async (data) => { data, }); }; + +export const saveRecord = async (data) => { + return request({ + url: "/api/blessing/save/record", + method: "POST", + data, + }); +}; + +export const viewRecord = async (data) => { + return request({ + url: "/api/blessing/view/record", + method: "POST", + data, + }); +}; diff --git a/pages/index/index.vue b/pages/index/index.vue index 0020797..9146bde 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -193,7 +193,7 @@ onMounted(() => { const features = ref([ { title: "新春祝福卡片", - subtitle: "定制专属贺卡", + subtitle: "定制专属贺卡吧", icon: "/static/icon/celebrate.png", type: "card", }, diff --git a/pages/make/index.vue b/pages/make/index.vue index 82a54ac..17d8bcd 100644 --- a/pages/make/index.vue +++ b/pages/make/index.vue @@ -290,7 +290,7 @@ import { getCardTemplateList, getCardTemplateContentList, } from "@/api/make"; -import { createShareToken } from "@/api/system"; +import { createShareToken, saveRecord } from "@/api/system"; import { onShareAppMessage, onLoad, @@ -299,6 +299,7 @@ import { } from "@dcloudio/uni-app"; import { useUserStore } from "@/stores/user"; import LoginPopup from "@/components/LoginPopup/LoginPopup.vue"; +import { uploadImage } from "@/utils/common.js"; const userStore = useUserStore(); const loginPopupRef = ref(null); @@ -563,11 +564,28 @@ const toggleAvatarDecor = () => { uni.showToast({ title: "挂饰功能即将上线~", icon: "none" }); }; -const preview = () => { - saveByCanvas(); +const preview = async () => { + if (!isLoggedIn.value) { + loginPopupRef.value.open(); + return; + } + const tempPath = await saveByCanvas(true); + createSaveRecord(tempPath); + // uni.showToast({ title: '已保存到相册', icon: 'checkmarkempty' }) }; +const createSaveRecord = async (path) => { + const imageUrl = await uploadImage(path); + const deviceInfo = getDeviceInfo(); + saveRecord({ + scene: "card_generate", + targetId: cardId.value || "", + imageUrl, + deviceInfo, + }); +}; + const shareOrSave = async () => { if (!isLoggedIn.value) { loginPopupRef.value.open();