feat: 主题颜色的调整,现在支持切换颜色

This commit is contained in:
2026-03-10 15:51:55 +08:00
parent 9cfde3f10a
commit df8a7f4de7
29 changed files with 106 additions and 267 deletions

View File

@@ -4,7 +4,7 @@
class="w-full bg-white border-box border-ff overflow-hidden rounded-20"
>
<view
class="border-box order-header w-vw flex flex-items-center flex-justify-between bg-EEF8FF"
class="border-box order-header w-vw flex flex-items-center flex-justify-between bg-theme-color-50"
>
<text class="font-size-18 font-500 color-171717 text-left ml-12">
{{ isCallSuccess ? "服务已创建" : "呼叫服务" }}

View File

@@ -15,7 +15,7 @@
</text>
</view>
<view class="flex flex-items-center" v-if="showBtn" @click="emit('click')">
<text class="font-size-12 color-2D91FF line-height-16">房间详情</text>
<text class="font-size-12 theme-color-500 line-height-16">房间详情</text>
<uni-icons type="right" size="15" color="#99A0AE" />
</view>
</view>

View File

@@ -4,7 +4,7 @@
class="w-full bg-white border-box border-ff overflow-hidden rounded-20"
>
<view
class="border-box order-header w-vw flex flex-items-center flex-justify-between bg-EEF8FF"
class="border-box order-header w-vw flex flex-items-center flex-justify-between bg-theme-color-50"
>
<text class="font-size-18 font-500 color-171717 text-left ml-12">
{{ isCallSuccess ? "反馈已创建" : "反馈意见" }}

View File

@@ -1,7 +1,7 @@
<template>
<view class="survey-questionnaire w-vw-24">
<view class="bg-white border-box border-ff overflow-hidden rounded-20">
<view class="border-box flex flex-items-center flex-justify-between bg-EEF8FF">
<view class="border-box flex flex-items-center flex-justify-between bg-theme-color-50">
<text class="font-size-18 font-500 color-171717 text-left ml-12">
调查问卷
</text>

View File

@@ -1,7 +1,7 @@
// TopNavBar 组件样式
.top-nav-bar {
width: 100%;
background-color: #d9eeff;
background-color: $theme-color-100;
&--fixed {
position: fixed;

View File

@@ -1,91 +0,0 @@
/**
* 主题颜色管理类
*
* 根据不同客户端切换主题颜色
* 支持5个颜色: color800, color700, color500, color100, color50
*/
import rawThemeConfigs from '../../theme-configs.json' with { type: 'json' };
import { currentClientType } from '@/constant/base.js';
// 主题颜色key定义
export const ThemeColorKey = {
COLOR_800: 'color800',
COLOR_700: 'color700',
COLOR_500: 'color500',
COLOR_100: 'color100',
COLOR_50: 'color50',
};
// 所有颜色key数组
const THEME_COLOR_KEYS = Object.values(ThemeColorKey);
class ThemeManager {
constructor() {
this.currentClient = currentClientType().toLowerCase();
this.themeConfigs = rawThemeConfigs;
this.currentTheme = this.themeConfigs[this.currentClient] || this.themeConfigs.zhinian;
}
/** 获取当前客户端 */
getClient() {
return this.currentClient;
}
/** 获取指定颜色 */
getColor(key) {
return this.currentTheme[key] || '';
}
/** 获取所有颜色对象 */
getAllColors() {
return { ...this.currentTheme };
}
/** 切换主题 */
switchTheme(clientType) {
if (this.themeConfigs[clientType]) {
this.currentClient = clientType;
this.currentTheme = this.themeConfigs[clientType];
}
}
/** 生成CSS变量 */
generateCssVariables() {
const colors = this.currentTheme;
return THEME_COLOR_KEYS.map(key => `--theme-${key}: ${colors[key]};`).join('\n');
}
/** 应用主题到页面 */
applyTheme() {
const cssVars = this.generateCssVariables();
// #ifdef H5
const style = document.createElement('style');
style.id = 'theme-variables';
style.innerHTML = `:root { ${cssVars} }`;
document.head.appendChild(style);
// #endif
// #ifdef MP-WEIXIN
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
currentPage?.setData({ themeCssVars: cssVars });
// #endif
return cssVars;
}
}
// 导出单例
export const themeManager = new ThemeManager();
// 便捷函数
export const getThemeColor = (key) => themeManager.getColor(key);
export const getAllThemeColors = () => themeManager.getAllColors();
export const applyTheme = () => themeManager.applyTheme();
// 便捷属性直接获取(推荐)
export const themeColors = themeManager.currentTheme;
export default ThemeManager;

View File

@@ -2,7 +2,7 @@
<view class="booking h-screen flex flex-col">
<TopNavBar
titleAlign="center"
backgroundColor="#D9EEFF"
:backgroundColor="$theme-color-100"
backIconColor="#000"
:shadow="false"
>
@@ -53,7 +53,7 @@
>
<view class="flex flex-items-center">
<text
class="font-size-12 color-2D91FF line-height-16"
class="font-size-12 theme-color-500 line-height-16"
@click="refundVisible = true"
>取消政策</text
>

View File

@@ -1,4 +1,4 @@
.booking {
background: linear-gradient(180deg, #d9eeff 0%, #f5f7fa 100%) 0 86px / 100%
background: linear-gradient(180deg, $theme-color-100 0%, #f5f7fa 100%) 0 86px / 100%
100px no-repeat;
}

View File

@@ -22,7 +22,7 @@
>
<view class="color-525866">取消政策及说明</view>
<view class="flex flex-items-center" @click="emit('click')">
<text class="color-2D91FF mr-4">查看详情</text>
<text class="theme-color-500 mr-4">查看详情</text>
<uni-icons type="right" size="12" color="#99A0AE" />
</view>
</view>

View File

@@ -14,7 +14,7 @@
'right border-none rounded-10 flex flex-full flex-items-center flex-justify-center font-size-14 font-500 color-white',
{
'bg-FF3D60': statusCode === '0',
'bg-2D91FF': ['1', '2', '3', '4', '5', '6'].includes(statusCode),
'theme-color-500': ['1', '2', '3', '4', '5', '6'].includes(statusCode),
},
]"
@click="handleButtonClick(orderData)"

View File

@@ -30,7 +30,7 @@
}
&.tag-4 {
color: #2d91ff;
color: $theme-color-500;
}
&.tag-5 {

View File

@@ -1,6 +1,6 @@
<template>
<view class="order-detail-page flex flex-col h-screen">
<TopNavBar titleAlign="center" background="#D9EEFF" title="订单详情" />
<TopNavBar titleAlign="center" :background="$theme-color-100" title="订单详情" />
<view
class="order-detail-wrapper border-box flex-full overflow-hidden scroll-y"

View File

@@ -1,14 +1,8 @@
<template>
<z-paging
bg-color="linear-gradient(180deg, #D9EEFF 0%, #F5F7FA 100%) 0 86px / 100% 100px no-repeat"
ref="paging"
v-model="dataList"
use-virtual-list
:force-close-inner-list="true"
cell-height-mode="dynamic"
safe-area-inset-bottom
@query="queryList"
>
:bg-color="'linear-gradient(180deg, ' + $theme-color-100 + ' 0%, #F5F7FA 100%) 0 86px / 100% 100px no-repeat'"
ref="paging" v-model="dataList" use-virtual-list :force-close-inner-list="true" cell-height-mode="dynamic"
safe-area-inset-bottom @query="queryList">
<template #top>
<TopNavBar title="全部订单" />
</template>
@@ -17,12 +11,7 @@
<CustomEmpty statusText="您暂无订单" />
</template>
<OrderCard
v-for="(item, index) in dataList"
:key="item.id || index"
:orderData="item"
@click="handleOrderClick"
/>
<OrderCard v-for="(item, index) in dataList" :key="item.id || index" :orderData="item" @click="handleOrderClick" />
</z-paging>
</template>

View File

@@ -1,4 +1,4 @@
.order-detail-wrapper {
background: linear-gradient(180deg, #d9eeff 0%, #f5f7fa 100%);
background: linear-gradient(180deg, $theme-color-100 0%, #f5f7fa 100%);
padding: 0 12px 40px;
}

View File

@@ -1,30 +1,19 @@
<template>
<view class="tab-container relative">
<view class="tab-wrapper flex flex-items-center flex-justify-center">
<view
v-for="(item, index) in tabList"
:key="index"
:class="[
'tab-item flex flex-full flex-items-center flex-justify-center relative',
activeIndex === index && 'tab-item-active',
]"
@click="handleTabClick(index)"
>
<view v-for="(item, index) in tabList" :key="index" :class="[
'tab-item flex flex-full flex-items-center flex-justify-center relative',
activeIndex === index && 'tab-item-active',
]" @click="handleTabClick(index)">
<view class="absolute flex flex-items-center">
<uni-icons
class="icon mr-4"
fontFamily="znicons"
size="20"
:color="activeIndex === index ? '#2D91FF' : '#525866'"
>
<uni-icons class="icon mr-4" fontFamily="znicons" size="20"
:color="activeIndex === index ? '$theme-color-500' : '#525866'">
{{ zniconsMap[item.icon] }}
</uni-icons>
<text
:class="[
'font-size-16 font-500 color-525866 ',
activeIndex === index && 'tab-text-active',
]"
>
<text :class="[
'font-size-16 font-500 color-525866 ',
activeIndex === index && 'tab-text-active',
]">
{{ item.label }}
</text>
</view>
@@ -32,17 +21,14 @@
</view>
<!-- 下划线指示器 -->
<view
:class="[
'tab-indicator absolute',
indicatorAnimating && 'animating',
indicatorInitialized && 'initialized',
]"
:style="{
left: indicatorLeft + 'px',
width: indicatorWidth + 'px',
}"
></view>
<view :class="[
'tab-indicator absolute',
indicatorAnimating && 'animating',
indicatorInitialized && 'initialized',
]" :style="{
left: indicatorLeft + 'px',
width: indicatorWidth + 'px',
}"></view>
</view>
</template>

View File

@@ -1,5 +1,5 @@
.tab-wrapper {
background-color: #d9eeff;
background-color: $theme-color-100;
height: 48px;
}
@@ -24,19 +24,19 @@
border-radius: 20px 20px 0 0;
transform: perspective(40px) rotateX(6deg) translate(0, -1px);
transform-origin: bottom bottom;
box-shadow: 0 -0.5px 0 #2d91ff;
box-shadow: 0 -0.5px 0 $theme-color-500;
}
}
.tab-text-active {
color: #2d91ff;
color: $theme-color-500;
z-index: 3;
}
.tab-indicator {
bottom: 0;
height: 3px;
background-color: #2d91ff;
background-color: $theme-color-500;
border-radius: 4px 4px 0 0;
transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1),
width 0.3s cubic-bezier(0.4, 0, 0.2, 1);

View File

@@ -1,23 +1,13 @@
<template>
<z-paging
ref="paging"
v-model="dataList"
use-virtual-list
:force-close-inner-list="true"
cell-height-mode="dynamic"
safe-area-inset-bottom
@query="queryList"
>
<z-paging ref="paging" v-model="dataList" use-virtual-list :force-close-inner-list="true" cell-height-mode="dynamic"
safe-area-inset-bottom @query="queryList">
<template #top>
<TopNavBar title="快速预定" />
<Tabs @change="handleTabChange" />
<!-- 选择入住离店日期 -->
<view
class="bg-white border-box flex flex-items-center p-12"
v-if="currentType === '0'"
>
<view class="bg-white border-box flex flex-items-center p-12" v-if="currentType === '0'">
<view class="in flex flex-items-center">
<text class="font-size-11 font-500 color-99A0AE mr-4">入住</text>
<text class="font-size-14 font-500 color-171717">
@@ -26,9 +16,7 @@
</view>
<!-- 几晚 -->
<text
class="nights bg-E5E8EE border-box font-size-11 font-500 color-525866 rounded-50 ml-8 mr-8"
>
<text class="nights bg-E5E8EE border-box font-size-11 font-500 color-525866 rounded-50 ml-8 mr-8">
{{ selectedDate.totalDays }}
</text>
@@ -40,32 +28,16 @@
</view>
<!-- 日期图标 -->
<uni-icons
class="ml-auto"
type="calendar"
size="24"
color="#2D91FF"
@click="calendarVisible = true"
/>
<uni-icons class="ml-auto" type="calendar" size="24" color="$theme-color-500" @click="calendarVisible = true" />
</view>
</template>
<Card
v-for="(item, index) in dataList"
:key="index"
:item="item"
:selectedDate="selectedDate"
/>
<Card v-for="(item, index) in dataList" :key="index" :item="item" :selectedDate="selectedDate" />
</z-paging>
<!-- 日历组件 -->
<Calender
:visible="calendarVisible"
mode="range"
:default-value="selectedDate"
@close="handleCalendarClose"
@range-select="handleDateSelect"
/>
<Calender :visible="calendarVisible" mode="range" :default-value="selectedDate" @close="handleCalendarClose"
@range-select="handleDateSelect" />
</template>
<script setup>

View File

@@ -1,30 +1,18 @@
<template>
<z-paging
bg-color="linear-gradient(180deg, #D9EEFF 0%, #F5F7FA 100%) 0 86px / 100% 100px no-repeat"
ref="paging"
v-model="dataList"
use-virtual-list
:force-close-inner-list="true"
cell-height-mode="dynamic"
safe-area-inset-bottom
@query="queryList"
>
:bg-color="'linear-gradient(180deg, ' + $theme - color - 100 + ' 0%, #F5F7FA 100%) 0 86px / 100% 100px no-repeat'"
ref="paging" v-model="dataList" use-virtual-list :force-close-inner-list="true" cell-height-mode="dynamic"
safe-area-inset-bottom @query="queryList">
<template #top>
<TopNavBar title="呼叫服务" />
</template>
<template #empty>
<CustomEmpty
emptyIcon="https://oss.nianxx.cn/mp/static/version_101/order/service_empty.png"
statusText="您暂无呼叫服务"
/>
<CustomEmpty emptyIcon="https://oss.nianxx.cn/mp/static/version_101/order/service_empty.png"
statusText="您暂无呼叫服务" />
</template>
<OrderCard
v-for="(item, index) in dataList"
:key="item.id || index"
:orderData="item"
/>
<OrderCard v-for="(item, index) in dataList" :key="item.id || index" :orderData="item" />
</z-paging>
</template>

View File

@@ -65,7 +65,7 @@
#8afcf8 0%,
rgba(138, 252, 248, 0) 100%
),
#2d91ff;
$theme-color-500;
}
.send-icon {

View File

@@ -4,7 +4,7 @@
@click="sendReply(item)">
<view class="flex items-center justify-center">
<image v-if="item.icon" class="icon" :src="item.icon" />
<text class="font-size-14 color-2D91FF line-height-20">
<text class="font-size-14 theme-color-500 line-height-20">
{{ item.title }}
</text>
</view>

View File

@@ -18,6 +18,6 @@
}
.tag-text {
color: #2d91ff; /* 蓝色文字,可根据设计调整 */
color: $theme-color-500;
font-size: $uni-font-size-base;
}

View File

@@ -23,7 +23,7 @@
}
.right {
background-color: #2d91ff;
background-color: $theme-color-500;
border-radius: 5px;
padding: 6px;
}

View File

@@ -17,9 +17,9 @@
<view class="login-agreement flex flex-items-center">
<CheckBox v-model="isAgree">
<text class="font-size-12 color-525866">我已阅读并同意</text>
<text class="font-size-12 color-2D91FF ml-4 mr-4" @click.stop="handleAgreeClick('service')">服务协议</text>
<text class="font-size-12 theme-color-500 ml-4 mr-4" @click.stop="handleAgreeClick('service')">服务协议</text>
<text class="font-size-12 color-525866"></text>
<text class="font-size-12 color-2D91FF ml-4 mr-4" @click.stop="handleAgreeClick('privacy')">隐私协议</text>
<text class="font-size-12 theme-color-500 ml-4 mr-4" @click.stop="handleAgreeClick('privacy')">隐私协议</text>
<text class="font-size-12 color-525866">\n</text>
<text class="font-size-12 color-525866 ml-30">授权与账号关联操作</text>
</CheckBox>

View File

@@ -30,7 +30,7 @@
width: 304px;
.login-btn {
background: #2d91ff;
background: $theme-color-500;
width: 100%;
border-radius: 10px;
}

View File

@@ -23,33 +23,31 @@
background-color: #f5f7fa;
}
.bg-EEF8FF {
background-color: #eef8ff;
}
.bg-FF3D60 {
background-color: #ff3d60;
}
.bg-2D91FF {
background-color: #2d91ff;
.bg-theme-color-500 {
background-color: $theme-color-500;
}
.bg-theme-color-50 {
background-color: $theme-color-50;
}
.bg-liner {
background: linear-gradient(205deg, #8ae3fc 0%, rgba(138, 227, 252, 0) 20%),
background: linear-gradient(205deg, $theme-color-100 0%, rgba(138, 227, 252, 0) 20%),
linear-gradient(155deg, #fef7e1 0%, rgba(254, 247, 225, 0) 20%),
radial-gradient(
48% 48% at 61% 118%,
radial-gradient(48% 48% at 61% 118%,
#ffffff 0%,
rgba(255, 255, 255, 0) 100%
),
linear-gradient(180deg, rgba(238, 248, 255, 0) 0%, #eef8ff 50%), #eef8ff;
rgba(255, 255, 255, 0) 100%),
linear-gradient(180deg, rgba(238, 248, 255, 0) 0%, $theme-color-50 50%), $theme-color-50;
}
.bg-button {
background: linear-gradient(90deg, #2d91ff 0%, #4de4ff 100%);
background: linear-gradient(90deg, $theme-color-500 0%, #4de4ff 100%);
}
.bg-transparent {
background-color: transparent;
}
}

View File

@@ -40,8 +40,8 @@
color: #ff3d60;
}
.color-2D91FF {
color: #2d91ff;
.theme-color-500 {
color: $theme-color-500;
}
.color-43669A {

View File

@@ -12,6 +12,32 @@
* 如果你的项目同样使用了scss预处理你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
*/
/* 主题颜色:蓝色 */
// $theme-color-800: #174BB6;
// $theme-color-700: #19428F;
// $theme-color-500: #2D91FF;
// $theme-color-100: #D9EEFF;
// $theme-color-50: #EEF8FF;
/* 主题颜色:绿色 */
$theme-color-800: #0B7034;
$theme-color-700: #0B5C2D;
$theme-color-500: #0CCD58;
$theme-color-100: #E8FFF1;
$theme-color-50: #F0F8F3;
// text 颜色
$text-color-900: #181B25;
$text-color-800: #222530;
$text-color-700: #2B303B;
$text-color-600: #525866;
$text-color-500: #717784;
$text-color-400: #99A0AE;
$text-color-300: #CACFD8;
$text-color-200: #E5E8EE;
$text-color-100: #F2F5F8;
$text-color-50: #F9FAFB;
/* 颜色变量 */
/* 行为相关颜色 */
@@ -74,4 +100,4 @@ $uni-font-size-title: 20px;
$uni-color-subtitle: #555555; // 二级标题颜色
$uni-font-size-subtitle: 26px;
$uni-color-paragraph: #3f536e; // 文章段落颜色
$uni-font-size-paragraph: 15px;
$uni-font-size-paragraph: 15px;

View File

@@ -1,13 +1,7 @@
<template>
<view class="zero-markdown-view">
<mp-html
:key="mpkey"
:selectable="selectable"
:scroll-table="scrollTable"
:tag-style="tagStyle"
:markdown="true"
:content="contentAi"
>
<mp-html :key="mpkey" :selectable="selectable" :scroll-table="scrollTable" :tag-style="tagStyle" :markdown="true"
:content="contentAi">
</mp-html>
</view>
</template>
@@ -35,7 +29,7 @@ export default {
},
themeColor: {
type: String,
default: "#2D91FF",
default: "#181B25",
},
codeBgColor: {
type: String,
@@ -47,11 +41,11 @@ export default {
},
fontColor: {
type: String,
default: "#171717",
default: "#181B25",
},
fontSubColor: {
type: String,
default: "#4D4D4D",
default: "#717784",
},
aiMode: {
type: Boolean,

View File

@@ -1,23 +0,0 @@
{
"zhinian": {
"color800": "#0B7034",
"color700": "#0B5C2D",
"color500": "#0CCD58",
"color100": "#E8FFF1",
"color50": "#F0F8F3"
},
"duohua": {
"color800": "#174BB6",
"color700": "#19428F",
"color500": "#2D91FF",
"color100": "#D9EEFF",
"color50": "#EEF8FF"
},
"tianmu": {
"color800": "#174BB6",
"color700": "#19428F",
"color500": "#2D91FF",
"color100": "#D9EEFF",
"color50": "#EEF8FF"
}
}