手持机

This commit is contained in:
张怡蓉
2025-09-10 15:03:51 +08:00
parent 94e3a9d000
commit 0e82934fc3
38 changed files with 905 additions and 131 deletions

View File

@@ -8,12 +8,23 @@
config: {}
},
onLaunch: function() {
this.initApp()
this.initApp(),
// 初始化 tabBar 文本
this.updateTabBarText()
// 监听语言变化事件
uni.$on('languageChanged', () => {
this.updateTabBarText()
})
},
onShow: function() {
// 检查应用状态,确保从后台恢复时状态一致
this.checkAppState()
},
onDestroy() {
// 移除事件监听器
uni.$off('languageChanged')
},
methods: {
// 初始化应用
initApp() {
@@ -62,6 +73,32 @@
}
},
updateTabBarText() {
// 使用 nextTick 确保 DOM 更新完成
this.$nextTick(() => {
try {
// 设置工作台 tabBar 项
uni.setTabBarItem({
index: 0,
text: this.$t('tabBar.workbench')
})
// 设置任务 tabBar 项
uni.setTabBarItem({
index: 1,
text: this.$t('tabBar.task')
})
// 设置我的 tabBar 项
uni.setTabBarItem({
index: 2,
text: this.$t('tabBar.mine')
})
} catch (error) {
console.error('更新 tabBar 文本失败:', error)
}
})
}
}

View File

@@ -56,3 +56,11 @@ export function getCodeImg() {
timeout: 20000
})
}
//检查更新
export function updateUrl(){
return request({
url: '/system/app/version',
method: 'get'
})
}

View File

@@ -37,6 +37,10 @@ export default {
// 切换语言
this.$i18n.locale = selectedLang
this.currentIndex = index
// 通知 App.vue 更新 tabBar
uni.$emit('languageChanged');
// 提示用户
uni.showToast({

View File

@@ -1,4 +1,12 @@
{
"tabBar": {
"workbench": "workbench",
"task": "task",
"mine": "mine"
},
"dict":{
"port_type": {
"a1": "Cache Point",

View File

@@ -1,4 +1,12 @@
{
"tabBar": {
"workbench": "工作台",
"task": "任务",
"mine": "我的"
},
"dict": {
"port_type": {
"a1": "缓存点位",

View File

@@ -14,7 +14,10 @@
"autoclose" : true,
"delay" : 0
},
"modules" : {},
"modules" : {
"Camera" : {},
"Barcode" : {}
},
"distribute" : {
"android" : {
"permissions" : [
@@ -32,7 +35,11 @@
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>",
"<uses-permission android:name=\"android.permission.REQUEST_INSTALL_PACKAGES\"/>",
"<uses-permission android:name=\"android.permission.INSTALL_PACKAGES\"/>",
"<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"/>",
"<uses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\"/>"
]
},
"ios" : {

View File

@@ -111,6 +111,14 @@ export default {
// 获取待处理任务数量
this.getPendingTaskCount()
},
onShow() {
// 根据当前语言动态设置标题
const currentLanguage = this.$i18n.locale;
const title = this.$t('tabBar.workbench');
uni.setNavigationBarTitle({
title: title
});
},
methods: {
navigateTo(url) {
uni.navigateTo({

View File

@@ -93,6 +93,14 @@
return uni.getSystemInfoSync().windowHeight - 50
}
},
onShow() {
// 根据当前语言动态设置标题
const currentLanguage = this.$i18n.locale;
const title = this.$t('tabBar.mine');
uni.setNavigationBarTitle({
title: title
});
},
methods: {
handleToInfo() {
this.$tab.navigateTo('/pages/mine/info/index')

View File

@@ -1,19 +1,19 @@
<template>
<view class="setting-container" :style="{height: `${windowHeight}px`}">
<view class="menu-list">
<!-- <view class="list-cell list-cell-arrow" @click="handleToPwd">
<!-- <view class="list-cell list-cell-arrow" @click="handleToPwd">
<view class="menu-item-box">
<view class="iconfont icon-password menu-icon"></view>
<view>修改密码</view>
</view>
</view>
</view> -->
<view class="list-cell list-cell-arrow" @click="handleToUpgrade">
<view class="menu-item-box">
<view class="iconfont icon-refresh menu-icon"></view>
<view>检查更新</view>
</view>
</view>
<view class="list-cell list-cell-arrow" @click="handleCleanTmp">
<!-- <view class="list-cell list-cell-arrow" @click="handleCleanTmp">
<view class="menu-item-box">
<view class="iconfont icon-clean menu-icon"></view>
<view>清理缓存</view>
@@ -37,6 +37,7 @@
</template>
<script>
import {updateUrl} from '@/api/login'
export default {
data() {
return {
@@ -47,24 +48,32 @@
handleToPwd() {
this.$tab.navigateTo('/pages/mine/pwd/index')
},
handleToUpgrade() {
const currentVersion = getApp().globalData.config.appInfo.version;
async handleToUpgrade() {
// const currentVersion = getApp().globalData.config.appInfo.version;
this.$modal.confirm(`是否下载安装包?`).then(async () => {
// 从服务器获取最新版本信息
uni.request({
url:'/system/app/version',
method: 'GET',
success: (res) => {
if (res.data.code === 200) {
const latestVersion = res.data.data.version;
const downloadUrl = res.data.data.downloadUrl;
const response = await updateUrl()
console.log(response)
if (response.code === 200) {
// const latestVersion = res.data.data.version;
const downloadUrl = response.data.downloadUrl;
if (this.compareVersion(currentVersion, latestVersion) >= 0) {
this.$modal.showToast('当前已是最新版本');
if (downloadUrl == '' || downloadUrl == null) {
this.$modal.showToast('获取下载路径失败!');
} else {
this.$modal.confirm(`发现新版本${latestVersion},是否立即更新?`).then(() => {
let fullDownloadUrl = downloadUrl;
const serverSettings = uni.getStorageSync('serverSettings');
if (serverSettings) {
const settings = JSON.parse(serverSettings);
fullDownloadUrl = `http://${settings.ip}:${settings.port}${downloadUrl}`;
}
// 下载更新包
const downloadTask = uni.downloadFile({
url: downloadUrl,
url: fullDownloadUrl,
success: (res) => {
if (res.statusCode === 200) {
// 安装更新
@@ -92,18 +101,16 @@
this.$modal.showToast(`正在下载:${progress}%`);
}
});
}).catch(() => {
this.$modal.showToast('已取消更新');
});
}
} else {
this.$modal.showToast('获取版本信息失败');
}
},
fail: () => {
this.$modal.showToast('检查更新失败,请检查网络');
}
});
}).catch(() => {
this.$modal.showToast('已取消更新');
});
},
// 版本号比较方法
compareVersion(v1, v2) {

View File

@@ -73,6 +73,14 @@ export default {
created() {
this.fetchTasks()
},
onShow() {
// 根据当前语言动态设置标题
const currentLanguage = this.$i18n.locale;
const title = this.$t('tabBar.task');
uni.setNavigationBarTitle({
title: title
});
},
methods: {
async fetchTasks() {
try {