diff --git a/api/system.js b/api/system.js index b49c9b6..261346e 100644 --- a/api/system.js +++ b/api/system.js @@ -66,3 +66,10 @@ export const getRandomGreeting = async () => { method: "get", }); }; + +export const getTipsList = async () => { + return request({ + url: `/api/blessing/tips/list`, + method: "get", + }); +}; diff --git a/pages/index/index.vue b/pages/index/index.vue index cd81d67..d0538fa 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -15,9 +15,8 @@ - + - 新品 + {{ getTagText(tip.tag) }} {{ tip.text }} @@ -135,7 +135,7 @@ import { onShow, } from "@dcloudio/uni-app"; import { getBavBarHeight } from "@/utils/system"; -import { getRecommendList, getRandomGreeting } from "@/api/system"; +import { getRecommendList, getRandomGreeting, getTipsList } from "@/api/system"; import { getShareToken, saveViewRequest } from "@/utils/common.js"; const countdownText = ref(""); @@ -177,6 +177,7 @@ const dailyGreeting = ref(""); onShow(() => { updateCountdown(); + getIndexTips(); const date = new Date(); todayDate.value = `${date.getMonth() + 1}月${date.getDate()}日`; }); @@ -216,6 +217,12 @@ onShareTimeline(() => { }; }); + +const getIndexTips = async () => { + const res = await getTipsList(); + noticeList.value = res || []; +}; + const getRandomGreetingText = async () => { const content = await getRandomGreeting(); dailyGreeting.value = @@ -229,27 +236,21 @@ const useGreeting = () => { }); }; -const noticeList = ref([ - { - text: "新春祝福上新品了,点击查看", - url: "https://mp.weixin.qq.com/s/mK438jWsYzsccJ2dDJG15A", - }, - { - text: "新春祝福上新品了3,点击查看", - url: "https://mp.weixin.qq.com/s/mK438jWsYzsccJ2dDJG15A", - }, - { - text: "新春祝福上新品了3,点击查看", - url: "https://mp.weixin.qq.com/s/mK438jWsYzsccJ2dDJG15A", - }, -]); +const noticeList = ref([]); const onNoticeTap = (tip) => { if (!tip.url) return; - uni.navigateTo({ + if (tip.type === "path") { + uni.navigateTo({ url: tip.url }); + } else if (tip.type === "switchTab") { + uni.switchTab({ url: tip.url }); + } else { + // 默认跳转 webview (公众号文章) + uni.navigateTo({ url: "/pages/webview/index?url=" + encodeURIComponent(tip.url), }); + } }; const features = ref([ @@ -322,7 +323,7 @@ const fetchRecommendList = async (isRefresh = false) => { const getTagText = (tag) => { const map = { hot: "热门", - new: "新款", + new: "新品", featured: "精选", hot2: "爆款", };