Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
monorepo
/
venus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 50bd8b19
authored
Mar 05, 2026
by
cen
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat:首页
1 parent
7d25cdcc
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
185 additions
and
382 deletions
apps/uniappX/uniapp-x-tape/components/CenterPopup.uvue
apps/uniappX/uniapp-x-tape/components/HomeFrame/LeftSide.uvue
apps/uniappX/uniapp-x-tape/components/HomeFrame/SettingBox.uvue
apps/uniappX/uniapp-x-tape/components/HomeFrame/index.uvue
apps/uniappX/uniapp-x-tape/composables/db/Sqlite.uts
apps/uniappX/uniapp-x-tape/composables/recorder/TempRecord.uts
apps/uniappX/uniapp-x-tape/static/images/boutique/customer-type-bg.webp
apps/uniappX/uniapp-x-tape/static/images/home/left-bg.png
apps/uniappX/uniapp-x-tape/static/images/home/start-btn.png
apps/uniappX/uniapp-x-tape/components/CenterPopup.uvue
View file @
50bd8b1
<template>
<template>
<view v-if="visible" class="popup-mask" @tap="close">
<view v-if="visible"
<view class="popup-box" @tap.stop="">
class="popup-mask"
<view class="popup-title">
@tap="close">
<text class="popup-title-text">{{ title }}</text>
<view class="popup-box" @tap.stop="">
<view class="popup-close" @tap="close">
<view class="popup-title">
<text class="close-icon">×</text>
<image class="popup-title-bg-img"
mode="aspectFill"
src="/static/images/boutique/customer-type-bg.webp" />
<text class="popup-title-text">{{ title }}</text>
<view class="popup-close" @tap="close">
<text class="close-icon">×</text>
</view>
</view>
<view class="popup-content">
<view v-for="(item, index) in list"
:key="index"
class="popup-item"
@tap="handleChoose(index)">
<view class="item-icon">
{{ (item as UTSJSONObject).icon ?? '' }}
</view>
<view class="item-text">
<text class="item-title">{{ (item as UTSJSONObject).title ?? '' }}</text>
<text class="item-describe">{{ (item as UTSJSONObject).describe ?? '' }}</text>
</view>
</view>
</view>
</view>
</view>
</view>
<view class="popup-content">
<view
v-for="(item, index) in list"
:key="index"
class="popup-item"
@tap="handleChoose(index)"
>
<view class="item-icon">{{ (item as UTSJSONObject)['icon'] ?? '' }}</view>
<view class="item-text">
<text class="item-title">{{ (item as UTSJSONObject)['title'] ?? '' }}</text>
<text class="item-describe">{{ (item as UTSJSONObject)['describe'] ?? '' }}</text>
</view>
</view>
</view>
</view>
</view>
</view>
</template>
</template>
<script setup lang="uts">
<script setup lang="uts">
import {
ref, defineExpose } from 'vue'
import {
computed, defineExpose, ref } from "vue";
const props = defineProps<{
const props = defineProps<{
list?: any[]
list?: any[]
title?: string
title?: string
}>()
/** 受控显示,父组件传 true 即打开 */
visible?: boolean
}>();
const emit = defineEmits<{
const emit = defineEmits<{
choose: [index: number]
choose: [index: number]
}>()
"update:visible": [value: boolean]
}>();
const visible = ref(false)
const internalVisible = ref(false);
const visible = computed((): boolean => {
if (props.visible != null) return props.visible === true;
return internalVisible.value;
});
function open(): void {
function open(): void {
visible.value = true
if (props.visible != null) {
emit("update:visible", true);
} else {
internalVisible.value = true;
}
}
}
function close(): void {
function close(): void {
visible.value = false
internalVisible.value = false;
emit("update:visible", false);
}
}
function handleChoose(index: number): void {
function handleChoose(index: number): void {
emit('choose', index)
emit("choose", index);
close()
close();
}
}
defineExpose({
defineExpose({
open,
open,
close
close
})
})
;
</script>
</script>
<style scoped lang="scss">
<style scoped lang="scss">
...
@@ -92,9 +109,24 @@ defineExpose({
...
@@ -92,9 +109,24 @@ defineExpose({
justify-content: center;
justify-content: center;
position: relative;
position: relative;
flex-shrink: 0;
flex-shrink: 0;
background-image: url('@/assets/images/boutique/customer-type-bg.webp');
overflow: hidden;
background-repeat: no-repeat;
background-image: linear-gradient(to right, #e8f0fe, #f5f7fa);
background-size: 100% 100%;
}
.popup-title-bg-img {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 0;
pointer-events: none;
}
.popup-title .popup-title-text,
.popup-title .popup-close {
position: relative;
z-index: 1;
}
}
.popup-title-text {
.popup-title-text {
...
...
apps/uniappX/uniapp-x-tape/components/HomeFrame/LeftSide.uvue
View file @
50bd8b1
<template>
<template>
<view class="left-side left-side-pad">
<view class="left-side left-side-pad">
<image class="left-side-bg-img"
src="/static/images/home/left-bg.png"
mode="aspectFill" />
<view class="user-box user-box-clickable" @click="jumpPersonCenter">
<view class="user-box user-box-clickable" @click="jumpPersonCenter">
<view class="user-info">
<view class="user-info">
<view class="user-avatar"></view>
<view class="user-avatar"></view>
...
@@ -19,16 +22,18 @@
...
@@ -19,16 +22,18 @@
</view>
</view>
</view>
</view>
<view class="left-footer flex-col">
<view class="left-footer flex-col">
<view class="btn-placeholder" @
click
="onSceneChange"></view>
<view class="btn-placeholder" @
tap
="onSceneChange"></view>
<view class="btn-placeholder" @
click
="onSetting"></view>
<view class="btn-placeholder" @
tap
="onSetting"></view>
</view>
</view>
<!-- 切换场景弹窗 -->
<!-- 切换场景弹窗:用 visible 受控,避免 UTS 下 ref+expose 的强转问题 -->
<CenterPopup ref="scenePopupRef"
<CenterPopup :list="sceneTypeList"
:list="sceneTypeList"
title="选择场景"
title="选择场景"
@choose="onChooseScene" />
:visible="showScenePopup"
@choose="onChooseScene"
@update:visible="onScenePopupVisible" />
<!-- 设置弹窗 -->
<!-- 设置弹窗 -->
<SettingBox ref="settingRef" />
<SettingBox :visible="showSetting"
@update:visible="onSettingVisible" />
</view>
</view>
</template>
</template>
...
@@ -49,8 +54,8 @@ const props = defineProps<{
...
@@ -49,8 +54,8 @@ const props = defineProps<{
const emit = defineEmits<{
const emit = defineEmits<{
changeTab: [index: number]
changeTab: [index: number]
}>();
}>();
const s
cenePopupRef = ref(null
);
const s
howScenePopup = ref(false
);
const s
ettingRef = ref(null
);
const s
howSetting = ref(false
);
const isPortraitMode = computed((): boolean => {
const isPortraitMode = computed((): boolean => {
return props.isPortrait === true;
return props.isPortrait === true;
...
@@ -146,26 +151,20 @@ function onChangeTab(index: number): void {
...
@@ -146,26 +151,20 @@ function onChangeTab(index: number): void {
emit("changeTab", index);
emit("changeTab", index);
}
}
function onScenePopupVisible(v: boolean): void {
showScenePopup.value = v;
}
function onSettingVisible(v: boolean): void {
showSetting.value = v;
}
function onSceneChange(): void {
function onSceneChange(): void {
const pop = scenePopupRef.value;
showScenePopup.value = true;
if (pop != null) {
const obj = pop as UTSJSONObject;
const fn = obj.open as (() => void) | null;
if (fn != null && typeof fn === "function") {
fn();
}
}
}
}
function onSetting(): void {
function onSetting(): void {
const box = settingRef.value;
showSetting.value = true;
if (box != null) {
const obj = box as UTSJSONObject;
const fn = obj.open as (() => void) | null;
if (fn != null && typeof fn === "function") {
fn();
}
}
}
}
function onChooseScene(index: number): void {
function onChooseScene(index: number): void {
...
@@ -204,8 +203,25 @@ function jumpPersonCenter(): void {
...
@@ -204,8 +203,25 @@ function jumpPersonCenter(): void {
position: relative;
position: relative;
width: 120px; /* toRpx(240) / 2 */
width: 120px; /* toRpx(240) / 2 */
flex-shrink: 0;
flex-shrink: 0;
background-image: url('@/assets/images/home/left-bg.png');
/* 背景图用下层 image 实现,此处仅作 fallback */
background-size: 100% 100%;
background-image: linear-gradient(to bottom, #e8f0fe, #e8ecf5);
}
.left-side-bg-img {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 0;
pointer-events: none;
}
.left-side .user-box,
.left-side .left-tabs,
.left-side .left-footer {
position: relative;
z-index: 1;
}
}
.left-side-pad {
.left-side-pad {
...
...
apps/uniappX/uniapp-x-tape/components/HomeFrame/SettingBox.uvue
View file @
50bd8b1
...
@@ -24,17 +24,35 @@
...
@@ -24,17 +24,35 @@
</template>
</template>
<script setup lang="uts">
<script setup lang="uts">
import { ref, defineExpose } from 'vue'
import {
computed,
ref, defineExpose } from 'vue'
const visible = ref(false)
const props = defineProps<{
/** 受控显示,父组件传 true 即打开 */
visible?: boolean
}>()
const emit = defineEmits<{
'update:visible': [value: boolean]
}>()
const internalVisible = ref(false)
const version = ref('1.0.0')
const version = ref('1.0.0')
const visible = computed((): boolean => {
if (props.visible != null) return props.visible === true
return internalVisible.value
})
function open(): void {
function open(): void {
visible.value = true
if (props.visible != null) {
emit('update:visible', true)
} else {
internalVisible.value = true
}
}
}
function close(): void {
function close(): void {
visible.value = false
internalVisible.value = false
emit('update:visible', false)
}
}
function handleCheck(): void {
function handleCheck(): void {
...
...
apps/uniappX/uniapp-x-tape/components/HomeFrame/index.uvue
View file @
50bd8b1
...
@@ -2,56 +2,17 @@
...
@@ -2,56 +2,17 @@
<view class="home-frame-container">
<view class="home-frame-container">
<!-- 首页内容区 -->
<!-- 首页内容区 -->
<view v-if="!showDetail"
<view v-if="!showDetail"
class="home-content"
class="home-content home-content-pad">
:class="[isPortraitMode ? 'home-content-portrait' : 'home-content-pad']">
<HomeFrameLeftSide :tab-index="tabIndex"
<HomeFrameLeftSide :is-portrait="isPortraitMode"
:tab-index="tabIndex"
:user-info="userInfo"
:user-info="userInfo"
@change-tab="onChangeTab">
@change-tab="onChangeTab" />
<template v-if="isPortraitMode && useCardLayout" #portraitAction>
<view class="portrait-start-btn" @click="onStartClick">
<text class="start-text">开始接待</text>
</view>
</template>
</HomeFrameLeftSide>
<view class="right-side">
<view class="right-side">
<!-- 竖屏布局:顶栏(含开始接待) + 纵向三卡片 -->
<view v-if="isPortraitMode && useCardLayout && tabIndex == 0" class="portrait-layout">
<scroll-view class="portrait-scroll" scroll-y="true">
<view class="portrait-cards">
<view class="module-box box-class portrait-card">
<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 portrait-card">
<view class="common-title">
<text class="title-text">展业工具</text>
</view>
<view class="content-box">
<Entrance :scene-type="sceneType" />
</view>
</view>
<view class="content-right box-class portrait-card">
<view class="common-title">
<text class="title-text">服务中心</text>
</view>
<view class="content-box">
<HomeFrameMessageIndex class="message-box" />
</view>
</view>
</view>
</scroll-view>
</view>
<!-- 横屏三卡片布局:轻改等使用 swiperCustom -->
<!-- 横屏三卡片布局:轻改等使用 swiperCustom -->
<view v-
else-if="isPortraitMode == false &&
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">
<image class="start-bg-img"
mode="scaleToFill"
src="/static/images/home/start-btn.png" />
<view class="start-inner">
<view class="start-inner">
<text class="start-text">开始接待</text>
<text class="start-text">开始接待</text>
</view>
</view>
...
@@ -94,12 +55,12 @@
...
@@ -94,12 +55,12 @@
</view>
</view>
</view>
</view>
<!-- 底部门店信息:与 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>
<view class="icon-addr"></view>
<view class="icon-addr"></view>
<text class="addr-text">{{ userInfo.shopMerchantName ?? '' }}</text>
<text class="addr-text">{{ userInfo.shopMerchantName ?? '' }}</text>
<view class="addr-line addr-line-right"></view>
<view class="addr-line addr-line-right"></view>
</view>
</view>
-->
</view>
</view>
<!-- 详情页内容区 -->
<!-- 详情页内容区 -->
...
@@ -113,7 +74,6 @@
...
@@ -113,7 +74,6 @@
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";
import { storage } from "@/utils/storage.uts";
import { storage } from "@/utils/storage.uts";
import HomeFrameLeftSide from "./LeftSide.uvue";
import HomeFrameLeftSide from "./LeftSide.uvue";
...
@@ -128,8 +88,6 @@ const emit = defineEmits<{
...
@@ -128,8 +88,6 @@ const emit = defineEmits<{
start: []
start: []
}>();
}>();
const isPortraitMode = computed((): boolean => layoutService.isMode("portrait"));
const useCardLayout = computed((): boolean => {
const useCardLayout = computed((): boolean => {
return props.swiperCustom === true;
return props.swiperCustom === true;
});
});
...
@@ -178,7 +136,7 @@ defineExpose({
...
@@ -178,7 +136,7 @@ defineExpose({
display: flex;
display: flex;
flex-direction: column;
flex-direction: column;
position: relative;
position: relative;
background: linear-gradient(
180deg, #e8f0fe 0%, #f5f7fa 100%
);
background: linear-gradient(
to bottom, #e8f0fe, #f5f7fa
);
}
}
.home-content {
.home-content {
...
@@ -194,65 +152,6 @@ defineExpose({
...
@@ -194,65 +152,6 @@ defineExpose({
flex-direction: row;
flex-direction: row;
}
}
.home-content-portrait {
flex-direction: column;
}
.portrait-layout {
flex: 1;
display: flex;
flex-direction: column;
overflow: hidden;
}
.portrait-start-btn {
padding: var(--l-spacing-sm) var(--l-spacing-lg);
background: linear-gradient(90deg, #4673ff 0%, #6b9bff 100%);
border-radius: var(--l-spacing-lg);
box-shadow: 0 2px 8px rgba(70, 115, 255, 0.3);
}
.portrait-start-btn .start-text {
font-size: var(--l-font-base);
font-weight: 600;
color: #ffffff;
}
.portrait-scroll {
flex: 1;
width: 100%;
}
.portrait-cards {
display: flex;
flex-direction: column;
padding: var(--l-spacing-md);
}
.portrait-card {
width: 100%;
margin-bottom: var(--l-spacing-md);
min-height: var(--l-tool-box-min-height);
flex-shrink: 0;
}
.portrait-card:last-child {
margin-bottom: 0;
}
.portrait-card.module-box {
height: auto;
min-height: var(--l-tool-box-min-height);
}
.portrait-card.tool-box {
min-height: 100px;
}
.portrait-card.content-right {
min-width: 0;
}
.detail-content {
.detail-content {
flex: 1;
flex: 1;
width: 100%;
width: 100%;
...
@@ -278,22 +177,38 @@ defineExpose({
...
@@ -278,22 +177,38 @@ defineExpose({
padding: 0 var(--l-spacing-xl) 0 var(--l-spacing-md);
padding: 0 var(--l-spacing-xl) 0 var(--l-spacing-md);
}
}
/* 与旧项目一致:背景图铺满,文字居中偏上,无渐变遮罩 */
.start {
.start {
// 参考旧项目:使用 start-btn.png 作为背景
height: 126px;
height: 232rpx;
box-sizing: border-box;
box-sizing: border-box;
margin-right:
64r
px;
margin-right:
32
px;
position: relative;
position: relative;
display: flex;
display: flex;
justify-content: center;
justify-content: center;
align-items: flex-start;
align-items: flex-start;
padding-top: 60rpx;
padding-top: 30px;
background: url('@/assets/images/home/start-btn.png') no-repeat;
overflow: hidden;
background-size: 100% 100%;
flex-shrink: 0;
min-width: 140px;
}
.start-bg-img {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 0;
pointer-events: none;
/* 与旧项目 background-size: 100% 100% 一致,铺满容器 */
}
}
.start-inner {
.start-inner {
// 背景由 .start 提供,这里只负责文字布局
position: relative;
z-index: 1;
display: flex;
align-items: center;
justify-content: center;
padding: 0;
padding: 0;
background: transparent;
background: transparent;
border-radius: 0;
border-radius: 0;
...
@@ -301,9 +216,10 @@ defineExpose({
...
@@ -301,9 +216,10 @@ defineExpose({
}
}
.start-text {
.start-text {
font-size:
var(--l-font-xl)
;
font-size:
36px
;
font-weight: 600;
font-weight: 600;
color: #ffffff;
color: #ffffff;
text-align: center;
}
}
.right-content-box {
.right-content-box {
...
@@ -428,10 +344,10 @@ defineExpose({
...
@@ -428,10 +344,10 @@ defineExpose({
}
}
.addr-line-left {
.addr-line-left {
background: linear-gradient(
270deg, #eeeeee 0%, rgba(216, 216, 216, 0) 100%
);
background: linear-gradient(
to left, #eeeeee, rgba(216, 216, 216, 0)
);
}
}
.addr-line-right {
.addr-line-right {
background: linear-gradient(
90deg, #eeeeee 0%, rgba(216, 216, 216, 0) 100%
);
background: linear-gradient(
to right, #eeeeee, rgba(216, 216, 216, 0)
);
}
}
</style>
</style>
apps/uniappX/uniapp-x-tape/composables/db/Sqlite.uts
View file @
50bd8b1
...
@@ -35,34 +35,16 @@ export default class SQLite {
...
@@ -35,34 +35,16 @@ export default class SQLite {
}
}
}
}
/**
/** 将 SQL 任务加入该数据库的串行队列 */
* 批量添加字段到表中
private enqueue(task: () => Promise<any | null>): Promise<any | null> {
*/
const queue = SQLite._queues.get(this.name);
async addColumns(tableName: string, columns: UTSJSONObject[]): Promise<void> {
if (queue == null) {
try {
return Promise.reject(new Error(`SQLite queue not found: ${this.name}`)) as Promise<any | null>;
const colArr = columns; // 避免在 for 循环中直接迭代参数导致类型问题(虽然应该没问题)
for (const column of colArr) {
const name = column.name;
// 确保 definition 存在
const definition = column.definition;
const defStr = (definition != null && definition != "") ? definition : "TEXT";
// 尝试执行添加列
if (name != null) {
try {
await this.executeSql(`ALTER TABLE ${tableName} ADD COLUMN ${name} ${defStr}`);
} catch (error) {
// 如果列已存在,可能会报错,忽略之
// uni.$logger?.local?.warn(`添加列 ${name} 失败: ${e}`)
console.log(`Add column ${name} failed (maybe exists): ${error}`);
}
}
}
} catch (error) {
// uni.$logger?.local?.error(`添加字段失败 error - > ${error}`)
throw new Error(`Add columns failed: ${error}`);
}
}
// TaskQueue.enqueue 要求 () => Promise<any>,用包装器统一类型
return queue.enqueue((): Promise<any> => task() as Promise<any>);
}
}
/**
/**
* 批量添加字段到表中
* 批量添加字段到表中
*/
*/
...
@@ -74,7 +56,7 @@ export default class SQLite {
...
@@ -74,7 +56,7 @@ export default class SQLite {
// 确保 definition 存在
// 确保 definition 存在
const definition = column.definition;
const definition = column.definition;
const defStr = (definition != null && definition != "") ? definition : "TEXT";
const defStr = (definition != null && definition != "") ? definition : "TEXT";
// 尝试执行添加列
// 尝试执行添加列
if (name != null) {
if (name != null) {
try {
try {
...
@@ -107,21 +89,6 @@ export default class SQLite {
...
@@ -107,21 +89,6 @@ export default class SQLite {
} as DatabaseOptions);
} as DatabaseOptions);
});
});
}
}
// 新增 asyncIsOpen 以备不时之需
asyncIsOpen(): Promise<boolean> {
return new Promise((resolve) => {
isOpenDatabase({
name: this.name,
success: (res) => {
// 假设 res 包含 open 状态,或者 success 回调意味着 open?
// 文档例子 console.log('isOpenDatabase', res)
// 我们假设 success 意味着已打开,或者 res 包含 boolean
resolve(true);
},
fail: () => resolve(false)
} as DatabaseOptions);
});
}
close() {
close() {
if (this.dbPath != null) { // this.db is not used in lime-sqlite
if (this.dbPath != null) { // this.db is not used in lime-sqlite
...
@@ -133,27 +100,12 @@ export default class SQLite {
...
@@ -133,27 +100,12 @@ export default class SQLite {
// this.db = null
// this.db = null
}
}
}
}
close() {
if (this.dbPath != null) { // this.db is not used in lime-sqlite
closeDatabase({
name: this.name,
success: () => { console.log("数据库连接已关闭"); },
fail: (err) => { console.error("关闭数据库失败", err); }
} as DatabaseOptions);
// this.db = null
}
}
// 创建新表示例
// 创建新表示例
createTable(tableName: string, columns: string[]): Promise<any | null> {
createTable(tableName: string, columns: string[]): Promise<any | null> {
const sql = `CREATE TABLE IF NOT EXISTS ${tableName} (${columns.join(", ")})`;
const sql = `CREATE TABLE IF NOT EXISTS ${tableName} (${columns.join(", ")})`;
return this.executeSql(sql);
return this.executeSql(sql);
}
}
// 创建新表示例
createTable(tableName: string, columns: string[]): Promise<any | null> {
const sql = `CREATE TABLE IF NOT EXISTS ${tableName} (${columns.join(", ")})`;
return this.executeSql(sql);
}
// 删除示例
// 删除示例
delete(tabName: string, where: UTSJSONObject): Promise<any | null> {
delete(tabName: string, where: UTSJSONObject): Promise<any | null> {
...
@@ -166,17 +118,6 @@ export default class SQLite {
...
@@ -166,17 +118,6 @@ export default class SQLite {
const sql = `DELETE FROM ${tabName} WHERE ${whereStr}`;
const sql = `DELETE FROM ${tabName} WHERE ${whereStr}`;
return this.executeSql(sql);
return this.executeSql(sql);
}
}
// 删除示例
delete(tabName: string, where: UTSJSONObject): Promise<any | null> {
const whereMap = where.toMap();
const whereList: UTSArray<string> = [];
whereMap.forEach((value, key) => {
whereList.push(`${key} = ${this.formatValue(value)}`);
});
const whereStr = whereList.join(" AND ");
const sql = `DELETE FROM ${tabName} WHERE ${whereStr}`;
return this.executeSql(sql);
}
drop(tabName: string): Promise<any | null> {
drop(tabName: string): Promise<any | null> {
const sql = `DROP TABLE IF EXISTS ${tabName}`;
const sql = `DROP TABLE IF EXISTS ${tabName}`;
...
@@ -185,14 +126,10 @@ export default class SQLite {
...
@@ -185,14 +126,10 @@ export default class SQLite {
console.log("🚀 ~ SQLite ~ createTable ~ sql:", sql);
console.log("🚀 ~ SQLite ~ createTable ~ sql:", sql);
return this.executeSql(sql);
return this.executeSql(sql);
}
}
drop(tabName: string): Promise<any | null> {
const sql = `DROP TABLE IF EXISTS ${tabName}`;
return this.executeSql(sql);
}
executeSql(sql: string): Promise<any | null> {
executeSql(sql: string): Promise<any | null> {
return this.enqueue(
return this.enqueue(
(): Promise<any> =>
(): Promise<any
| null
> =>
new Promise((resolve, reject) => {
new Promise((resolve, reject) => {
console.warn(`执行SQL语句: ${sql}`);
console.warn(`执行SQL语句: ${sql}`);
const options = {
const options = {
...
@@ -218,34 +155,6 @@ export default class SQLite {
...
@@ -218,34 +155,6 @@ export default class SQLite {
})
})
);
);
}
}
executeSql(sql: string): Promise<any | null> {
return this.enqueue(
(): Promise<any> =>
new Promise((resolve, reject) => {
console.warn(`执行SQL语句: ${sql}`);
const options = {
name: this.name,
sql: [sql],
success: (res: any) => {
resolve(res);
},
fail: (err: SqliteFail) => {
// Ignore cast error for executeSql too if it happens
if (err.errCode == 9_010_007) {
console.warn(`[SQLite] executeSql encountered cast error (9010007), assuming success. SQL: ${sql}`);
// 9010007 means boolean returned (likely true), so we return something non-null to avoid NPE in TaskQueue or subsequent calls
// Returning a dummy object is safer than null if caller expects object
resolve({ result: "success_with_cast_warning" });
} else {
reject(err);
}
}
} as SqlOperationOptions;
executeSql(options);
})
);
}
formatValue(value: any | null): string {
formatValue(value: any | null): string {
let strVal = "";
let strVal = "";
...
@@ -257,16 +166,6 @@ export default class SQLite {
...
@@ -257,16 +166,6 @@ export default class SQLite {
// SQL 中转义单引号的方法是将 ' 替换为 ''
// SQL 中转义单引号的方法是将 ' 替换为 ''
return `'${strVal.replaceAll("'", "''")}'`;
return `'${strVal.replaceAll("'", "''")}'`;
}
}
formatValue(value: any | null): string {
let strVal = "";
if (typeof value === "object" && value !== null) {
strVal = JSON.stringify(value);
} else {
strVal = `${value}`;
}
// SQL 中转义单引号的方法是将 ' 替换为 ''
return `'${strVal.replaceAll("'", "''")}'`;
}
async init(): Promise<any> {
async init(): Promise<any> {
// 如果已经有路径,直接使用
// 如果已经有路径,直接使用
...
@@ -296,21 +195,6 @@ export default class SQLite {
...
@@ -296,21 +195,6 @@ export default class SQLite {
const sql = `INSERT INTO ${tabName} (${keyStr}) VALUES (${valStr.join(", ")})`;
const sql = `INSERT INTO ${tabName} (${keyStr}) VALUES (${valStr.join(", ")})`;
return this.executeSql(sql);
return this.executeSql(sql);
}
}
// 插入示例
insert(tabName: string, keyValues: UTSJSONObject): Promise<any | null> {
const map = keyValues.toMap();
const valStr: UTSArray<string> = [];
const keyList: UTSArray<string> = [];
map.forEach((value, key) => {
keyList.push(key);
valStr.push(`${this.formatValue(value)}`);
});
const keyStr = keyList.join(", ");
const sql = `INSERT INTO ${tabName} (${keyStr}) VALUES (${valStr.join(", ")})`;
return this.executeSql(sql);
}
/**
/**
* 检查指定字段是否存在于表中
* 检查指定字段是否存在于表中
...
@@ -328,22 +212,6 @@ export default class SQLite {
...
@@ -328,22 +212,6 @@ export default class SQLite {
throw new Error(`Check column exists failed: ${error}`);
throw new Error(`Check column exists failed: ${error}`);
}
}
}
}
/**
* 检查指定字段是否存在于表中
*/
async isColumnExists(tableName: string, columnName: string): Promise<boolean> {
try {
const columnInfo = await this.selectSql(`PRAGMA table_info(${tableName})`);
// columnInfo 是数组
return columnInfo.some((col: any): boolean => {
const colObj = col as UTSJSONObject;
return colObj.name == columnName;
});
} catch (error) {
// console.error(`检查字段是否存在失败 error - > ${error.message}`)
throw new Error(`Check column exists failed: ${error}`);
}
}
isOpen(): boolean {
isOpen(): boolean {
// lime-sqlite 提供了 isOpenDatabase 异步方法?
// lime-sqlite 提供了 isOpenDatabase 异步方法?
...
@@ -364,45 +232,7 @@ export default class SQLite {
...
@@ -364,45 +232,7 @@ export default class SQLite {
return false; // 无法同步检查,返回 false 让它去尝试打开
return false; // 无法同步检查,返回 false 让它去尝试打开
}
}
isOpen(): boolean {
// lime-sqlite 提供了 isOpenDatabase 异步方法?
// 文档里是 isOpenDatabase({ ... })
// interface 里没写返回值类型,但通常是 void (async callback)
// 但 plus.sqlite.isOpenDatabase 是同步的
// lime-sqlite 的 isOpenDatabase 看起来是异步的 (interface export type ... success/fail)
// 如果必须同步返回,这很难办。
// 但是原代码 isOpen() 是同步返回 boolean。
// 如果 lime-sqlite 只能异步检查,那我们需要改变 isOpen 的签名,或者在 init 时记录状态。
// 暂时,我们可以用一个 flag 记录状态,或者尝试调用同步方法(如果有)。
// interface 里注释了 `// export type SqliteSync = (paramA : boolean) => SqliteResult`
// 看起来没有同步方法。
// 我们只能修改 isOpen 为 async,或者依赖 openDatabase 内部的幂等性(重复打开会成功)。
// 在 openDatabase 实现里,我们调用了 this.isOpen()。
// 现在的策略:移除同步 isOpen 检查,直接调用 openDatabase,并在 fail 回调里处理 "already open" 的情况。
// 或者,我们可以维护一个本地状态 `this.isOpened`。
return false; // 无法同步检查,返回 false 让它去尝试打开
}
async isTableExists(tableName: string): Promise<boolean> {
const sql = `SELECT COUNT(*) as isTable FROM sqlite_master WHERE type='table' and name='${tableName}'`;
try {
const result = await this.selectSql(sql);
// result 是数组,取第一项
if (result.length > 0) {
const row = result[0] as UTSJSONObject;
const count = row.isTable;
return count == 1 || count == "1";
}
return false;
} catch (error) {
// 如果查询失败,尝试捕获错误码 9010007 并视为表不存在(或数据库状态异常),
// 但不要抛出,以免阻断初始化。或者返回 false 让它尝试创建表。
// 但如果数据库根本没打开,这里会报错。
console.error("检查表是否存在出错:", error);
return false;
}
}
async isTableExists(tableName: string): Promise<boolean> {
async isTableExists(tableName: string): Promise<boolean> {
const sql = `SELECT COUNT(*) as isTable FROM sqlite_master WHERE type='table' and name='${tableName}'`;
const sql = `SELECT COUNT(*) as isTable FROM sqlite_master WHERE type='table' and name='${tableName}'`;
try {
try {
...
@@ -496,7 +326,7 @@ export default class SQLite {
...
@@ -496,7 +326,7 @@ export default class SQLite {
selectSql(sql: string): Promise<any[]> {
selectSql(sql: string): Promise<any[]> {
return this.enqueue(
return this.enqueue(
(): Promise<any> =>
(): Promise<any
| null
> =>
new Promise((resolve, reject) => {
new Promise((resolve, reject) => {
// uni.$logger?.local?.warn(`执行SQL语句: ${sql}`)
// uni.$logger?.local?.warn(`执行SQL语句: ${sql}`)
// lime-sqlite 使用 executeSql 执行所有 SQL,包括查询
// lime-sqlite 使用 executeSql 执行所有 SQL,包括查询
...
...
apps/uniappX/uniapp-x-tape/composables/recorder/TempRecord.uts
View file @
50bd8b1
...
@@ -300,19 +300,10 @@ class TempRecord {
...
@@ -300,19 +300,10 @@ class TempRecord {
}
}
/**
/**
* 缓存物料点数据
* 缓存物料点数据
* @param
{Array} list
* @param
list 物料点列表
*/
*/
cacheMaterialPoints(list: any[]) {
cacheMaterialPoints(list: UTSJSONObject[]): void {
if (this.record != null && this.record!.id != null) {
if (this.record != null && this.record!.id != null && this.record!.id !== "") {
RecordCache.set(this.record!.id, "MATERIAL_POINTS", list);
}
}
/**
* 缓存物料点数据
* @param {Array} list
*/
cacheMaterialPoints(list: UTSJSONObject[]) {
if (this.record != null && this.record!.id != "") {
RecordCache.set(this.record!.id, "MATERIAL_POINTS", list);
RecordCache.set(this.record!.id, "MATERIAL_POINTS", list);
}
}
}
}
...
...
apps/uniappX/uniapp-x-tape/static/images/boutique/customer-type-bg.webp
0 → 100644
View file @
50bd8b1
No preview for this file type
apps/uniappX/uniapp-x-tape/static/images/home/left-bg.png
0 → 100644
View file @
50bd8b1
22.7 KB
apps/uniappX/uniapp-x-tape/static/images/home/start-btn.png
0 → 100644
View file @
50bd8b1
17.6 KB
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment