fix: make page

This commit is contained in:
zzc
2026-02-26 15:56:10 +08:00
parent 916c383dd5
commit 5d735736ad
2 changed files with 174 additions and 13 deletions

View File

@@ -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({ return request({
url: "/api/blessing/card/template/list?page=" + page, url,
method: "GET", 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({ return request({
url: "/api/blessing/card/template-content/list?page=" + page, url,
method: "GET", 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({ return request({
url: "/api/blessing/card/template-title/list?page=" + page, url,
method: "GET", method: "GET",
}); });
}; };

View File

@@ -485,6 +485,27 @@
</view> </view>
</view> </view>
</uni-popup> </uni-popup>
<!-- Scene Selection Popup -->
<uni-popup ref="scenePopup" type="center" :is-mask-click="false">
<view class="scene-popup">
<view class="scene-title">选择祝福场景</view>
<view class="scene-grid">
<view
class="scene-item"
v-for="(scene, index) in scenes"
:key="index"
@tap="selectScene(scene)"
>
<view class="scene-icon-box" :style="{ background: scene.color }">
<uni-icons :type="scene.icon" size="32" color="#fff"></uni-icons>
</view>
<text class="scene-name">{{ scene.name }}</text>
</view>
</view>
<view class="skip-btn" @tap="skipScene">跳过直接制作</view>
</view>
</uni-popup>
</view> </view>
</template> </template>
@@ -878,10 +899,6 @@ const userOffsetY = ref(0);
const shareToken = ref(""); const shareToken = ref("");
onLoad((options) => { onLoad((options) => {
getTemplateList();
getTemplateContentList();
getTemplateTitleList();
getMusicList();
if (options.shareToken) { if (options.shareToken) {
shareToken.value = options.shareToken; shareToken.value = options.shareToken;
} }
@@ -889,8 +906,77 @@ onLoad((options) => {
eventName: "make_page_visit", eventName: "make_page_visit",
eventType: `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) => { const syncUserInfo = (force = false) => {
if (isLoggedIn.value) { if (isLoggedIn.value) {
if (signatureName.value === "xxx" || !signatureName.value) { if (signatureName.value === "xxx" || !signatureName.value) {
@@ -988,7 +1074,10 @@ const getTemplateList = async (isLoadMore = false) => {
loadingTemplates.value = true; loadingTemplates.value = true;
try { try {
const res = await getCardTemplateList(templatePage.value); const res = await getCardTemplateList(
templatePage.value,
currentScene.value,
);
// 兼容数组或对象列表格式 // 兼容数组或对象列表格式
const list = Array.isArray(res) ? res : res.list || []; const list = Array.isArray(res) ? res : res.list || [];
@@ -1052,7 +1141,10 @@ const getTemplateTitleList = async (isLoadMore = false) => {
loadingTitles.value = true; loadingTitles.value = true;
try { try {
const res = await getCardTemplateTitleList(titlePage.value); const res = await getCardTemplateTitleList(
titlePage.value,
currentScene.value,
);
const list = Array.isArray(res) ? res : res.list || []; const list = Array.isArray(res) ? res : res.list || [];
if (list.length > 0) { if (list.length > 0) {
@@ -1105,7 +1197,10 @@ const getTemplateContentList = async (isLoadMore = false) => {
loadingBlessings.value = true; loadingBlessings.value = true;
try { try {
const res = await getCardTemplateContentList(blessingPage.value); const res = await getCardTemplateContentList(
blessingPage.value,
currentScene.value,
);
const list = Array.isArray(res) ? res : res.list || []; const list = Array.isArray(res) ? res : res.list || [];
if (list.length > 0) { if (list.length > 0) {
@@ -2415,4 +2510,58 @@ function drawRoundRect(ctx, x, y, w, h, r, color) {
color: #666; color: #666;
font-size: 28rpx; 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;
}
</style> </style>