From a403393c1190994b473e679e1751794d9a1b9502 Mon Sep 17 00:00:00 2001 From: cloudroam <cloudroam> Date: 星期二, 01 七月 2025 10:36:07 +0800 Subject: [PATCH] add: 分享+景点管理 --- pages/home/home-main.vue | 65 ++++++++++++++++++++++++++++---- 1 files changed, 56 insertions(+), 9 deletions(-) diff --git a/pages/home/home-main.vue b/pages/home/home-main.vue index 3e545c6..e809a9b 100644 --- a/pages/home/home-main.vue +++ b/pages/home/home-main.vue @@ -2,23 +2,26 @@ <view> <!-- <view class="card" v-if="!showVideo"> --> <view class="card"> - <view class="main-title">每一帧画面,都藏着一个等待探索的世界</view> + <view class="main-title">{{ config.mainTitle }}</view> <view class="sub-title"> - 从经典场景到幕后故事,开启你的专属影视朝圣之旅 + {{ config.subTitle }} </view> <view class="btn-group"> <view class="custom-btn explore-btn" @click="startExplore"> - <text class="btn-text">开始探索</text> - <up-icon name="play-right-fill" size="34rpx" color="black" class="btn-icon" /> + <text class="btn-text">{{ config.btnText1 }}</text> + <up-icon + :name="config.btnIcon1" + :color="config.iconColor1" + size="34rpx" class="btn-icon" /> </view> <view class="custom-btn route-btn" @click="hotRoute"> - <text class="btn-text">热门路线</text> + <text class="btn-text">{{ config.btnText2 }}</text> <up-icon - name="/static/common/road-map-fill.png" + :name="config.btnIcon2" + :color="config.iconColor2" size="34rpx" - color="white" class="btn-icon" /> </view> @@ -54,7 +57,9 @@ <script setup lang="ts"> import { ref, computed } from 'vue' - + import { onLoad } from '@dcloudio/uni-app' + import { useGlobal } from '@/composables/useGlobal' + const { $http, $message, $store } = useGlobal() const showVideo = ref(false) const currentIndex = ref(0) @@ -70,7 +75,17 @@ ] const currentVideo = computed(() => videoList[currentIndex.value]) - + // 添加配置响应式对象 + const config = ref({ + mainTitle: '每一帧画面,都藏着一个等待探索的世界', + subTitle: '从经典场景到幕后故事,开启你的专属影视朝圣之旅', + btnText1: '开始探索', + btnText2: '热门路线', + btnIcon1: 'play-right-fill', + btnIcon2: '/static/common/road-map-fill.png', + iconColor1: 'black', + iconColor2: 'white' + }) function startExplore() { // 跳转到具体页面 uni.navigateTo({ @@ -89,6 +104,38 @@ icon: 'none', }) } + + onLoad((options: any) => { + getHomeConfig() + }) + + // 获取首页配置信息 + const getHomeConfig = async () => { + try { + const { code, data } = await $http.request( + 'get', + '/api/home/homeConfig/info', + {} + ) + if (code == 0) { + console.log("接口返回数据:", data); + // 只更新接口返回的有效字段 + Object.keys(config.value).forEach(key => { + const newValue = data[key]; + console.log(`字段 ${key}: 接口值=${newValue}, 本地值=${config.value[key]}`); + if (newValue !== undefined && newValue !== null && newValue !== '') { + config.value[key] = newValue; + } + }); + console.log("首页配置加载成功", config.value) + } else { + } + } catch (error) { + console.error('配置请求失败', error) + } + } + + </script> <style scoped> .card { -- Gitblit v1.9.3