Commit d9faa747 by liimin

init

1 parent 9fa68e3e
Showing 323 changed files with 3547 additions and 572 deletions
...@@ -20,7 +20,7 @@ export default { ...@@ -20,7 +20,7 @@ export default {
// updateResolutionConfig(); // updateResolutionConfig();
// 连接(自动登录) // 连接(自动登录)
// #ifdef APP // #ifdef APP
// ws.connect(); ws.connect();
// #endif // #endif
}, },
onShow () { onShow () {
...@@ -61,7 +61,7 @@ export default { ...@@ -61,7 +61,7 @@ export default {
/* 引入自定义 CSS 工具类 */ /* 引入自定义 CSS 工具类 */
@import url("./common.css"); @import url("./common.css");
/* I18n 布局适配:横竖屏 + 分辨率 */ /* I18n 布局适配:横竖屏 + 分辨率 */
@import "./services/adapter/styles/layout-adapt.scss"; // @import "./services/adapter/styles/layout-adapt.scss";
/* 全局默认样式:App 端 view 不支持 font-size,基准字号用 var(--l-font-*) 落在 <text> 上 */ /* 全局默认样式:App 端 view 不支持 font-size,基准字号用 var(--l-font-*) 落在 <text> 上 */
.layout-root { .layout-root {
......
...@@ -3,24 +3,6 @@ ...@@ -3,24 +3,6 @@
*/ */
import http from "@/api/request/http.uts"; import http from "@/api/request/http.uts";
/** 轻改素材配置 */
export function getBoutiqueMaterialConfig(data: UTSJSONObject): Promise<any> {
return http.post({
"method": "dj.api.boutique.recepiton.material.merchant.detail",
"projectName": "boutique",
...data
} as UTSJSONObject);
}
/** 查询商户套餐推荐配置列表 */
export function getBoutiquePackageList(data: UTSJSONObject): Promise<any> {
return http.post({
"method": "dj.api.smartcarlife.receptionMaterialRecommendPackageConfig.getByMerchantId",
"projectName": "boutique",
...data
} as UTSJSONObject);
}
// 新历史订单列表 // 新历史订单列表
export function getOrderListPage(data: UTSJSONObject): Promise<any> { export function getOrderListPage(data: UTSJSONObject): Promise<any> {
return http.post({ return http.post({
......
...@@ -45,3 +45,26 @@ export function findPayInfo(data: UTSJSONObject): Promise<any> { ...@@ -45,3 +45,26 @@ export function findPayInfo(data: UTSJSONObject): Promise<any> {
...data ...data
} as UTSJSONObject); } as UTSJSONObject);
} }
/** Pad 业务类型列表(与 simgle_app `getPadBusinessTypeList` 一致) */
export function getPadBusinessTypeListApi(): Promise<any> {
return http.shukeRequest(
"linkwe-gateway/reception/pad/materials/biz-types/list",
{} as UTSJSONObject,
"POST",
true
);
}
/** Pad 文件夹列表(与 simgle_app `getPadFolderList` → `materials/folders/list` 一致) */
export function getPadFolderListApi(body: UTSJSONObject): Promise<any> {
return http.shukeRequest("linkwe-gateway/reception/pad/materials/folders/list", body, "POST", true);
}
/**
* Pad 素材列表(与 simgle_app `getPadMaterialList` → `materials/materials/list` 一致)
* 首页轮播:`{ typeCode, status: 0, showOnHomepage: 1 }`
*/
export function getPadMaterialListApi(body: UTSJSONObject): Promise<any> {
return http.shukeRequest("linkwe-gateway/reception/pad/materials/materials/list", body, "POST", true);
}
...@@ -64,6 +64,16 @@ const djDomainMap: UTSJSONObject = { ...@@ -64,6 +64,16 @@ const djDomainMap: UTSJSONObject = {
pet: "https://cdptest.glsx.com.cn" pet: "https://cdptest.glsx.com.cn"
}; };
/** 数科 linkwe-gateway(与 simgle_app/env.js shukeDomain 对齐) */
const shukeDomainMap: UTSJSONObject = {
ip: "http://wescrm.test.glshuke.com",
dev: "http://wescrm.test.glshuke.com",
test: "http://wescrm.test.glshuke.com",
beta: "http://wescrm.beta.glshuke.com",
prod: "http://wescrm.test.glshuke.com",
pet: "http://wescrm.test.glshuke.com"
};
const merchantDomainMap: UTSJSONObject = { const merchantDomainMap: UTSJSONObject = {
ip: "http://rop-merchant.dev.glsx.com.cn", ip: "http://rop-merchant.dev.glsx.com.cn",
dev: "http://rop-merchant.dev.glsx.com.cn", dev: "http://rop-merchant.dev.glsx.com.cn",
...@@ -176,6 +186,7 @@ export const secretKey: SecretKeyMap = pickEnvObject(secretKeyMap) as SecretKeyM ...@@ -176,6 +186,7 @@ export const secretKey: SecretKeyMap = pickEnvObject(secretKeyMap) as SecretKeyM
export const domain: string = pickEnvString(domainMap); export const domain: string = pickEnvString(domainMap);
export const evaluationDomain: string = pickEnvString(evaluationDomainMap); export const evaluationDomain: string = pickEnvString(evaluationDomainMap);
export const djDomain: string = pickEnvString(djDomainMap); export const djDomain: string = pickEnvString(djDomainMap);
export const shukeDomain: string = pickEnvString(shukeDomainMap);
export const merchantDomain: string = pickEnvString(merchantDomainMap); export const merchantDomain: string = pickEnvString(merchantDomainMap);
export const djSecretKey: SecretKeyItem = pickEnvObject(djSecretKeyMap) as SecretKeyItem; export const djSecretKey: SecretKeyItem = pickEnvObject(djSecretKeyMap) as SecretKeyItem;
export const signSecretKey: SignSecretKeyItem = pickEnvObject(signSecretKeyMap) as SignSecretKeyItem; export const signSecretKey: SignSecretKeyItem = pickEnvObject(signSecretKeyMap) as SignSecretKeyItem;
......
...@@ -48,7 +48,10 @@ export function getMockData(immediate: boolean = false): Promise<UTSJSONObject> ...@@ -48,7 +48,10 @@ export function getMockData(immediate: boolean = false): Promise<UTSJSONObject>
return http.uni_request({ "url": CONFIG_URL }).then((data: any): UTSJSONObject => { return http.uni_request({ "url": CONFIG_URL }).then((data: any): UTSJSONObject => {
const result = (data != null ? data : {}) as UTSJSONObject; const result = (data != null ? data : {}) as UTSJSONObject;
result.createTime = Date.now(); result.createTime = Date.now();
// ✅ 性能优化:异步写入 Storage,避免阻塞主线程
setTimeout(() => {
storage.set("mock_data", result, 0); storage.set("mock_data", result, 0);
}, 0);
return result; return result;
}).catch((): UTSJSONObject => { }).catch((): UTSJSONObject => {
const fallback: UTSJSONObject = { "createTime": Date.now() }; const fallback: UTSJSONObject = { "createTime": Date.now() };
...@@ -71,7 +74,10 @@ export function getBoutiqueMockData(immediate: boolean = false): Promise<UTSJSON ...@@ -71,7 +74,10 @@ export function getBoutiqueMockData(immediate: boolean = false): Promise<UTSJSON
result.moduleList = result.moduleList != null ? result.moduleList : _emptyList; result.moduleList = result.moduleList != null ? result.moduleList : _emptyList;
result.toolList = result.toolList != null ? result.toolList : _emptyList; result.toolList = result.toolList != null ? result.toolList : _emptyList;
result.defaultCarId = result.defaultCarId != null ? result.defaultCarId : ""; result.defaultCarId = result.defaultCarId != null ? result.defaultCarId : "";
// ✅ 性能优化:异步写入 Storage,避免阻塞主线程
setTimeout(() => {
storage.set("boutique_mock_data", result, 0); storage.set("boutique_mock_data", result, 0);
}, 0);
return result; return result;
}).catch((): UTSJSONObject => { }).catch((): UTSJSONObject => {
const fallback = { ...defaultBoutiqueMock, "createTime": Date.now() } as UTSJSONObject; const fallback = { ...defaultBoutiqueMock, "createTime": Date.now() } as UTSJSONObject;
...@@ -125,6 +131,7 @@ export async function getSoureData( ...@@ -125,6 +131,7 @@ export async function getSoureData(
}); });
if (res != null && (res as UTSJSONObject).id != null) { if (res != null && (res as UTSJSONObject).id != null) {
console.log((res as UTSJSONObject).id, "res.idres.idres.idres.id");
const data = await getEquityMaterialConfig({ const data = await getEquityMaterialConfig({
id: (res as UTSJSONObject).id id: (res as UTSJSONObject).id
...@@ -171,7 +178,10 @@ export async function getSoureData( ...@@ -171,7 +178,10 @@ export async function getSoureData(
try { try {
configList = await findReceptionpriproConfigList({}) as Array<any>; configList = await findReceptionpriproConfigList({}) as Array<any>;
// ✅ 性能优化:异步写入 Storage,避免阻塞主线程
setTimeout(() => {
storage.set("findReceptionpriproConfigList", configList, 0); storage.set("findReceptionpriproConfigList", configList, 0);
}, 0);
} catch { } catch {
configList = storage.get("findReceptionpriproConfigList") as Array<any>; configList = storage.get("findReceptionpriproConfigList") as Array<any>;
} }
...@@ -214,15 +224,11 @@ export async function getSoureData( ...@@ -214,15 +224,11 @@ export async function getSoureData(
materialInfoList = materialInfoList.concat(moduleOtherList); materialInfoList = materialInfoList.concat(moduleOtherList);
} }
// dataObj.toolList = await imgTransformBase64(toolList, ["shortTitleUrl"]); /** 权益素材直接使用网络 URL:App 端 `<image>` / un-image 可加载 https,转 base64 体积大、慢且无必要 */
// dataObj.moduleList = await imgTransformBase64(materialInfoList, ["thumbnail", "receptionSourceDetailList", "screenList"]); dataObj.toolList = toolList;
dataObj.moduleList = materialInfoList;
// uni.setStorageSync(storageName, {
// moduleList: dataObj.moduleList,
// toolList: dataObj.toolList,
// id: (res as UTSJSONObject).id
// });
// ✅ 返回数据,由调用方决定是否缓存
return dataObj; return dataObj;
} else { } else {
throw new Error("获取数据失败"); throw new Error("获取数据失败");
...@@ -243,113 +249,3 @@ export async function getSoureData( ...@@ -243,113 +249,3 @@ export async function getSoureData(
} }
} }
/** 批量图片转 base64 */
async function imgTransformBase64(imgList: Array<any>= [], keyList: string[]): Promise<Array<any>> {
const result: Array<any> = [];
for (const e of imgList) {
const eObj = e as UTSJSONObject;
for (const key in eObj) {
if (keyList.includes(key)) {
const isArray = Array.isArray(eObj[key]);
if (isArray) {
const arr = eObj[key] as Array<any>;
for (const item of arr) {
const itemObj = item as UTSJSONObject;
for (const k in itemObj) {
if (k == "detailUrl" && itemObj[k] != null) {
itemObj[k] = await getBase64(itemObj[k] as string);
}
}
}
} else {
if (typeof eObj[key] === "string" && eObj[key] != null) {
eObj[key] = await getBase64(eObj[key] as string);
}
if (eObj[key] != null && typeof eObj[key] === "object") {
const nestedObj = eObj[key] as UTSJSONObject;
for (const k in nestedObj) {
if (nestedObj[k] != null) {
nestedObj[k] = await getBase64(nestedObj[k] as string);
}
}
}
}
}
}
result.push(e);
}
return result;
}
/** 转 base64 */
async function getBase64(url: string): Promise<string> {
function isRequestableUrl(value: string): boolean {
if (value == null || value == "") return false;
const trimmed = value.trim();
if (trimmed == "") return false;
if (trimmed.startsWith("data:image/")) return false;
return /^https?:\/\//.test(trimmed);
}
function isProbablyBase64(raw: string): boolean {
if (raw == null || raw == "") return false;
const cleaned = raw.replace(/\s/g, "");
if (cleaned.length < 16) return false;
if ((cleaned.length % 4) != 0) return false;
return /^[A-Za-z0-9+/=]+$/.test(cleaned);
}
if (!isRequestableUrl(url)) {
return url;
}
return new Promise((resolve, reject) => {
uni.request({
url,
method: "GET",
responseType: "arraybuffer",
success: res => {
try {
const data: any | null = res.data;
let base64: string;
if (data == null) {
console.warn("res.data is null or undefined");
resolve(url);
return;
}
if (typeof data === "string") {
const strData = (data as string).trim();
if (strData.startsWith("data:image/")) {
// 已是 data URI,直接返回
resolve(strData);
return;
}
const cleaned = strData.replace(/\s/g, "");
if (isProbablyBase64(cleaned)) {
base64 = `data:image/png;base64,${cleaned}`;
} else {
// 某些端会回二进制乱码字符串(如 "�PNG..."),该值不可直接作为 base64
resolve(url);
return;
}
} else {
base64 = `data:image/png;base64,${uni.arrayBufferToBase64(data as ArrayBuffer)}`;
}
// console.log("转换后的 base64:", `${base64.slice(0, 50) }...`);
resolve(base64);
} catch (error) {
// console.error("转换 base64 失败:", error, "res.data:", res.data);
resolve(url);
}
},
fail: err => {
console.error("请求失败:", err);
resolve(url);
}
});
});
}
...@@ -2,6 +2,24 @@ ...@@ -2,6 +2,24 @@
import http from '@/api/request/http.uts' import http from '@/api/request/http.uts'
// ---------- 数科账号登录(与 simgle_app/api/module/loginApi.js 对齐) ----------
export async function apiShukeLoginInit(params: UTSJSONObject): Promise<UTSJSONObject> {
return await http.shukeRequest("linkwe-gateway/auth/accountLoginSp/init", params, "POST", true) as UTSJSONObject
}
export async function apiShukeStoreList(body: UTSJSONObject): Promise<UTSJSONObject> {
return await http.shukeRequest("linkwe-gateway/auth/accountLoginSp/stores", body, "POST", true) as UTSJSONObject
}
export async function apiShukeConfirmStore(body: UTSJSONObject): Promise<UTSJSONObject> {
return await http.shukeRequest("linkwe-gateway/auth/accountLoginSp/confirm", body, "POST", true) as UTSJSONObject
}
export async function apiShukeSaveLogin(body: UTSJSONObject): Promise<UTSJSONObject> {
return await http.shukeRequest("linkwe-gateway/auth/accountLoginSp/save", body, "POST", true) as UTSJSONObject
}
// 获取短信验证码:dj.api.smartcarlife.sms.get.code // 获取短信验证码:dj.api.smartcarlife.sms.get.code
export async function apiGetSmsCode(params: UTSJSONObject): Promise<UTSJSONObject> { export async function apiGetSmsCode(params: UTSJSONObject): Promise<UTSJSONObject> {
const data: UTSJSONObject = { const data: UTSJSONObject = {
...@@ -31,71 +49,7 @@ export async function apiAutoLogin(params: UTSJSONObject): Promise<UTSJSONObject ...@@ -31,71 +49,7 @@ export async function apiAutoLogin(params: UTSJSONObject): Promise<UTSJSONObject
return await http.fetch('dj.api.smartcarlife.sms.noSignIn.login', data, true, 'dj') return await http.fetch('dj.api.smartcarlife.sms.noSignIn.login', data, true, 'dj')
} }
// 获取账号列表:dj.api.smartcarlife.workWechat.listSelectAccount /** 查询门店保险权益 */
export async function apiGetListSelectAccount(params: UTSJSONObject): Promise<UTSJSONObject> {
const data: UTSJSONObject = {
projectName: 'boutique',
...params
}
return await http.fetch('dj.api.smartcarlife.workWechat.listSelectAccount', data, true, 'dj')
}
// 选择账号登录:dj.api.smartcarlife.workWechat.selectAccountLogin
export async function apiSelectAccountLogin(params: UTSJSONObject): Promise<UTSJSONObject> {
const data: UTSJSONObject = {
projectName: 'boutique',
method: 'dj.api.smartcarlife.workWechat.selectAccountLogin',
...params
}
return await http.post(data, true, 'dj', null)
}
// 获取园区店下的4S店:dj.api.scenemerchantref.query4SRefByYqShopByLogin
export async function apiGetSceneMerchantRefStoreList(params: UTSJSONObject): Promise<any> {
console.log("🚀 ~ 取园区店下的4S店 ~ params:", params)
const data: UTSJSONObject = {
projectName: 'boutique',
method: 'dj.api.scenemerchantref.query4SRefByYqShopByLogin',
...params
}
console.log("🚀 ~ 取园区店下的4S店 ~ params:", data)
return await http.post(data, true, 'dj', null)
}
// 获取园区店开通的场景:dj.api.smartcarlife.select.openScene.info
export async function apiGetYqMerchantSceneConfigAPI(params: UTSJSONObject): Promise<any> {
const data: UTSJSONObject = {
projectName: 'boutique',
method: 'dj.api.smartcarlife.select.openScene.info',
...params
}
return await http.post(data, true, 'dj', null)
}
// 选择4S店和场景:dj.api.smartcarlife.selectMerchantScene
export async function apiSelectMerchantScene(params: UTSJSONObject): Promise<any> {
const data: UTSJSONObject = {
projectName: 'boutique',
method: 'dj.api.smartcarlife.selectMerchantScene',
...params
}
return await http.post(data, true, 'dj', null)
}
// 查询门店品牌:dj.api.smartcarlife.recepiton.findMerchantBrand
export async function apiGetMerchantBrand(params: UTSJSONObject): Promise<any> {
const data: UTSJSONObject = {
projectName: 'boutique',
method: 'dj.api.smartcarlife.recepiton.findMerchantBrand',
...params
}
return await http.post(data, true, 'dj', null)
}
/**
* 查询门店保险权益
*/
export function getMerchantInsuranceListApi(data: UTSJSONObject): Promise<any> { export function getMerchantInsuranceListApi(data: UTSJSONObject): Promise<any> {
return http.post({ return http.post({
'method': 'dj.api.smartcarlife.recepiton.findMerchantItem', 'method': 'dj.api.smartcarlife.recepiton.findMerchantItem',
......
// ==================== WebSocket 配置 ====================
export type WsConfig = {
loginUrl: string
wsUrl: string
}
// TODO: 请根据实际后端服务地址修改
// export const SERVER_HOST: string = "192.168.1.237";
// export const HTTP_SERVER: string = `http://${SERVER_HOST}:3000`;
// export const SOCKET_SERVER: string = `ws://${SERVER_HOST}:8081/ws-native`;
export const SERVER_HOST: string = "192.168.3.63";
export const HTTP_SERVER: string = `http://${SERVER_HOST}:82/api`;
export const SOCKET_SERVER: string = `ws://${SERVER_HOST}:82/ws-native`;
export const wsConfig: WsConfig = {
wsUrl: SOCKET_SERVER,
loginUrl: `${HTTP_SERVER}/login` // ← 如果接口路径不同,修改这里,例如:/api/login
};
// ==================== 日志服务配置 ====================
export const LoggerUploadServerUrl: string = `http://${SERVER_HOST}:3000/file/upload`;
export const LoggerUploadHeaders: null | UTSJSONObject = null;
export const LoggerUploadDays: number = 7;
type LoggerUploadConfig = {
days?: number
headers?: null | UTSJSONObject
serverUrl: string
}
type LoggerDefaultConfig = {
upload: LoggerUploadConfig
}
/**
* 日志服务默认配置
*/
export const LoggerConfig = {
/**
* 默认上传配置
*/
upload: {
/**
* 上传服务器地址
*/
serverUrl: LoggerUploadServerUrl,
/**
* 默认请求头
*/
headers: LoggerUploadHeaders,
/**
* 默认上传最近几天的日志
*/
days: LoggerUploadDays
} as LoggerUploadConfig
} as LoggerDefaultConfig;
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
--l-radius-md: 8px; --l-radius-md: 8px;
--l-radius-lg: 12px; --l-radius-lg: 12px;
--l-radius-xl: 16px; --l-radius-xl: 16px;
--l-radius-a: 100rpx; --l-radius-a : 100rpx;
/* 接待中心左右模块宽度(1173x768 基准),LayoutService 动态覆盖 */ /* 接待中心左右模块宽度(1173x768 基准),LayoutService 动态覆盖 */
--l-reception-left-width: 328px; --l-reception-left-width: 328px;
--l-reception-right-width: 677px; --l-reception-right-width: 677px;
......
<!-- 退出弹框 -->
<template>
<MessageBox ref="finishRef" :content="finishContene" :isFooter="false">
<view class="footer">
<view class="footer-btn confirm flex" @click="$emit('openStep')">
<template v-if="finishDoneText">
{{ finishDoneText }}
</template>
<template v-else>
完成接待
<text class="btn-text">
(推荐)
</text>
</template>
</view>
<view class="footer-btn cancel flex" @click="$emit('backHome')">
仍要退出
<text class="btn-text">
(不推荐)
</text>
</view>
</view>
</MessageBox>
</template>
<script setup lang="uts">
import MessageBox from './MessageBox.uvue'
import { callComponentMethod } from '@/utils/common.uts'
const props = defineProps({
finishDoneText: String,
finishContene: {
type: String,
default: '当前操作视为强制退出接待,若需正常流程完成接待请点击「完成接待」'
}
})
const finishRef = ref(null)
function open(): void {
callComponentMethod(finishRef, 'open')
}
function hide(): void {
callComponentMethod(finishRef, 'close')
}
const emit = defineEmits(['openStep', 'backHome'])
defineExpose({ open, hide })
</script>
<style lang="scss">
.footer {
border-top: 2rpx solid #eff0f2;
font-weight: 600;
font-size: 32rpx;
margin-top: 48rpx;
.footer-btn {
justify-content: center;
margin: 16rpx auto 0;
flex-direction: row;
align-items: center;
}
.confirm {
width: 608rpx;
height: 80rpx;
background: #2c66f7;
border-radius: 40rpx;
color: #fff;
}
.cancel {
width: 608rpx;
height: 80rpx;
background: #ffffff00;
border-radius: 40rpx;
color: #2c66f7;
}
.btn-text { // ✅ UVUE 只支持类名选择器,不能使用元素选择器 text
font-size: 24rpx;
}
}
</style>
...@@ -4,12 +4,13 @@ ...@@ -4,12 +4,13 @@
:z-index="99" :z-index="99"
:title="title" :title="title"
:closeable="true" :closeable="true"
@close="close"> @close="close"
@close-icon-click="close">
<view class="popup-panel" :style="popupStyle"> <view class="popup-panel" :style="popupStyle">
<view class="popup-content"> <view class="popup-content">
<view v-for="(item, index) in list" <view v-for="(item, index) in list"
:key="index" :key="index"
class="popup-item" :class="['popup-item', itemRowActive(item) ? 'popup-item-active' : '']"
@tap="handleChoose(index)"> @tap="handleChoose(index)">
<view class="item-icon"> <view class="item-icon">
<text class="item-icon-text">{{ (item as UTSJSONObject).icon ?? '' }}</text> <text class="item-icon-text">{{ (item as UTSJSONObject).icon ?? '' }}</text>
...@@ -18,6 +19,9 @@ ...@@ -18,6 +19,9 @@
<text class="item-title">{{ (item as UTSJSONObject).title ?? '' }}</text> <text class="item-title">{{ (item as UTSJSONObject).title ?? '' }}</text>
<text class="item-describe">{{ (item as UTSJSONObject).describe ?? '' }}</text> <text class="item-describe">{{ (item as UTSJSONObject).describe ?? '' }}</text>
</view> </view>
<view v-if="itemRowActive(item)" class="item-active-pill">
<text class="item-active-pill-text">当前</text>
</view>
<view class="item-arrow"> <view class="item-arrow">
<un-icon name="arrow-right" size="14" color="#8aa0bf"></un-icon> <un-icon name="arrow-right" size="14" color="#8aa0bf"></un-icon>
</view> </view>
...@@ -28,14 +32,18 @@ ...@@ -28,14 +32,18 @@
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import { computed, defineExpose, ref } from "vue"; import { computed, defineExpose, ref, withDefaults } from "vue";
const props = defineProps<{ const props = withDefaults(defineProps<{
list?: any[] list?: any[]
title?: string title?: string
/** 受控显示,父组件传 true 即打开 */ /** 受控显示,父组件传 true 即打开 */
visible?: boolean visible?: boolean
}>(); /** 与列表项 `typeCode` 比对,高亮当前选中(Pad 业务类型等) */
selectedTypeCode?: string | null
}>(), {
selectedTypeCode: null,
});
const emit = defineEmits<{ const emit = defineEmits<{
choose: [index: number] choose: [index: number]
...@@ -56,10 +64,20 @@ const popupStyle = computed((): UTSJSONObject => { ...@@ -56,10 +64,20 @@ const popupStyle = computed((): UTSJSONObject => {
}); });
const visible = computed((): boolean => { const visible = computed((): boolean => {
if (props.visible != null) return props.visible === true; if (props.visible != null) return props.visible == true;
return internalVisible.value; return internalVisible.value;
}); });
function itemRowActive(item: any): boolean {
const sel = props.selectedTypeCode;
if (sel == null || sel === "") {
return false;
}
const obj = item as UTSJSONObject;
const code = obj["typeCode"] as string | null;
return code != null && code !== "" && code === sel;
}
function open(): void { function open(): void {
if (props.visible != null) { if (props.visible != null) {
emit("update:visible", true); emit("update:visible", true);
...@@ -88,7 +106,7 @@ defineExpose({ ...@@ -88,7 +106,7 @@ defineExpose({
.popup-panel { .popup-panel {
border-radius: 16px; border-radius: 16px;
overflow: hidden; overflow: hidden;
background: linear-gradient(180deg, #ffffff 0%, #f7faff 100%); background-color: var(--bg-card, #FFFFFF);
margin: 0 auto; margin: 0 auto;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
...@@ -117,6 +135,34 @@ defineExpose({ ...@@ -117,6 +135,34 @@ defineExpose({
margin-bottom: 0; margin-bottom: 0;
} }
.popup-item-active {
border-color: rgba(44, 102, 247, 0.55);
background: rgba(44, 102, 247, 0.08);
box-shadow: 0 6px 16px rgba(44, 102, 247, 0.18);
}
.item-active-pill {
flex-shrink: 0;
margin-right: 6px;
padding: 2px 8px;
border-radius: 10px;
background: rgba(44, 102, 247, 0.16);
border-width: 1px;
border-style: solid;
border-color: rgba(44, 102, 247, 0.35);
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
}
.item-active-pill-text {
font-size: 11px;
font-weight: 600;
color: #2c66f7;
line-height: 14px;
}
.item-icon { .item-icon {
width: 40px; width: 40px;
height: 40px; height: 40px;
......
<template> <template>
<!-- 引用示例:<CustomEmpty type="contract" :icon="'/static/empty/icon-base-empty.png'" :title="'自定义文案'" :customStyle="{ backgroundColor: '#999999', width: '300rpx' }"/> --> <!-- 引用示例:<CustomEmpty preset="contract" :icon="'/static/empty/icon-base-empty.png'" :title="'自定义文案'" :customStyle="{ backgroundColor: '#999999', width: '300rpx' }"/> -->
<view class="empty-wrapper" :style="wrapperStyle"> <view class="empty-wrapper" :style="wrapperStyle">
<!-- 图标插槽,支持完全自定义图标 --> <!-- 图标插槽,支持完全自定义图标 -->
<slot name="icon"> <slot name="icon">
...@@ -23,107 +23,57 @@ ...@@ -23,107 +23,57 @@
<script setup lang="uts"> <script setup lang="uts">
import { computed } from 'vue' import { computed } from 'vue'
import {
type EmptyTypeConfig = { EMPTY_FALLBACK_TITLE,
icon: string EMPTY_PROP_DEFAULT_DESCRIPTION,
title: string EMPTY_PROP_DEFAULT_ICON,
} EMPTY_PROP_DEFAULT_PRESET,
EMPTY_PROP_DEFAULT_TITLE,
/** 预设类型 key,扩展时在此类型和 PRESET_TYPES 中同步添加 */ getEmptyPreset,
type PresetTypesMap = { TYPE_ICON_BASE_PATH,
base: EmptyTypeConfig type EmptyTypeConfig
home: EmptyTypeConfig } from './presets.uts'
common: EmptyTypeConfig
contract: EmptyTypeConfig type Props = {
function: EmptyTypeConfig preset?: String
} icon?: String
title?: String
const TYPE_ICON_BASE_PATH: string = '/static/empty/' description?: String
customStyle?: any | null
/** 预设类型配置,图标需放在 /static/empty/ 下 */
const PRESET_TYPES: PresetTypesMap = {
base: {
icon: 'icon-base-empty.png',
title: '暂无数据'
},
home: {
icon: 'icon-home-empty.png',
title: '暂无数据'
},
common: {
icon: 'icon-common-empty.png',
title: '暂无数据'
},
contract: {
icon: 'icon-contract-empty.png',
title: '请先选择合同,签约个人信息自动带出'
},
function: {
icon: 'icon-function-empty.png',
title: '请先选择合同,签约个人信息自动带出'
}
}
interface CustomEmptyProps {
/**
* 预设类型:base | home | common | contract | function,展示对应图标与默认文案;扩展时在 PRESET_TYPES 中增加配置即可
*/
type: string
/**
* 直接传入图标地址,优先级高于 type
*/
icon: string
/**
* 主标题文案,不传时使用当前类型的默认文案
*/
title: string
/**
* 副标题/描述文案
*/
description: string
/**
* 外层容器样式,支持字符串或对象,覆盖默认居中样式
*/
customStyle: any | null
} }
const props = withDefaults(defineProps<CustomEmptyProps>(), { const props = withDefaults(defineProps<Props>(), {
type: 'base', preset: EMPTY_PROP_DEFAULT_PRESET,
icon: '', icon: EMPTY_PROP_DEFAULT_ICON,
title: '', title: EMPTY_PROP_DEFAULT_TITLE,
description: '', description: EMPTY_PROP_DEFAULT_DESCRIPTION,
customStyle: null customStyle: null
}) })
const getPreset = (type: string): EmptyTypeConfig | null => {
if (type == 'base') return PRESET_TYPES.base
if (type == 'home') return PRESET_TYPES.home
if (type == 'common') return PRESET_TYPES.common
if (type == 'contract') return PRESET_TYPES.contract
if (type == 'function') return PRESET_TYPES.function
return null
}
const typeConfig = computed<EmptyTypeConfig | null>(() => { const typeConfig = computed<EmptyTypeConfig | null>(() => {
return getPreset(props.type) return getEmptyPreset(props.preset)
}) })
const iconSrc = computed<string>(() => { const iconSrc = computed<String>(() => {
if (props.icon != '') { if (props.icon != EMPTY_PROP_DEFAULT_ICON) {
return props.icon return props.icon
} }
const config = typeConfig.value const config = typeConfig.value
if (config == null) { if (config == null) {
return '' return EMPTY_PROP_DEFAULT_ICON
} }
return TYPE_ICON_BASE_PATH + config.icon return `${TYPE_ICON_BASE_PATH}${config.icon}`
}) })
const displayTitle = computed<string>(() => { const displayTitle = computed<String>(() => {
if (props.title != '') { if (props.title != EMPTY_PROP_DEFAULT_TITLE) {
return props.title return props.title
} }
return typeConfig.value?.title ?? '暂无数据' const cfg = typeConfig.value
if (cfg == null) {
return EMPTY_FALLBACK_TITLE
}
return cfg.title
}) })
const wrapperStyle = computed<any>(() => { const wrapperStyle = computed<any>(() => {
...@@ -131,15 +81,15 @@ ...@@ -131,15 +81,15 @@
}) })
const showIcon = computed<boolean>(() => { const showIcon = computed<boolean>(() => {
return iconSrc.value != '' return iconSrc.value != EMPTY_PROP_DEFAULT_ICON
}) })
const showTitle = computed<boolean>(() => { const showTitle = computed<boolean>(() => {
return displayTitle.value != '' return displayTitle.value != EMPTY_PROP_DEFAULT_TITLE
}) })
const showDescription = computed<boolean>(() => { const showDescription = computed<boolean>(() => {
return props.description != '' return props.description != EMPTY_PROP_DEFAULT_DESCRIPTION
}) })
</script> </script>
......
/**
* CustomEmpty 预设配置:放在 .uts 中,避免 uvue 内大量字符串字面量触发 Android kotlin/java String(error17)
*/
export type EmptyTypeConfig = {
icon: String
title: String
}
export type PresetTypesMap = {
base: EmptyTypeConfig
home: EmptyTypeConfig
common: EmptyTypeConfig
contract: EmptyTypeConfig
function: EmptyTypeConfig
}
export const TYPE_ICON_BASE_PATH: String = "/static/empty/"
export const PRESET_TYPES: PresetTypesMap = {
base: {
icon: "icon-base-empty.png",
title: "暂无数据"
},
home: {
icon: "icon-home-empty.png",
title: "暂无数据"
},
common: {
icon: "icon-common-empty.png",
title: "暂无数据"
},
contract: {
icon: "icon-contract-empty.png",
title: "请先选择合同,签约个人信息自动带出"
},
function: {
icon: "icon-function-empty.png",
title: "请先选择合同,签约个人信息自动带出"
}
}
export function getEmptyPreset(preset: String): EmptyTypeConfig | null {
if (preset == "base") return PRESET_TYPES.base
if (preset == "home") return PRESET_TYPES.home
if (preset == "common") return PRESET_TYPES.common
if (preset == "contract") return PRESET_TYPES.contract
if (preset == "function") return PRESET_TYPES.function
return null
}
/** defineProps 默认值用 .uts 字面量,减轻 uvue 侧 String 桥接问题 */
export const EMPTY_PROP_DEFAULT_PRESET: String = "base"
export const EMPTY_PROP_DEFAULT_ICON: String = ""
export const EMPTY_PROP_DEFAULT_TITLE: String = ""
export const EMPTY_PROP_DEFAULT_DESCRIPTION: String = ""
export const EMPTY_FALLBACK_TITLE: String = "暂无数据"
# CustomPopup 公共弹窗组件
高度可配置的公共弹窗组件,支持多种定位模式、丰富的自定义选项及完善的交互体验。
## 过渡效果
- **遮罩**:淡入淡出
- **居中弹窗**:缩放 + 透明度(scale 0.9→1)
- **底部/顶部弹窗**:垂直滑入滑出
- **左侧/右侧弹窗**:水平滑入滑出
- **时长**:通过 `transitionDuration` 配置,默认 2000ms
## 使用方式
```vue
<template>
<custom-popup
v-model:visible="showPopup"
position="center"
title="提示"
@confirm="onConfirm"
@cancel="onCancel"
>
<text>弹窗内容</text>
</custom-popup>
</template>
<script setup lang="uts">
import { ref } from 'vue'
const showPopup = ref(false)
function onConfirm() {
// 确认逻辑
}
function onCancel() {
// 取消逻辑
}
</script>
```
## Props
| 属性 | 类型 | 默认值 | 说明 |
|------|------|--------|------|
| visible | boolean | false | 受控显示,支持 v-model:visible |
| position | 'center' \| 'bottom' \| 'top' \| 'left' \| 'right' | 'center' | 定位模式 |
| radiusPreset | 'sm' \| 'md' \| 'lg' \| 'full' | 'md' | 圆角预设:小(4px)、中(8px)、大(12px)、全圆角 |
| borderRadius | string | - | 自定义圆角值,优先级高于 radiusPreset |
| bottomHeight | string | '50%' | 底部/顶部弹窗高度 |
| sideWidth | string | '80%' | 侧边弹窗宽度 |
| showMask | boolean | true | 是否显示遮罩 |
| maskClosable | boolean | true | 遮罩点击是否关闭 |
| maskOpacity | number | 0.5 | 遮罩透明度 |
| showHeader | boolean | true | 是否显示标题栏 |
| title | string | '' | 标题文本 |
| showClose | boolean | true | 是否显示关闭按钮 |
| closePosition | 'top-right' \| 'top-left' \| 'bottom-right' \| 'bottom-left' | 'top-right' | 关闭按钮位置 |
| headerBorder | boolean | true | 标题栏底部分隔线 |
| showFooter | boolean | true | 是否显示底部按钮区 |
| showCancelBtn | boolean | true | 是否显示取消按钮 |
| cancelText | string | '取消' | 取消按钮文案 |
| confirmText | string | '确认' | 确认按钮文案 |
| confirmLoadingText | string | '加载中...' | 确认按钮加载中文案 |
| buttonOrder | 'cancel-first' \| 'confirm-first' | 'cancel-first' | 按钮顺序 |
| confirmLoading | boolean | false | 确认按钮加载中 |
| confirmDisabled | boolean | false | 确认按钮禁用 |
| cancelDisabled | boolean | false | 取消按钮禁用 |
| customStyle | object | null | 自定义容器样式 |
| transitionDuration | number | 2000 | 过渡时长(毫秒),遮罩与容器的动画时长 |
## Slots
| 插槽名 | 说明 |
|--------|------|
| default | 主体内容 |
| header | 自定义标题栏,替换默认标题+关闭 |
| close-icon | 自定义关闭图标 |
| footer | 自定义底部区域,替换默认按钮组 |
## Events
| 事件 | 说明 |
|------|------|
| update:visible | v-model 同步 |
| close | 弹窗关闭时 |
| cancel | 点击取消按钮 |
| confirm | 点击确认按钮 |
## 方法(defineExpose)
| 方法 | 说明 |
|------|------|
| open() | 打开弹窗 |
| close() | 关闭弹窗 |
## CSS 变量(主题化)
父级可通过以下变量覆盖样式:
- `--popup-primary-color` 主色
- `--popup-border-radius` 圆角
- `--popup-shadow` 阴影
- `--popup-spacing` 间距
- `--popup-font-size` 字体大小
- `--popup-mask-color` 遮罩颜色
- `--popup-mask-opacity` 遮罩透明度
## 结构类名
- `.popup-mask` 遮罩层
- `.popup-container` 弹窗容器
- `.popup-header` 标题栏
- `.popup-body` 内容区
- `.popup-footer` 底部操作区
<template>
<view :class="['customer-box',{'is-show':showCustomerBox}]">
<view class="customer-title">
客户档案的记录
</view>
<scroll-view
scroll-y
class="scroll-box"
:style="scrollBoxStyle"
>
<template v-if="loading">
<view class="loading flex">
<uni-icons
type="refreshempty"
:size="46"
color="#3773F8"
class="icon"
>
</uni-icons>
</view>
</template>
<template v-else>
<template v-if="searchList.length">
<template v-for="(i,index) in searchList" :key="index">
<view
class="item flex"
hover-class="active"
@click="chooseItem(i)"
>
{{ `${showType == 'tel'?i.ownerPhone:i.ownerName}`}}
</view>
</template>
</template>
<template v-else>
<view class="nothing flex">
<view class="icon">
</view>
未匹配到客户信息
</view>
</template>
</template>
</scroll-view>
</view>
</template>
<script setup lang="uts">
import { storage } from '@/utils/storage.uts'
import { state } from '@/store/index.uts'
import { getCustomerInfoListApi } from '@/api/customer-api.uts'
type CustomerInfo = UTSJSONObject
type UserInfo = UTSJSONObject
type SearchParams = {
merchantId: string
bussinessScene: number
ownerPhone?: string
ownerName?: string
}
const props = defineProps({
searchValue: String,
showType: String,
show: Boolean
})
const emit = defineEmits(['choose'])
const loading = ref<boolean>(true)
const searchList = ref<Array<CustomerInfo>>([])
const showCustomerBox = computed<boolean>(() => {
const searchValue = props.searchValue ?? ''
return props.show == true && (state.user?.haveCustomerAccess ?? false) && (searchValue !== '' && searchValue !== null)
})
// ✅ UVUE 不支持 calc(),动态计算 scroll-box 高度
const scrollBoxStyle = computed<UTSJSONObject>(() => {
// 原样式: height: calc(100% - 64rpx)
// 64rpx ≈ 32px (rpx 是响应式像素,通常 2rpx = 1px)
// 使用百分比近似:95%
return {
"height": "95%"
} as UTSJSONObject;
});
async function getCustomerInfoList(val: string, type: string): Promise<void> {
try {
loading.value = true
const userInfo: UserInfo | null = storage.get("userInfo") as UTSJSONObject | null
const userInfoObj = userInfo ?? { shopMerchantId: '', sceneType: 0 }
const shopMerchantId = userInfoObj.shopMerchantId
const params: SearchParams = {
merchantId: shopMerchantId as String,
bussinessScene: userInfoObj.sceneType == 0 ? 1 : 2
}
if (type == 'tel') {
params.ownerPhone= val
} else {
params.ownerName = val
}
const result = await getCustomerInfoListApi(params as UTSJSONObject)
searchList.value = result as UTSArray<UTSJSONObject>
loading.value = false
} catch (error) {
loading.value = false
}
}
watch(showCustomerBox.value , (newVal: boolean) => {
if (newVal == true) {
getCustomerInfoList(props.searchValue ?? '', props.showType ?? '')
}
}, { immediate: true })
function chooseItem(item: CustomerInfo): void {
emit('choose', item)
}
</script>
<style scoped lang='scss'>
.customer-box {
position: absolute;
left: 0;
top: 88rpx;
width: 100%;
height: 352rpx;
background: #ffffff;
border-radius: 16rpx;
z-index: -1;
opacity: 0;
.customer-title {
font-size: 24rpx;
color: #999999;
line-height: 40rpx;
padding: 16rpx 24rpx 8rpx;
}
.scroll-box {
// ✅ UVUE 不支持 calc(),高度由 JS 动态计算
height: 95%;
.loading {
width: 100%;
height: 100%;
justify-content: center;
.icon {
// ✅ UVUE 不支持 animation,已移除旋转动画
}
}
.nothing {
width: 100%;
height: 100%;
font-size: 24rpx;
color: #c7ccd7;
flex-direction: column;
.icon {
margin-top: 52rpx;
width: 96rpx;
height: 96rpx;
/* background-image: url('@/assets/images/common/nothing.webp'); */
background-size: 100%;
}
}
.item {
width: 100%;
height: 48rpx;
font-size: 28rpx;
color: #333333;
line-height: 40rpx;
padding-left: 24rpx;
margin-bottom: 8rpx;
}
.active {
background: #ecf1ff;
}
// ✅ UVUE 不支持 @keyframes,已移除 rotate-loading 动画
}
}
.is-show {
z-index: 1;
opacity: 1;
}
</style>
...@@ -17,18 +17,18 @@ ...@@ -17,18 +17,18 @@
:show-scrollbar="false" :show-scrollbar="false"
:bounces="false" :bounces="false"
:scroll-with-animation="false" :scroll-with-animation="false"
:enable-back-to-top="false"
scroll-y> scroll-y>
<view v-if="employeeList.length === 0" style="padding: 40px 20px; text-align: center;"> <view v-if="employeeList.length == 0" style="padding: 40px 20px; text-align: center;">
<text style="color: #999; font-size: 14px;">暂无销售人员数据</text> <text style="color: #999; font-size: 14px;">暂无销售人员数据</text>
</view> </view>
<view v-if="employeeList.length > 0" class="view-content"> <view class="view-content">
<view v-for="(item, index) in employeeList" :key="index" <template v-for="(item, index) in employeeList" :key="index">
class="select-item" <view class="select-item"
:class="[{ 'is-active': (salesUuid as string) == (item as UTSJSONObject).uuid }]" :class="[{ 'is-active': (salesUuid as string) == (item as UTSJSONObject).uuid }]"
@click="handleSelect(item)"> @click="handleSelect(item)">
<text class="select-item-text" :class="[{ 'is-active-text': (salesUuid as string) == (item as UTSJSONObject).uuid }]">{{ (item as UTSJSONObject).staffName }}</text> <text class="select-item-text" :class="[{ 'is-active-text': (salesUuid as string) == (item as UTSJSONObject).uuid }]">{{ (item as UTSJSONObject).staffName }}</text>
</view> </view>
</template>
</view> </view>
</scroll-view> </scroll-view>
</view> </view>
...@@ -37,13 +37,16 @@ ...@@ -37,13 +37,16 @@
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import { ComponentPublicInstance, computed, ref, watch } from "vue"; import { ComponentPublicInstance, computed, onUnmounted, ref, watch } from "vue";
import { getEmployeeListApi } from "@/api/common-api.uts"; import { getEmployeeListApi } from "@/api/common-api.uts";
// import { resolutionState } from "@/services/adapter/index.uts"; // import { resolutionState } from "@/services/adapter/index.uts";
import { dispatch, state } from "@/store/index.uts"; import { dispatch, state } from "@/store/index.uts";
import { storage } from "@/utils/storage.uts"; import { storage } from "@/utils/storage.uts";
import { useWindowHeight } from "@/services/adapter/hooks/index.uts";
// 使用统一的 windowHeight hook
const windowHeight = useWindowHeight();
type Props = { type Props = {
salesPropsUuid?: string salesPropsUuid?: string
title?: string title?: string
...@@ -58,6 +61,11 @@ const props = withDefaults(defineProps<Props>(), { ...@@ -58,6 +61,11 @@ const props = withDefaults(defineProps<Props>(), {
const emit = defineEmits(["close", "select"]); const emit = defineEmits(["close", "select"]);
let componentDisposed = false;
onUnmounted((): void => {
componentDisposed = true;
});
const visible = ref<boolean>(false); const visible = ref<boolean>(false);
const watchStatus = computed<boolean>(() => { const watchStatus = computed<boolean>(() => {
...@@ -82,17 +90,45 @@ const salesUuid = computed<string>(() => { ...@@ -82,17 +90,45 @@ const salesUuid = computed<string>(() => {
const dynamicZIndex = computed<number>(() => { const dynamicZIndex = computed<number>(() => {
return 10090; return 10090;
}); });
const windowHeight = computed<number>(() => { // const windowHeight = computed<number>(() => {
// const height = resolutionState.windowHeight; // const height = resolutionState.windowHeight;
return uni.getWindowInfo().windowHeight; // return height > 0 ? height : uni.getWindowInfo().windowHeight;
}); // });
const employeeList = ref<Array<any>>([]); const employeeList = ref<Array<any>>([]);
watch(updateView, (newVal: number) => { /** 使用 `string` 字面量键;`String` 类型在桥接时可能异常;缓存可能是 JSON 字符串或数组 */
// 优先从 store 读取,避免 storage 序列化问题 const STORAGE_KEY_EMPLOYEE_LIST = "employeeList";
const employeeListFromStore = state.user.employeeList;
employeeList.value = employeeListFromStore != null ? employeeListFromStore : []; function readEmployeeListFromStorage(): Array<any> {
const raw = storage.get(STORAGE_KEY_EMPLOYEE_LIST) as any | null;
if (raw == null) {
return [] as any[];
}
if (Array.isArray(raw)) {
return raw as Array<any>;
}
if (typeof raw === "string") {
const s = (raw as string).trim();
if (s === "") {
return [] as any[];
}
try {
const parsed = JSON.parse(s) as any;
return Array.isArray(parsed) ? (parsed as Array<any>) : ([] as any[]);
} catch (_e) {
return [] as any[];
}
}
return [] as any[];
}
watch(updateView, () => {
console.log("updateView triggered, reading from storage");
const list = readEmployeeListFromStorage();
console.log("storage employeeList length:", list.length);
employeeList.value = list;
console.log("employeeList.value updated, length:", employeeList.value.length);
}, { immediate: true }); }, { immediate: true });
function close(): void { function close(): void {
...@@ -117,27 +153,29 @@ function handleHide(): void { ...@@ -117,27 +153,29 @@ function handleHide(): void {
} }
function open(): void { function open(): void {
// 先显示弹窗
visible.value = true; visible.value = true;
const userInfo = storage.getParse("userInfo") as UserInfo;
// 如果已有数据,直接返回 const shopMerchantIdRaw = userInfo["shopMerchantId"] as string | null;
if (employeeList.value.length > 0) { const shopMerchantId = shopMerchantIdRaw != null ? shopMerchantIdRaw : "";
if (shopMerchantId === "") {
return; return;
} }
const userInfo: null | UserInfo = storage.get("userInfo") as null | UTSJSONObject; // 获取销售人员列表
if (userInfo == null) return;
const shopMerchantId = userInfo.shopMerchantId;
// 异步获取销售人员列表,不阻塞弹窗显示
getEmployeeListApi({ merchantId: shopMerchantId }).then((res: any) => { getEmployeeListApi({ merchantId: shopMerchantId }).then((res: any) => {
if (componentDisposed) {
return;
}
console.log("getEmployeeListApi response:", res);
const list = res as Array<any>; const list = res as Array<any>;
console.log("list length:", list != null ? list.length : 0);
dispatch("setEmployeeList", list); dispatch("setEmployeeList", list);
const listToStore = list != null ? list : []; const listToStore = list != null ? list : [];
storage.set("employeeList", listToStore, 0); console.log("Saving to storage, length:", listToStore.length);
storage.set(STORAGE_KEY_EMPLOYEE_LIST, listToStore, 0);
console.log("Triggering updateView");
updateView.value = Date.now(); updateView.value = Date.now();
}).catch((error) => { console.log("updateView triggered with:", updateView.value);
console.error('[Employee] getEmployeeListApi 失败:', error);
}); });
} }
...@@ -202,7 +240,7 @@ defineExpose({ open, close }); ...@@ -202,7 +240,7 @@ defineExpose({ open, close });
width: 100%; width: 100%;
padding: 16px 24px 24px; padding: 16px 24px 24px;
box-sizing: border-box; box-sizing: border-box;
min-height: 0; // ✅ UVUE 不支持 min-height: 100%,移除后由 flex 布局自适应
} }
.select-item { .select-item {
......
...@@ -50,7 +50,7 @@ const iconSize = computed((): number => { ...@@ -50,7 +50,7 @@ const iconSize = computed((): number => {
const entranceList = computed((): EntranceItem[] => { const entranceList = computed((): EntranceItem[] => {
const sceneType = props.sceneType ?? 1; const sceneType = props.sceneType ?? 1;
if (sceneType === 1) { if (sceneType == 1) {
// 轻改场景:对应老项目 icon-daily-report / icon-create-order / icon-defeat-order / icon-order-management / icon-wage-appeal // 轻改场景:对应老项目 icon-daily-report / icon-create-order / icon-defeat-order / icon-order-management / icon-wage-appeal
return [ return [
{ label: "驻店日报", icon: "daily-report", color: "#7c4dff" }, { label: "驻店日报", icon: "daily-report", color: "#7c4dff" },
...@@ -60,7 +60,7 @@ const entranceList = computed((): EntranceItem[] => { ...@@ -60,7 +60,7 @@ const entranceList = computed((): EntranceItem[] => {
{ label: "工资申诉", icon: "wage-appeal", color: "#ffc107" } { label: "工资申诉", icon: "wage-appeal", color: "#ffc107" }
]; ];
} }
if (sceneType === 0) { if (sceneType == 0) {
// 权益场景:在轻改基础上增加“权益提单” icon-equity-order // 权益场景:在轻改基础上增加“权益提单” icon-equity-order
return [ return [
{ label: "驻店日报", icon: "daily-report", color: "#7c4dff" }, { label: "驻店日报", icon: "daily-report", color: "#7c4dff" },
...@@ -123,11 +123,11 @@ function getIconUrl(icon: string): string { ...@@ -123,11 +123,11 @@ function getIconUrl(icon: string): string {
justify-content: space-between; justify-content: space-between;
align-content: flex-start; align-content: flex-start;
gap: var(--entrance-item-gap); gap: var(--entrance-item-gap);
min-height: 0; // ✅ UVUE 不支持 min-height: 100%,移除后由 flex 布局自适应
} }
.entrance-item { .entrance-item {
width: 33.33%; width: 33.33%; // ✅ UVUE 不支持 calc(100% / 3),直接使用百分比
min-height: 90px; min-height: 90px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
...@@ -136,10 +136,8 @@ function getIconUrl(icon: string): string { ...@@ -136,10 +136,8 @@ function getIconUrl(icon: string): string {
padding: 2px; padding: 2px;
border-radius: var(--l-radius-md); border-radius: var(--l-radius-md);
background: rgba(255, 255, 255, 0.6); background: rgba(255, 255, 255, 0.6);
transition-property: transform, background, box-shadow; // ✅ UVUE 不支持 cursor,移动端无鼠标指针
transition-duration: 0.3s; // ✅ 移除 transition,低端机上减少重绘
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
cursor: pointer;
} }
.entrance-item-hover { .entrance-item-hover {
...@@ -152,7 +150,7 @@ function getIconUrl(icon: string): string { ...@@ -152,7 +150,7 @@ function getIconUrl(icon: string): string {
width: var(--entrance-icon-size); width: var(--entrance-icon-size);
height: var(--entrance-icon-size); height: var(--entrance-icon-size);
border-radius: var(--l-radius-md); border-radius: var(--l-radius-md);
background-color: var(--bg-icon); background: linear-gradient(135deg, #f5f7fa 0%, #e8ecf5 100%);
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
...@@ -161,9 +159,14 @@ function getIconUrl(icon: string): string { ...@@ -161,9 +159,14 @@ function getIconUrl(icon: string): string {
margin-bottom: var(--l-spacing-sm); margin-bottom: var(--l-spacing-sm);
} }
// ✅ UVUE 不支持 :hover 伪类与后代选择器组合,移动端无鼠标悬停
// 简单的按压反馈已通过 hover-class="entrance-item-hover" 实现
.entrance-icon { .entrance-icon {
width: 36px; // ✅ UVUE 不支持 calc() 和 CSS 变量计算,使用固定值
height: 36px; // iconSize 由 JS 控制(56 或 52),这里设置为稍小的值
width: 40px; // 56 - 16 = 40 (横屏)
height: 40px; // 52 - 16 = 36 ≈ 40 (竖屏取整)
} }
.entrance-name { .entrance-name {
...@@ -176,14 +179,15 @@ function getIconUrl(icon: string): string { ...@@ -176,14 +179,15 @@ function getIconUrl(icon: string): string {
} }
.entrance-item-compact { .entrance-item-compact {
width: 33.33%; width: 33.33%; // ✅ UVUE 不支持 calc(100% / 3),直接使用百分比
min-height: 100px; min-height: 100px;
padding: var(--l-spacing-md); padding: var(--l-spacing-md);
} }
.entrance-icon-compact { .entrance-icon-compact {
width: 32px; // ✅ UVUE 不支持 calc() 和 CSS 变量计算,使用固定值
height: 32px; width: 36px; // 56 - 20 = 36 (横屏)
height: 36px; // 52 - 20 = 32 ≈ 36 (竖屏取整)
} }
.entrance-name-compact { .entrance-name-compact {
......
<template> <template>
<view v-if="!loadComplete" class="intro-swiper-loading"> <!-- <view v-if="!loadComplete" class="intro-swiper-loading">
<BannerSkeleton /> <BannerSkeleton />
</view> </view> -->
<view v-else-if="modules.length > 0" class="intro-swiper-custom-wrap fade-in"> <view class="intro-swiper-custom-wrap fade-in">
<view class="intro-swiper-custom-content"> <view class="intro-swiper-custom-content">
<view class="intro-hero-head"> <view class="intro-hero-head">
<view class="intro-hero-title-wrap"> <view class="intro-hero-title-wrap flex-row items-center">
<text class="intro-hero-eyebrow">{{ eyebrow }}</text> <text class="intro-hero-eyebrow">{{ eyebrow }}</text>
<text class="intro-hero-title">{{ heroTitle }}</text> <text class="intro-hero-title">{{ heroTitle }}</text>
</view> </view>
<view class="intro-hero-indicator-pill"> <view v-if="showSwitchProduct"
class="intro-switch-btn"
hover-class="intro-switch-btn-hover"
@click="onSwitchProductClick">
<view class="intro-switch-icon-box">
<un-icon name="reload" size="14" color="#2c66f7"></un-icon>
</view>
<text class="intro-switch-text">切换产品</text>
</view>
<view v-else-if="modules.length > 0" class="intro-hero-indicator-pill">
<text class="intro-hero-indicator-text">{{ currentSwiperIndex + 1 }}/{{ modules.length }}</text> <text class="intro-hero-indicator-text">{{ currentSwiperIndex + 1 }}/{{ modules.length }}</text>
</view> </view>
</view> </view>
<view class="intro-swiper-stack"> <view class="intro-swiper-stack" v-if="modules.length > 0">
<un-swiper <un-swiper class="intro-swiper"
class="intro-swiper"
:list="swiperList" :list="swiperList"
:autoplay="modules.length > 1" :autoplay="modules.length > 1"
:circular="modules.length > 1" :circular="modules.length > 1"
:indicator="false" :indicator="false"
:height="swiperHeight"
image-mode="aspectFill"
@change="(e: any) => onSwiperChangeFromEvent(e)" @change="(e: any) => onSwiperChangeFromEvent(e)"
@click="(idx: any) => onSlideTapFromEvent(idx)" @click="(idx: any) => onSlideTapFromEvent(idx)"></un-swiper>
></un-swiper>
<view v-if="hasDotsOverlay" class="intro-swiper-overlay"> <view v-if="hasDotsOverlay" class="intro-swiper-overlay">
<view class="intro-swiper-dots"> <view class="intro-swiper-dots">
<view v-for="(_, i) in modules" <view v-for="(_, i) in modules"
...@@ -32,43 +41,99 @@ ...@@ -32,43 +41,99 @@
</view> </view>
</view> </view>
</view> </view>
<view v-else class="intro-empty-un-wrap">
<un-empty mode="data"
:text="emptyDisplayText" />
</view> </view>
</view> </view>
<view v-else class="intro-swiper-empty fade-in">
<view class="intro-empty-card">
<text class="intro-empty-title">{{ emptyTitle }}</text>
<text class="intro-empty-text">{{ emptyText }}</text>
</view>
</view> </view>
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import { computed, ref, watch } from "vue"; import { computed, ref, watch, withDefaults } from "vue";
import BannerSkeleton from "@/components/Skeleton/BannerSkeleton.uvue"; import BannerSkeleton from "@/components/Skeleton/BannerSkeleton.uvue";
// ✅ 从 uview-unix 模块导入 UnSwiperItem 类型
import type { UnSwiperItem } from "@/uni_modules/uview-unix"; import type { UnSwiperItem } from "@/uni_modules/uview-unix";
import { useScreenVars } from "@/services/adapter/hooks/index.uts";
import homeFramePageVars from "./styles/index.vars.uts"; // ✅ 直接导入
const props = defineProps<{ const props = withDefaults(defineProps<{
loadComplete: boolean loadComplete: boolean
swiperList: UnSwiperItem[] swiperList: UnSwiperItem[]
modules: any[] modules: any[]
eyebrow: string eyebrow: string
emptyTitle: string emptyTitle: string
emptyText: string emptyText: string
// swiperHeight: number /** 与 simgle_app HomeSlot「切换产品」一致:展示按钮并向外触发选择流程 */
}>(); showSwitchProduct?: boolean
}>(), {
showSwitchProduct: false,
});
const emit = defineEmits<{ const emit = defineEmits<{
swiperChange: [index: number] swiperChange: [index: number]
slideTap: [index: number] slideTap: [index: number]
switchProduct: []
}>(); }>();
const currentSwiperIndex = ref<number>(0); const currentSwiperIndex = ref<number>(0);
/** 轮播图高度:从 useScreenVars 中获取 --swiper-height 变量 */
const screenVars = useScreenVars(homeFramePageVars);
const swiperHeight = computed((): number => {
// 从 CSS 变量中获取轮播图高度
const heightStr = screenVars.value["--swiper-height"] as string | null;
if (heightStr != null && heightStr !== "") {
// 如果是 calc() 表达式,无法直接解析,返回默认值
if (heightStr.indexOf("calc") >= 0) {
// calc(var(--module-box-height) - 40px) 的情况
// 尝试提取 module-box-height 的值
const moduleBoxHeightStr = screenVars.value["--module-box-height"] as string | null;
if (moduleBoxHeightStr != null && moduleBoxHeightStr.indexOf("px") > 0) {
const moduleBoxHeight = parseInt(moduleBoxHeightStr.replace("px", ""));
return moduleBoxHeight - 40; // 减去头部高度 40px
}
}
// 如果是直接的 px 值
if (heightStr.indexOf("px") > 0) {
return parseInt(heightStr.replace("px", ""));
}
}
// 默认高度(竖屏)
return 380;
});
/** 无列表数据时 un-empty 主文案(仍可用父级 intro-empty-text) */
const emptyDisplayText = computed((): string => {
const t = props.emptyText;
if (t != null && t !== "") {
return t;
}
return "暂无数据";
});
watch((): number => props.modules.length, (_len: number) => { watch((): number => props.modules.length, (_len: number) => {
currentSwiperIndex.value = 0; currentSwiperIndex.value = 0;
}); });
/** 切换业务类型后列表可能条数不变但 URL 已变,需回到第一张 */
watch((): string => {
const list = props.swiperList;
const n = list.length;
if (n == 0) {
return "0|";
}
// ✅ 使用导入的 UnSwiperItem 类型
const firstItem = list[0] as UnSwiperItem;
const u = firstItem.url != null ? firstItem.url : "";
const uStr = u !== "" ? `${u}` : "";
return `${n}|${uStr}`;
}, (_sig: string) => {
currentSwiperIndex.value = 0;
});
function moduleTitleAt(item: any): string { function moduleTitleAt(item: any): string {
if (item == null) { if (item == null) {
return ""; return "";
...@@ -132,6 +197,10 @@ function onSlideTapFromEvent(idx: any): void { ...@@ -132,6 +197,10 @@ function onSlideTapFromEvent(idx: any): void {
const n = typeof idx === "number" ? (idx as number) : 0; const n = typeof idx === "number" ? (idx as number) : 0;
onSlideTap(n); onSlideTap(n);
} }
function onSwitchProductClick(): void {
emit("switchProduct");
}
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
...@@ -171,23 +240,32 @@ function onSlideTapFromEvent(idx: any): void { ...@@ -171,23 +240,32 @@ function onSlideTapFromEvent(idx: any): void {
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
border-bottom: 1px solid rgba(226, 236, 248, 0.8); border-bottom: 1px solid rgba(226, 236, 248, 0.8);
background-color: var(--bg-header); background-color: var(--bg-card, #FFFFFF);
} }
.intro-hero-title-wrap { .intro-hero-title-wrap {
flex: 1; flex: 1;
min-width: 0; min-width: 0;
display: flex; display: flex;
flex-direction: column; flex-direction: row;
align-items: center;
font-size: 14px;
} }
/* 对齐 simgle_app `HomeSlot.vue` .title-text .highlight-type */
.intro-hero-eyebrow { .intro-hero-eyebrow {
font-size: 10px; flex-shrink: 0;
color: #8ea0ba; color: #2c66f7;
line-height: 12px; font-weight: 700;
margin-right: 8px;
font-size: 18px; // ✅ UVUE 不支持 em 单位,1.1em ≈ 18px
line-height: 1.2;
// text-shadow: 0 4px 8px rgba(44, 102, 247, 0.15);
} }
.intro-hero-title { .intro-hero-title {
flex: 1;
min-width: 0;
margin-top: 0; margin-top: 0;
font-size: 14px; font-size: 14px;
font-weight: 700; font-weight: 700;
...@@ -218,23 +296,76 @@ function onSlideTapFromEvent(idx: any): void { ...@@ -218,23 +296,76 @@ function onSlideTapFromEvent(idx: any): void {
color: #2a5ecf; color: #2a5ecf;
} }
/* 对齐 simgle_app `HomeSlot.vue` .switch-btn */
.intro-switch-btn {
flex-shrink: 0;
display: flex;
flex-direction: row;
align-items: center;
padding: 4px 10px 4px 6px;
margin-left: 8px;
background: rgba(44, 102, 247, 0.08);
border-radius: 16px;
border-width: 1px;
border-style: solid;
border-color: rgba(44, 102, 247, 0.15);
box-sizing: border-box;
}
.intro-switch-btn-hover {
opacity: 0.92;
background: rgba(44, 102, 247, 0.14);
}
.intro-switch-icon-box {
width: 18px;
height: 18px;
border-radius: 9px;
background: #ffffff;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
margin-right: 6px;
box-shadow: 0 2px 4px rgba(44, 102, 247, 0.12);
}
.intro-switch-text {
font-size: 12px;
color: #2c66f7;
font-weight: 500;
line-height: 14px;
}
.intro-swiper-stack { .intro-swiper-stack {
flex: 1; flex: 1;
width: 100%; width: 100%;
min-height: 0;
position: relative; position: relative;
padding: 0; display: flex;
flex-direction: column;
}
/* 无轮播数据:un-empty 在卡片内容区(标题下)水平垂直居中 */
.intro-empty-un-wrap {
flex: 1;
width: 100%;
min-height: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-sizing: border-box; box-sizing: border-box;
padding: 16px;
} }
.intro-swiper { .intro-swiper {
width: 100%; width: 100%;
height: 100%;
border-radius: 10px; border-radius: 10px;
overflow: hidden; overflow: hidden;
box-shadow: 0 8px 18px rgba(15, 23, 42, 0.10); box-shadow: 0 8px 18px rgba(15, 23, 42, 0.10);
} }
.intro-swiper-overlay { .intro-swiper-overlay {
position: absolute; position: absolute;
left: 0; left: 0;
...@@ -246,7 +377,8 @@ function onSlideTapFromEvent(idx: any): void { ...@@ -246,7 +377,8 @@ function onSlideTapFromEvent(idx: any): void {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: flex-end; justify-content: flex-end;
background-color: rgba(30, 58, 138, 0.3); /* uni-app x 仅支持 background-image 的 linear-gradient */
background-image: linear-gradient(to bottom, rgba(30, 58, 138, 0), rgba(30, 58, 138, 0.35));
border-radius: 10px; border-radius: 10px;
} }
...@@ -275,37 +407,4 @@ function onSlideTapFromEvent(idx: any): void { ...@@ -275,37 +407,4 @@ function onSlideTapFromEvent(idx: any): void {
background: rgba(255, 255, 255, 0.95); background: rgba(255, 255, 255, 0.95);
} }
.intro-swiper-empty {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
box-sizing: border-box;
}
.intro-empty-card {
margin: auto;
width: 70%;
min-height: 118px;
border-radius: 18px;
background: rgba(255, 255, 255, 0.86);
box-shadow: 0 10px 20px rgba(15, 23, 42, 0.08);
border: 1px solid #e3ecf8;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.intro-empty-title {
font-size: 16px;
font-weight: 600;
color: #1e293b;
margin-bottom: 6px;
}
.intro-empty-text {
font-size: 13px;
color: #94a3b8;
}
</style> </style>
<template> <template>
<!-- <!--
层级(仅 index 物理 tab 页): 简化版首页:仅产品介绍(精品套餐),无多场景切换。
1) SceneShell:横/竖两套 MainTabShell + 槽,见 SceneShell.uvue TabBarShell:横/竖 MainTabShell + 槽,见 TabBarShell.uvue
2) HomeMainTab:按 userInfo.sceneType 切换下方三选一子树
3) *HomePanel:各场景业务 + 内层 HomeFrame(三卡片区,embedInTabSlot 与壳分工)
--> -->
<view class="hf-home-main-tab"> <view class="hf-home-main-tab">
<view v-if="resolvedSceneType === 1" <view class="hf-home-main-inner">
class="hf-home-main-inner">
<BoutiqueHomePanel :logic="logic" /> <BoutiqueHomePanel :logic="logic" />
</view> </view>
<view v-else-if="resolvedSceneType === 0"
class="hf-home-main-inner">
<EquityHomePanel />
</view>
<view v-else-if="resolvedSceneType === 7"
class="hf-home-main-inner">
<UsedCarHomePanel />
</view>
<view v-else
class="hf-home-main-fallback">
<text class="hf-fallback-text">暂不支持当前场景</text>
</view>
</view> </view>
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import { computed } from "vue";
import BoutiqueHomePanel from "@/pages/boutique/components/BoutiqueHomePanel.uvue"; import BoutiqueHomePanel from "@/pages/boutique/components/BoutiqueHomePanel.uvue";
import EquityHomePanel from "@/pages/equity/components/EquityHomePanel.uvue";
import UsedCarHomePanel from "@/pages/usedCar/components/UsedCarHomePanel.uvue";
import type { BoutiqueLogic } from "@/pages/boutique/useBoutiqueLogic.uts"; import type { BoutiqueLogic } from "@/pages/boutique/useBoutiqueLogic.uts";
import { storage } from "@/utils/storage.uts";
const props = defineProps<{ const props = defineProps<{
logic: BoutiqueLogic logic: BoutiqueLogic
/** SceneShell 同步的 userInfo;switchTab 回首页时随 updateApp 更新,避免子组件 onShow 不触发导致场景不刷新 */
userInfo?: null | UTSJSONObject
}>(); }>();
const logic = props.logic; const logic = props.logic;
function sceneTypeFromStorage(): number {
const raw = storage.get("userInfo");
if (raw == null) {
return 1;
}
const st = (raw as UTSJSONObject).sceneType as null | number;
return st != null ? st : 1;
}
const resolvedSceneType = computed((): number => {
const u = props.userInfo;
if (u != null) {
const st = (u as UTSJSONObject).sceneType as null | number;
if (st != null) {
return st as number;
}
}
return sceneTypeFromStorage();
});
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
...@@ -82,22 +40,4 @@ const resolvedSceneType = computed((): number => { ...@@ -82,22 +40,4 @@ const resolvedSceneType = computed((): number => {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
.hf-home-main-fallback {
flex: 1;
width: 100%;
min-height: 0;
min-width: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 24px;
}
.hf-fallback-text {
font-size: 15px;
color: #666;
text-align: center;
}
</style> </style>
<template> <template>
<view class="home-frame-container scene-shell-root"> <view class="home-frame-container scene-shell-root"
>
<view class="my-center-wrap"> <view class="my-center-wrap">
<MyCenterMain :user-info="resolvedUserInfo" /> <MyCenterMain :user-info="resolvedUserInfo" />
</view> </view>
...@@ -10,7 +11,7 @@ ...@@ -10,7 +11,7 @@
import { computed } from "vue"; import { computed } from "vue";
// import { cssClassRef, useResolutionConfig } from "@/services/adapter"; // import { cssClassRef, useResolutionConfig } from "@/services/adapter";
import { layoutService } from "@/services/LayoutService.uts"; // import { layoutService } from "@/services/LayoutService.uts";
import MyCenterMain from "@/pages/person/MyCenterMain.uvue"; import MyCenterMain from "@/pages/person/MyCenterMain.uvue";
const props = defineProps<{ const props = defineProps<{
...@@ -29,12 +30,11 @@ const props = defineProps<{ ...@@ -29,12 +30,11 @@ const props = defineProps<{
// const m = modeRef.value; // const m = modeRef.value;
// return m == "portrait" ? "mode-portrait" : "mode-landscape"; // return m == "portrait" ? "mode-portrait" : "mode-landscape";
// }); // });
// TODO
const resolutionClass = computed((): string => { // const resolutionClass = computed((): string => {
const bucket = layoutService.getResolutionBucket(); // const bucket = layoutService.getResolutionBucket();
return `res-${bucket}`; // return `res-${bucket}`;
}); // });
const resolvedUserInfo = computed((): UTSJSONObject => { const resolvedUserInfo = computed((): UTSJSONObject => {
const u = props.userInfo; const u = props.userInfo;
......
<template> <template>
<view class="hf-reception-stack"> <view class="hf-reception-stack">
<ReceptionCenterMain /> <ReceptionCenter />
</view> </view>
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import ReceptionCenterMain from "@/pages/receptionCenter/center.uvue"; import ReceptionCenter from "@/pages/receptionCenter/center.uvue";
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
......
...@@ -5,14 +5,12 @@ ...@@ -5,14 +5,12 @@
HomeFrame 采用现代化的企业级设计语言,融合以下核心设计理念: HomeFrame 采用现代化的企业级设计语言,融合以下核心设计理念:
### 设计原则 ### 设计原则
- **视觉层次**:通过阴影、渐变、圆角建立清晰的层级关系 - **视觉层次**:通过阴影、渐变、圆角建立清晰的层级关系
- **微交互**:悬停效果、过渡动画提升用户体验 - **微交互**:悬停效果、过渡动画提升用户体验
- **响应式适配**:横竖屏自动切换,多分辨率精确适配 - **响应式适配**:横竖屏自动切换,多分辨率精确适配
- **一致性**:统一的设计令牌(Design Tokens)确保视觉一致性 - **一致性**:统一的设计令牌(Design Tokens)确保视觉一致性
### 核心特性 ### 核心特性
✨ **玻璃态卡片** - `backdrop-filter: blur(10px)` 营造现代感 ✨ **玻璃态卡片** - `backdrop-filter: blur(10px)` 营造现代感
🌈 **渐变色彩** - 企业级渐变色方案(primary/secondary/success) 🌈 **渐变色彩** - 企业级渐变色方案(primary/secondary/success)
💫 **流畅动画** - cubic-bezier 缓动函数实现自然过渡 💫 **流畅动画** - cubic-bezier 缓动函数实现自然过渡
...@@ -38,37 +36,37 @@ HomeFrame 组件采用 **CSS 变量 + layout-root** 的响应式方案,无需 ...@@ -38,37 +36,37 @@ HomeFrame 组件采用 **CSS 变量 + layout-root** 的响应式方案,无需
export default { export default {
common: { common: {
// 所有场景通用 // 所有场景通用
"--common-title-height": "48px", '--common-title-height': '48px',
// 设计系统变量 // 设计系统变量
"--l-spacing-sm": "8px", '--l-spacing-sm': '8px',
"--l-radius-lg": "16px", '--l-radius-lg': '16px',
"--l-shadow-md": "0 4px 16px rgba(0, 0, 0, 0.08)", '--l-shadow-md': '0 4px 16px rgba(0, 0, 0, 0.08)',
"--l-bg-card": "rgba(255, 255, 255, 0.85)", '--l-bg-card': 'rgba(255, 255, 255, 0.85)',
"--l-gradient-primary": "linear-gradient(135deg, #667eea 0%, #764ba2 100%)", '--l-gradient-primary': 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
}, },
portrait: { portrait: {
// 竖屏专用 // 竖屏专用
"--module-box-height": "auto", '--module-box-height': 'auto',
"--tool-box-min-height": "280px", '--tool-box-min-height': '280px',
"--entrance-icon-size": "52px", '--entrance-icon-size': '52px',
}, },
landscape: { landscape: {
// 横屏专用 // 横屏专用
"--module-box-height": "320px", '--module-box-height': '320px',
"--tool-box-height": "280px", '--tool-box-height': '280px',
"--entrance-icon-size": "56px", '--entrance-icon-size': '56px',
}, },
resolutions: { resolutions: {
// 精确分辨率适配(优先级最高) // 精确分辨率适配(优先级最高)
"landscape-1024x768": { 'landscape-1024x768': {
"--module-box-height": "360px", '--module-box-height': '360px',
"--entrance-icon-size": "60px", '--entrance-icon-size': '60px',
},
}, },
}; }
}
``` ```
## 使用方式 ## 使用方式
...@@ -76,7 +74,7 @@ export default { ...@@ -76,7 +74,7 @@ export default {
### 1. 在组件中导入配置 ### 1. 在组件中导入配置
```typescript ```typescript
import pageVars from "./styles/index.vars"; import pageVars from "./styles/index.vars"
``` ```
### 2. 在 SCSS 中使用 CSS 变量 ### 2. 在 SCSS 中使用 CSS 变量
...@@ -91,14 +89,12 @@ import pageVars from "./styles/index.vars"; ...@@ -91,14 +89,12 @@ import pageVars from "./styles/index.vars";
### 3. 无需任何 JavaScript 逻辑 ### 3. 无需任何 JavaScript 逻辑
❌ **不需要**: ❌ **不需要**:
- 监听屏幕旋转事件 - 监听屏幕旋转事件
- 手动计算样式 - 手动计算样式
- 条件判断横竖屏 - 条件判断横竖屏
- 动态绑定 `:style` - 动态绑定 `:style`
✅ **只需要**: ✅ **只需要**:
- 定义 CSS 变量 - 定义 CSS 变量
- 在 SCSS 中引用 - 在 SCSS 中引用
...@@ -107,9 +103,8 @@ import pageVars from "./styles/index.vars"; ...@@ -107,9 +103,8 @@ import pageVars from "./styles/index.vars";
HomeFrame 布局相关变量简洁命名,间距和字体保留 `l-` 前缀: HomeFrame 布局相关变量简洁命名,间距和字体保留 `l-` 前缀:
### 基础变量 ### 基础变量
| 变量名 | 说明 | 示例值 | | 变量名 | 说明 | 示例值 |
| -------------------------- | ------------------------ | ---------------- | |--------|------|--------|
| `--module-box-height` | 产品介绍模块高度 | `320px` / `auto` | | `--module-box-height` | 产品介绍模块高度 | `320px` / `auto` |
| `--tool-box-height` | 展业工具模块高度(横屏) | `280px` | | `--tool-box-height` | 展业工具模块高度(横屏) | `280px` |
| `--tool-box-min-height` | 展业工具最小高度(竖屏) | `280px` | | `--tool-box-min-height` | 展业工具最小高度(竖屏) | `280px` |
...@@ -123,9 +118,8 @@ HomeFrame 布局相关变量简洁命名,间距和字体保留 `l-` 前缀: ...@@ -123,9 +118,8 @@ HomeFrame 布局相关变量简洁命名,间距和字体保留 `l-` 前缀:
| `--entrance-item-gap` | Entrance 项目间距 | `20px` / `24px` | | `--entrance-item-gap` | Entrance 项目间距 | `20px` / `24px` |
### 设计系统变量 ### 设计系统变量
| 变量名 | 说明 | 示例值 | | 变量名 | 说明 | 示例值 |
| ---------------- | ---------------------------------- | --------------------------- | |--------|------|--------|
| `--l-spacing-*` | 间距变量 (xs/sm/md/lg/xl/2xl/3xl) | `4px` ~ `32px` | | `--l-spacing-*` | 间距变量 (xs/sm/md/lg/xl/2xl/3xl) | `4px` ~ `32px` |
| `--l-font-*` | 字体变量 (xs/sm/md/lg) | `12px` ~ `18px` | | `--l-font-*` | 字体变量 (xs/sm/md/lg) | `12px` ~ `18px` |
| `--l-radius-*` | 圆角变量 (sm/md/lg/xl) | `8px` ~ `20px` | | `--l-radius-*` | 圆角变量 (sm/md/lg/xl) | `8px` ~ `20px` |
...@@ -151,7 +145,6 @@ resolutions[方向-分辨率] > portrait/landscape > common ...@@ -151,7 +145,6 @@ resolutions[方向-分辨率] > portrait/landscape > common
## 注意事项 ## 注意事项
⚠️ **重要**: ⚠️ **重要**:
- 变量名必须与 `index.vars.uts` 中定义的完全一致 - 变量名必须与 `index.vars.uts` 中定义的完全一致
- 分辨率 key 格式:`{方向}-{宽}x{高}`,如 `portrait-393x816` - 分辨率 key 格式:`{方向}-{宽}x{高}`,如 `portrait-393x816`
- UTS 对象属性间必须用逗号分隔 - UTS 对象属性间必须用逗号分隔
......
...@@ -3,6 +3,8 @@ export default { ...@@ -3,6 +3,8 @@ export default {
common: { common: {
// 通用标题高度 // 通用标题高度
'--common-title-height': '48px', '--common-title-height': '48px',
// 内容盒子的内边距(右、下、左共用)
'--content-box-padding-side': '8px',
// 间距变量 // 间距变量
'--l-spacing-xs': '4px', '--l-spacing-xs': '4px',
'--l-spacing-sm': '8px', '--l-spacing-sm': '8px',
...@@ -28,18 +30,17 @@ export default { ...@@ -28,18 +30,17 @@ export default {
// 背景色 // 背景色
'--l-bg-card': 'rgba(255, 255, 255, 0.85)', '--l-bg-card': 'rgba(255, 255, 255, 0.85)',
'--l-bg-card-hover': 'rgba(255, 255, 255, 0.95)', '--l-bg-card-hover': 'rgba(255, 255, 255, 0.95)',
// 渐变色 // 主题色(纯色,替代渐变)
'--l-gradient-primary': 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)', '--l-color-primary': '#667eea',
'--l-gradient-secondary': 'linear-gradient(135deg, #f093fb 0%, #f5576c 100%)', '--l-color-secondary': '#f093fb',
'--l-gradient-success': 'linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)', '--l-color-success': '#4facfe',
}, },
portrait: { portrait: {
// 竖屏布局 - 产品介绍占 60% // 竖屏布局 - 产品介绍占 60%
// 可用高度 = 屏幕高度 - 状态栏(44px) - 标题栏(48px) - TabBar(60px) ≈ 屏幕高度 - 152px // 可用高度 = 屏幕高度 - 状态栏(44px) - 标题栏(48px) - TabBar(60px) ≈ 屏幕高度 - 152px
'--module-box-height': '288px', '--module-box-height': '420px',
'--tool-box-min-height': '200px', '--swiper-height': 'calc(var(--module-box-height) - 40px)', // 轮播图高度 = module-box - 头部(40px)
'--tool-box-margin-bottom': 'var(--l-spacing-lg)',
// Entrance 图标尺寸(竖屏) // Entrance 图标尺寸(竖屏)
'--entrance-icon-size': '52px', '--entrance-icon-size': '52px',
'--entrance-item-gap': 'var(--l-spacing-xl)', '--entrance-item-gap': 'var(--l-spacing-xl)',
...@@ -51,18 +52,14 @@ export default { ...@@ -51,18 +52,14 @@ export default {
landscape: { landscape: {
// 横屏布局 - 产品介绍占 65% // 横屏布局 - 产品介绍占 65%
// 可用高度 = 屏幕高度 - 状态栏(44px) - 标题栏(48px) ≈ 屏幕高度 - 92px (TabBar在左侧,不影响高度) // 可用高度 = 屏幕高度 - 状态栏(44px) - 标题栏(48px) ≈ 屏幕高度 - 92px (TabBar在左侧,不影响高度)
'--module-box-height': '288px', '--module-box-height': '440px',
'--tool-box-height': '200px', '--swiper-height': 'calc(var(--module-box-height) - 40px)', // 轮播图高度 = module-box - 头部(40px)
'--tool-box-min-height': 'auto',
'--tool-box-margin-bottom': '0',
// Entrance 图标尺寸(横屏) // Entrance 图标尺寸(横屏)
'--entrance-icon-size': '56px', '--entrance-icon-size': '56px',
'--entrance-item-gap': 'var(--l-spacing-2xl)', '--entrance-item-gap': 'var(--l-spacing-2xl)',
// TabBar 相关(横屏左侧) // TabBar 相关(横屏左侧)
'--tabbar-width': '120px', '--tabbar-width': '120px',
'--tabbar-height': '540px',
'--tabbar-padding': '16px', '--tabbar-padding': '16px',
'--tabbar-icon-size': '28px',
// TabBar 相关(竖屏底部) // TabBar 相关(竖屏底部)
'--tabbar-height': '70px', '--tabbar-height': '70px',
'--tabbar-icon-size': '34px', '--tabbar-icon-size': '34px',
...@@ -73,45 +70,64 @@ export default { ...@@ -73,45 +70,64 @@ export default {
// 可用高度 = 768 - 44(状态栏) - 54(标题) ≈ 670px // 可用高度 = 768 - 44(状态栏) - 54(标题) ≈ 670px
'landscape-1174x768': { 'landscape-1174x768': {
'--module-box-height': '360px', '--module-box-height': '360px',
'--tool-box-height': '280px', '--swiper-height': 'calc(var(--module-box-height) - 40px)', // 320px
'--common-title-height': '54px', '--common-title-height': '54px',
'--entrance-icon-size': '64px', '--entrance-icon-size': '64px',
'--entrance-item-gap': 'var(--l-spacing-3xl)', '--entrance-item-gap': 'var(--l-spacing-3xl)',
'--tabbar-height': '70px', '--tabbar-height': '640px',
'--tabbar-icon-size': '46px', '--tabbar-icon-size': '34px',
'--tabbar-width': '140px',
}, },
// 小屏 Pad 横屏 (816x393) - 产品介绍占 65% // 小屏 Pad 横屏 (816x393) - 产品介绍占 65%
// 可用高度 = 393 - 44(状态栏) - 44(标题) ≈ 305px // 可用高度 = 393 - 44(状态栏) - 44(标题) ≈ 305px
'landscape-816x393': { 'landscape-816x393': {
'--module-box-height': '200px', '--module-box-height': '200px',
'--tool-box-height': '90px', '--swiper-height': 'calc(var(--module-box-height) - 40px)', // 160px
'--common-title-height': '44px', '--common-title-height': '44px',
'--entrance-icon-size': '52px', '--entrance-icon-size': '52px',
'--tabbar-height': '70px', '--tabbar-height': '70px',
'--tabbar-icon-size': '34px', '--tabbar-icon-size': '34px',
}, },
'landscape-1024x640': {
'--module-box-height': '300px',
'--swiper-height': 'calc(var(--module-box-height) - 40px)', // 160px
},
// iPhone 14 Pro 竖屏 (393x816) - 产品介绍占 60% // iPhone 14 Pro 竖屏 (393x816) - 产品介绍占 60%
// 可用高度 = 816 - 44(状态栏) - 42(标题) - 60(TabBar) ≈ 670px // 可用高度 = 816 - 44(状态栏) - 42(标题) - 60(TabBar) ≈ 670px
'portrait-393x816': { 'portrait-393x816': {
'--module-box-height': '288px', '--module-box-height': '400px',
'--tool-box-min-height': '200px', '--swiper-height': 'calc(var(--module-box-height) - 40px)', // 360px
'--common-title-height': '42px', '--common-title-height': '42px',
'--tabbar-height': '70px', '--tabbar-height': '70px',
'--tabbar-icon-size': '34px', '--tabbar-icon-size': '34px',
}, },
// iPhone 14 Pro 竖屏 (393x816) - 产品介绍占 60%
// 可用高度 = 816 - 44(状态栏) - 42(标题) - 60(TabBar) ≈ 670px
'portrait-414x736': {
'--module-box-height': '400px',
'--swiper-height': 'calc(var(--module-box-height) - 40px)', // 360px
'--common-title-height': '42px',
// '--tabbar-height': '70px',
'--tabbar-icon-size': '34px',
},
// 大屏平板竖屏 (768x1174) - 产品介绍占 65% // 大屏平板竖屏 (768x1174) - 产品介绍占 65%
// 可用高度 = 1174 - 44(状态栏) - 54(标题) - 70(TabBar) ≈ 1006px // 可用高度 = 1174 - 44(状态栏) - 54(标题) - 70(TabBar) ≈ 1006px
'portrait-768x1174': { 'portrait-768x1174': {
'--module-box-height': '500px', '--module-box-height': '550px',
'--tool-box-min-height': '200px', '--swiper-height': 'calc(var(--module-box-height) - 40px)', // 510px
'--common-title-height': '54px', '--common-title-height': '54px',
'--entrance-icon-size': '64px', '--entrance-icon-size': '64px',
'--entrance-item-gap': 'var(--l-spacing-3xl)', '--entrance-item-gap': 'var(--l-spacing-3xl)',
'--tabbar-height': '100px', '--tabbar-height': '70px',
'--tabbar-icon-size': '36px', '--tabbar-icon-size': '34px',
},
'portrait-640x1024': {
'--module-box-height': '550px',
'--swiper-height': 'calc(var(--module-box-height) - 40px)', // 510px
}, },
} }
} }
<template>
<view class="home-tabbar home-tabbar-landscape">
<!-- <image class="home-tabbar-bg-img"
mode="aspectFill"
src="/static/images/home/left-bg.png" /> -->
<view class="hf-landscape-column">
<view class="user-box user-box-clickable hf-landscape-user"
@click="emit('jumpPersonCenter')">
<view class="hf-landscape-profile">
<un-avatar :text="avatarText"
shape="circle"
size="42"
bgColor="#2f6af7"
color="#ffffff"
fontSize="20" />
<text class="hf-landscape-name">{{ userName }}</text>
</view>
</view>
</view>
<view class="landscape-tabbar-wrap">
<view class="landscape-un-tabbar landscape-vertical-tabs">
<view v-for="(item, index) in tabs"
:key="index"
class="landscape-vertical-tabs__item"
:class="index === currentTabIndex ? 'landscape-vertical-tabs__item--active' : ''"
@click="onTabItemClick(index)">
<view class="landscape-vertical-tabs__inner">
<image class="landscape-vertical-tabs__icon"
mode="aspectFit"
:src="index === currentTabIndex ? item.iconSrcActive : item.iconSrcInactive" />
<text class="landscape-vertical-tabs__label">{{ item.label }}</text>
</view>
</view>
</view>
</view>
<view class="home-tabbar-footer flex-col hf-landscape-footer">
<!-- ✅ 分隔线,与上方 Tab 区域区分 -->
<view class="hf-landscape-footer-divider"></view>
<!-- ✅ 切换门店按钮 -->
<view class="hf-landscape-footer-btn"
@tap="emit('switchStore')">
<image class="hf-landscape-footer-icon"
mode="aspectFit"
src="/static/images/home/scene-change.png" />
<text class="hf-landscape-footer-label">切换</text>
</view>
<!-- ✅ 设置按钮 -->
<view class="hf-landscape-footer-btn"
@tap="emit('setting')">
<image class="hf-landscape-footer-icon"
mode="aspectFit"
src="/static/images/home/setting.png" />
<text class="hf-landscape-footer-label">设置</text>
</view>
</view>
</view>
</template>
<script setup lang="uts">
import { useTabbarCommon, useLandscapeUserInfo } from "./hooks";
const props = defineProps<{
currentTabIndex: number
}>();
const emit = defineEmits<{
tabChange: [name: string | number]
setting: []
jumpPersonCenter: []
switchStore: []
}>();
const { tabs } = useTabbarCommon();
const { userName, avatarText } = useLandscapeUserInfo();
function onTabItemClick(index: number): void {
emit("tabChange", index);
}
</script>
<style scoped lang="scss">
@import "../styles/common.scss";
/* 顶部用户区:仅内容高度,不把中间 Tab 区挤没 */
.hf-landscape-column {
flex-shrink: 0;
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
box-sizing: border-box;
padding: 14px 10px 0;
position: relative;
z-index: 1;
}
/* 横屏侧栏:用户区 / Tab / 底按钮同一竖直中轴 */
.hf-landscape-user {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
box-sizing: border-box;
padding-top: 0;
flex-shrink: 0;
}
.hf-landscape-profile {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
}
/* 与 MyCenterMain .name 一致;与 Tab 文案同宽便于视觉对齐 */
.hf-landscape-name {
margin-top: 10px;
font-size: 14px;
font-weight: 600;
color: #1a2433;
line-height: 24px;
text-align: center;
width: 100%;
max-width: 104px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.hf-landscape-footer {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
box-sizing: border-box;
flex-shrink: 0;
padding: 24px 10px 4px; /* ✅ 增加上下内边距 */
}
/* ✅ 分隔线:与上方 Tab 区域明确区分 */
.hf-landscape-footer-divider {
width: 40px;
height: 1px; /* ✅ 改为 1px,更细腻 */
background-color: #e5edf8;
// margin-bottom: 10px; /* ✅ 分隔线与按钮的间距 */
}
.hf-landscape-footer-btn {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
// padding: 2px 0; /* ✅ 按钮内边距 */
margin-top: 8px; /* ✅ 按钮之间的间距 */
border-radius: 8px;
transition: background-color 0.2s;
}
.hf-landscape-footer-btn:active {
background-color: #f5f7fa; /* ✅ 点击反馈 */
}
.hf-landscape-footer-icon {
width: 24px; /* ✅ 缩小图标,与导航图标(28px)形成层次 */
height: 24px;
flex-shrink: 0;
opacity: 0.7; /* ✅ 降低透明度,与导航图标区分 */
}
.hf-landscape-footer-label {
margin-top: 4px;
font-size: 11px; /* ✅ 小字号 */
color: #8a98b5; /* ✅ 灰色文字 */
text-align: center;
line-height: 16px;
}
.hf-landscape-footer-switch {
font-size: 13px;
font-weight: 600;
color: #3773f8;
line-height: 20px;
text-align: center;
}
/* 横屏侧栏 Tab:占满中间 landscape-tabbar-wrap,条目在剩余高度内垂直居中 */
.landscape-vertical-tabs {
flex: 1;
min-height: 0;
width: 100%;
padding-left: var(--tabbar-padding, 16px);
padding-right: var(--tabbar-padding, 16px);
padding-top: 8px;
padding-bottom: 8px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
box-sizing: border-box;
}
.landscape-vertical-tabs__item {
width: 100%;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
padding: 18px 0;
box-sizing: border-box;
}
.landscape-vertical-tabs__item + .landscape-vertical-tabs__item {
margin-top: 10px;
}
.landscape-vertical-tabs__inner {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.landscape-vertical-tabs__icon {
width: var(--tabbar-icon-size, 28px);
height: var(--tabbar-icon-size, 28px);
flex-shrink: 0;
}
.landscape-vertical-tabs__label {
margin-top: 6px;
font-size: 12px;
color: #8a98b5;
text-align: center;
width: 100%;
max-width: 104px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.landscape-vertical-tabs__item--active .landscape-vertical-tabs__label {
color: #3773f8;
font-weight: 500;
}
</style>
<template>
<view class="home-tabbar home-tabbar-portrait home-tabbar-portrait-pad">
<un-tabbar :model-value="currentTabIndex"
class="portrait-un-tabbar"
:fixed="true"
:placeholder="false"
:safe-area-inset-bottom="true"
active-color="#3773f8"
inactive-color="#8a98b5"
bg-color="#ffffff"
@change="emit('tabChange', ($event as string | number))">
<un-tabbar-item v-for="(item, index) in tabs"
:key="index"
:name="index"
:text="item.label">
<template #icon="{ active }">
<image class="tabbar-icon-img"
mode="aspectFit"
:src="active == true ? item.iconSrcActive : item.iconSrcInactive" />
</template>
</un-tabbar-item>
</un-tabbar>
</view>
</template>
<script setup lang="uts">
import { useTabbarCommon } from "./hooks";
const props = defineProps<{
currentTabIndex: number
}>();
const emit = defineEmits<{
tabChange: [name: string | number]
}>();
const { tabs } = useTabbarCommon();
</script>
<style scoped lang="scss">
@import "../styles/common.scss";
/* 与 layout-root 注入的 index.vars.uts 中 --tabbar-icon-size 一致;横屏侧栏见 TabbarLandscape .landscape-vertical-tabs__icon */
.tabbar-icon-img {
width: var(--tabbar-icon-size, 24px);
height: var(--tabbar-icon-size, 24px);
}
</style>
<template>
<!-- TabBar 壳组件:横/竖两套布局 + 默认槽;方向由 useOrientation 驱动 -->
<view v-if="shellIsPortrait" class="scene-shell-root-portrait">
<view class="scene-shell-slot-portrait">
<slot></slot>
</view>
<view class="scene-shell-tabbar-portrait">
<Portrait :current-tab-index="props.activeTabIndex"
@tab-change="onTabChange" />
</view>
</view>
<view v-else class="scene-shell-root-landscape">
<view class="scene-shell-body-landscape">
<Landscape :user-name="userName"
:current-tab-index="props.activeTabIndex"
@tab-change="onTabChange"
@setting="onSetting"
@jump-person-center="jumpPersonCenter"
@switch-store="onSwitchStore" />
<view class="scene-shell-slot-landscape">
<slot></slot>
</view>
</view>
</view>
<!-- ✅ 统一的设置弹窗(横竖屏共用) -->
<SettingBox :visible="showSetting"
@update:visible="onSettingVisible" />
</template>
<script setup lang="uts">
import { computed, onMounted, onShow, type Ref } from "vue";
import SettingBox from "@/pages/person/SettingBox.uvue";
import { useOrientation } from "@/services/adapter/hooks/index.uts";
import { requestRecordPermission } from "@/utils/permission.uts";
import { storage } from "@/utils/storage.uts";
import { hideNativeTabBar } from "@/utils/tabBarShell.uts";
import Landscape from "./Landscape.uvue";
import Portrait from "./Portrait.uvue";
import type { HomeFrameTabbarSource } from "./tabbarShared.uts";
import { useHomeFrameTabbar } from "./tabbarShared.uts";
defineSlots();
const props = defineProps<{
/** 当前 tab 页下标:0 首页、1 接待中心、2 我的(与 un-tabbar 高亮一致) */
activeTabIndex: number
}>();
// updateOrientation();
const orientationHook = useOrientation();
const shellIsPortrait = computed((): boolean => {
const ip = orientationHook.isPortrait as Ref<boolean>;
return ip.value == true;
});
// ✅ Tabbar 逻辑(userInfo 从 storage 直接获取)
const tabbarSource: HomeFrameTabbarSource = {
getTabIndex: (): number => props.activeTabIndex,
getUserInfo: (): null | UTSJSONObject => {
return storage.getUserInfo();
}
};
const _tabbar = useHomeFrameTabbar(tabbarSource);
const userName = _tabbar.userName;
const showSetting = _tabbar.showSetting;
const onTabChange = _tabbar.onTabChange;
const onSettingVisible = _tabbar.onSettingVisible;
const onSetting = _tabbar.onSetting;
const jumpPersonCenter = _tabbar.jumpPersonCenter;
const onSwitchStore = _tabbar.onSwitchStore;
onMounted((): void => {
requestRecordPermission();
hideNativeTabBar();
});
onShow(() => {
hideNativeTabBar();
});
</script>
<style scoped lang="scss">
/* ✅ 竖屏布局 */
.scene-shell-root-portrait {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
min-height: 0;
min-width: 0;
}
.scene-shell-slot-portrait {
flex: 1;
min-height: 0;
min-width: 0;
display: flex;
flex-direction: column;
overflow: hidden;
}
.scene-shell-tabbar-portrait {
height: var(--tabbar-height, 70px); /* ✅ 使用 CSS 变量控制 tabbar 高度 */
}
/* ✅ 横屏布局 */
.scene-shell-root-landscape {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
min-height: 0;
min-width: 0;
}
.scene-shell-body-landscape {
flex: 1;
display: flex;
flex-direction: row;
width: 100%;
height: 100%;
min-height: 0;
min-width: 0;
overflow: hidden;
}
.scene-shell-slot-landscape {
flex: 1 1 0%;
min-width: 0;
min-height: 0;
display: flex;
flex-direction: column;
overflow: hidden;
}
</style>
/**
* Tabbar Hooks 统一导出
*
* 集中管理 tabbar 相关的 Composable Hooks
*/
// 通用 tabbar 逻辑
export { useTabbarCommon } from "./useTabbar.uts";
export type { UseTabbarCommonReturn } from "./useTabbar.uts";
// 横屏用户信息逻辑
export { useLandscapeUserInfo } from "./useLandscapeUserInfo.uts";
export type { UseLandscapeUserInfoReturn } from "./useLandscapeUserInfo.uts";
/**
* 横屏 Tabbar 用户信息 Hook
*
* 管理横屏侧栏的用户头像和姓名显示
*/
import { ref, onMounted, type Ref } from "vue";
import { storage } from "@/utils/storage.uts";
import { toStr } from "@/utils/common.uts";
/** Hook 返回值类型 */
type UseLandscapeUserInfoReturn = {
userName: Ref<string>
avatarText: Ref<string>
}
export function useLandscapeUserInfo(): UseLandscapeUserInfoReturn {
const userName = ref<string>("");
/** ✅ 头像文字:从 storage 获取用户信息,取姓名首字 */
const avatarText = ref<string>("我");
onMounted(() => {
const userInfo = storage.getUserInfo();
if (userInfo != null) {
const __userName = toStr(userInfo.get("userName") ?? "");
userName.value = __userName;
avatarText.value = __userName == "" ? "我" : __userName.substring(0, 1);
}
});
return {
userName,
avatarText
};
}
/**
* Tabbar 通用逻辑 Hook
*
* 提取 Portrait 和 Landscape 的公共逻辑,减少代码重复
*/
import { HOME_FRAME_TABS, type TabItem } from "../tabbarShared.uts";
/** Hook 返回值类型 */
type UseTabbarCommonReturn = {
tabs: TabItem[]
getIconSrc: (item: TabItem, active: boolean) => string
}
export function useTabbarCommon(): UseTabbarCommonReturn {
const tabs = HOME_FRAME_TABS;
/**
* 根据激活状态获取图标路径
*/
const getIconSrc = (item: TabItem, active: boolean): string => {
return active ? item.iconSrcActive : item.iconSrcInactive;
};
return {
tabs,
getIconSrc
};
}
/**
* Tabbar 模块导出
*
* 统一导出 tabbar 相关的组件和工具函数
*/
// 场景壳组件导出(唯一入口)
export { default as TabBarShell } from "./TabBarShell.uvue";
// Tabbar 组件导出
export { default as HomeFrameTabbarLandscape } from "./Landscape.uvue";
export { default as HomeFrameTabbarPortrait } from "./Portrait.uvue";
// Composable Hooks
export { useTabbarCommon, useLandscapeUserInfo } from "./hooks";
export type { UseTabbarCommonReturn, UseLandscapeUserInfoReturn } from "./hooks";
// 类型和工具函数导出
export type { HomeFrameTabbarSource } from "./tabbarShared.uts";
export { SCENE_SHELL_USER_INFO_INJECT_KEY, useHomeFrameTabbar, HOME_FRAME_TABS } from "./tabbarShared.uts";
import { computed, ref } from "vue";
import { hideNativeTabBar } from "@/utils/tabBarShell.uts";
import { navigateToSelectStoreWithSessionStores } from "@/utils/shukeSelectStoreNav.uts";
export type HomeFrameTabbarSource = {
getTabIndex: () => number
getUserInfo: () => null | UTSJSONObject
}
/** TabBarShell `provide`:`Ref<UTSJSONObject>`;MainTabShell `inject`,与插槽同源 */
export const SCENE_SHELL_USER_INFO_INJECT_KEY = "homeFrame.sceneShellUserInfo"
/**
* 横屏侧栏头像文案:与 simgle_app `LeftSide` 使用 `userInfo.userName` 一致;
* 数科/ROP 返回里常见 `name`、`staffName`、`nickName`、`merchantName` 等作回退。
*/
export function resolveHomeFrameDisplayName(info: null | UTSJSONObject): string {
if (info == null) {
return "";
}
const obj = info as UTSJSONObject;
const userName = obj.userName as string | null;
if (userName != null && userName !== "") {
return userName;
}
const raw = obj.name ?? obj.staffName ?? obj.nickName ?? obj.merchantName;
if (raw == null) {
return "";
}
const s = `${raw}`;
return s !== "" ? s : "";
}
export type TabItem = {
label: string;
icon: string;
name: string;
/** 模板内仅用路径字段,避免 UTS 在 slot 中调用 import 的函数 */
iconSrcActive: string;
iconSrcInactive: string;
};
/** 与 pages.json tabBar 一致:首页 | 接待中心 | 我的(选店为普通页,见 shukeSelectStoreNav) */
export const HOME_FRAME_TABS: TabItem[] = [
{
label: "首页",
icon: "home",
name: "HomeSlot",
iconSrcActive: "/static/images/tabbar/home-active.png",
iconSrcInactive: "/static/images/tabbar/home.png"
},
{
label: "接待",
icon: "record",
name: "ReceptionCenter",
iconSrcActive: "/static/images/tabbar/record-active.png",
iconSrcInactive: "/static/images/tabbar/record.png"
},
{
label: "我的",
icon: "my",
name: "MyCenter",
iconSrcActive: "/static/images/tabbar/study-active.png",
iconSrcInactive: "/static/images/tabbar/study.png"
},
];
export function getTabIconSrc(icon: string, active: boolean): string {
if (icon === "home") {
return active ? "/static/images/tabbar/home-active.png" : "/static/images/tabbar/home.png";
}
if (icon === "record") {
return active ? "/static/images/tabbar/record-active.png" : "/static/images/tabbar/record.png";
}
if (icon === "study") {
return active ? "/static/images/tabbar/study-active.png" : "/static/images/tabbar/study.png";
}
if (icon === "my") {
return active ? "/static/images/tabbar/study-active.png" : "/static/images/tabbar/study.png";
}
return "/static/images/tabbar/home.png";
}
function reLaunchPage(pagesJsonPath: string): void {
const trimmed = pagesJsonPath.startsWith("/") ? pagesJsonPath.substring(1) : pagesJsonPath;
const withSlash = "/" + trimmed;
uni.reLaunch({
url: withSlash,
fail: (_err: any) => {
uni.reLaunch({ url: trimmed });
}
});
}
function switchTabPage(pagesJsonPath: string): void {
const trimmed = pagesJsonPath.startsWith("/") ? pagesJsonPath.substring(1) : pagesJsonPath;
const url = "/" + trimmed;
uni.switchTab({
url,
success: () => {
hideNativeTabBar();
},
fail: (_err: any) => {
reLaunchPage(trimmed);
}
});
}
export function useHomeFrameTabbar(source: HomeFrameTabbarSource) {
const showSetting = ref(false);
const currentTabIndex = computed((): number => {
return source.getTabIndex();
});
const userName = computed((): string => {
return resolveHomeFrameDisplayName(source.getUserInfo());
});
const navigateToTab = (index: number): void => {
const cur = source.getTabIndex();
if (index == cur) {
return;
}
if (index == 0) {
switchTabPage("pages/index/index");
return;
}
if (index == 1) {
switchTabPage("pages/receptionCenter/center");
return;
}
if (index == 2) {
switchTabPage("pages/person/myCenter");
return;
}
};
const onTabChange = (name: string | number): void => {
const idx = name as number;
navigateToTab(idx);
};
const onSettingVisible = (v: boolean): void => {
showSetting.value = v;
};
const onSetting = (): void => {
showSetting.value = true;
};
const jumpPersonCenter = (): void => {
uni.navigateTo({ url: "/pages/person/attendance" });
};
/** 横屏侧栏底栏「切换」:进选店页(非 tab) */
const onSwitchStore = async (): Promise<void> => {
try {
uni.showLoading({ title: "加载中", mask: true });
await navigateToSelectStoreWithSessionStores();
} catch (error) {
const msg = error != null ? `${error}` : "操作失败";
uni.showToast({ title: msg, icon: "none" });
} finally {
uni.hideLoading();
}
};
return {
showSetting,
currentTabIndex,
userName,
onTabChange,
onSettingVisible,
onSetting,
jumpPersonCenter,
onSwitchStore
};
}
<template> <template>
<un-page class="layout-root layout-column-shell"> <un-page class="layout-root layout-column-shell" :class="[resolutionState.cssClass]">
<slot /> <slot />
</un-page> </un-page>
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
// import { resolutionState } from "@/services/adapter/index.uts"; import { resolutionState, useResolutionConfig } from "@/services/adapter/index.uts";
// 在这里统一调用初始化,确保任何使用 Layout 的页面都能获得正确的配置 // 在这里统一调用初始化,确保任何使用 Layout 的页面都能获得正确的配置
// useResolutionConfig(); useResolutionConfig();
</script> </script>
<style> <style>
......
...@@ -5,15 +5,17 @@ ...@@ -5,15 +5,17 @@
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import { computed, onMounted, onUnmounted, type Ref, ref } from 'vue' import { computed, onMounted, onUnmounted, type Ref, ref, provide } from 'vue'
// import { useLayout } from '@/composables/useLayout' // import { useLayout } from '@/composables/useLayout'
// import { cssClassRef, updateResolutionConfig, useResolutionConfig } from '@/services/adapter' // import { cssClassRef, updateResolutionConfig, useResolutionConfig } from '@/services/adapter'
import { updateOrientation, useScreenVars } from '@/services/adapter/hooks/index.uts' import { updateOrientation, useScreenVars } from '@/services/adapter/hooks/index.uts'
// import { layoutService } from '@/services/LayoutService.uts' // import { layoutService } from '@/services/LayoutService.uts'
// import pageVars from '@/pages/common/accountItems/index.vars'
const props = defineProps<{ const props = defineProps<{
pageVars?: UTSJSONObject | null pageVars?: UTSJSONObject | null
}>() }>()
// 通过 provide 注入 pageVars,供子组件使用
provide('PAGE_VARS', props.pageVars ?? null)
// const layout = useLayout() // const layout = useLayout()
// const rawCssVars = (layout as UTSJSONObject)['cssVars'] as Ref<UTSJSONObject> | null // const rawCssVars = (layout as UTSJSONObject)['cssVars'] as Ref<UTSJSONObject> | null
// onResize(() => { // onResize(() => {
...@@ -54,11 +56,8 @@ const props = defineProps<{ ...@@ -54,11 +56,8 @@ const props = defineProps<{
// layoutService.refreshScreenInfo() // layoutService.refreshScreenInfo()
// updateResolutionConfig() // updateResolutionConfig()
// } // }
const screenVarsHook = useScreenVars(props.pageVars ?? null) const styleObject = useScreenVars(props.pageVars ?? null)
const styleObject = computed((): Any => { // screenVarsHook 已经是 ComputedRef<UTSJSONObject>,直接使用,无需再包 computed
const sv = screenVarsHook.screenVars as Ref<UTSJSONObject>
return sv.value as Any
})
// const adapterClass = computed((): string => { // const adapterClass = computed((): string => {
// const cls = cssClassRef.value // const cls = cssClassRef.value
// return cls != null ? (cls as string) : '' // return cls != null ? (cls as string) : ''
...@@ -76,9 +75,8 @@ const styleObject = computed((): Any => { ...@@ -76,9 +75,8 @@ const styleObject = computed((): Any => {
// }) // })
onMounted(() => { onMounted(() => {
// syncLayoutRootResolution() // 无需在此调用 updateOrientation,useScreenVars 已处理
// layoutRootPollId = setInterval(syncLayoutRootResolution, LAYOUT_ROOT_POLL_MS) });
})
onUnmounted(() => { onUnmounted(() => {
// const tid = layoutRootPollId // const tid = layoutRootPollId
......
<template>
<view class="wn-canvas">
<zoom-pan
:class="['canvas-box', { fill: custom }]"
:disabled="(drawStatus == true || scaleSwitch == false)"
:scale-max="3"
:scale-min="1"
@scale="onScale"
>
<template #content>
<!-- <canvas
:class="['board-canvas', { 'draw-canvas': drawStatus }]"
:canvas-id="canvasId"
:disable-scroll="drawStatus"
@touchstart="onTouchStart"
@touchmove="onTouchMove"
@touchend="onTouchEnd"
>
</canvas> -->
<template v-if="custom">
<slot name="customContent">
</slot>
</template>
<template v-else>
<template v-if="aspectRatio">
<view
class="under-image"
:style="{ backgroundImage: `URL(${drawImage})`, aspectRatio: aspectRatio }"
>
</view>
</template>
<template v-else>
<view class="skeleton-box">
</view>
</template>
</template>
</template>
</zoom-pan>
</view>
</template>
<script setup lang="uts">
import zoomPan from './zoom-pan.uvue'
import { state } from "@/store/index.uts"
type HistoryItemStyle = {
color: string
width: number
}
type HistoryItemCoordinate = {
type: string
mode: string
x: number
y: number
}
type HistoryItem = {
style: HistoryItemStyle
coordinates: Array<HistoryItemCoordinate>
}
type ColorPickObj = {
color: string
}
const props = defineProps({
drawImage: {
type: String,
default: ''
},
saveImageType: {
type: String,
default: '1'
},
drawStatus: Boolean,
canvasId: {
type: String,
default: 'drawCanvas'
},
custom: Boolean,
scaleSwitch: {
type: Boolean,
default: true
}
})
const emit = defineEmits(['scale',])
const colorShow = ref<boolean>(false)
// Canvas 相关 - 已注释
// let canvasContext: CanvasContext | null = null
// let renderingContext: CanvasRenderingContext2D | null = null
const historyList = ref<Array<HistoryItem>>([])
const startX = ref<number>(0)
const startY = ref<number>(0)
const lastX = ref<number>(0)
const lastY = ref<number>(0)
const mode = ref<string>('pen')
const currentColor = ref<string>('red')
const bgColor = ref<string>('#fff')
const lineWidth = ref<number>(2)
const lastRect = ref<UTSObject>({})
const lastCircle = ref<UTSObject>({})
const isLandScape = ref<boolean>(false)
const aspectRatio = ref<number | null>(null)
const height = ref<number | string | null>(null)
const scaleValue = ref<number>(1)
const defaultScaleValue = ref<number>(1)
const viewX = ref<number>(0)
const viewY = ref<number>(0)
const touchX = ref<number>(0)
const touchY = ref<number>(0)
const begin = ref<boolean>(false)
const isUnderBkg = ref<boolean>(false)
const watchStatus = computed(() => {
const status = state.user?.historyStatus
if (status == null) {
return false
} else if (status == 1) {
return true
} else {
return false
}
})
function onScale(e: number): void {
scaleValue.value = e
emit('scale', e)
}
onMounted(() => {
// initBoard()
// uni.createCanvasContextAsync({
// id: props.canvasId as string,
// component: getCurrentInstance()?.proxy,
// success: (context : CanvasContext) => {
// canvasContext = context
// renderingContext = context.getContext('2d')!
// }
// })
})
watch(watchStatus, (newval: boolean) => {
if (newval != null) {
// clearBoard()
}
}, { immediate: true })
watch(props.drawImage, (n: string) => {
if (n != null) {
// initBoard()
}
})
</script>
<style lang="scss">
.wn-canvas {
height: 100%;
width: 100%;
box-sizing: border-box;
position: relative;
overflow: hidden;
}
.under-image {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-size: cover;
background-repeat: no-repeat;
z-index: -1;
}
.skeleton-box {
width: 100%;
height: 100%;
background: #f0f0f0;
}
@media screen and (orientation: portrait) {
.canvas-box {
width: 100%;
position: relative;
.board-canvas {
height: 100%;
width: 100%;
position: absolute;
background: rgba(0, 0, 0, 0);
}
}
}
@media screen and (orientation: landscape) {
.canvas-box {
width: 100%;
position: relative;
z-index: 99;
.board-canvas {
height: 100%;
width: 100%;
position: absolute;
background: rgba(0, 0, 0, 0);
pointer-events: none;
z-index: 99;
}
.draw-canvas {
pointer-events: auto;
}
}
.fill {
height: 100% !important;
}
}
</style>
<template>
<view
class="zoom-pan-container"
:style="{ 'overflow': 'hidden', 'position': 'relative', 'touch-action': 'none' }"
>
<!-- @touchstart="handleTouchStart"
@touchmove="handleTouchMove"
@touchend="handleTouchEnd" -->
<view
class="content"
:style="contentStyle"
>
<slot name="content">
</slot>
</view>
</view>
</template>
<script setup lang="uts">
import { throttle } from '@/utils/common.uts'
import { state } from "@/store/index.uts"
type Point = {
x: number
y: number
}
type TouchPoint = {
pageX: number
pageY: number
clientX: number
clientY: number
x: number
y: number
}
type TouchEvent = {
touches: Array<TouchPoint>
changedTouches: Array<TouchPoint>
}
const props = defineProps({
disabled: Boolean,
scaleMax: {
type: Number,
default: 10
},
scaleMin: {
type: Number,
default: 1
}
})
const scale = ref<number>(1)
const isScaling = ref<boolean>(false)
const initialDistance = ref<number>(0)
const initialScale = ref<number>(1)
const translateX = ref<number>(0)
const translateY = ref<number>(0)
const lastTouchCenter = ref<Point>({ x: 0, y: 0 })
const currentTouchCenter = ref<Point>({ x: 0, y: 0 })
const contentStyle = computed(() => {
return {
'transform': `translate(${translateX.value}px, ${translateY.value}px) scale(${scale.value})`,
'transform-origin': 'center center',
'transition': isScaling.value ? 'none' : 'transform 0.3s ease-out',
'will-change': 'transform',
'position': 'absolute',
'left': '0',
'top': '0',
'width': '100%',
'height': '100%'
}
})
const watchStatus = computed(() => {
const status = state.user?.historyStatus
if (status == null) {
return false
} else if (status == 1) {
return true
} else {
return false
}
})
watch(watchStatus.value , () => {
if (scale.value != 1) {
scale.value = 1
translateX.value = 0
translateY.value = 0
}
}, { immediate: true })
// function handleTouchStart(e: TouchEvent): void {
// if (props.disabled == true) return
// if (e.touches.length === 2) {
// isScaling.value = true
// initialDistance.value = getTouchDistance(e.touches)
// initialScale.value = scale.value
// const center = getTouchCenter(e.touches)
// lastTouchCenter.value = center
// currentTouchCenter.value = center
// }
// }
// const handleTouchMove = throttle(function(e: TouchEvent): void {
// if (props.disabled == true) return
// if (isScaling.value && e.touches.length === 2) {
// const currentDistance = getTouchDistance(e.touches)
// const newScale = Math.max(
// props.scaleMin,
// Math.min(
// props.scaleMax,
// initialScale.value * (currentDistance / initialDistance.value)
// )
// )
// scale.value = newScale
// const center = getTouchCenter(e.touches)
// currentTouchCenter.value = center
// if (scale.value > 1) {
// const deltaX = center.x - lastTouchCenter.value.x
// const deltaY = center.y - lastTouchCenter.value.y
// translateX.value += deltaX
// translateY.value += deltaY
// }
// lastTouchCenter.value = center
// emit('scale', scale.value)
// }
// }, 16)
// function handleTouchEnd(): void {
// if (isScaling.value) {
// isScaling.value = false
// adjustPosition()
// }
// }
function adjustPosition(): void {
if (scale.value <= 1) {
translateX.value = 0
translateY.value = 0
scale.value = 1
}
}
function getTouchDistance(touches: Array<TouchPoint>): number {
const dx = touches[0].pageX - touches[1].pageX
const dy = touches[0].pageY - touches[1].pageY
return Math.sqrt(dx * dx + dy * dy)
}
function getTouchCenter(touches: Array<TouchPoint>): Point {
const centerX = (touches[0].pageX + touches[1].pageX) / 2
const centerY = (touches[0].pageY + touches[1].pageY) / 2
return { x: centerX, y: centerY }
}
const emit = defineEmits(['scale'])
</script>
<style lang="scss">
.zoom-pan-container {
width: 100%;
height: 100%;
position: relative;
overflow: hidden;
touch-action: none;
}
.content {
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
transform-origin: center center;
}
</style>
<template>
<!-- ✅ UVUE 需要单一根节点,避免 v-if 导致片段渲染 -->
<view class="publish-popup-root">
<view v-if="isShow" class="publish-popup-mask" @click="closePopup">
<view class="publish-popup-container" @click.stop>
<slot name="content"></slot>
</view>
</view>
</view>
</template>
<script setup lang="uts">
import { ref } from 'vue';
// Props
const props = defineProps<{
type?: string;
isShowFooter?: boolean;
showTitle?: boolean;
}>();
// 响应式数据
const isShow = ref<boolean>(false);
// 方法
const openPopup = () => {
isShow.value = true;
};
const closePopup = () => {
isShow.value = false;
};
// 暴露方法供父组件调用
defineExpose({
openPopup,
closePopup
});
</script>
<style>
.publish-popup-mask {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
z-index: 9999;
}
.publish-popup-container {
background-color: #ffffff;
border-radius: 8px;
max-width: 90%;
max-height: 80%;
overflow: hidden;
}
</style>
<template>
<view class="skeleton-wrap">
<un-skeleton :animate="animate"
:loading="loading"
:rows="rows"
:title="title"
:avatar="avatar"
:avatar-shape="avatarShape"
:avatar-size="avatarSize">
</un-skeleton>
<view :style="{ height: spacing + 'px' }"></view>
<un-skeleton :animate="animate"
:loading="loading"
:rows="rows"
:title="title"
:avatar="avatar"
:avatar-shape="avatarShape"
:avatar-size="avatarSize">
</un-skeleton>
<view :style="{ height: spacing + 'px' }"></view>
<un-skeleton :animate="animate"
:loading="loading"
:rows="rows"
:title="title"
:avatar="avatar"
:avatar-shape="avatarShape"
:avatar-size="avatarSize">
</un-skeleton>
</view>
</template>
<script setup lang="uts">
defineProps({
loading: {
type: Boolean,
default: true
},
animate: {
type: Boolean,
default: true
},
rows: {
type: Number,
default: 2
},
title: {
type: Boolean,
default: true
},
avatar: {
type: Boolean,
default: true
},
avatarShape: {
type: String,
default: 'circle' // 'circle' or 'square'
},
avatarSize: {
type: Number,
default: 48
},
spacing: {
type: Number,
default: 24
}
});
</script>
<style scoped lang="scss">
.skeleton-wrap {
padding: 24px;
width: 100%;
box-sizing: border-box;
}
</style>
<template>
<view class="product-intro-skeleton">
<!-- 标题占位 -->
<view class="skeleton-header">
<view class="skeleton-title"></view>
</view>
<!-- 内容区占位(模拟轮播图) -->
<view class="skeleton-content">
<view class="skeleton-swiper">
<view class="skeleton-slide">
<view class="skeleton-image"></view>
<view class="skeleton-caption"></view>
</view>
</view>
</view>
</view>
</template>
<script setup lang="uts">
// 产品介绍模块骨架屏
</script>
<style scoped lang="scss">
.product-intro-skeleton {
width: 100%;
display: flex;
flex-direction: column;
}
.skeleton-header {
padding: 12px 16px 8px;
}
.skeleton-title {
width: 80px;
height: 18px;
border-radius: 4px;
background-color: #f0f0f0; /* ✅ UVUE 不支持 animation,使用静态背景 */
}
.skeleton-content {
padding: 0 16px 16px;
}
.skeleton-swiper {
width: 100%;
height: 200px;
border-radius: 12px;
overflow: hidden;
background-color: #f5f5f5;
}
.skeleton-slide {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: flex-end;
padding: 16px;
box-sizing: border-box;
}
.skeleton-image {
flex: 1;
width: 100%;
border-radius: 8px;
background-color: #f0f0f0; /* ✅ UVUE 不支持 animation,使用静态背景 */
margin-bottom: 12px;
}
.skeleton-caption {
width: 60%;
height: 14px;
border-radius: 4px;
background-color: #f0f0f0; /* ✅ UVUE 不支持 animation,使用静态背景 */
}
</style>
<template>
<view class="start-reception-skeleton">
<view class="skeleton-inner">
<!-- 图标占位 -->
<view class="skeleton-icon-wrap">
<view class="skeleton-circle"></view>
</view>
<!-- 文字占位 -->
<view class="skeleton-text"></view>
</view>
</view>
</template>
<script setup lang="uts">
// 开始接待按钮骨架屏
</script>
<style scoped lang="scss">
.start-reception-skeleton {
width: 100%;
padding: 16px;
box-sizing: border-box;
}
.skeleton-inner {
display: flex;
flex-direction: row;
align-items: center;
background-color: #ffffff;
border-radius: 12px;
padding: 14px 18px;
// ✅ 性能优化:移除 box-shadow
// box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.skeleton-icon-wrap {
width: 28px;
height: 28px;
border-radius: 50%;
background-color: #f0f0f0; /* ✅ UVUE 不支持 animation,使用静态背景 */
margin-right: 12px;
flex-shrink: 0;
}
.skeleton-circle {
width: 14px;
height: 14px;
border-radius: 50%;
background-color: transparent;
}
.skeleton-text {
flex: 1;
height: 16px;
border-radius: 4px;
background-color: #f0f0f0; /* ✅ UVUE 不支持 animation,使用静态背景 */
}
</style>
<template>
<view class="tool-skeleton-container">
<!-- 模拟 Entrance 组件的网格布局 -->
<view class="tool-grid">
<view v-for="i in count"
:key="'tool-' + i"
class="tool-item-skeleton">
<!-- 图标占位 -->
<view class="tool-icon-placeholder"></view>
<!-- 文字占位 -->
<view class="tool-text-placeholder"></view>
</view>
</view>
</view>
</template>
<script setup lang="uts">
interface ToolSkeletonProps {
count: number
}
const props = withDefaults(defineProps<ToolSkeletonProps>(), {
count: 4
});
</script>
<style scoped lang="scss">
.tool-skeleton-container {
width: 100%;
padding: 16px;
box-sizing: border-box;
}
.tool-grid {
width: 100%;
display: flex;
flex-direction: row;
flex-wrap: wrap;
// ✅ UVUE 不支持 gap,需用 margin + 负margin 替代
// gap: 12px;
}
.tool-item-skeleton {
width: 25%; // ✅ UVUE 不支持 calc(),4列布局使用 25%
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 12px 8px;
box-sizing: border-box;
}
.tool-icon-placeholder {
width: 40px;
height: 40px;
border-radius: 12px;
background-color: #e8e8e8;
margin-bottom: 8px;
}
.tool-text-placeholder {
width: 50px;
height: 12px;
border-radius: 6px;
background-color: #e0e0e0;
}
</style>
<template>
<view class="type-tab">
<template v-if="styleV2">
<!-- 样式一:固定宽度 tab,滑动背景滑块 -->
<view class="type-box">
<view
:class="['slider-block', getSliderBlockClass()]"
:style="{ left: blockLeft, width: sliderBlockWidth }"
></view>
<view
:class="['tab-item', { active: tabIndex == idx }]"
v-for="(item, idx) in typeList"
:key="idx"
:style="{ width: getTabItemWidth(idx) }"
@click="handleTabClick(idx)"
>
<view
class="text-wrap"
:class="{ active: tabIndex == idx }"
:style="{ width: getTabItemWidth(idx) }"
>
<text class="tab-text">{{ getItemName(item) }}</text>
<view v-if="tabIndex == idx" class="underline-wrap"></view>
</view>
</view>
</view>
<!-- <view class="mask-box"></view> -->
</template>
<template v-else>
<!-- 样式二:横向滚动 tab,切换时平滑滑动到选中项 -->
<scroll-view
scroll-x
enable-flex
class="scroll-box"
:scroll-into-view="`tab-id-${tabIndex}`"
scroll-with-animation
>
<view class="type-box-v2">
<view
:class="['tab-item-v2', { active: tabIndex == idx }]"
v-for="(item, idx) in typeList"
:key="idx"
:style="getTabItemV2Style(idx)"
@click="handleTabClick(idx)"
:id="`tab-id-${idx}`"
>
<template v-if="idx == 0">
<view class="sprite-icon icon-first-right"></view>
</template>
<template v-else>
<view class="sprite-icon icon-second-left"></view>
<view class="sprite-icon icon-second-right"></view>
</template>
<view class="text-wrap-v2">
<text class="tab-text-v2">{{ getItemName(item) }}</text>
</view>
<view
v-if="tabIndex == idx"
class="underline-bar"
></view>
</view>
</view>
</scroll-view>
</template>
</view>
</template>
<script setup lang="uts">
import { computed } from "vue";
/** Tab 项数据类型 */
type TabItem = UTSJSONObject;
const props = withDefaults(
defineProps<{
/** Tab 数据列表 */
typeList?: TabItem[]
/** 当前选中索引 */
tabIndex?: number
/** 显示名称的字段 key,默认 tabName */
nameKey?: string
/** 是否使用样式二(横向滚动) */
styleV2?: boolean
}>(),
{
typeList: () => [],
tabIndex: 0,
nameKey: "tabName",
styleV2: false
}
);
const emit = defineEmits<{
"update:tabIndex": [number]
tabClick: [number]
}>();
const FIRST_TAB_ITEM_WIDTH = 152
const TAB_ITEM_WIDTH = 208
function getTabItemWidth(index: number): string {
if (index == 0) {
return `${FIRST_TAB_ITEM_WIDTH}px`
}
return `${TAB_ITEM_WIDTH}px`
}
const sliderBlockWidth = computed((): string => {
return getTabItemWidth(props.tabIndex)
})
/** 滑块位置(样式一) */
const blockLeft = computed((): string => {
const idx = props.tabIndex
if (idx <= 0) {
return "0px"
}
const left = FIRST_TAB_ITEM_WIDTH + (idx - 1) * TAB_ITEM_WIDTH
return `${left}px`
});
/** 获取 tab 项显示名称 */
function getItemName(item: TabItem): string {
const key = props.nameKey
if (key == null || key == "") {
return ""
}
const val = item[key]
if (val == null) {
return ""
}
return `${val}`
}
/** 获取滑块圆角 class(样式一) */
function getSliderBlockClass(): string {
const idx = props.tabIndex
const len = props.typeList != null ? props.typeList.length : 0
if (len <= 1) {
return "slider-only"
}
if (idx == 0) {
return "slider-first"
}
if (idx == len - 1) {
return "slider-last"
}
return "slider-middle"
}
/** 获取 tab-item-v2 的内联样式,tabIndex == 1 时非激活项追加左下/右下圆角及红色背景 */
function getTabItemV2Style(idx: number): UTSJSONObject {
if (props.tabIndex == 1 && idx != props.tabIndex) {
return {
width: getTabItemWidth(idx),
borderBottomLeftRadius: '24px',
borderBottomRightRadius: '24px',
backgroundColor: '#eef4fe'
}
}
return { width: getTabItemWidth(idx) }
}
/** 点击 tab */
function handleTabClick(index: number): void {
if (props.tabIndex == index) {
return
}
emit("update:tabIndex", index)
emit("tabClick", index)
}
</script>
<style scoped lang="scss">
/* 遵循 uni-app x 规范:px 单位、无 vh/calc/gap、font-weight 仅 400|700、伪元素改为真实节点 */
.type-tab {
position: relative;
}
.type-box {
position: relative;
display: flex;
flex-direction: row;
width: 100%;
background-color: #eef4fe;
height: 80px;
border-radius: 24px 24px 0 0;
overflow: hidden;
z-index: 0;
}
.tab-item {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
position: relative;
}
.tab-item .text-wrap {
position: relative;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
}
.tab-item .text-wrap.active {
position: relative;
z-index: 1;
}
.tab-item .tab-text {
font-size: 20px;
font-weight: 400;
color: #1f2133;
text-align: center;
}
.tab-item .text-wrap.active .tab-text {
font-weight: 700;
color: #2c66f7;
}
.tab-item .underline-wrap {
position: absolute;
bottom: 0;
left: 50%;
margin-left: -12px;
width: 24px;
height: 4px;
background-color: #2c66f7;
border-radius: 8px;
}
/* 样式一:滑动背景滑块,left 由 :style 动态绑定,切换时平滑过渡 */
.type-box .slider-block {
position: absolute;
top: 0;
height: 80px;
z-index: 0;
background-color: #fff;
transition: left 0.2s ease-out;
}
.slider-block.slider-first {
border-radius: 24px 0 0 0;
}
.slider-block.slider-last {
border-radius: 0 24px 0 0;
}
.slider-block.slider-middle {
border-radius: 0;
}
.slider-block.slider-only {
border-radius: 24px 24px 0 0;
}
// .mask-box {
// position: absolute;
// height: 100%;
// width: 100%;
// background: #fff;
// left: 0;
// top: 80px;
// border-radius: 24px;
// overflow: hidden;
// }
.scroll-box {
width: 100%;
}
.type-box-v2 {
position: relative;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
width: 100%;
background-color: #eef4fe;
height: 48px;
border-radius: 24px 24px 0 0;
z-index: 0;
}
.tab-item-v2 {
padding: 0 20px;
margin-right: 0;
flex-shrink: 0;
position: relative;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
background-color: #eef4fe;
transition: background-color 0.25s ease-out;
}
.tab-item-v2:first-child {
padding-left: 20px;
}
.tab-item-v2 .text-wrap-v2 {
position: relative;
display: flex;
flex-direction: column;
align-items: center;
z-index: 2;
}
.tab-item-v2 .tab-text-v2 {
color: #292d33;
font-size: 16px;
}
.tab-item-v2.active .tab-text-v2 {
color: #3b73ff;
font-weight: 400;
}
.tab-item-v2 .underline-bar {
position: absolute;
bottom: 0;
left: 50%;
margin-left: -10px;
width: 20px;
height: 3px;
border-radius: 2px;
background: #3b73ff;
}
.tab-item-v2 .sprite-icon {
position: absolute;
display: none;
}
.tab-item-v2.active .sprite-icon {
display: flex; // ✅ UVUE 不支持 display: block,改为 flex
}
.tab-item-v2.active {
background: #fff;
border-radius: 24px 24px 0 0;
overflow: hidden;
z-index: 1;
}
.icon-first-right {
right: -50px;
}
.icon-second-left {
left: -50px;
}
.icon-second-right {
right: -50px;
background-color: #eef4fe;
}
</style>
<template>
<view class="type-tab">
<scroll-view class="type-box" scroll-x="true" :show-scrollbar="false" scroll-with-animation>
<view class="type-scroll-content">
<view
class="tab-item"
:class="[tabClass(index)]"
v-for="(i, index) in typeList"
:key="index"
@click.stop="tabClick(index, i)"
>
<view class="text flex justify-center align-center" :class="[tabIndex == index ? 'active' : '']">
<text class="tab-name">{{ getTabName(i) }}</text>
<text v-if="isShowCount" class="count ml-8">{{ (getTabCount(i) > 99) ? '99+' : getTabCount(i).toString() }}</text>
</view>
</view>
</view>
</scroll-view>
</view>
</template>
<script setup lang="uts">
import { ref, computed } from 'vue';
import { get } from '@/utils/common.uts';
// Props 类型:使用 any[] 避免响应式对象类型转换问题
const props = withDefaults(defineProps<{
typeList: any[];
tabIndex: number;
nameKey?: string;
isShowCount?: boolean;
}>(), {
nameKey: 'tabName',
isShowCount: false
});
// Emits
const emit = defineEmits<{
(e: 'tabClick', index: number, item: any): void;
}>();
// 辅助方法:安全访问响应式对象的属性
// 响应式对象在 app 端无法通过 get() 访问,使用 JSON 序列化/反序列化解包
const getTabName = (item: any): string => {
// 先尝试 get()
let name = get(item, props.nameKey);
if (name != null) {
return name as string;
}
// get() 失败,尝试 JSON 序列化/反序列化解包响应式对象
try {
const jsonStr = JSON.stringify(item);
const parsed = JSON.parse(jsonStr) as any;
if (parsed != null) {
const name1 = get(parsed, props.nameKey);
if (name1 != null) {
return name1 as string;
}
const name2 = get(parsed, 'tabName');
if (name2 != null) {
return name2 as string;
}
}
} catch (e: any) {
// 静默失败
}
return '未知';
};
const getTabCount = (item: any): number => {
// 先尝试 get()
let count = get(item, 'count');
if (count != null) {
return count as number;
}
// get() 失败,尝试 JSON 序列化/反序列化解包响应式对象
try {
const jsonStr = JSON.stringify(item);
const parsed = JSON.parse(jsonStr) as any;
if (parsed != null) {
const countValue = get(parsed, 'count');
if (countValue != null) {
return countValue as number;
}
}
} catch (e: any) {
// 静默失败
}
return 0;
};
// 方法
const tabClass = (index: number): string => {
let className = '';
if (props.tabIndex == index) {
className = 'active ';
if (index == 0) className += 'first-nav';
else className += 'second-nav';
}
return className;
};
const tabClick = (index: number, item: any) => {
emit('tabClick', index, item);
};
</script>
<style>
.type-tab {
position: relative;
overflow: hidden;
}
.type-box {
position: relative;
width: 100%;
background-color: #eef4fe;
height: 48px;
border-radius: 24px 24px 0 0;
overflow: hidden;
z-index: 0;
}
.type-scroll-content {
display: flex;
flex-direction: row;
align-items: center;
flex-wrap: nowrap;
}
.tab-item {
flex-shrink: 0;
position: relative;
margin-right: 8px;
}
.tab-item .text {
position: relative;
height: 48px;
padding: 0 32px;
transition: all 0.15s;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
}
.tab-item .text .tab-name {
font-weight: 400;
font-size: 14px;
color: #292d33;
text-align: center;
}
.tab-item .text.active .tab-name {
font-weight: 500;
font-size: 16px;
color: #3b73ff;
}
.tab-item .text .count {
font-size: 12px;
margin-left: 4px;
color: #292d33;
}
.flex {
display: flex;
flex-direction: row;
}
.justify-center {
justify-content: center;
}
.align-center {
align-items: center;
}
.ml-8 {
margin-left: 8px;
}
</style>
...@@ -11,22 +11,21 @@ ...@@ -11,22 +11,21 @@
**使用示例:** **使用示例:**
```typescript ```typescript
import { useRecorder } from "@/composables/useRecorder"; import { useRecorder } from '@/composables/useRecorder'
const { isRecording, startAudio, stopAudio } = useRecorder(); const { isRecording, startAudio, stopAudio } = useRecorder()
// 开始录音 // 开始录音
startAudio(); startAudio()
// 停止录音 // 停止录音
stopAudio(); stopAudio()
// 强制停止录音 // 强制停止录音
stopAudio(true); stopAudio(true)
``` ```
**API:** **API:**
- `isRecording: Ref<boolean>` - 是否正在录音 - `isRecording: Ref<boolean>` - 是否正在录音
- `startAudio(): void` - 开始录音 - `startAudio(): void` - 开始录音
- `stopAudio(force?: boolean): void` - 停止录音 - `stopAudio(force?: boolean): void` - 停止录音
...@@ -38,22 +37,21 @@ stopAudio(true); ...@@ -38,22 +37,21 @@ stopAudio(true);
**使用示例:** **使用示例:**
```typescript ```typescript
import { useUploader } from "@/composables/useUploader"; import { useUploader } from '@/composables/useUploader'
const { uploadQueue, isUploading, addToQueue, upload, clearQueue } = useUploader(); const { uploadQueue, isUploading, addToQueue, upload, clearQueue } = useUploader()
// 添加文件到队列 // 添加文件到队列
addToQueue("/path/to/file.mp3"); addToQueue('/path/to/file.mp3')
// 执行上传 // 执行上传
await upload(); await upload()
// 清空队列 // 清空队列
clearQueue(); clearQueue()
``` ```
**API:** **API:**
- `uploadQueue: Ref<string[]>` - 上传队列 - `uploadQueue: Ref<string[]>` - 上传队列
- `isUploading: Ref<boolean>` - 是否正在上传 - `isUploading: Ref<boolean>` - 是否正在上传
- `addToQueue(filePath: string): void` - 添加文件到队列 - `addToQueue(filePath: string): void` - 添加文件到队列
...@@ -67,22 +65,21 @@ clearQueue(); ...@@ -67,22 +65,21 @@ clearQueue();
**使用示例:** **使用示例:**
```typescript ```typescript
import { usePermission } from "@/composables/usePermission"; import { usePermission } from '@/composables/usePermission'
const { checkMicrophonePermission, checkStoragePermission, requestPermission } = usePermission(); const { checkMicrophonePermission, checkStoragePermission, requestPermission } = usePermission()
// 检查麦克风权限 // 检查麦克风权限
const hasMicPermission = await checkMicrophonePermission(); const hasMicPermission = await checkMicrophonePermission()
// 检查存储权限 // 检查存储权限
const hasStoragePermission = await checkStoragePermission(); const hasStoragePermission = await checkStoragePermission()
// 请求权限 // 请求权限
const granted = await requestPermission("microphone"); const granted = await requestPermission('microphone')
``` ```
**API:** **API:**
- `checkMicrophonePermission(): Promise<boolean>` - 检查麦克风权限 - `checkMicrophonePermission(): Promise<boolean>` - 检查麦克风权限
- `checkStoragePermission(): Promise<boolean>` - 检查存储权限 - `checkStoragePermission(): Promise<boolean>` - 检查存储权限
- `requestPermission(permissionType: string): Promise<boolean>` - 请求权限 - `requestPermission(permissionType: string): Promise<boolean>` - 请求权限
...@@ -94,26 +91,31 @@ const granted = await requestPermission("microphone"); ...@@ -94,26 +91,31 @@ const granted = await requestPermission("microphone");
**使用示例:** **使用示例:**
```typescript ```typescript
import { useReception } from "@/composables/useReception"; import { useReception } from '@/composables/useReception'
const { receptionStatus, showFinishDialog, startReception, finishReception, closeFinishDialog, clearHistory } = const {
useReception(); receptionStatus,
showFinishDialog,
startReception,
finishReception,
closeFinishDialog,
clearHistory
} = useReception()
// 开始接待 // 开始接待
startReception(); startReception()
// 完成接待 // 完成接待
finishReception(); finishReception()
// 关闭完成弹窗 // 关闭完成弹窗
closeFinishDialog(); closeFinishDialog()
// 清除历史 // 清除历史
clearHistory(); clearHistory()
``` ```
**API:** **API:**
- `receptionStatus: Ref<number>` - 接待状态(0: 未开始, 1: 接待中, 2: 已完成) - `receptionStatus: Ref<number>` - 接待状态(0: 未开始, 1: 接待中, 2: 已完成)
- `showFinishDialog: Ref<boolean>` - 是否显示完成弹窗 - `showFinishDialog: Ref<boolean>` - 是否显示完成弹窗
- `startReception(): void` - 开始接待 - `startReception(): void` - 开始接待
...@@ -128,26 +130,76 @@ clearHistory(); ...@@ -128,26 +130,76 @@ clearHistory();
**使用示例:** **使用示例:**
```typescript ```typescript
import { useVersionCheck } from "@/composables/useVersionCheck"; import { useVersionCheck } from '@/composables/useVersionCheck'
const { hasNewVersion, versionInfo, checkVersion, doUpdate } = useVersionCheck(); const { hasNewVersion, versionInfo, checkVersion, doUpdate } = useVersionCheck()
// 检查版本 // 检查版本
await checkVersion(); await checkVersion()
// 执行更新 // 执行更新
if (hasNewVersion.value) { if (hasNewVersion.value) {
doUpdate(); doUpdate()
} }
``` ```
**API:** **API:**
- `hasNewVersion: Ref<boolean>` - 是否有新版本 - `hasNewVersion: Ref<boolean>` - 是否有新版本
- `versionInfo: Ref<UTSJSONObject | null>` - 版本信息 - `versionInfo: Ref<UTSJSONObject | null>` - 版本信息
- `checkVersion(): Promise<void>` - 检查版本更新 - `checkVersion(): Promise<void>` - 检查版本更新
- `doUpdate(): void` - 执行更新 - `doUpdate(): void` - 执行更新
### 6. useSwipeBack.uts - 左滑返回检测
提供 iOS 侧滑返回手势检测功能(因为 iOS 侧滑不会触发 onBackPress)。
**使用示例:**
```typescript
import { useSwipeBack } from '@/composables/useSwipeBack'
const swipeHandlers = useSwipeBack(() => {
// 检测到左滑返回时的回调
showConfirmModal.value = true
}, {
threshold: 80, // 滑动距离阈值 80px
timeThreshold: 300, // 滑动时间阈值 300ms
angleThreshold: 30, // 角度阈值 30°
verticalTolerance: 20, // 垂直容差 20px
edgeOnly: false, // 是否只在左侧边缘触发
edgeWidth: 50 // 左侧边缘宽度 50px
})
```
**模板中使用:**
```vue
<template>
<view
@touchstart="swipeHandlers.onTouchStart"
@touchmove="swipeHandlers.onTouchMove"
@touchend="swipeHandlers.onTouchEnd"
>
<!-- 页面内容 -->
</view>
</template>
```
**API:**
- `onTouchStart(e: UniTouchEvent): void` - 触摸开始处理函数
- `onTouchMove(e: UniTouchEvent): void` - 触摸移动处理函数
- `onTouchEnd(e: UniTouchEvent): void` - 触摸结束处理函数
- `isSwiping: Ref<boolean>` - 是否正在滑动
- `reset(): void` - 重置滑动状态
**配置选项:**
- `threshold?: number` - 滑动距离阈值(像素),默认 80
- `timeThreshold?: number` - 滑动时间阈值(毫秒),默认 300
- `angleThreshold?: number` - 角度阈值(度),默认 30
- `verticalTolerance?: number` - 垂直滑动容差(像素),默认 20
- `edgeOnly?: boolean` - 是否仅在屏幕左侧边缘触发,默认 false
- `edgeWidth?: number` - 左侧边缘宽度(像素),默认 50
## 在页面中使用 ## 在页面中使用
### 完整示例 ### 完整示例
......
/**
* 录音服务 Composable Hook
* 提供响应式的录音服务访问方式
*
* 使用方式:
* const { recordService, isRecording } = useRecordService()
*/
import { computed, type ComputedRef } from "vue";
import { RecordService } from "@/services/recorder/RecordService.uts";
/**
* 获取录音服务实例
* @returns 录音服务单例
*/
export function useRecordService(): {
recordService: RecordService;
isRecording: ComputedRef<boolean>;
} {
const recordService = RecordService.getInstance();
// 响应式计算属性:是否正在录音
const isRecording = computed((): boolean => {
return recordService.isReceptioning();
});
return {
recordService,
isRecording
};
}
// composables/useSwipeBack.uts
// 左滑返回检测 Composable - 用于 iOS 侧滑返回手势检测
import { ref, type Ref } from 'vue'
import type { UniTouchEvent, UniTouch } from '@dcloudio/uni-app'
/**
* 左滑返回配置选项
*/
export type SwipeBackOptions = {
/** 滑动距离阈值(像素),默认 80 */
threshold?: number
/** 滑动时间阈值(毫秒),默认 300 */
timeThreshold?: number
/** 角度阈值(度),默认 30,避免误触上下滑动 */
angleThreshold?: number
/** 垂直滑动容差(像素),超过此值取消检测,默认 20 */
verticalTolerance?: number
/** 是否仅在屏幕左侧边缘触发,默认 false */
edgeOnly?: boolean
/** 左侧边缘宽度(像素),仅当 edgeOnly 为 true 时有效,默认 50 */
edgeWidth?: number
}
/**
* 左滑返回检测结果
*/
export type SwipeBackResult = {
/** 触摸事件处理函数 */
onTouchStart: (e: UniTouchEvent) => void
/** 触摸移动事件处理函数 */
onTouchMove: (e: UniTouchEvent) => void
/** 触摸结束事件处理函数 */
onTouchEnd: (e: UniTouchEvent) => void
/** 是否正在滑动 */
isSwiping: Ref<boolean>
/** 重置滑动状态 */
reset: () => void
}
/**
* 左滑返回检测 Hook
*
* @param onSwipeBack - 检测到左滑返回时的回调函数
* @param options - 配置选项
* @returns 触摸事件处理函数和状态
*
* @example
* ```typescript
* const { onTouchStart, onTouchMove, onTouchEnd } = useSwipeBack(() => {
* // 显示确认弹窗或执行返回逻辑
* showConfirmModal.value = true
* })
* ```
*
* @example
* ```vue
* <template>
* <view
* @touchstart="onTouchStart"
* @touchmove="onTouchMove"
* @touchend="onTouchEnd"
* >
* <!-- 页面内容 -->
* </view>
* </template>
* ```
*/
export function useSwipeBack(
onSwipeBack: () => void,
options: SwipeBackOptions = {}
): SwipeBackResult {
const {
threshold = 80,
timeThreshold = 300,
angleThreshold = 30,
verticalTolerance = 20,
edgeOnly = false,
edgeWidth = 50
} = options
// 内部状态
const startX = ref<number>(0)
const startY = ref<number>(0)
const startTime = ref<number>(0)
const isSwiping = ref<boolean>(false)
/**
* 触摸开始
*/
function onTouchStart(e: UniTouchEvent): void {
const touches = e.touches
if (touches.length == 0) {
return
}
const firstTouch = touches[0] as UniTouch
// 如果启用边缘检测,检查是否在左侧边缘区域
if (edgeOnly && firstTouch.clientX > edgeWidth) {
return
}
startX.value = firstTouch.clientX
startY.value = firstTouch.clientY
startTime.value = Date.now()
isSwiping.value = true
}
/**
* 触摸移动
*/
function onTouchMove(e: UniTouchEvent): void {
if (!isSwiping.value) {
return
}
const touches = e.touches
if (touches.length == 0) {
return
}
const firstTouch = touches[0] as UniTouch
const deltaY = firstTouch.clientY - startY.value
// 如果垂直滑动距离过大,取消左滑检测(避免与滚动冲突)
const absDeltaY = deltaY >= 0 ? deltaY : -deltaY
if (absDeltaY > verticalTolerance) {
isSwiping.value = false
}
}
/**
* 触摸结束
*/
function onTouchEnd(e: UniTouchEvent): void {
if (!isSwiping.value) {
return
}
isSwiping.value = false
const touches = e.changedTouches
if (touches.length == 0) {
return
}
const endTouch = touches[0] as UniTouch
const deltaX = endTouch.clientX - startX.value
const deltaY = endTouch.clientY - startY.value
const deltaTime = Date.now() - startTime.value
// 计算滑动距离
const absDeltaX = deltaX >= 0 ? deltaX : -deltaX
const absDeltaY = deltaY >= 0 ? deltaY : -deltaY
// 判断是否为有效的右滑手势(从左向右滑,即返回手势)
// 条件:
// 1. 向右滑动(deltaX > 0)
// 2. 滑动距离超过阈值
// 3. 滑动时间在合理范围内
// 4. 滑动角度符合要求(主要是水平滑动)
if (
deltaX > 0 &&
absDeltaX > threshold &&
deltaTime < timeThreshold
) {
// 计算滑动角度,确保主要是水平滑动
const angle = Math.atan2(absDeltaY, absDeltaX) * 180 / Math.PI
if (angle < angleThreshold) {
console.log('[useSwipeBack] 检测到右滑返回手势')
onSwipeBack()
}
}
}
/**
* 重置滑动状态
*/
function reset(): void {
isSwiping.value = false
startX.value = 0
startY.value = 0
startTime.value = 0
}
return {
onTouchStart,
onTouchMove,
onTouchEnd,
isSwiping,
reset
}
}
# 图片缓存配置说明
## 📋 配置文件位置
```
config/image-cache.config.uts
```
## ⚙️ 默认配置
```typescript
export const DEFAULT_IMAGE_CACHE_CONFIG: ImageCacheConfig = {
enabled: false, // ⚠️ 默认禁用,提升性能
expiryTime: 7 * 24 * 60 * 60 * 1000, // 7天
maxCacheCount: 100
};
```
## 🎯 为什么默认禁用?
### 1. **性能优化**
- 避免低端机 Storage 阻塞导致 ANR(应用无响应)
- 减少主线程负担,提升页面加载速度
- 降低内存占用
### 2. **用户体验**
- 快速启动,无白屏等待
- 流畅的页面切换
- 减少卡顿和掉帧
### 3. **资源节省**
- 减少 Storage 空间占用
- 降低网络请求(虽然禁用了缓存,但图片本身会从 CDN 加载)
## 🔧 如何启用缓存
### 方法 1:修改配置文件(全局生效)
编辑 `config/image-cache.config.uts`:
```typescript
export const DEFAULT_IMAGE_CACHE_CONFIG: ImageCacheConfig = {
enabled: true, // ✅ 改为 true 启用
expiryTime: 7 * 24 * 60 * 60 * 1000,
maxCacheCount: 100
};
```
### 方法 2:运行时动态修改(推荐)
在设置页面或应用启动时:
```typescript
import imageCache from "@/services/cache/ImageCacheService.uts";
// 启用缓存
imageCache.setEnabled(true);
// 禁用缓存
imageCache.setEnabled(false);
```
### 方法 3:在代码中临时启用
```typescript
import imageCache from "@/services/cache/ImageCacheService.uts";
// 临时启用(仅当前会话)
imageCache.updateConfig({
enabled: true,
expiryTime: 3 * 24 * 60 * 60 * 1000, // 3天
maxCacheCount: 50
});
```
## 📊 配置项说明
| 配置项 | 类型 | 默认值 | 说明 |
|--------|------|--------|------|
| `enabled` | boolean | `false` | 是否启用缓存 |
| `expiryTime` | number | `7天` | 缓存过期时间(毫秒) |
| `maxCacheCount` | number | `100` | 最大缓存数量 |
## 💡 使用建议
### 低端机(内存 < 2GB)
```typescript
// 保持默认禁用
imageCache.setEnabled(false);
```
### 中高端机(内存 >= 4GB)
```typescript
// 可以启用,但限制缓存数量
imageCache.updateConfig({
enabled: true,
maxCacheCount: 50, // 限制数量
expiryTime: 3 * 24 * 60 * 60 * 1000 // 缩短过期时间
});
```
### 离线场景需求强
```typescript
// 完全启用,延长过期时间
imageCache.updateConfig({
enabled: true,
expiryTime: 30 * 24 * 60 * 60 * 1000, // 30天
maxCacheCount: 200
});
```
## 🔍 检查缓存状态
```typescript
import imageCache from "@/services/cache/ImageCacheService.uts";
// 检查是否启用
const enabled = imageCache.isEnabled();
console.log('缓存状态:', enabled ? '已启用' : '已禁用');
// 获取统计信息
const stats = imageCache.getCacheStats();
console.log('缓存统计:', stats);
// {
// totalCount: 50, // 总缓存数
// validCount: 45, // 有效缓存数
// expiredCount: 5 // 过期缓存数
// }
```
## 🗑️ 清理缓存
```typescript
import imageCache from "@/services/cache/ImageCacheService.uts";
// 清空所有缓存
imageCache.clearAllCache();
// 删除单个缓存
imageCache.removeCache('cache_key');
```
## 📝 注意事项
1. **默认禁用是出于性能考虑** - 除非有明确的离线需求,否则建议保持禁用
2. **启用后会增加 Storage 占用** - 注意监控存储空间
3. **缓存会自动清理** - 过期或超出数量限制时自动删除
4. **异步写入不阻塞** - 即使启用也不会影响主线程性能
## 🚀 最佳实践
```typescript
// App.uvue 或 main.uts
import imageCache from "@/services/cache/ImageCacheService.uts";
import { isImageCacheEnabled } from "@/config/image-cache.config.uts";
onLaunch(() => {
// 根据设备性能决定是否启用
const deviceInfo = uni.getDeviceInfo();
if (isImageCacheEnabled()) {
// 配置已启用,可以根据设备调整参数
if (deviceInfo.memorySize < 2 * 1024) {
// 低端机:禁用
imageCache.setEnabled(false);
console.log('[性能优化] 低端机已禁用图片缓存');
} else {
// 中高端机:启用但限制数量
imageCache.updateConfig({
maxCacheCount: 50
});
console.log('[性能优化] 已启用图片缓存(限制50条)');
}
}
});
```
---
**总结**:默认禁用缓存是为了保证最佳性能,如需离线功能可按需启用。
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
### 3. 变量列表 ### 3. 变量列表
| 变量 | 说明 | 默认值(1024基准) | | 变量 | 说明 | 默认值(1024基准) |
| --------------- | ---- | ---------------- | |------|------|-----------------|
| --l-spacing-xs | 间距 | 8px | | --l-spacing-xs | 间距 | 8px |
| --l-spacing-sm | 间距 | 12px | | --l-spacing-sm | 间距 | 12px |
| --l-spacing-md | 间距 | 16px | | --l-spacing-md | 间距 | 16px |
...@@ -63,18 +63,18 @@ ...@@ -63,18 +63,18 @@
### 4. JS 中按设计稿缩放 ### 4. JS 中按设计稿缩放
```typescript ```typescript
import { useLayout } from "@/composables/useLayout"; import { useLayout } from '@/composables/useLayout'
const { scaleSize } = useLayout(); const { scaleSize } = useLayout()
// 设计稿 200px 宽的按钮 // 设计稿 200px 宽的按钮
const btnWidth = scaleSize(200); const btnWidth = scaleSize(200)
``` ```
### 5. 模式判断(预留) ### 5. 模式判断(预留)
```typescript ```typescript
const { isPad, isPortrait, isDesktop } = useLayout(); const { isPad, isPortrait, isDesktop } = useLayout()
if (isPad.value) { if (isPad.value) {
// pad 布局 // pad 布局
......
/**
* 图片缓存配置
*
* 说明:
* - 默认禁用图片缓存,以提升低端机性能
* - 可在设置页面中由用户手动启用
* - 启用后支持离线访问,但会增加 Storage 占用
*/
export interface ImageCacheConfig {
/** 是否启用图片缓存(默认禁用) */
enabled: boolean;
/** 缓存过期时间(毫秒),默认 7 天 */
expiryTime: number;
/** 最大缓存数量,默认 100 条 */
maxCacheCount: number;
}
/**
* 默认图片缓存配置
*
* 注意:默认禁用缓存,原因:
* 1. 避免低端机 Storage 阻塞导致 ANR
* 2. 减少内存占用
* 3. 提升页面加载速度
*
* 如需启用,可在设置页面中修改
*/
export const DEFAULT_IMAGE_CACHE_CONFIG: ImageCacheConfig = {
enabled: false, // ⚠️ 默认禁用,提升性能
expiryTime: 7 * 24 * 60 * 60 * 1000, // 7天
maxCacheCount: 100
};
/**
* 获取图片缓存配置
*/
export function getImageCacheConfig(): ImageCacheConfig {
return DEFAULT_IMAGE_CACHE_CONFIG;
}
/**
* 检查图片缓存是否启用
*/
export function isImageCacheEnabled(): boolean {
return DEFAULT_IMAGE_CACHE_CONFIG.enabled;
}
This diff could not be displayed because it is too large.
No preview for this file type
No preview for this file type
No preview for this file type
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!