feat(update): 启用应用启动时的更新检查功能
refactor(update): 重构更新检查逻辑,优化代码结构和错误处理 feat(easycode): 新增移库和发货功能按钮及弹窗表单 chore: 更新应用版本号至1.3.10
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
export default {
|
export default {
|
||||||
onLaunch: function() {
|
onLaunch: function() {
|
||||||
this.initApp()
|
this.initApp()
|
||||||
// updateManager.checkUpdate();
|
updateManager.checkUpdate();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// 初始化应用
|
// 初始化应用
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"name" : "科伦普",
|
"name" : "科伦普",
|
||||||
"appid" : "__UNI__E781B49",
|
"appid" : "__UNI__E781B49",
|
||||||
"description" : "",
|
"description" : "",
|
||||||
"versionName" : "1.3.7",
|
"versionName" : "1.3.10",
|
||||||
"versionCode" : 1,
|
"versionCode" : 1,
|
||||||
"transformPx" : false,
|
"transformPx" : false,
|
||||||
"app-plus" : {
|
"app-plus" : {
|
||||||
|
|||||||
@@ -5,16 +5,60 @@
|
|||||||
|
|
||||||
<!-- 操作类型按钮区域 -->
|
<!-- 操作类型按钮区域 -->
|
||||||
<view class="btn-grid">
|
<view class="btn-grid">
|
||||||
<button
|
<button v-for='item in types' :key="item.dictValue" @click="handleScan(item.dictValue)" class="type-btn">
|
||||||
v-for='item in types'
|
|
||||||
:key="item.dictValue"
|
|
||||||
@click="handleScan(item.dictValue)"
|
|
||||||
class="type-btn"
|
|
||||||
>
|
|
||||||
{{ item.dictLabel }}
|
{{ item.dictLabel }}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
<button class="type-btn" style="background-color: orange;" @click="handleTranfer">移库</button>
|
||||||
|
|
||||||
|
<button class="type-btn" style="background-color: greenyellow;" @click="handleShip">发货</button>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<uni-popup ref="tranferPopup" type="bottom">
|
||||||
|
<view style="background-color: white;">
|
||||||
|
<view class="info-card" v-if="form.coilId">
|
||||||
|
<view class="card-title">
|
||||||
|
<text class="title-dot"></text>
|
||||||
|
<text class="title-text">原钢卷信息</text>
|
||||||
|
<view class="more-btn" @click.stop="showBomDialog"
|
||||||
|
v-if="coilDetail.bomItemList && coilDetail.bomItemList.length > 0">
|
||||||
|
<text class="icon-more">⚙</text>
|
||||||
|
<text class="more-text">参数</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="info-grid">
|
||||||
|
<view class="info-item">
|
||||||
|
<text class="item-label">入场钢卷号</text>
|
||||||
|
<text class="item-value">{{ coilDetail.enterCoilNo || '-' }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="info-item">
|
||||||
|
<text class="item-label">当前钢卷号</text>
|
||||||
|
<text class="item-value">{{ coilDetail.currentCoilNo || '-' }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="info-item">
|
||||||
|
<text class="item-label">当前库区</text>
|
||||||
|
<text class="item-value">{{ coilDetail.actualWarehouseName }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="form-card" v-if="form.coilId">
|
||||||
|
<view class="form-item form-item-optional">
|
||||||
|
<text class="form-label-optional">真实库区</text>
|
||||||
|
<klp-warehouse-picker v-model="form.actualWarehouseId" :disabled="coilDetail.dataType === 0"
|
||||||
|
placeholder="请选择目标库区" ware-type="actual" />
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="action-buttons">
|
||||||
|
<button class="btn btn-secondary" @click="handleReScan">重新扫码</button>
|
||||||
|
<button v-if="coilDetail.dataType === 1" class="btn btn-primary" @click="handleConfirm" :disabled="loading">
|
||||||
|
{{ loading ? '提交中...' : '保存' }}
|
||||||
|
</button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</uni-popup>
|
||||||
|
|
||||||
<!-- 退出登录按钮(固定在底部) -->
|
<!-- 退出登录按钮(固定在底部) -->
|
||||||
<view class="logout-container">
|
<view class="logout-container">
|
||||||
<button @click='handleLogout' class="logout-btn">
|
<button @click='handleLogout' class="logout-btn">
|
||||||
@@ -25,16 +69,27 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { getDicts } from '@/api/system/dict/data.js'
|
import {
|
||||||
import { getGenerateRecord } from '@/api/wms/code.js'
|
getDicts
|
||||||
import { getMaterialCoil } from '@/api/wms/coil.js'
|
} from '@/api/system/dict/data.js'
|
||||||
import { addPendingAction } from '@/api/wms/pendingAction.js'
|
import {
|
||||||
|
getGenerateRecord
|
||||||
|
} from '@/api/wms/code.js'
|
||||||
|
import {
|
||||||
|
getMaterialCoil,
|
||||||
|
updateMaterialCoilSimple
|
||||||
|
} from '@/api/wms/coil.js'
|
||||||
|
import {
|
||||||
|
addPendingAction
|
||||||
|
} from '@/api/wms/pendingAction.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
types: [],
|
types: [],
|
||||||
loading: false
|
loading: false,
|
||||||
|
coilDetail: {},
|
||||||
|
form: {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -53,7 +108,9 @@
|
|||||||
console.log('=== 开始扫码流程 ===');
|
console.log('=== 开始扫码流程 ===');
|
||||||
console.log('扫码结果:', res.result);
|
console.log('扫码结果:', res.result);
|
||||||
console.log('操作类型:', actionType);
|
console.log('操作类型:', actionType);
|
||||||
uni.showLoading({ title: '处理中...' });
|
uni.showLoading({
|
||||||
|
title: '处理中...'
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const qrcodeId = res.result;
|
const qrcodeId = res.result;
|
||||||
@@ -85,12 +142,14 @@
|
|||||||
console.log('解析后的内容:', content);
|
console.log('解析后的内容:', content);
|
||||||
|
|
||||||
// 优先使用current_coil_id(当前有效的钢卷ID),如果没有则使用coil_id(兼容旧数据)
|
// 优先使用current_coil_id(当前有效的钢卷ID),如果没有则使用coil_id(兼容旧数据)
|
||||||
let coilId = content.current_coil_id && content.current_coil_id !== 'null' ? content.current_coil_id : null;
|
let coilId = content.current_coil_id && content.current_coil_id !== 'null' ? content
|
||||||
|
.current_coil_id : null;
|
||||||
if (!coilId) {
|
if (!coilId) {
|
||||||
coilId = content.coil_id && content.coil_id !== 'null' ? content.coil_id : null;
|
coilId = content.coil_id && content.coil_id !== 'null' ? content.coil_id : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('提取钢卷ID - current_coil_id:', content.current_coil_id, 'coil_id:', content.coil_id, '最终使用:', coilId);
|
console.log('提取钢卷ID - current_coil_id:', content.current_coil_id, 'coil_id:', content.coil_id,
|
||||||
|
'最终使用:', coilId);
|
||||||
|
|
||||||
if (!coilId) {
|
if (!coilId) {
|
||||||
throw new Error('二维码中未包含有效的钢卷ID');
|
throw new Error('二维码中未包含有效的钢卷ID');
|
||||||
@@ -174,6 +233,230 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
handleShip() {
|
||||||
|
uni.scanCode({
|
||||||
|
success: async (res) => {
|
||||||
|
console.log('=== 开始扫码流程 ===');
|
||||||
|
console.log('扫码结果:', res.result);
|
||||||
|
// console.log('操作类型:', actionType);
|
||||||
|
uni.showLoading({
|
||||||
|
title: '处理中...'
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const qrcodeId = res.result;
|
||||||
|
// 1. 通过二维码ID获取二维码详情
|
||||||
|
console.log('1. 获取二维码详情,ID:', qrcodeId);
|
||||||
|
const qrcodeRes = await getGenerateRecord(qrcodeId);
|
||||||
|
console.log('二维码响应:', qrcodeRes);
|
||||||
|
|
||||||
|
if (qrcodeRes.code !== 200) {
|
||||||
|
throw new Error('未找到二维码记录');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 解析二维码的content,获取coil_id
|
||||||
|
const qrcodeRecord = qrcodeRes.data;
|
||||||
|
console.log('2. 二维码记录:', qrcodeRecord);
|
||||||
|
|
||||||
|
// 检查二维码状态(0=失效,1=有效)
|
||||||
|
if (qrcodeRecord.status === 0) {
|
||||||
|
uni.hideLoading();
|
||||||
|
uni.showModal({
|
||||||
|
title: '提示',
|
||||||
|
content: '该二维码已失效,无法创建待操作任务',
|
||||||
|
showCancel: false
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const content = JSON.parse(qrcodeRecord.content);
|
||||||
|
console.log('解析后的内容:', content);
|
||||||
|
|
||||||
|
// 优先使用current_coil_id(当前有效的钢卷ID),如果没有则使用coil_id(兼容旧数据)
|
||||||
|
let coilId = content.current_coil_id && content.current_coil_id !== 'null' ? content
|
||||||
|
.current_coil_id : null;
|
||||||
|
if (!coilId) {
|
||||||
|
coilId = content.coil_id && content.coil_id !== 'null' ? content.coil_id : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('提取钢卷ID - current_coil_id:', content.current_coil_id, 'coil_id:', content.coil_id,
|
||||||
|
'最终使用:', coilId);
|
||||||
|
|
||||||
|
if (!coilId) {
|
||||||
|
throw new Error('二维码中未包含有效的钢卷ID');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 3. 直接通过钢卷ID获取钢卷详情
|
||||||
|
console.log('3. 获取钢卷详情,钢卷ID:', coilId);
|
||||||
|
const coilRes = await getMaterialCoil(coilId);
|
||||||
|
console.log('钢卷详情响应:', coilRes);
|
||||||
|
|
||||||
|
if (coilRes.code !== 200) {
|
||||||
|
throw new Error(coilRes.msg || '查询钢卷信息失败');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!coilRes.data) {
|
||||||
|
throw new Error('未找到钢卷信息');
|
||||||
|
}
|
||||||
|
|
||||||
|
const coilData = coilRes.data;
|
||||||
|
|
||||||
|
if (coilRes.data.status == 1) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '钢卷已经发货,无需再次发货'
|
||||||
|
})
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uni.showModal({
|
||||||
|
cancelText: '取消',
|
||||||
|
confirmText: '确认',
|
||||||
|
title: '确定要将钢卷号为:' + coilRes.data.currentCoilNo + '发货吗?',
|
||||||
|
showCancel: true,
|
||||||
|
success() {
|
||||||
|
updateMaterialCoilSimple({
|
||||||
|
...coilRes.data,
|
||||||
|
status: 1,
|
||||||
|
}).then(_ => {
|
||||||
|
uni.showToast({
|
||||||
|
title: '发货成功',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
fail() {
|
||||||
|
uni.showToast({
|
||||||
|
title: '已取消发货',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} catch (err) {
|
||||||
|
console.error('=== 扫码处理失败 ===');
|
||||||
|
console.error('错误信息:', err);
|
||||||
|
console.error('错误堆栈:', err.stack);
|
||||||
|
uni.hideLoading();
|
||||||
|
uni.showToast({
|
||||||
|
title: err.message || '处理失败',
|
||||||
|
icon: 'none',
|
||||||
|
duration: 3000
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
console.error('扫码失败:', err);
|
||||||
|
uni.showToast({
|
||||||
|
title: '扫码失败,请重试',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
handleTranfer() {
|
||||||
|
uni.scanCode({
|
||||||
|
success: async (res) => {
|
||||||
|
console.log('=== 开始扫码流程 ===');
|
||||||
|
console.log('扫码结果:', res.result);
|
||||||
|
// console.log('操作类型:', actionType);
|
||||||
|
uni.showLoading({
|
||||||
|
title: '处理中...'
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const qrcodeId = res.result;
|
||||||
|
// 1. 通过二维码ID获取二维码详情
|
||||||
|
console.log('1. 获取二维码详情,ID:', qrcodeId);
|
||||||
|
const qrcodeRes = await getGenerateRecord(qrcodeId);
|
||||||
|
console.log('二维码响应:', qrcodeRes);
|
||||||
|
|
||||||
|
if (qrcodeRes.code !== 200) {
|
||||||
|
throw new Error('未找到二维码记录');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 解析二维码的content,获取coil_id
|
||||||
|
const qrcodeRecord = qrcodeRes.data;
|
||||||
|
console.log('2. 二维码记录:', qrcodeRecord);
|
||||||
|
|
||||||
|
// 检查二维码状态(0=失效,1=有效)
|
||||||
|
if (qrcodeRecord.status === 0) {
|
||||||
|
uni.hideLoading();
|
||||||
|
uni.showModal({
|
||||||
|
title: '提示',
|
||||||
|
content: '该二维码已失效,无法创建待操作任务',
|
||||||
|
showCancel: false
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const content = JSON.parse(qrcodeRecord.content);
|
||||||
|
console.log('解析后的内容:', content);
|
||||||
|
|
||||||
|
// 优先使用current_coil_id(当前有效的钢卷ID),如果没有则使用coil_id(兼容旧数据)
|
||||||
|
let coilId = content.current_coil_id && content.current_coil_id !== 'null' ? content
|
||||||
|
.current_coil_id : null;
|
||||||
|
if (!coilId) {
|
||||||
|
coilId = content.coil_id && content.coil_id !== 'null' ? content.coil_id : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('提取钢卷ID - current_coil_id:', content.current_coil_id, 'coil_id:', content.coil_id,
|
||||||
|
'最终使用:', coilId);
|
||||||
|
|
||||||
|
if (!coilId) {
|
||||||
|
throw new Error('二维码中未包含有效的钢卷ID');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 3. 直接通过钢卷ID获取钢卷详情
|
||||||
|
console.log('3. 获取钢卷详情,钢卷ID:', coilId);
|
||||||
|
const coilRes = await getMaterialCoil(coilId);
|
||||||
|
console.log('钢卷详情响应:', coilRes);
|
||||||
|
|
||||||
|
if (coilRes.code !== 200) {
|
||||||
|
throw new Error(coilRes.msg || '查询钢卷信息失败');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!coilRes.data) {
|
||||||
|
throw new Error('未找到钢卷信息');
|
||||||
|
}
|
||||||
|
|
||||||
|
this.coilDetail = coilRes.data;
|
||||||
|
this.form = coilRes.data;
|
||||||
|
|
||||||
|
this.$refs.tranferPopup.open();
|
||||||
|
uni.hideLoading()
|
||||||
|
} catch (err) {
|
||||||
|
console.error('=== 扫码处理失败 ===');
|
||||||
|
console.error('错误信息:', err);
|
||||||
|
console.error('错误堆栈:', err.stack);
|
||||||
|
uni.hideLoading();
|
||||||
|
uni.showToast({
|
||||||
|
title: err.message || '处理失败',
|
||||||
|
icon: 'none',
|
||||||
|
duration: 3000
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
console.error('扫码失败:', err);
|
||||||
|
uni.showToast({
|
||||||
|
title: '扫码失败,请重试',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
handleConfirm() {
|
||||||
|
updateMaterialCoilSimple(this.form).then(_ => {
|
||||||
|
uni.showToast({
|
||||||
|
title: '移库成功',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
this.$refs.tranferPopup.close()
|
||||||
|
})
|
||||||
|
},
|
||||||
// 获取设备信息
|
// 获取设备信息
|
||||||
getDeviceInfo() {
|
getDeviceInfo() {
|
||||||
try {
|
try {
|
||||||
@@ -199,80 +482,150 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.container {
|
.container {
|
||||||
padding: 20rpx;
|
padding: 20rpx;
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
background-color: #f5f7fa;
|
background-color: #f5f7fa;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 页面标题 */
|
/* 页面标题 */
|
||||||
.page-title {
|
.page-title {
|
||||||
font-size: 32rpx;
|
font-size: 32rpx;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: #333;
|
color: #333;
|
||||||
padding: 20rpx 0;
|
padding: 20rpx 0;
|
||||||
margin-bottom: 30rpx;
|
margin-bottom: 30rpx;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 按钮网格布局 */
|
/* 按钮网格布局 */
|
||||||
.btn-grid {
|
.btn-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 200rpx 200rpx; /* 固定按钮宽度 */
|
grid-template-columns: 200rpx 200rpx;
|
||||||
grid-template-rows: repeat(2, 1fr);
|
/* 固定按钮宽度 */
|
||||||
gap: 40rpx; /* 按钮间距 */
|
grid-template-rows: repeat(2, 1fr);
|
||||||
margin-bottom: 60rpx;
|
gap: 40rpx;
|
||||||
}
|
/* 按钮间距 */
|
||||||
|
margin-bottom: 60rpx;
|
||||||
|
}
|
||||||
|
|
||||||
/* 操作类型按钮样式 */
|
/* 操作类型按钮样式 */
|
||||||
.type-btn {
|
.type-btn {
|
||||||
width: 200rpx;
|
width: 200rpx;
|
||||||
height: 150rpx;
|
height: 150rpx;
|
||||||
line-height: 150rpx; /* 文字竖直居中 */
|
line-height: 150rpx;
|
||||||
font-size: 28rpx;
|
/* 文字竖直居中 */
|
||||||
color: #333;
|
font-size: 36rpx;
|
||||||
background-color: #fff;
|
color: #333;
|
||||||
border-radius: 12rpx;
|
background-color: #fff;
|
||||||
border: none;
|
border-radius: 12rpx;
|
||||||
box-shadow: 0 4rpx 10rpx rgba(0, 0, 0, 0.05);
|
border: none;
|
||||||
transition: all 0.2s ease;
|
box-shadow: 0 4rpx 10rpx rgba(0, 0, 0, 0.05);
|
||||||
}
|
transition: all 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
.type-btn:active {
|
.type-btn:active {
|
||||||
background-color: #f0f0f0;
|
background-color: #f0f0f0;
|
||||||
box-shadow: 0 2rpx 5rpx rgba(0, 0, 0, 0.1);
|
box-shadow: 0 2rpx 5rpx rgba(0, 0, 0, 0.1);
|
||||||
transform: scale(0.98);
|
transform: scale(0.98);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 退出登录按钮容器 */
|
/* 退出登录按钮容器 */
|
||||||
.logout-container {
|
.logout-container {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 30rpx;
|
bottom: 30rpx;
|
||||||
left: 0;
|
left: 0;
|
||||||
padding: 0 20rpx;
|
padding: 0 20rpx;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 退出登录按钮样式 */
|
/* 退出登录按钮样式 */
|
||||||
.logout-btn {
|
.logout-btn {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 90rpx;
|
height: 90rpx;
|
||||||
line-height: 90rpx; /* 文字竖直居中 */
|
line-height: 90rpx;
|
||||||
font-size: 30rpx;
|
/* 文字竖直居中 */
|
||||||
color: #fff;
|
font-size: 30rpx;
|
||||||
background-color: #ff4d4f;
|
color: #fff;
|
||||||
border-radius: 16rpx;
|
background-color: #ff4d4f;
|
||||||
border: none;
|
border-radius: 16rpx;
|
||||||
box-shadow: 0 4rpx 10rpx rgba(255, 77, 79, 0.2);
|
border: none;
|
||||||
transition: all 0.2s ease;
|
box-shadow: 0 4rpx 10rpx rgba(255, 77, 79, 0.2);
|
||||||
}
|
transition: all 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
.logout-btn:active {
|
.logout-btn:active {
|
||||||
background-color: #f5222d;
|
background-color: #f5222d;
|
||||||
transform: scale(0.98);
|
transform: scale(0.98);
|
||||||
}
|
}
|
||||||
</style>
|
|
||||||
|
/* 卡片样式 */
|
||||||
|
.info-card,
|
||||||
|
.material-card,
|
||||||
|
.form-card {
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 16rpx;
|
||||||
|
padding: 30rpx;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 表单项 */
|
||||||
|
.form-item {
|
||||||
|
margin-bottom: 30rpx;
|
||||||
|
|
||||||
|
&:last-of-type {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-label {
|
||||||
|
display: block;
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #333;
|
||||||
|
margin-bottom: 15rpx;
|
||||||
|
font-weight: 500;
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
content: '*';
|
||||||
|
color: #ff4d4f;
|
||||||
|
margin-right: 6rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-label-optional {
|
||||||
|
display: block;
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #333;
|
||||||
|
margin-bottom: 15rpx;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-input {
|
||||||
|
width: 100%;
|
||||||
|
height: 88rpx;
|
||||||
|
padding: 0 24rpx;
|
||||||
|
background: #f8f9fa;
|
||||||
|
border: 2rpx solid #e8e8e8;
|
||||||
|
border-radius: 12rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #333;
|
||||||
|
box-sizing: border-box;
|
||||||
|
transition: all 0.3s;
|
||||||
|
|
||||||
|
&:focus {
|
||||||
|
background: #fff;
|
||||||
|
border-color: #007aff;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.form-input-disabled {
|
||||||
|
background: #f5f5f5;
|
||||||
|
color: #999;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -71,156 +71,250 @@ function checkStorageSpace() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function checkUpdate(forceCheck = false) {
|
function checkUpdate(forceCheck = false) {
|
||||||
const localVersion = plus.runtime.version;
|
// 1. 准备本地版本信息
|
||||||
const staticVersion = '1.0.0';
|
const localVersion = plus.runtime.version; // 基座版本
|
||||||
const localWgtVersion = uni.getStorageSync('wgtVersion') || staticVersion;
|
const staticVersion = '1.0.0'; // 静态默认版本
|
||||||
|
const localWgtVersion = uni.getStorageSync('wgtVersion') || staticVersion; // 本地wgt版本(从存储获取或用默认)
|
||||||
|
const currentVersion = compareVersion(localWgtVersion, localVersion) > 0
|
||||||
|
? localWgtVersion
|
||||||
|
: localVersion; // 当前有效版本(取两者较高者)
|
||||||
|
|
||||||
|
|
||||||
|
// 2. 请求远程版本信息
|
||||||
uni.request({
|
uni.request({
|
||||||
url: `${baseURL}/version.json?t=` + Date.now(),
|
url: `${baseURL}/version.json?t=${Date.now()}`, // 加时间戳防缓存
|
||||||
success: (res) => {
|
success: handleRemoteVersionSuccess,
|
||||||
const remoteVersion = res.data.version;
|
fail: handleCheckFail
|
||||||
const wgtUrl = res.data.wgtUrl;
|
|
||||||
const currentVersion = compareVersion(localWgtVersion, localVersion) > 0 ? localWgtVersion : localVersion;
|
|
||||||
console.log('本地基座版本:', localVersion, '本地wgt版本:', localWgtVersion, '当前对比版本:', currentVersion, '远程版本:', remoteVersion);
|
|
||||||
if (compareVersion(remoteVersion, currentVersion) > 0) {
|
|
||||||
if (!checkVersionCompatibility(remoteVersion, localVersion)) {
|
|
||||||
console.warn('版本不兼容,跳转到浏览器下载新版安装包');
|
|
||||||
uni.showModal({
|
|
||||||
title: '版本不兼容',
|
|
||||||
content: `新版本 ${remoteVersion} 与当前基座版本 ${localVersion} 不兼容,请前往官网下载最新安装包。`,
|
|
||||||
showCancel: true,
|
|
||||||
confirmText: '去下载',
|
|
||||||
cancelText: '取消',
|
|
||||||
success: (res) => {
|
|
||||||
if (res.confirm) {
|
|
||||||
const downloadUrl = `${baseURL}/fad${remoteVersion}.apk`;
|
|
||||||
// #ifdef APP-PLUS
|
|
||||||
plus.runtime.openURL(downloadUrl);
|
|
||||||
// #endif
|
|
||||||
// #ifndef APP-PLUS
|
|
||||||
window.open(downloadUrl, '_blank');
|
|
||||||
// #endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const ignoredVersion = uni.getStorageSync('ignoredVersion');
|
|
||||||
if (!forceCheck && ignoredVersion === remoteVersion) {
|
|
||||||
console.log('用户已选择忽略此版本:', remoteVersion);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
uni.showModal({
|
|
||||||
title: '发现新版本',
|
|
||||||
content: `检测到新版本(${remoteVersion}),是否立即下载并更新?`,
|
|
||||||
confirmText: '立即更新',
|
|
||||||
cancelText: '暂不更新',
|
|
||||||
showCancel: true,
|
|
||||||
success: (modalRes) => {
|
|
||||||
if (modalRes.confirm) {
|
|
||||||
checkStorageSpace().then(() => {
|
|
||||||
uni.showLoading({title: '正在下载更新包...'});
|
|
||||||
console.log('开始下载wgt包:', wgtUrl);
|
|
||||||
uni.downloadFile({
|
|
||||||
url: wgtUrl,
|
|
||||||
success: (downloadResult) => {
|
|
||||||
uni.hideLoading();
|
|
||||||
console.log('下载结果:', downloadResult);
|
|
||||||
if (downloadResult.statusCode === 200) {
|
|
||||||
console.log('开始安装wgt包:', downloadResult.tempFilePath);
|
|
||||||
plus.io.resolveLocalFileSystemURL(downloadResult.tempFilePath, (entry) => {
|
|
||||||
console.log('文件存在,开始安装');
|
|
||||||
plus.runtime.install(downloadResult.tempFilePath, {force: true}, function() {
|
|
||||||
console.log('wgt包安装成功');
|
|
||||||
uni.setStorageSync('wgtVersion', remoteVersion);
|
|
||||||
uni.showModal({
|
|
||||||
title: '更新完成',
|
|
||||||
content: '应用需要重启才能生效,是否立即重启?',
|
|
||||||
success: function (res) {
|
|
||||||
if (res.confirm) {
|
|
||||||
plus.runtime.restart();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}, function(e) {
|
|
||||||
console.error('wgt包安装失败:', e);
|
|
||||||
let errorMsg = '安装失败';
|
|
||||||
if (e && e.message) {
|
|
||||||
errorMsg += ': ' + e.message;
|
|
||||||
}
|
|
||||||
if (e && e.code) {
|
|
||||||
errorMsg += ' (错误代码: ' + e.code + ')';
|
|
||||||
}
|
|
||||||
uni.showModal({
|
|
||||||
title: '安装失败',
|
|
||||||
content: errorMsg + '\n\n可能的原因:\n1. 版本不兼容\n2. 文件损坏\n3. 权限不足\n4. 存储空间不足',
|
|
||||||
showCancel: false,
|
|
||||||
confirmText: '确定'
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}, (error) => {
|
|
||||||
console.error('文件不存在:', error);
|
|
||||||
uni.showModal({
|
|
||||||
title: '安装失败',
|
|
||||||
content: '下载的文件不存在或已损坏',
|
|
||||||
showCancel: false,
|
|
||||||
confirmText: '确定'
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
console.error('下载失败,状态码:', downloadResult.statusCode);
|
|
||||||
uni.showModal({
|
|
||||||
title: '下载失败',
|
|
||||||
content: `服务器返回错误,状态码: ${downloadResult.statusCode}`,
|
|
||||||
showCancel: false,
|
|
||||||
confirmText: '确定'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fail: (error) => {
|
|
||||||
uni.hideLoading();
|
|
||||||
console.error('下载失败:', error);
|
|
||||||
uni.showModal({
|
|
||||||
title: '下载失败',
|
|
||||||
content: '网络连接异常,请检查网络后重试',
|
|
||||||
showCancel: false,
|
|
||||||
confirmText: '确定'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}).catch((error) => {
|
|
||||||
console.error('存储空间检查失败:', error);
|
|
||||||
uni.showModal({
|
|
||||||
title: '存储空间不足',
|
|
||||||
content: '设备存储空间不足,无法下载更新包',
|
|
||||||
showCancel: false,
|
|
||||||
confirmText: '确定'
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
uni.showModal({
|
|
||||||
title: '忽略更新',
|
|
||||||
content: `是否忽略版本 ${remoteVersion}?忽略后下次启动时将不再提示此版本更新。`,
|
|
||||||
confirmText: '忽略此版本',
|
|
||||||
cancelText: '下次提醒',
|
|
||||||
success: (ignoreRes) => {
|
|
||||||
if (ignoreRes.confirm) {
|
|
||||||
uni.setStorageSync('ignoredVersion', remoteVersion);
|
|
||||||
uni.showToast({title: '已忽略此版本更新'});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
console.log('当前已是最新版本');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fail: (error) => {
|
|
||||||
console.error('检查更新失败:', error);
|
|
||||||
uni.showToast({title: '网络异常,请稍后重试'});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// 处理远程版本请求成功
|
||||||
|
function handleRemoteVersionSuccess(res) {
|
||||||
|
const remoteVersion = res.data.version;
|
||||||
|
const wgtUrl = res.data.wgtUrl;
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
'本地基座版本:', localVersion,
|
||||||
|
'本地wgt版本:', localWgtVersion,
|
||||||
|
'当前对比版本:', currentVersion,
|
||||||
|
'远程版本:', remoteVersion
|
||||||
|
);
|
||||||
|
|
||||||
|
// 远程版本高于本地wgt版本时才需要处理更新
|
||||||
|
if (compareVersion(remoteVersion, localWgtVersion) > 0) {
|
||||||
|
handleNeedUpdate(remoteVersion, wgtUrl);
|
||||||
|
} else {
|
||||||
|
console.log('当前已是最新版本');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 处理需要更新的情况
|
||||||
|
function handleNeedUpdate(remoteVersion, wgtUrl) {
|
||||||
|
// 2.1 先检查版本兼容性
|
||||||
|
if (!checkVersionCompatibility(remoteVersion, localWgtVersion)) {
|
||||||
|
handleIncompatibleVersion(remoteVersion);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2.2 检查用户是否忽略过该版本(非强制检查时)
|
||||||
|
const ignoredVersion = uni.getStorageSync('ignoredVersion');
|
||||||
|
if (!forceCheck && ignoredVersion === remoteVersion) {
|
||||||
|
console.log('用户已选择忽略此版本:', remoteVersion);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2.3 显示更新提示
|
||||||
|
showUpdateModal(remoteVersion, wgtUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 处理版本不兼容的情况(引导下载完整安装包)
|
||||||
|
function handleIncompatibleVersion(remoteVersion) {
|
||||||
|
console.warn('版本不兼容,跳转到浏览器下载新版安装包');
|
||||||
|
uni.showModal({
|
||||||
|
title: '版本不兼容',
|
||||||
|
content: `新版本 ${remoteVersion} 与当前基座版本 ${localVersion} 不兼容,请前往官网下载最新安装包。`,
|
||||||
|
showCancel: true,
|
||||||
|
confirmText: '去下载',
|
||||||
|
cancelText: '取消',
|
||||||
|
success: (res) => {
|
||||||
|
if (res.confirm) {
|
||||||
|
const downloadUrl = `${baseURL}/klp.apk`;
|
||||||
|
// 区分环境打开下载链接
|
||||||
|
plus.runtime.openURL(downloadUrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 显示更新提示模态框
|
||||||
|
function showUpdateModal(remoteVersion, wgtUrl) {
|
||||||
|
uni.showModal({
|
||||||
|
title: '发现新版本',
|
||||||
|
content: `检测到新版本(${remoteVersion}),是否立即下载并更新?`,
|
||||||
|
confirmText: '立即更新',
|
||||||
|
cancelText: '暂不更新',
|
||||||
|
showCancel: true,
|
||||||
|
success: (modalRes) => {
|
||||||
|
if (modalRes.confirm) {
|
||||||
|
// 用户确认更新:检查存储空间 -> 下载 -> 安装
|
||||||
|
handleConfirmUpdate(wgtUrl, remoteVersion);
|
||||||
|
} else {
|
||||||
|
// 用户取消更新:询问是否忽略该版本
|
||||||
|
handleCancelUpdate(remoteVersion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 处理用户确认更新
|
||||||
|
function handleConfirmUpdate(wgtUrl, remoteVersion) {
|
||||||
|
checkStorageSpace()
|
||||||
|
.then(() => {
|
||||||
|
// 存储空间充足,开始下载
|
||||||
|
uni.showLoading({ title: '正在下载更新包...' });
|
||||||
|
console.log('开始下载wgt包:', wgtUrl);
|
||||||
|
|
||||||
|
uni.downloadFile({
|
||||||
|
url: wgtUrl,
|
||||||
|
success: (downloadResult) => handleDownloadSuccess(downloadResult, remoteVersion),
|
||||||
|
fail: handleDownloadFail
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
// 存储空间不足
|
||||||
|
console.error('存储空间检查失败:', error);
|
||||||
|
uni.showModal({
|
||||||
|
title: '存储空间不足',
|
||||||
|
content: '设备存储空间不足,无法下载更新包',
|
||||||
|
showCancel: false,
|
||||||
|
confirmText: '确定'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 处理下载成功
|
||||||
|
function handleDownloadSuccess(downloadResult, remoteVersion) {
|
||||||
|
uni.hideLoading();
|
||||||
|
console.log('下载结果:', downloadResult);
|
||||||
|
|
||||||
|
if (downloadResult.statusCode === 200) {
|
||||||
|
// 下载成功,开始安装wgt包
|
||||||
|
installWgtPackage(downloadResult.tempFilePath, remoteVersion);
|
||||||
|
} else {
|
||||||
|
// 下载状态码异常
|
||||||
|
console.error('下载失败,状态码:', downloadResult.statusCode);
|
||||||
|
uni.showModal({
|
||||||
|
title: '下载失败',
|
||||||
|
content: `服务器返回错误,状态码: ${downloadResult.statusCode}`,
|
||||||
|
showCancel: false,
|
||||||
|
confirmText: '确定'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 安装wgt包
|
||||||
|
function installWgtPackage(filePath, remoteVersion) {
|
||||||
|
console.log('开始安装wgt包:', filePath);
|
||||||
|
|
||||||
|
plus.io.resolveLocalFileSystemURL(filePath,
|
||||||
|
// 文件存在,执行安装
|
||||||
|
() => {
|
||||||
|
plus.runtime.install(filePath, { force: true },
|
||||||
|
// 安装成功
|
||||||
|
() => {
|
||||||
|
console.log('wgt包安装成功');
|
||||||
|
uni.setStorageSync('wgtVersion', remoteVersion); // 更新本地wgt版本记录
|
||||||
|
showRestartConfirm();
|
||||||
|
},
|
||||||
|
// 安装失败
|
||||||
|
(e) => handleInstallFail(e)
|
||||||
|
);
|
||||||
|
},
|
||||||
|
// 文件不存在/损坏
|
||||||
|
(error) => {
|
||||||
|
console.error('文件不存在:', error);
|
||||||
|
uni.showModal({
|
||||||
|
title: '安装失败',
|
||||||
|
content: '下载的文件不存在或已损坏',
|
||||||
|
showCancel: false,
|
||||||
|
confirmText: '确定'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 显示重启确认
|
||||||
|
function showRestartConfirm() {
|
||||||
|
uni.showModal({
|
||||||
|
title: '更新完成',
|
||||||
|
content: '应用需要重启才能生效,是否立即重启?',
|
||||||
|
success: (res) => {
|
||||||
|
if (res.confirm) {
|
||||||
|
plus.runtime.restart();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 处理安装失败
|
||||||
|
function handleInstallFail(e) {
|
||||||
|
console.error('wgt包安装失败:', e);
|
||||||
|
let errorMsg = '安装失败';
|
||||||
|
if (e?.message) errorMsg += ': ' + e.message;
|
||||||
|
if (e?.code) errorMsg += ' (错误代码: ' + e.code + ')';
|
||||||
|
|
||||||
|
uni.showModal({
|
||||||
|
title: '安装失败',
|
||||||
|
content: `${errorMsg}\n\n可能的原因:\n1. 版本不兼容\n2. 文件损坏\n3. 权限不足\n4. 存储空间不足`,
|
||||||
|
showCancel: false,
|
||||||
|
confirmText: '确定'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 处理下载失败
|
||||||
|
function handleDownloadFail(error) {
|
||||||
|
uni.hideLoading();
|
||||||
|
console.error('下载失败:', error);
|
||||||
|
uni.showModal({
|
||||||
|
title: '下载失败',
|
||||||
|
content: '网络连接异常,请检查网络后重试',
|
||||||
|
showCancel: false,
|
||||||
|
confirmText: '确定'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 处理用户取消更新(询问是否忽略)
|
||||||
|
function handleCancelUpdate(remoteVersion) {
|
||||||
|
uni.showModal({
|
||||||
|
title: '忽略更新',
|
||||||
|
content: `是否忽略版本 ${remoteVersion}?忽略后下次启动时将不再提示此版本更新。`,
|
||||||
|
confirmText: '忽略此版本',
|
||||||
|
cancelText: '下次提醒',
|
||||||
|
success: (ignoreRes) => {
|
||||||
|
if (ignoreRes.confirm) {
|
||||||
|
uni.setStorageSync('ignoredVersion', remoteVersion);
|
||||||
|
uni.showToast({ title: '已忽略此版本更新' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 处理检查更新请求失败
|
||||||
|
function handleCheckFail(error) {
|
||||||
|
console.error('检查更新失败:', error);
|
||||||
|
uni.showToast({ title: '网络异常,请稍后重试' });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "klp 1.2.0",
|
"version": "klp 1.3.10",
|
||||||
"wgtUrl": "http://49.232.154.205:10900/fadapp-update/klp/klp.wgt",
|
"wgtUrl": "http://49.232.154.205:10900/fadapp-update/klp/klp.wgt",
|
||||||
"apkUrl": "http://49.232.154.205:10900/fadapp-update/klp/klp.apk"
|
"apkUrl": "http://49.232.154.205:10900/fadapp-update/klp/klp.apk"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user