diff --git a/api/make.js b/api/make.js index 3b5f335..002b7bc 100644 --- a/api/make.js +++ b/api/make.js @@ -16,16 +16,24 @@ export const updateCard = async (data) => { }); }; -export const getCardTemplateList = async (page = 1) => { +export const getCardTemplateList = async (page = 1, scene = "") => { + let url = "/api/blessing/card/template/list?page=" + page; + if (scene) { + url += "&scene=" + scene; + } return request({ - url: "/api/blessing/card/template/list?page=" + page, + url, method: "GET", }); }; -export const getCardTemplateContentList = async (page = 1) => { +export const getCardTemplateContentList = async (page = 1, scene = "") => { + let url = "/api/blessing/card/template-content/list?page=" + page; + if (scene) { + url += "&scene=" + scene; + } return request({ - url: "/api/blessing/card/template-content/list?page=" + page, + url, method: "GET", }); }; @@ -37,9 +45,13 @@ export const getCardMusicList = async () => { }); }; -export const getCardTemplateTitleList = async (page = 1) => { +export const getCardTemplateTitleList = async (page = 1, scene = "") => { + let url = "/api/blessing/card/template-title/list?page=" + page; + if (scene) { + url += "&scene=" + scene; + } return request({ - url: "/api/blessing/card/template-title/list?page=" + page, + url, method: "GET", }); }; diff --git a/pages/make/index.vue b/pages/make/index.vue index 7e3e64e..c192fde 100644 --- a/pages/make/index.vue +++ b/pages/make/index.vue @@ -485,6 +485,27 @@ + + + + + 选择祝福场景 + + + + + + {{ scene.name }} + + + 跳过,直接制作 + + @@ -878,10 +899,6 @@ const userOffsetY = ref(0); const shareToken = ref(""); onLoad((options) => { - getTemplateList(); - getTemplateContentList(); - getTemplateTitleList(); - getMusicList(); if (options.shareToken) { shareToken.value = options.shareToken; } @@ -889,8 +906,77 @@ onLoad((options) => { eventName: "make_page_visit", eventType: `visit`, }); + + if (options.scene) { + currentScene.value = options.scene; + loadData(); + } else { + setTimeout(() => { + scenePopup.value.open(); + }, 200); + } }); +const loadData = () => { + getTemplateList(); + getTemplateContentList(); + getTemplateTitleList(); + getMusicList(); +}; + +const currentScene = ref(""); +const scenePopup = ref(null); +const scenes = [ + { + name: "节日祝福", + value: "holiday", + icon: "calendar-filled", + color: "#FF3B30", + }, + { + name: "生日纪念", + value: "birthday", + icon: "gift-filled", + color: "#FF9500", + }, + { + name: "每日问候", + value: "daily", + icon: "notification-filled", + color: "#FFCC00", + }, + { + name: "情绪表达", + value: "emotion", + icon: "heart-filled", + color: "#AF52DE", + }, + { + name: "人际关系", + value: "relationship", + icon: "contact-filled", + color: "#5856D6", + }, + { + name: "职场祝福", + value: "workplace", + icon: "vip-filled", + color: "#007AFF", + }, +]; + +const selectScene = (scene) => { + currentScene.value = scene.value; + scenePopup.value.close(); + loadData(); +}; + +const skipScene = () => { + currentScene.value = ""; + scenePopup.value.close(); + loadData(); +}; + const syncUserInfo = (force = false) => { if (isLoggedIn.value) { if (signatureName.value === "xxx" || !signatureName.value) { @@ -988,7 +1074,10 @@ const getTemplateList = async (isLoadMore = false) => { loadingTemplates.value = true; try { - const res = await getCardTemplateList(templatePage.value); + const res = await getCardTemplateList( + templatePage.value, + currentScene.value, + ); // 兼容数组或对象列表格式 const list = Array.isArray(res) ? res : res.list || []; @@ -1052,7 +1141,10 @@ const getTemplateTitleList = async (isLoadMore = false) => { loadingTitles.value = true; try { - const res = await getCardTemplateTitleList(titlePage.value); + const res = await getCardTemplateTitleList( + titlePage.value, + currentScene.value, + ); const list = Array.isArray(res) ? res : res.list || []; if (list.length > 0) { @@ -1105,7 +1197,10 @@ const getTemplateContentList = async (isLoadMore = false) => { loadingBlessings.value = true; try { - const res = await getCardTemplateContentList(blessingPage.value); + const res = await getCardTemplateContentList( + blessingPage.value, + currentScene.value, + ); const list = Array.isArray(res) ? res : res.list || []; if (list.length > 0) { @@ -2415,4 +2510,58 @@ function drawRoundRect(ctx, x, y, w, h, r, color) { color: #666; font-size: 28rpx; } + +/* 场景选择弹窗 */ +.scene-popup { + width: 600rpx; + background: #fff; + border-radius: 30rpx; + padding: 40rpx; + display: flex; + flex-direction: column; + align-items: center; +} + +.scene-title { + font-size: 36rpx; + font-weight: bold; + color: #333; + margin-bottom: 40rpx; +} + +.scene-grid { + display: grid; + grid-template-columns: repeat(3, 1fr); + gap: 30rpx; + width: 100%; + margin-bottom: 40rpx; +} + +.scene-item { + display: flex; + flex-direction: column; + align-items: center; + gap: 16rpx; +} + +.scene-icon-box { + width: 100rpx; + height: 100rpx; + border-radius: 50%; + display: flex; + align-items: center; + justify-content: center; + box-shadow: 0 8rpx 20rpx rgba(0, 0, 0, 0.1); +} + +.scene-name { + font-size: 26rpx; + color: #666; +} + +.skip-btn { + font-size: 28rpx; + color: #999; + padding: 20rpx; +}