Commit 28206b44 by cen Committed by chenwq1

fix: 竖屏布局

1 parent 00f5c1cd
Showing 25 changed files with 580 additions and 234 deletions
...@@ -11,10 +11,8 @@ export default { ...@@ -11,10 +11,8 @@ export default {
onLaunch () { onLaunch () {
// #ifdef APP // #ifdef APP
layoutService.init(); layoutService.init();
const sys = uni.getSystemInfoSync();
// uni.onWindowResize((res) => { console.log(`[App] 当前分辨率:${ sys.screenWidth } x ${ sys.screenHeight}`);
// updateResolutionConfig();
// });
// #endif // #endif
console.log("App Launch"); console.log("App Launch");
...@@ -60,9 +58,24 @@ export default { ...@@ -60,9 +58,24 @@ export default {
}; };
</script> </script>
<style> <style lang="scss">
/* 引入自定义 CSS 工具类 */ /* 引入自定义 CSS 工具类 */
@import url("./common.css"); @import url("./common.css");
/* I18n 布局适配:横竖屏 + 分辨率 */
@import "./adapt/landscape/1080/home-frame.scss";
@import "./adapt/landscape/1920/home-frame.scss";
@import "./adapt/portrait/1080/home-frame.scss";
@import "./adapt/portrait/1920/home-frame.scss";
@import "./adapt/landscape/1080/boutique-index.scss";
@import "./adapt/landscape/1920/boutique-index.scss";
@import "./adapt/portrait/1080/boutique-index.scss";
@import "./adapt/portrait/1920/boutique-index.scss";
@import "./adapt/landscape/1080/login.scss";
@import "./adapt/landscape/1920/login.scss";
@import "./adapt/portrait/1080/login.scss";
@import "./adapt/portrait/1920/login.scss";
@import "./adapt/portrait/1080/account-items.scss";
@import "./adapt/portrait/1920/account-items.scss";
/* 全局默认样式 */ /* 全局默认样式 */
uni-page-body { uni-page-body {
......
/* 精品页 横屏 1080 档位适配
* 目前主要依赖全局 spacing/font/radius 变量,这里预留结构,后续可按需补充页面级变量
*/
.mode-landscape.res-1080 {
/* 示例:可在此处为精品页单独定义变量,例如:
* --boutique-card-height: 200px;
*/
}
/* HomeFrame 横屏 1080 档位适配 */
.home-frame-container.mode-landscape.res-1080 {
/* 对应 layout-vars.uts 中 1024/1174 档的值 */
--l-content-left-width: 605px;
--l-module-box-height: 332px;
--l-tool-box-min-height: 120px;
--l-common-title-height: 60px;
}
/* 登录选择账号页 横屏 1080 档位适配
* 通过 LayoutRoot 上的 .mode-landscape.res-1080 类控制,仅在横屏 1080 档时生效。
*/
.mode-landscape.res-1080 {
/* 示例:可根据登录页设计调整根容器
* .page-container {
* padding: 0 var(--l-spacing-lg);
* }
*/
}
/* 精品页 横屏 1920 档位适配(预留) */
.mode-landscape.res-1920 {
/* 示例:后续可在此定义 1920 档变量 */
}
/* HomeFrame 横屏 1920 档位适配 */
.home-frame-container.mode-landscape.res-1920 {
/* 对应 layout-vars.uts 中 1920 档的值 */
--l-content-left-width: 1134px;
--l-module-box-height: 623px;
--l-tool-box-min-height: 225px;
--l-common-title-height: 113px;
}
/* 登录选择账号页 横屏 1920 档位适配
* 大屏(如 1920 宽度)下,可在此增加更宽松的留白和布局。
*/
.mode-landscape.res-1920 {
/* 示例:后续按实际设计稿补充
* .page-container {
* max-width: 1600px;
* margin: 0 auto;
* }
*/
}
/* 账号选择页 竖屏 1080 档位适配
* 典型手机竖屏场景(如 360 x 800 等宽度归为 1080 档)。
* 通过 .account-page 避免影响其他页面。
*/
.mode-portrait.res-1080 .account-page {
.layout {
padding-top: 48px;
padding-bottom: 24px;
}
.content-box {
top: 120px;
bottom: 48px;
width: 94%;
border-radius: 16px;
}
.step-box {
transform: scale(0.9);
}
/* 竖屏下账号/门店列表:一行一个,撑满宽度 */
.box {
padding: 0 16px;
justify-content: flex-start;
}
.box .items {
width: 100%;
margin-bottom: 16px;
}
}
/* 精品页 竖屏 1080 档位适配
* 使用 LayoutRoot 提供的 mode/res class:
* - .mode-portrait.res-1080
* 可在此范围内定制精品页在竖屏手机上的布局与尺寸。
*/
.mode-portrait.res-1080 {
/* 精品首页竖屏下“开始接待”区域适配,降低高度避免图片拉伸感 */
.start {
height: 96px;
padding-top: 24px;
}
}
/* HomeFrame 竖屏 1080 档位适配
* 注意:数值暂时复用横屏 1080 档,后续可根据你的竖屏设计稿单独调整
*/
.home-frame-container.mode-portrait.res-1080 {
--l-content-left-width: 605px;
--l-module-box-height: 332px;
--l-tool-box-min-height: 120px;
--l-common-title-height: 60px;
}
/* 登录页 竖屏 1080 档位适配(如 360 x 800 等宽度归为 1080 档)
* 通过 .login-page 避免影响其他页面;仅在手机竖屏时生效。
*/
.mode-portrait.res-1080 .login-page {
.layout {
justify-content: flex-start;
align-items: stretch;
padding: 32px 24px;
}
.login {
align-items: stretch;
margin-top: 16px;
max-width: 320px;
margin-left: auto;
margin-right: auto;
}
.login .title {
font-size: 28px;
margin-bottom: 12px;
}
.login .sub-title {
font-size: 14px;
margin: 12px 0 20px;
}
.login .input {
width: 100%;
height: 48px;
border-radius: 24px;
margin-bottom: 16px;
}
.login .btn {
width: 100%;
height: 48px;
margin-top: 8px;
font-size: 18px;
}
.form-footer {
padding-left: 0;
margin-top: 16px;
}
.app-code {
bottom: 12px;
/* 手机端登录页 APP 编码:完全使用固定像素,不参与变量缩放 */
font-size: 10px !important;
line-height: 14px;
left: 50%;
transform: translateX(-50%) scale(0.85);
}
}
/* 账号选择页 竖屏 1920 档位适配(预留)
* 如后续有竖屏大屏需求,可在此补充。
*/
.mode-portrait.res-1920 .account-page {
}
/* 精品页 竖屏 1920 档位适配(预留)
* 当前大屏场景通常为横屏,此处作为扩展占位。
*/
.mode-portrait.res-1920 {
/* 根据后续竖屏大屏设计补充 */
}
/* HomeFrame 竖屏 1920 档位适配
* 注意:数值暂时复用横屏 1920 档,后续可根据你的竖屏设计稿单独调整
*/
.home-frame-container.mode-portrait.res-1920 {
--l-content-left-width: 1134px;
--l-module-box-height: 623px;
--l-tool-box-min-height: 225px;
--l-common-title-height: 113px;
}
/* 登录选择账号页 竖屏 1920 档位适配(预留)
* 如后续有竖屏大屏设备需求,可在此补充。
*/
.mode-portrait.res-1920 {
/* 预留占位,不影响现有布局 */
}
<template> <template>
<view class="left-side left-side-pad"> <!-- 横屏 / Pad:左侧竖向导航(头像 + 场景切换 + 设置) -->
<view v-if="!isPortraitMode"
class="left-side left-side-pad">
<image class="left-side-bg-img" <image class="left-side-bg-img"
mode="aspectFill" mode="aspectFill"
src="/static/images/home/left-bg.png" /> src="/static/images/home/left-bg.png" />
...@@ -35,6 +37,20 @@ ...@@ -35,6 +37,20 @@
<SettingBox :visible="showSetting" <SettingBox :visible="showSetting"
@update:visible="onSettingVisible" /> @update:visible="onSettingVisible" />
</view> </view>
<!-- 竖屏手机:底部 TabBar,仅保留场景 Tab,不显示头像和底部两个按钮 -->
<view v-else
class="left-side left-side-portrait">
<view class="portrait-tabs-row">
<view v-for="(item, index) in tabs"
:key="index"
class="tab-item tab-item-inline"
:class="[tabIndex == index ? 'tabActive' : '']"
@click="onChangeTab(index)">
<text class="tab-label">{{ item.label }}</text>
</view>
</view>
</view>
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
...@@ -234,6 +250,7 @@ function jumpPersonCenter(): void { ...@@ -234,6 +250,7 @@ function jumpPersonCenter(): void {
padding: var(--l-spacing-sm) var(--l-spacing-md); padding: var(--l-spacing-sm) var(--l-spacing-md);
min-height: 56px; min-height: 56px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
justify-content: center;
} }
.portrait-top-row { .portrait-top-row {
...@@ -255,6 +272,7 @@ function jumpPersonCenter(): void { ...@@ -255,6 +272,7 @@ function jumpPersonCenter(): void {
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
padding: 0 var(--l-spacing-sm); padding: 0 var(--l-spacing-sm);
justify-content: center;
} }
.portrait-tabs-row .tab-item-inline { .portrait-tabs-row .tab-item-inline {
......
<template> <template>
<view class="home-frame-container"> <view class="home-frame-container"
:class="[modeClass, resolutionClass]">
<!-- 首页内容区 --> <!-- 首页内容区 -->
<view v-if="!showDetail" <view v-if="!showDetail"
class="home-content home-content-pad"> class="home-content"
<HomeFrameLeftSide :tab-index="tabIndex" :class="[isPortraitMode ? 'home-content-portrait' : 'home-content-pad']">
:user-info="userInfo"
@change-tab="onChangeTab" /> <!-- 右侧内容:竖屏和横屏共用一套结构,只是顺序不同 -->
<view class="right-side"> <view v-if="isPortraitMode" class="right-side">
<!-- 横屏三卡片布局:轻改等使用 swiperCustom -->
<view v-if="useCardLayout && tabIndex == 0" class="app-content-box right-content show-content-box">
<view class="start" @click="onStartClick">
<image class="start-bg-img"
:mode="isPortraitMode ? 'aspectFill' : 'scaleToFill'"
src="/static/images/home/start-btn.png" />
<view class="start-inner">
<text class="start-text">开始接待</text>
</view>
</view>
<view class="right-content-box flex-row">
<view class="content-left">
<view class="module-box box-class">
<view class="common-title">
<text class="title-text">产品介绍</text>
</view>
<view class="content-box">
<slot v-if="swiperCustom" name="swiperCustom"></slot>
<view v-else class="swiper-placeholder">
<text class="placeholder-text">敬请期待</text>
</view>
</view>
</view>
<view class="tool-box box-class">
<view class="common-title">
<text class="title-text">展业工具</text>
</view>
<view class="content-box">
<Entrance :scene-type="sceneType" />
</view>
</view>
</view>
<view class="content-right box-class">
<view class="common-title">
<text class="title-text">服务中心</text>
</view>
<view class="content-box">
<HomeFrameMessageIndex class="message-box" />
</view>
</view>
</view>
</view>
<!-- 旧版居中布局:权益、二手车等使用 #home -->
<view v-else-if="tabIndex == 0" class="legacy-home-wrap">
<slot name="home"></slot>
</view>
</view>
<view v-else class="right-side">
<!-- 横屏三卡片布局:轻改等使用 swiperCustom --> <!-- 横屏三卡片布局:轻改等使用 swiperCustom -->
<view v-if="useCardLayout && tabIndex == 0" class="app-content-box right-content show-content-box"> <view v-if="useCardLayout && tabIndex == 0" class="app-content-box right-content show-content-box">
<view class="start" @click="onStartClick"> <view class="start" @click="onStartClick">
...@@ -54,6 +104,18 @@ ...@@ -54,6 +104,18 @@
<slot name="home"></slot> <slot name="home"></slot>
</view> </view>
</view> </view>
<!-- 竖屏:底部 TabBar;横屏:左侧栏 -->
<HomeFrameLeftSide v-if="isPortraitMode"
:is-portrait="true"
:tab-index="tabIndex"
:user-info="userInfo"
@change-tab="onChangeTab" />
<HomeFrameLeftSide v-else
:is-portrait="false"
:tab-index="tabIndex"
:user-info="userInfo"
@change-tab="onChangeTab" />
<!-- 底部门店信息:与 right-side 同级,样式与旧项目 store-addr 一致 --> <!-- 底部门店信息:与 right-side 同级,样式与旧项目 store-addr 一致 -->
<!-- <view v-if="showFooter" class="store-addr"> <!-- <view v-if="showFooter" class="store-addr">
<view class="addr-line addr-line-left"></view> <view class="addr-line addr-line-left"></view>
...@@ -74,6 +136,7 @@ ...@@ -74,6 +136,7 @@
import { computed, defineExpose, ref } from "vue"; import { computed, defineExpose, ref } from "vue";
import Entrance from "@/components/Entrance.uvue"; import Entrance from "@/components/Entrance.uvue";
import { layoutService } from "@/services/LayoutService.uts";
import { storage } from "@/utils/storage.uts"; import { storage } from "@/utils/storage.uts";
import HomeFrameLeftSide from "./LeftSide.uvue"; import HomeFrameLeftSide from "./LeftSide.uvue";
...@@ -92,6 +155,22 @@ const useCardLayout = computed((): boolean => { ...@@ -92,6 +155,22 @@ const useCardLayout = computed((): boolean => {
return props.swiperCustom === true; return props.swiperCustom === true;
}); });
const modeClass = computed((): string => {
const modeRef = layoutService.getCurrentMode();
const m = modeRef.value;
// pad / desktop 归为横屏,portrait 归为竖屏
return m == "portrait" ? "mode-portrait" : "mode-landscape";
});
const resolutionClass = computed((): string => {
const bucket = layoutService.getResolutionBucket();
return `res-${bucket}`;
});
const isPortraitMode = computed((): boolean => {
return layoutService.isMode("portrait");
});
const showDetail = ref(false); const showDetail = ref(false);
const userInfo = ref<UTSJSONObject>({}); const userInfo = ref<UTSJSONObject>({});
const sceneType = ref<number>(1); const sceneType = ref<number>(1);
...@@ -130,6 +209,7 @@ defineExpose({ ...@@ -130,6 +209,7 @@ defineExpose({
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.home-frame-container { .home-frame-container {
width: 100%; width: 100%;
height: 100%; height: 100%;
...@@ -152,6 +232,10 @@ defineExpose({ ...@@ -152,6 +232,10 @@ defineExpose({
flex-direction: row; flex-direction: row;
} }
.home-content-portrait {
flex-direction: column;
}
.detail-content { .detail-content {
flex: 1; flex: 1;
width: 100%; width: 100%;
...@@ -166,7 +250,16 @@ defineExpose({ ...@@ -166,7 +250,16 @@ defineExpose({
overflow: hidden; overflow: hidden;
} }
.mode-portrait .right-side {
order: 1;
}
.mode-portrait .left-side-portrait {
order: 2;
}
.app-content-box { .app-content-box {
margin-top: 50px;
flex: 1; flex: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
...@@ -179,7 +272,7 @@ defineExpose({ ...@@ -179,7 +272,7 @@ defineExpose({
/* 与旧项目一致:背景图铺满,文字居中偏上,无渐变遮罩 */ /* 与旧项目一致:背景图铺满,文字居中偏上,无渐变遮罩 */
.start { .start {
height: 126px; height: 86px;
box-sizing: border-box; box-sizing: border-box;
margin-right: 32px; margin-right: 32px;
position: relative; position: relative;
...@@ -216,7 +309,7 @@ defineExpose({ ...@@ -216,7 +309,7 @@ defineExpose({
} }
.start-text { .start-text {
font-size: 36px; font-size: 20px;
font-weight: 600; font-weight: 600;
color: #ffffff; color: #ffffff;
text-align: center; text-align: center;
......
<template> <template>
<view class="layout-root" :style="styleObj"> <view class="layout-root" :class="[modeClass, resolutionClass]" :style="styleObj">
<slot></slot> <slot></slot>
</view> </view>
</template> </template>
...@@ -7,15 +7,28 @@ ...@@ -7,15 +7,28 @@
<script setup lang="uts"> <script setup lang="uts">
import { computed, type Ref } from 'vue' import { computed, type Ref } from 'vue'
import { useLayout } from '@/composables/useLayout' import { useLayout } from '@/composables/useLayout'
import { layoutService } from '@/services/LayoutService.uts'
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
const styleObj = computed((): UTSJSONObject => { const styleObj = computed((): UTSJSONObject => {
const r = rawCssVars const r = rawCssVars
if (r == null) return {} if (r == null) return {}
const v = r.value const v = r.value
return v != null ? v : {} return v != null ? v : {}
}) })
const modeClass = computed((): string => {
const modeRef = layoutService.getCurrentMode()
const m = modeRef.value
return m == 'portrait' ? 'mode-portrait' : 'mode-landscape'
})
const resolutionClass = computed((): string => {
const bucket = layoutService.getResolutionBucket()
return `res-${bucket}`
})
</script> </script>
<style scoped> <style scoped>
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
} }
}, },
"orientation": [ "orientation": [
"portrait-primary",
"landscape-primary" "landscape-primary"
] ]
} }
...@@ -66,6 +67,7 @@ ...@@ -66,6 +67,7 @@
"default": {} "default": {}
}, },
"orientation": [ "orientation": [
"portrait-primary",
"landscape-primary" "landscape-primary"
], ],
"permissions": [ "permissions": [
...@@ -93,6 +95,7 @@ ...@@ -93,6 +95,7 @@
"icons": {}, "icons": {},
"splashScreens": {}, "splashScreens": {},
"orientation": [ "orientation": [
"portrait-primary",
"landscape-primary" "landscape-primary"
] ]
} }
......
...@@ -82,8 +82,7 @@ ...@@ -82,8 +82,7 @@
"navigationBarTextStyle": "black", "navigationBarTextStyle": "black",
"navigationBarTitleText": "uni-app x", "navigationBarTitleText": "uni-app x",
"navigationBarBackgroundColor": "#F8F8F8", "navigationBarBackgroundColor": "#F8F8F8",
"backgroundColor": "#F8F8F8", "backgroundColor": "#F8F8F8"
"pageOrientation": "landscape"
}, },
"uniIdRouter": {} "uniIdRouter": {}
} }
<template> <template>
<!-- #ifdef APP -->
<layout-root> <layout-root>
<!-- #endif --> <!-- #endif -->
<view class="page-container"> <view class="page-container account-page">
<view class="bg"> <view class="bg">
<image class="bg-image" src="/static/images/login/account-bg.webp" mode="aspectFill"></image> <image class="bg-image"
mode="aspectFill"
src="/static/images/login/account-bg.webp">
</image>
</view> </view>
<view class="layout"> <view class="layout">
<view class="nav-bar"> <view class="nav-bar">
<view class="back" @click="back"> <view class="back" @click="back">
<uni-icons type="left" :size="20" color="#000"></uni-icons> <uni-icons color="#000"
:size="20"
type="left">
</uni-icons>
</view> </view>
</view> </view>
<view class="step-box"> <view class="step-box">
<view <view v-for="(item, index) in stepList"
v-for="(item, index) in stepList" v-show="stepIndex === index"
:key="index" :key="index"
:class="['step-item', stepIndex >= index ? 'active-item' : '']" class="step-item"
@click="setStep(index)" :class="[stepIndex >= index ? 'active-item' : '']"
> @click="setStep(index)">
<view class="num"> <view class="num">
<view :class="['text', stepIndex >= index ? 'text-active' : '']"> <view class="text" :class="[stepIndex >= index ? 'text-active' : '']">
<text class="num-text">{{ index + 1 }}</text> <text class="num-text">{{ index + 1 }}</text>
</view> </view>
</view> </view>
<text :class="['step-label', stepIndex >= index ? 'step-label-active' : '']">{{ item }}</text> <text class="step-label" :class="[stepIndex >= index ? 'step-label-active' : '']">{{ item }}</text>
</view> </view>
</view> </view>
<view class="content-box"> <view class="content-box">
<view v-if="stepIndex != 2" class="search-box"> <view v-if="stepIndex != 2" class="search-box">
<view class="search-input"> <view class="search-input">
<view v-if="!edit" :class="['input', searchValue != '' ? '' : 'placeholder']" @click="open"> <view v-if="!edit"
class="input"
:class="[searchValue != '' ? '' : 'placeholder']"
@click="open">
<text v-if="searchValue != ''">{{ searchValue }}</text> <text v-if="searchValue != ''">{{ searchValue }}</text>
<text class="placeholder" v-else> <text v-else class="placeholder">
请输入门店名称/商户号搜索 请输入门店名称/商户号搜索
<view class="sprite-icon icon-search"></view> <view class="sprite-icon icon-search"></view>
</text> </text>
</view> </view>
<input <input v-else
v-else
type="text"
class="input"
v-model="searchValue" v-model="searchValue"
:focus="inputFocus" class="input"
confirm-type="search" confirm-type="search"
:focus="inputFocus"
type="text"
@blur="search" @blur="search"
@confirm="search" @confirm="search" />
/>
</view> </view>
<view v-if="searchValue != ''" class="clear" @click="clear"> <view v-if="searchValue != ''"
<uni-icons type="closeempty" :size="16" color="#1A1A1A"></uni-icons> class="clear"
@click="clear">
<uni-icons color="#1A1A1A"
:size="16"
type="closeempty">
</uni-icons>
</view> </view>
</view> </view>
<scroll-view class="list" direction="vertical" :show-scrollbar="true"> <scroll-view class="list"
<account-list direction="vertical"
v-show="stepIndex == 0" :show-scrollbar="true">
<AccountList v-show="stepIndex == 0"
ref="accountRef" ref="accountRef"
@chooseAccount="chooseAccount" @choose-account="chooseAccount" />
/> <MerchantList v-show="stepIndex == 1"
<merchant-list
v-show="stepIndex == 1"
ref="merchantRef" ref="merchantRef"
@chooseMerchant="chooseMerchant" @choose-merchant="chooseMerchant" />
/> <Scene v-show="stepIndex == 2"
<scene ref="sceneRef" />
v-show="stepIndex == 2"
ref="sceneRef"
/>
</scroll-view> </scroll-view>
</view> </view>
</view> </view>
</view> </view>
<!-- #ifdef APP --> <!-- #ifdef APP -->
</layout-root> </layout-root>
<!-- #endif -->
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import { ref, nextTick, ComponentPublicInstance } from 'vue' import { ComponentPublicInstance, nextTick, ref } from "vue";
// import { onLoad } from '@dcloudio/uni-app'
import AccountList from '@/pages/common/components/AccountList.uvue' import AccountList from "@/pages/common/components/AccountList.uvue";
import MerchantList from '@/pages/common/components/MerchantList.uvue' import MerchantList from "@/pages/common/components/MerchantList.uvue";
import Scene from '@/pages/common/components/Scene.uvue' import Scene from "@/pages/common/components/Scene.uvue";
import { onLoad } from "@dcloudio/uni-app";
const stepList = ref<string[]>(['选择账号', '选择4S店', '选择场景'])
const stepIndex = ref<number>(0) const stepList = ref<string[]>(["选择账号", "选择4S店", "选择场景"]);
const searchValue = ref<string>('') const stepIndex = ref<number>(0);
const edit = ref<boolean>(false) const searchValue = ref<string>("");
const inputFocus = ref<boolean>(false) const edit = ref<boolean>(false);
const inputFocus = ref<boolean>(false);
// 组件 ref 使用 any + 方括号调用,避免 as RefWithXxx 在运行时触发 ClassCastException // 组件 ref 使用 any + 方括号调用,避免 as RefWithXxx 在运行时触发 ClassCastException
const accountRef = ref(null) const accountRef = ref(null);
const merchantRef = ref(null) const merchantRef = ref(null);
const sceneRef = ref(null) const sceneRef = ref(null);
onLoad((options: UTSJSONObject | null) => { onLoad((options: null | UTSJSONObject) => {
const stepIndexOpt = options != null ? (options['stepIndex'] as string | null) : null const stepIndexOpt = options != null ? (options.stepIndex as null | string) : null;
if (stepIndexOpt == '1') { if (stepIndexOpt == "1") {
stepIndex.value = 1 stepIndex.value = 1;
setTimeout((): void => { setTimeout((): void => {
if (accountRef.value != null) { if (accountRef.value != null) {
(accountRef.value as ComponentPublicInstance).$callMethod('getListSelectAccount', true) (accountRef.value as ComponentPublicInstance).$callMethod("getListSelectAccount", true);
} }
}, 100) }, 100);
} }
}) });
const search = (): void => { const search = (): void => {
edit.value = false edit.value = false;
inputFocus.value = false inputFocus.value = false;
const step = stepIndex.value const step = stepIndex.value;
if (step == 0) { if (step == 0) {
if (accountRef.value != null) { if (accountRef.value != null) {
(accountRef.value as ComponentPublicInstance).$callMethod('searchEvent', searchValue.value) (accountRef.value as ComponentPublicInstance).$callMethod("searchEvent", searchValue.value);
}
} else if (step == 1) {
if (merchantRef.value != null) {
(merchantRef.value as ComponentPublicInstance).$callMethod('searchEvent', searchValue.value)
} }
} else if (step == 1 && merchantRef.value != null) {
(merchantRef.value as ComponentPublicInstance).$callMethod("searchEvent", searchValue.value);
} }
} };
const open = (): void => { const open = (): void => {
edit.value = true edit.value = true;
inputFocus.value = true inputFocus.value = true;
} };
const back = (): void => { const back = (): void => {
uni.navigateBack() uni.navigateBack();
} };
const setStep = (index: number): void => { const setStep = (index: number): void => {
if (index == 2) return if (index == 2) return;
if (stepIndex.value > index) { if (stepIndex.value > index) {
stepIndex.value = index stepIndex.value = index;
} }
} };
const clear = (): void => { const clear = (): void => {
searchValue.value = '' searchValue.value = "";
search() search();
} };
const chooseAccount = (userInfo: any): void => { const chooseAccount = (userInfo: any): void => {
stepIndex.value = 1 stepIndex.value = 1;
searchValue.value = '' searchValue.value = "";
nextTick((): void => { nextTick((): void => {
if (merchantRef.value != null) { if (merchantRef.value != null) {
// 直接传递,让运行时处理 // 直接传递,让运行时处理
(merchantRef.value as ComponentPublicInstance).$callMethod('init', userInfo) (merchantRef.value as ComponentPublicInstance).$callMethod("init", userInfo);
} }
}) });
} };
const chooseMerchant = (userInfo: any): void => { const chooseMerchant = (userInfo: any): void => {
stepIndex.value = 2 stepIndex.value = 2;
searchValue.value = '' searchValue.value = "";
nextTick((): void => { nextTick((): void => {
if (sceneRef.value != null) { if (sceneRef.value != null) {
// userInfo 已经是 UTSJSONObject,直接传递 // userInfo 已经是 UTSJSONObject,直接传递
(sceneRef.value as ComponentPublicInstance).$callMethod('init', userInfo) (sceneRef.value as ComponentPublicInstance).$callMethod("init", userInfo);
} }
}) });
} };
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
......
...@@ -323,13 +323,13 @@ defineExpose({ ...@@ -323,13 +323,13 @@ defineExpose({
.items .name { .items .name {
font-weight: 500; font-weight: 500;
font-size: var(--l-font-base); font-size: 16px;
color: #181a1f; color: #181a1f;
margin-bottom: 6px; margin-bottom: 6px;
} }
.items .text_no { .items .text_no {
font-size: var(--l-font-sm); font-size: 14px;
color: #999ea8; color: #999ea8;
} }
......
<template> <template>
<view class="box"> <view class="box">
<view <view v-for="(item, index) in sceneList"
v-for="(item, index) in sceneList"
:key="index" :key="index"
:class="['items', item.actived ? 'active' : '']" class="items"
@click="selectScene(item, index)" :class="[item.actived ? 'active' : '']"
> @click="selectScene(item, index)">
<view class="left"> <view class="left">
<view :class="['sprite-icon', 'icon-scene-' + item.sceneType]"></view> <view class="sprite-icon" :class="[`icon-scene-${ item.sceneType}`]"></view>
</view> </view>
<view class="right"> <view class="right">
<text class="name">{{ item.sceneName }}</text> <text class="name">{{ item.sceneName }}</text>
...@@ -18,186 +17,184 @@ ...@@ -18,186 +17,184 @@
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import { ref, defineExpose } from 'vue' import { defineExpose, ref } from "vue";
import { apiSelectMerchantScene, apiGetMerchantBrand } from '@/api/user-api.uts'
import { storage } from '@/utils/storage.uts' import { apiGetMerchantBrand, apiSelectMerchantScene } from "@/api/user-api.uts";
import { layoutService } from '@/services/LayoutService' import { layoutService } from "@/services/LayoutService";
import { storage } from "@/utils/storage.uts";
type SceneItem = { type SceneItem = {
sceneName: string actived: boolean
sceneDesc: string sceneDesc: string
sceneName: string
sceneType: number sceneType: number
actived: boolean
} }
const sceneList = ref<SceneItem[]>([ const sceneList = ref<SceneItem[]>([
{ sceneName: '轻改', sceneDesc: '太阳膜升级转化', sceneType: 1, actived: false }, { sceneName: "轻改", sceneDesc: "太阳膜升级转化", sceneType: 1, actived: false },
{ sceneName: '会员权益/升级', sceneDesc: '权益、延保', sceneType: 0, actived: false }, { sceneName: "会员权益/升级", sceneDesc: "权益、延保", sceneType: 0, actived: false },
{ sceneName: '二手车', sceneDesc: '二手车业务', sceneType: 7, actived: false } { sceneName: "二手车", sceneDesc: "二手车业务", sceneType: 7, actived: false }
]) ]);
let userInfo: UTSJSONObject | null = null let userInfo: null | UTSJSONObject = null;
let jumpTimer: number = 0 let jumpTimer: number = 0;
function jump(info: UTSJSONObject, data: any | null): void { function jump(info: UTSJSONObject, data: any | null): void {
const now = Date.now() const now = Date.now();
if (now - jumpTimer < 3000) { if (now - jumpTimer < 3000) {
uni.hideLoading() uni.hideLoading();
return return;
} }
jumpTimer = now jumpTimer = now;
console.log('跳转进入首页!') console.log("跳转进入首页!");
uni.hideLoading() uni.hideLoading();
if (data != null) { if (data != null) {
const loginRole = (data as UTSJSONObject)['loginRoleOnSelectMerchant'] const loginRole = (data as UTSJSONObject).loginRoleOnSelectMerchant;
if (loginRole != null) { if (loginRole != null) {
info['loginRoleOnSelectMerchant'] = loginRole info.loginRoleOnSelectMerchant = loginRole;
} }
} }
const shopMerchantId = info['shopMerchantId'] as string | null const shopMerchantId = info.shopMerchantId as null | string;
if (shopMerchantId == null || shopMerchantId == '') { if (shopMerchantId == null || shopMerchantId == "") {
uni.showToast({ title: '参数异常', icon: 'none' }) uni.showToast({ title: "参数异常", icon: "none" });
return return;
} }
uni.showLoading({ title: '加载中', mask: true }) uni.showLoading({ title: "加载中", mask: true });
console.log('调用 getMerchantBrand, merchantId: ' + shopMerchantId) console.log(`调用 getMerchantBrand, merchantId: ${ shopMerchantId}`);
apiGetMerchantBrand({ merchantId: shopMerchantId }).then((res: any): void => { apiGetMerchantBrand({ merchantId: shopMerchantId }).then((res: any): void => {
console.log('getMerchantBrand 成功') console.log("getMerchantBrand 成功");
uni.hideLoading() uni.hideLoading();
const code = (res as UTSJSONObject)['code'] as string | null const code = (res as UTSJSONObject).code as null | string;
if (code == '0') { if (code == "0") {
const dataObj = (res as UTSJSONObject)['data'] as UTSJSONObject | null const dataObj = (res as UTSJSONObject).data as null | UTSJSONObject;
const channelType = dataObj != null ? (dataObj['channelType'] as number | null) : null const channelType = dataObj != null ? (dataObj.channelType as null | number) : null;
info['channelType'] = channelType ?? 1 info.channelType = channelType ?? 1;
} else { } else {
info['channelType'] = 1 info.channelType = 1;
} }
storage.set('userInfo', info, 0) storage.set("userInfo", info, 0);
const sceneType = info['sceneType'] as number | null const sceneType = info.sceneType as null | number;
storage.remove('boutique_YQorderSetting') storage.remove("boutique_YQorderSetting");
let url = '/pages/index/index' let url = "/pages/index/index";
if (sceneType == 1) { if (sceneType == 1) {
url = layoutService.isMode('portrait') ? '/pages/boutique/portrait' : '/pages/boutique/index' url = layoutService.isMode("portrait") ? "/pages/boutique/portrait" : "/pages/boutique/index";
} else if (sceneType == 0) { } else if (sceneType == 0) {
url = '/pages/equity/index' url = "/pages/equity/index";
} else if (sceneType == 7) { } else if (sceneType == 7) {
url = '/pages/usedCar/index' url = "/pages/usedCar/index";
} }
console.log('准备跳转: ' + url) console.log(`准备跳转: ${ url}`);
uni.reLaunch({ url }) uni.reLaunch({ url });
}).catch((err) => { }).catch((error) => {
uni.hideLoading() uni.hideLoading();
console.error('getMerchantBrand 失败: ' + JSON.stringify(err)) console.error(`getMerchantBrand 失败: ${ JSON.stringify(error)}`);
info['channelType'] = 1 info.channelType = 1;
storage.set('userInfo', info, 0) storage.set("userInfo", info, 0);
const sceneType = info['sceneType'] as number | null const sceneType = info.sceneType as null | number;
let url = '/pages/index/index' let url = "/pages/index/index";
if (sceneType == 1) { if (sceneType == 1) {
url = layoutService.isMode('portrait') ? '/pages/boutique/portrait' : '/pages/boutique/index' url = layoutService.isMode("portrait") ? "/pages/boutique/portrait" : "/pages/boutique/index";
} else if (sceneType == 0) { } else if (sceneType == 0) {
url = '/pages/equity/index' url = "/pages/equity/index";
} else if (sceneType == 7) { } else if (sceneType == 7) {
url = '/pages/usedCar/index' url = "/pages/usedCar/index";
} }
console.log('准备跳转(catch): ' + url) console.log(`准备跳转(catch): ${ url}`);
uni.reLaunch({ url }) uni.reLaunch({ url });
}) });
} }
function init(info: any): void { function init(info: any): void {
// 将 any 转换为 UTSJSONObject // 将 any 转换为 UTSJSONObject
userInfo = info as UTSJSONObject userInfo = info as UTSJSONObject;
console.log('进入选择场景页!') console.log("进入选择场景页!");
const openSceneArr = userInfo['openSceneArr'] const openSceneArr = userInfo.openSceneArr;
console.log('init - openSceneArr type: ' + typeof openSceneArr) console.log(`init - openSceneArr type: ${ typeof openSceneArr}`);
if (openSceneArr != null) { if (openSceneArr != null) {
console.log('init - openSceneArr length: ' + (openSceneArr as any[]).length) console.log(`init - openSceneArr length: ${ (openSceneArr as any[]).length}`);
} else { } else {
console.log('init - openSceneArr is null') console.log("init - openSceneArr is null");
} }
} }
function selectScene(item: SceneItem, index: number): void { function selectScene(item: SceneItem, index: number): void {
const sceneType = item.sceneType const sceneType = item.sceneType;
console.log('选择场景' + sceneType + '!') console.log(`选择场景${ sceneType }!`);
if (userInfo == null) { if (userInfo == null) {
uni.showToast({ title: '参数异常', icon: 'none' }) uni.showToast({ title: "参数异常", icon: "none" });
return return;
} }
const openSceneArr = userInfo['openSceneArr'] as any[] | null const openSceneArr = userInfo.openSceneArr as any[] | null;
const isSuper = userInfo['isSuper'] as boolean | null const isSuper = userInfo.isSuper as boolean | null;
// 手动检查是否包含 sceneType(indexOf 在 App 端有 bug) // 手动检查是否包含 sceneType(indexOf 在 App 端有 bug)
let sceneAllowed = isSuper == true let sceneAllowed = isSuper == true;
if (!sceneAllowed && openSceneArr != null) { if (!sceneAllowed && openSceneArr != null) {
let i = 0 let i = 0;
while (i < openSceneArr.length) { while (i < openSceneArr.length) {
if (openSceneArr[i] == sceneType) { if (openSceneArr[i] == sceneType) {
sceneAllowed = true sceneAllowed = true;
break break;
} }
i++ i++;
} }
} }
if (!sceneAllowed) { if (!sceneAllowed) {
uni.showToast({ title: '暂未开通此场景', icon: 'none' }) uni.showToast({ title: "暂未开通此场景", icon: "none" });
return return;
} }
const list = sceneList.value const list = sceneList.value;
let i = 0 let i = 0;
while (i < list.length) { while (i < list.length) {
list[i].actived = false list[i].actived = false;
i++ i++;
} }
list[index].actived = true list[index].actived = true;
sceneList.value = list sceneList.value = list;
userInfo['sceneType'] = sceneType userInfo.sceneType = sceneType;
uni.showLoading({ title: '加载中', mask: true }) uni.showLoading({ title: "加载中", mask: true });
if (isSuper == true) { if (isSuper == true) {
jump(userInfo, null) jump(userInfo, null);
} else { } else {
const shopMerchantId = userInfo['shopMerchantId'] as string | null const shopMerchantId = userInfo.shopMerchantId as null | string;
const shopMerchantName = userInfo['shopMerchantName'] as string | null const shopMerchantName = userInfo.shopMerchantName as null | string;
apiSelectMerchantScene({ apiSelectMerchantScene({
merchantId: shopMerchantId ?? '', merchantId: shopMerchantId ?? "",
merchantName: shopMerchantName ?? '', merchantName: shopMerchantName ?? "",
sceneType: sceneType sceneType
}).then((res: any): void => { }).then((data: any): void => {
const data = (res as UTSJSONObject)['data'] as UTSJSONObject | null jump(userInfo, data);
if (data != null) { }).catch((error) => {
jump({...(data as UTSJSONObject), ...(userInfo as UTSJSONObject)}, data) uni.hideLoading();
} console.error("selectMerchantScene 失败:", error);
}).catch((err: any | null): void => { uni.showToast({ title: "网络异常,请稍后重试", icon: "none" });
uni.hideLoading() });
console.error('selectMerchantScene 失败:', err)
uni.showToast({ title: '网络异常,请稍后重试', icon: 'none' })
})
} }
} }
defineExpose({ defineExpose({
init init
}) });
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
......
<template> <template>
<Layout class="layout"> <layout-root>
<view class="layout login-page">
<view class="bg"></view> <view class="bg"></view>
<view class="login flex-col"> <view class="login flex-col">
<text class="title">登录</text> <text class="title">登录</text>
...@@ -73,20 +75,10 @@ ...@@ -73,20 +75,10 @@
@click="copyDeviceId"> @click="copyDeviceId">
</view> </view>
</view> </view>
<!-- Test Entry Point -->
<!-- <view class="test-entry" @click="goToTest">
<text>测试入口</text>
</view> </view>
<view class="demo-test" :style="{ paddingLeft: $resState.config.demo.paddingLeft }"> </layout-root>
<text :style="{ fontSize: $resState.config.demo.titleFontSize }">Resolution Demo Text</text>
<image mode="widthFix"
:src="$getResImg($resState.config.demo.heroImageSrc)"
:style="{ width: $resState.config.demo.heroImageWidth }">
</image>
</view> -->
</Layout>
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
...@@ -94,7 +86,7 @@ import { ref, watch } from "vue"; ...@@ -94,7 +86,7 @@ import { ref, watch } from "vue";
import { apiAutoLogin, apiGetSmsCode, apiSmsLogin } from "@/api/user-api.uts"; import { apiAutoLogin, apiGetSmsCode, apiSmsLogin } from "@/api/user-api.uts";
import { storage } from "@/utils/storage.uts"; import { storage } from "@/utils/storage.uts";
// import { onLoad } from "@dcloudio/uni-app"; import { onLoad } from "@dcloudio/uni-app";
// 手机号正则 // 手机号正则
const phoneRex = /^1([3-9])\d{9}$/; const phoneRex = /^1([3-9])\d{9}$/;
...@@ -370,12 +362,6 @@ function toggleReadingStatus(): void { ...@@ -370,12 +362,6 @@ function toggleReadingStatus(): void {
function toggleNoSignIn(): void { function toggleNoSignIn(): void {
noSignIn.value = !noSignIn.value; noSignIn.value = !noSignIn.value;
} }
function goToTest(): void {
uni.navigateTo({
url: "/pages/test/index"
});
}
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
......
...@@ -118,7 +118,12 @@ class LayoutService { ...@@ -118,7 +118,12 @@ class LayoutService {
* 更新 CSS 变量缓存(遍历 LAYOUT_VARS) * 更新 CSS 变量缓存(遍历 LAYOUT_VARS)
*/ */
private updateCSSVariables(): void { private updateCSSVariables(): void {
const w = this.screenWidth.value // 对于 portrait 模式,使用物理短边参与缩放,避免横屏手机出现非常大的宽度(例如 800x360),
// 造成与 H5 模拟器(390x844)视觉比例差异过大
const sw = this.screenWidth.value
const sh = this.screenHeight.value
const isPortraitMode = this.currentMode.value == 'portrait'
const w = isPortraitMode ? (sw < sh ? sw : sh) : sw
const baseWidth = this.getBaseWidth() const baseWidth = this.getBaseWidth()
const out: UTSJSONObject = {} const out: UTSJSONObject = {}
...@@ -180,6 +185,22 @@ class LayoutService { ...@@ -180,6 +185,22 @@ class LayoutService {
} }
/** /**
* 获取当前分辨率档位(例如 1080 / 1920)
* - 仅用于选择 I18n 适配配置,不追求特别细的区分
*/
getResolutionBucket(): string {
if (!this.initialized.value) {
this.init()
}
const sw = this.screenWidth.value
const sh = this.screenHeight.value
const isPortraitMode = this.currentMode.value == 'portrait'
const w = isPortraitMode ? (sw < sh ? sw : sh) : sw
// 简单两档划分:大于等于 1440 归为 1920,否则归为 1080
return w >= 1440 ? '1920' : '1080'
}
/**
* 是否指定模式 * 是否指定模式
*/ */
isMode(mode: LayoutMode): boolean { isMode(mode: LayoutMode): boolean {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!