修改商品查询、关于页面
This commit is contained in:
parent
95651ccb19
commit
2aecd0e863
538
components/AppUpdateDialog/AppUpdateDialog.vue
Normal file
538
components/AppUpdateDialog/AppUpdateDialog.vue
Normal file
@ -0,0 +1,538 @@
|
||||
<template>
|
||||
<view v-if="showUpdateDialog" class="update-mask">
|
||||
<view class="update-dialog">
|
||||
<view class="update-header">
|
||||
<text class="update-title">发现新版本</text>
|
||||
<text class="update-version">当前 {{ currentAppVersion || '--' }} → 最新 {{ updateInfo.version || '--' }}</text>
|
||||
</view>
|
||||
|
||||
<view class="update-body">
|
||||
<view class="update-row">
|
||||
<text class="update-label">安装包</text>
|
||||
<text class="update-value">{{ updateInfo.file || '未提供文件名' }}</text>
|
||||
</view>
|
||||
<view v-if="updateInfo.publishedAtUtc" class="update-row">
|
||||
<text class="update-label">发布时间</text>
|
||||
<text class="update-value">{{ formatUpdateTime(updateInfo.publishedAtUtc) }}</text>
|
||||
</view>
|
||||
<view class="update-tip-box">
|
||||
<text class="update-tip">检测到新版本,确认后将开始下载安装包。</text>
|
||||
<text class="update-tip">下载完成后会自动打开文件。</text>
|
||||
</view>
|
||||
|
||||
<view v-if="isDownloadingUpdate" class="update-progress-section">
|
||||
<view class="update-progress-head">
|
||||
<text class="update-progress-text">正在下载更新</text>
|
||||
<text class="update-progress-text">{{ updateDownloadProgress }}%</text>
|
||||
</view>
|
||||
<view class="update-progress-bar">
|
||||
<view class="update-progress-inner" :style="{ width: updateDownloadProgress + '%' }"></view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<text v-if="updateErrorMessage" class="update-error">{{ updateErrorMessage }}</text>
|
||||
</view>
|
||||
|
||||
<view class="update-actions">
|
||||
<u-button
|
||||
v-if="!isDownloadingUpdate"
|
||||
plain
|
||||
text="暂不更新"
|
||||
@click="closeUpdateDialog"
|
||||
></u-button>
|
||||
<u-button
|
||||
type="primary"
|
||||
:loading="isDownloadingUpdate"
|
||||
:disabled="isDownloadingUpdate"
|
||||
:text="isDownloadingUpdate ? '下载中...' : '立即更新'"
|
||||
@click="confirmUpdateDownload"
|
||||
></u-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
/**
|
||||
* AppUpdateDialog 版本更新弹窗组件
|
||||
* 复用登录页 checkForAppUpdate 的完整更新流程:
|
||||
* 读取远端 latest.json → 比较版本 → 弹窗 → 下载 APK → plus.runtime.openFile 调用系统安装器
|
||||
* 使用方法:
|
||||
* <app-update-dialog ref="appUpdateDialog"></app-update-dialog>
|
||||
* this.$refs.appUpdateDialog.checkForAppUpdate(true) // force=true 每次强制重新检查
|
||||
*/
|
||||
export default {
|
||||
name: 'AppUpdateDialog',
|
||||
data() {
|
||||
return {
|
||||
updateLogSeq: 0,
|
||||
currentAppVersion: '',
|
||||
showUpdateDialog: false,
|
||||
isCheckingUpdate: false,
|
||||
isDownloadingUpdate: false,
|
||||
updateDownloadProgress: 0,
|
||||
updateErrorMessage: '',
|
||||
hasCheckedUpdate: false,
|
||||
updateTask: null,
|
||||
updateInfo: {
|
||||
version: '',
|
||||
file: '',
|
||||
url: '',
|
||||
sha256: '',
|
||||
publishedAtUtc: ''
|
||||
}
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
logUpdateStep(step, payload) {
|
||||
this.updateLogSeq += 1;
|
||||
const seq = String(this.updateLogSeq).padStart(2, '0');
|
||||
if (typeof payload === 'undefined') {
|
||||
console.log(`[update][${seq}] ${step}`);
|
||||
return;
|
||||
}
|
||||
console.log(`[update][${seq}] ${step}`, payload);
|
||||
},
|
||||
/**
|
||||
* 检查更新并弹窗
|
||||
* @param {Boolean} force 为 true 时忽略 hasCheckedUpdate,强制重新检查远端配置
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async checkForAppUpdate(force = false) {
|
||||
this.logUpdateStep('checkForAppUpdate -> 开始执行', { force });
|
||||
if (force) {
|
||||
this.hasCheckedUpdate = false;
|
||||
}
|
||||
if (this.hasCheckedUpdate || this.isCheckingUpdate) {
|
||||
this.logUpdateStep('checkForAppUpdate -> 已检查过或正在检查,直接返回', {
|
||||
hasCheckedUpdate: this.hasCheckedUpdate,
|
||||
isCheckingUpdate: this.isCheckingUpdate
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof plus === 'undefined' || !plus.runtime) {
|
||||
this.logUpdateStep('checkForAppUpdate -> 非 APP-PLUS 环境,跳过更新检查');
|
||||
return;
|
||||
}
|
||||
|
||||
this.hasCheckedUpdate = true;
|
||||
this.isCheckingUpdate = true;
|
||||
this.updateErrorMessage = '';
|
||||
this.logUpdateStep('checkForAppUpdate -> 状态已置为检查中');
|
||||
|
||||
try {
|
||||
this.logUpdateStep('checkForAppUpdate -> 并行获取当前版本和远端配置');
|
||||
const [currentVersion, latestInfoRaw] = await Promise.all([
|
||||
this.getCurrentAppVersion(),
|
||||
this.fetchLatestVersionInfo()
|
||||
]);
|
||||
const latestInfo = this.normalizeLatestInfo(latestInfoRaw);
|
||||
|
||||
this.currentAppVersion = currentVersion;
|
||||
this.logUpdateStep('checkForAppUpdate -> 已拿到版本信息', {
|
||||
currentVersion,
|
||||
latestVersion: latestInfo && latestInfo.version ? latestInfo.version : ''
|
||||
});
|
||||
this.logUpdateStep('checkForAppUpdate -> 标准化后的远端配置', latestInfo || {});
|
||||
|
||||
if (!latestInfo || !latestInfo.version || !latestInfo.url) {
|
||||
this.logUpdateStep('checkForAppUpdate -> 远端配置缺少必要字段,结束', latestInfo || {});
|
||||
return;
|
||||
}
|
||||
|
||||
const isNewer = this.isVersionNewer(latestInfo.version, currentVersion);
|
||||
this.logUpdateStep('checkForAppUpdate -> 版本比较完成', {
|
||||
latestVersion: latestInfo.version,
|
||||
currentVersion,
|
||||
isNewer
|
||||
});
|
||||
|
||||
if (!isNewer) {
|
||||
this.logUpdateStep('checkForAppUpdate -> 远端版本不高于当前版本,不弹窗');
|
||||
return;
|
||||
}
|
||||
|
||||
this.updateInfo = {
|
||||
version: String(latestInfo.version || '').trim(),
|
||||
file: String(latestInfo.file || '').trim(),
|
||||
url: String(latestInfo.url || '').trim(),
|
||||
sha256: String(latestInfo.sha256 || '').trim(),
|
||||
publishedAtUtc: String(latestInfo.publishedAtUtc || '').trim()
|
||||
};
|
||||
this.showUpdateDialog = true;
|
||||
this.logUpdateStep('checkForAppUpdate -> 发现新版本,显示更新弹窗', this.updateInfo);
|
||||
} catch (error) {
|
||||
this.logUpdateStep('checkForAppUpdate -> 检查异常', error);
|
||||
console.warn('[update] check failed:', error);
|
||||
} finally {
|
||||
this.isCheckingUpdate = false;
|
||||
this.logUpdateStep('checkForAppUpdate -> 结束,isCheckingUpdate=false');
|
||||
}
|
||||
},
|
||||
fetchLatestVersionInfo() {
|
||||
this.logUpdateStep('fetchLatestVersionInfo -> 发起请求', {
|
||||
url: 'http://dl.wms.gztbyc.com/pda/latest.json'
|
||||
});
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.request({
|
||||
url: 'http://dl.wms.gztbyc.com/pda/latest.json',
|
||||
method: 'GET',
|
||||
timeout: 10000,
|
||||
success: (res) => {
|
||||
this.logUpdateStep('fetchLatestVersionInfo -> 请求成功', {
|
||||
statusCode: res.statusCode
|
||||
});
|
||||
if (res.statusCode !== 200) {
|
||||
this.logUpdateStep('fetchLatestVersionInfo -> 状态码异常,reject', {
|
||||
statusCode: res.statusCode
|
||||
});
|
||||
reject(new Error(`更新配置获取失败: ${res.statusCode}`));
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const data = typeof res.data === 'string' ? JSON.parse(res.data) : res.data;
|
||||
this.logUpdateStep('fetchLatestVersionInfo -> 配置解析成功', data || {});
|
||||
resolve(data || {});
|
||||
} catch (parseError) {
|
||||
this.logUpdateStep('fetchLatestVersionInfo -> 配置解析失败', parseError);
|
||||
reject(parseError);
|
||||
}
|
||||
},
|
||||
fail: (error) => {
|
||||
this.logUpdateStep('fetchLatestVersionInfo -> 请求失败', error);
|
||||
reject(error || new Error('更新配置获取失败'));
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
normalizeLatestInfo(raw) {
|
||||
const source = raw && typeof raw === 'object' ? raw : {};
|
||||
const version = String(source.version || source.versionName || source.appVersion || '').trim();
|
||||
const url = String(
|
||||
source.url ||
|
||||
source.downloadUrl ||
|
||||
source.apkUrl ||
|
||||
source.download_url ||
|
||||
''
|
||||
).trim();
|
||||
const file = String(source.file || source.fileName || source.apkName || source.name || '').trim();
|
||||
|
||||
return {
|
||||
...source,
|
||||
version,
|
||||
url,
|
||||
file,
|
||||
sha256: String(source.sha256 || source.md5 || '').trim(),
|
||||
publishedAtUtc: String(source.publishedAtUtc || source.publishedAt || source.releaseTime || '').trim()
|
||||
};
|
||||
},
|
||||
getCurrentAppVersion() {
|
||||
this.logUpdateStep('getCurrentAppVersion -> 开始读取当前版本');
|
||||
return new Promise((resolve) => {
|
||||
if (typeof plus === 'undefined' || !plus.runtime) {
|
||||
this.logUpdateStep('getCurrentAppVersion -> 非 APP-PLUS,返回空版本');
|
||||
resolve('');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
plus.runtime.getProperty(plus.runtime.appid, (info) => {
|
||||
const version = String(info?.version || plus.runtime.version || '').trim();
|
||||
this.logUpdateStep('getCurrentAppVersion -> 读取成功', {
|
||||
version,
|
||||
appid: plus.runtime.appid
|
||||
});
|
||||
resolve(version);
|
||||
});
|
||||
} catch (error) {
|
||||
const fallbackVersion = String((typeof plus !== 'undefined' && plus.runtime && plus.runtime.version) || '').trim();
|
||||
this.logUpdateStep('getCurrentAppVersion -> 读取异常,走兜底版本', {
|
||||
fallbackVersion,
|
||||
error
|
||||
});
|
||||
resolve(fallbackVersion);
|
||||
}
|
||||
});
|
||||
},
|
||||
isVersionNewer(latestVersion, currentVersion) {
|
||||
const normalize = (version) => String(version || '')
|
||||
.split('.')
|
||||
.map(item => parseInt(item, 10) || 0);
|
||||
|
||||
const latest = normalize(latestVersion);
|
||||
const current = normalize(currentVersion);
|
||||
|
||||
const maxLength = Math.max(latest.length, current.length);
|
||||
for (let i = 0; i < maxLength; i++) {
|
||||
const latestPart = latest[i] || 0;
|
||||
const currentPart = current[i] || 0;
|
||||
|
||||
if (latestPart > currentPart) {
|
||||
return true;
|
||||
}
|
||||
if (latestPart < currentPart) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
formatUpdateTime(value) {
|
||||
if (!value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const date = new Date(value);
|
||||
if (Number.isNaN(date.getTime())) {
|
||||
return value;
|
||||
}
|
||||
|
||||
const pad = (num) => String(num).padStart(2, '0');
|
||||
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`;
|
||||
},
|
||||
closeUpdateDialog() {
|
||||
if (this.isDownloadingUpdate) {
|
||||
this.logUpdateStep('closeUpdateDialog -> 下载中,禁止关闭弹窗');
|
||||
return;
|
||||
}
|
||||
|
||||
this.showUpdateDialog = false;
|
||||
this.updateErrorMessage = '';
|
||||
this.logUpdateStep('closeUpdateDialog -> 用户取消更新,弹窗关闭');
|
||||
},
|
||||
confirmUpdateDownload() {
|
||||
if (this.isDownloadingUpdate) {
|
||||
this.logUpdateStep('confirmUpdateDownload -> 已在下载中,忽略重复点击');
|
||||
return;
|
||||
}
|
||||
|
||||
this.logUpdateStep('confirmUpdateDownload -> 用户确认更新,准备下载');
|
||||
this.startUpdateDownload();
|
||||
},
|
||||
startUpdateDownload() {
|
||||
this.logUpdateStep('startUpdateDownload -> 开始下载流程', {
|
||||
url: this.updateInfo.url,
|
||||
file: this.updateInfo.file
|
||||
});
|
||||
if (!this.updateInfo.url) {
|
||||
this.updateErrorMessage = '未获取到下载地址';
|
||||
this.logUpdateStep('startUpdateDownload -> 缺少下载地址,终止');
|
||||
return;
|
||||
}
|
||||
|
||||
this.isDownloadingUpdate = true;
|
||||
this.updateDownloadProgress = 0;
|
||||
this.updateErrorMessage = '';
|
||||
|
||||
const downloadTask = uni.downloadFile({
|
||||
url: this.updateInfo.url,
|
||||
success: (res) => {
|
||||
this.updateTask = null;
|
||||
this.logUpdateStep('startUpdateDownload -> 下载完成回调', {
|
||||
statusCode: res.statusCode,
|
||||
tempFilePath: res.tempFilePath
|
||||
});
|
||||
if (res.statusCode !== 200 || !res.tempFilePath) {
|
||||
this.isDownloadingUpdate = false;
|
||||
this.updateErrorMessage = '安装包下载失败';
|
||||
this.logUpdateStep('startUpdateDownload -> 下载结果无效,终止');
|
||||
return;
|
||||
}
|
||||
|
||||
this.updateDownloadProgress = 100;
|
||||
this.logUpdateStep('startUpdateDownload -> 下载成功,准备打开文件');
|
||||
this.openDownloadedFile(res.tempFilePath);
|
||||
},
|
||||
fail: (error) => {
|
||||
this.updateTask = null;
|
||||
this.isDownloadingUpdate = false;
|
||||
this.updateErrorMessage = error?.errMsg || '安装包下载失败';
|
||||
this.logUpdateStep('startUpdateDownload -> 下载失败', error);
|
||||
}
|
||||
});
|
||||
|
||||
this.updateTask = downloadTask;
|
||||
this.logUpdateStep('startUpdateDownload -> downloadTask 已创建');
|
||||
|
||||
if (downloadTask && typeof downloadTask.onProgressUpdate === 'function') {
|
||||
downloadTask.onProgressUpdate((progressEvent) => {
|
||||
this.updateDownloadProgress = Number(progressEvent.progress || 0);
|
||||
this.logUpdateStep('startUpdateDownload -> 下载进度', {
|
||||
progress: this.updateDownloadProgress,
|
||||
totalBytesWritten: progressEvent.totalBytesWritten,
|
||||
totalBytesExpectedToWrite: progressEvent.totalBytesExpectedToWrite
|
||||
});
|
||||
});
|
||||
} else {
|
||||
this.logUpdateStep('startUpdateDownload -> 当前环境不支持进度回调');
|
||||
}
|
||||
},
|
||||
openDownloadedFile(filePath) {
|
||||
this.logUpdateStep('openDownloadedFile -> 尝试打开下载文件', {
|
||||
filePath
|
||||
});
|
||||
if (typeof plus === 'undefined' || !plus.runtime || typeof plus.runtime.openFile !== 'function') {
|
||||
this.updateTask = null;
|
||||
this.isDownloadingUpdate = false;
|
||||
this.updateErrorMessage = '当前环境不支持打开安装包';
|
||||
this.logUpdateStep('openDownloadedFile -> 环境不支持 plus.runtime.openFile');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
plus.runtime.openFile(filePath, {}, () => {
|
||||
this.updateTask = null;
|
||||
this.isDownloadingUpdate = false;
|
||||
this.updateErrorMessage = '';
|
||||
this.showUpdateDialog = false;
|
||||
this.logUpdateStep('openDownloadedFile -> 文件打开成功,更新流程完成');
|
||||
}, (error) => {
|
||||
this.updateTask = null;
|
||||
this.isDownloadingUpdate = false;
|
||||
this.updateErrorMessage = error?.message || '文件已下载,但打开失败';
|
||||
this.logUpdateStep('openDownloadedFile -> 文件打开失败', error);
|
||||
});
|
||||
} catch (error) {
|
||||
this.updateTask = null;
|
||||
this.isDownloadingUpdate = false;
|
||||
this.updateErrorMessage = error?.message || '文件已下载,但打开失败';
|
||||
this.logUpdateStep('openDownloadedFile -> 调用异常', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.update-mask {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.48);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 9999;
|
||||
padding: 32rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.update-dialog {
|
||||
width: 100%;
|
||||
max-width: 680rpx;
|
||||
background: #fff;
|
||||
border-radius: 24rpx;
|
||||
padding: 36rpx;
|
||||
box-sizing: border-box;
|
||||
box-shadow: 0 24rpx 80rpx rgba(0, 0, 0, 0.18);
|
||||
}
|
||||
|
||||
.update-header {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10rpx;
|
||||
margin-bottom: 28rpx;
|
||||
}
|
||||
|
||||
.update-title {
|
||||
font-size: 36rpx;
|
||||
font-weight: 600;
|
||||
color: #222;
|
||||
}
|
||||
|
||||
.update-version {
|
||||
font-size: 24rpx;
|
||||
color: #5c6b77;
|
||||
}
|
||||
|
||||
.update-body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.update-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.update-label {
|
||||
font-size: 26rpx;
|
||||
color: #86909c;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.update-value {
|
||||
font-size: 26rpx;
|
||||
color: #333;
|
||||
text-align: right;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.update-tip-box {
|
||||
background: #f6f9ff;
|
||||
border-radius: 16rpx;
|
||||
padding: 24rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12rpx;
|
||||
}
|
||||
|
||||
.update-tip {
|
||||
font-size: 26rpx;
|
||||
line-height: 1.6;
|
||||
color: #4e5969;
|
||||
}
|
||||
|
||||
.update-progress-section {
|
||||
margin-top: 8rpx;
|
||||
}
|
||||
|
||||
.update-progress-head {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 14rpx;
|
||||
}
|
||||
|
||||
.update-progress-text {
|
||||
font-size: 26rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.update-progress-bar {
|
||||
height: 18rpx;
|
||||
background: #eef1f5;
|
||||
border-radius: 999rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.update-progress-inner {
|
||||
height: 100%;
|
||||
background: linear-gradient(90deg, #2979ff, #19be6b);
|
||||
border-radius: 999rpx;
|
||||
transition: width 0.2s ease;
|
||||
}
|
||||
|
||||
.update-error {
|
||||
font-size: 24rpx;
|
||||
color: #fa3534;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.update-actions {
|
||||
display: flex;
|
||||
gap: 20rpx;
|
||||
margin-top: 32rpx;
|
||||
}
|
||||
|
||||
.update-actions :deep(.u-button) {
|
||||
flex: 1;
|
||||
}
|
||||
</style>
|
||||
@ -16,20 +16,8 @@
|
||||
</u-cell-group>
|
||||
</view>
|
||||
|
||||
<view v-if="hasUpdate" class="about-update">
|
||||
<text class="about-update__title">发现新版本 {{ latestVersion }}</text>
|
||||
<text class="about-update__desc">请扫描二维码下载更新</text>
|
||||
<image
|
||||
class="about-update__qr"
|
||||
:src="qrCodeUrl"
|
||||
mode="aspectFit"
|
||||
@click="previewQr"
|
||||
></image>
|
||||
<text class="about-update__link" @click="copyDownloadUrl">{{ downloadUrl }}</text>
|
||||
</view>
|
||||
|
||||
<view class="about-actions">
|
||||
<u-button type="primary" plain size="small" @click="checkUpdate" :loading="updateChecking">
|
||||
<u-button type="primary" plain size="small" @click="handleCheckUpdate" :loading="updateChecking">
|
||||
检查更新
|
||||
</u-button>
|
||||
</view>
|
||||
@ -38,24 +26,27 @@
|
||||
<text class="about-copyright">© 2026 天豹云仓</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 版本更新弹窗(复用登录页更新流程) -->
|
||||
<app-update-dialog ref="appUpdateDialog"></app-update-dialog>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import AppUpdateDialog from '@/components/AppUpdateDialog/AppUpdateDialog.vue'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
AppUpdateDialog
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
appVersion: '',
|
||||
updateChecking: false,
|
||||
hasUpdate: false,
|
||||
latestVersion: '',
|
||||
downloadUrl: '',
|
||||
qrCodeUrl: ''
|
||||
updateChecking: false
|
||||
};
|
||||
},
|
||||
onLoad() {
|
||||
this.getAppVersion();
|
||||
this.checkUpdate();
|
||||
},
|
||||
methods: {
|
||||
getAppVersion() {
|
||||
@ -72,54 +63,19 @@ export default {
|
||||
this.appVersion = '1.0.8';
|
||||
// #endif
|
||||
},
|
||||
checkUpdate() {
|
||||
this.updateChecking = true;
|
||||
handleCheckUpdate() {
|
||||
// #ifdef APP-PLUS
|
||||
try {
|
||||
plus.runtime.getProperty(plus.runtime.appid, (info) => {
|
||||
this.updateChecking = false;
|
||||
const currentVersion = info.version || '';
|
||||
// TODO: 替换为实际更新接口
|
||||
// this.fetchUpdateInfo(currentVersion);
|
||||
this.setNoUpdate();
|
||||
});
|
||||
} catch (error) {
|
||||
this.updateChecking = false;
|
||||
this.setNoUpdate();
|
||||
}
|
||||
const dialog = this.$refs.appUpdateDialog;
|
||||
if (!dialog) return;
|
||||
this.updateChecking = true;
|
||||
// force=true:每次点击都强制重新检查远端配置
|
||||
dialog.checkForAppUpdate(true).finally(() => {
|
||||
this.updateChecking = dialog.isCheckingUpdate;
|
||||
});
|
||||
// #endif
|
||||
// #ifndef APP-PLUS
|
||||
setTimeout(() => {
|
||||
this.updateChecking = false;
|
||||
this.setNoUpdate();
|
||||
}, 800);
|
||||
uni.showToast({ title: '当前环境不支持更新检查', icon: 'none' });
|
||||
// #endif
|
||||
},
|
||||
setNoUpdate() {
|
||||
// 暂无更新时清除
|
||||
this.hasUpdate = false;
|
||||
},
|
||||
setUpdateAvailable(latestVersion, downloadUrl) {
|
||||
this.hasUpdate = true;
|
||||
this.latestVersion = latestVersion;
|
||||
this.downloadUrl = downloadUrl;
|
||||
this.qrCodeUrl = `https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=${encodeURIComponent(downloadUrl)}`;
|
||||
},
|
||||
previewQr() {
|
||||
if (!this.qrCodeUrl) return;
|
||||
uni.previewImage({
|
||||
urls: [this.qrCodeUrl],
|
||||
current: this.qrCodeUrl
|
||||
});
|
||||
},
|
||||
copyDownloadUrl() {
|
||||
if (!this.downloadUrl) return;
|
||||
uni.setClipboardData({
|
||||
data: this.downloadUrl,
|
||||
success: () => {
|
||||
uni.showToast({ title: '下载链接已复制', icon: 'success' });
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -161,45 +117,6 @@ export default {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.about-update {
|
||||
width: 100%;
|
||||
padding: 32rpx 24rpx 0;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.about-update__title {
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
color: #f56c6c;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.about-update__desc {
|
||||
font-size: 26rpx;
|
||||
color: #909399;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
.about-update__qr {
|
||||
width: 400rpx;
|
||||
height: 400rpx;
|
||||
border-radius: 12rpx;
|
||||
border: 2rpx solid #ebeef5;
|
||||
}
|
||||
|
||||
.about-update__link {
|
||||
font-size: 24rpx;
|
||||
color: #2979ff;
|
||||
margin-top: 16rpx;
|
||||
text-decoration: underline;
|
||||
word-break: break-all;
|
||||
text-align: center;
|
||||
padding: 0 24rpx;
|
||||
}
|
||||
|
||||
.about-actions {
|
||||
padding: 48rpx 24rpx 0;
|
||||
width: 100%;
|
||||
|
||||
@ -195,6 +195,7 @@ export default {
|
||||
formData: {
|
||||
item_name: '',
|
||||
goods_code: '',
|
||||
item_code: '',
|
||||
barcodes: '',
|
||||
brand_name: '',
|
||||
sku_property: '',
|
||||
@ -259,6 +260,7 @@ export default {
|
||||
};
|
||||
this.formData.item_name = String(cached.item_name || cached.product_name || cached.name || '');
|
||||
this.formData.goods_code = String(cached.goods_code || cached.item_code || '');
|
||||
this.formData.item_code = String(cached.item_code || '');
|
||||
this.formData.barcodes = this.normalizeBarcodeDisplay(cached);
|
||||
this.formData.brand_name = String(cached.brand_name || '');
|
||||
this.formData.sku_property = String(cached.sku_property || '');
|
||||
@ -1230,6 +1232,8 @@ export default {
|
||||
this.showToastMessage('请输入商品编码');
|
||||
return;
|
||||
}
|
||||
// 真实商品编码优先取 item_code(如 011000001536),无则回退到商品编码输入值
|
||||
const saveItemCode = String(this.formData.item_code || '').trim() || itemCode;
|
||||
|
||||
const stockUnit = String(this.formData.stock_unit || '').trim();
|
||||
if (!stockUnit) {
|
||||
@ -1310,7 +1314,7 @@ export default {
|
||||
const recordId = this.resolveWarehouseStockId(this.rawItem || {});
|
||||
|
||||
const checkPayload = {
|
||||
item_code: itemCode,
|
||||
item_code: saveItemCode,
|
||||
store_id: Number(storeId)
|
||||
};
|
||||
if (recordId) {
|
||||
@ -1322,40 +1326,45 @@ export default {
|
||||
throw new Error((checkRes && checkRes.message) || '商品编码已存在,请更换');
|
||||
}
|
||||
|
||||
// 解析条码(保存请求与条码保存接口共用)
|
||||
const barcodeList = this.parseBarcodeInput(this.formData.barcodes);
|
||||
|
||||
const savePayload = {
|
||||
item_code: saveItemCode,
|
||||
store_id: Number(storeId),
|
||||
store_name: String((this.rawItem && this.rawItem.store_name) || '').trim(),
|
||||
barcode: barcodeList[0] || (this.rawItem && this.rawItem.barcode) || '',
|
||||
item_name: itemName,
|
||||
item_code: itemCode,
|
||||
brand_name: String(this.formData.brand_name || '').trim(),
|
||||
sku_property: String(this.formData.sku_property || '').trim(),
|
||||
prohibited_type_id: this.formData.prohibited_type_id ? Number(this.formData.prohibited_type_id) : null,
|
||||
prohibited_type_name: String(this.formData.prohibited_type_name || '').trim(),
|
||||
gross_weight: grossWeight,
|
||||
net_weight: String(this.formData.net_weight || '').trim(),
|
||||
stock_unit: stockUnit,
|
||||
packing_requirements: String(this.formData.packing_requirements || '').trim(),
|
||||
length: Number(this.formData.length) || 0,
|
||||
width: Number(this.formData.width) || 0,
|
||||
height: Number(this.formData.height) || 0,
|
||||
volume: Number(this.formData.volume) || 0,
|
||||
gross_weight: normalizedGrossWeight,
|
||||
net_weight: Number(this.formData.net_weight) || 0,
|
||||
tag_price: normalizedTagPrice,
|
||||
retail_price: normalizedRetailPrice,
|
||||
is_sn_mgmt: this.toYesNoFlag(this.formData.is_sn_mgmt),
|
||||
is_shelf_life_mgmt: this.toYesNoFlag(this.formData.is_shelf_life_mgmt),
|
||||
is_batch_mgmt: this.toYesNoFlag(this.formData.is_batch_mgmt),
|
||||
shelf_life_days: Number(this.formData.shelf_life_days) || 0,
|
||||
is_batch_mgmt: this.toYesNoFlag(this.formData.is_batch_mgmt),
|
||||
inbound_min_days: Number(this.formData.inbound_min_days) || 0,
|
||||
outbound_min_days: Number(this.formData.outbound_min_days) || 0,
|
||||
remaining_threshold_days: Number(this.formData.remaining_threshold_days) || 0,
|
||||
length: String(this.formData.length || ''),
|
||||
width: String(this.formData.width || ''),
|
||||
height: String(this.formData.height || ''),
|
||||
volume: String(this.formData.volume || ''),
|
||||
enable_box_spec: this.toApiFlag(this.formData.enable_box_spec),
|
||||
brand_name: String(this.formData.brand_name || '').trim(),
|
||||
managementFlags: [],
|
||||
enable_box_spec: enableBoxSpec,
|
||||
quantity_per_box: enableBoxSpec ? normalizedQuantityPerBox : 0,
|
||||
box_gross_weight: String(this.formData.box_gross_weight || ''),
|
||||
box_net_weight: String(this.formData.box_net_weight || ''),
|
||||
box_length: String(this.formData.box_length || ''),
|
||||
box_width: String(this.formData.box_width || ''),
|
||||
box_height: String(this.formData.box_height || ''),
|
||||
box_volume: String(this.formData.box_volume || ''),
|
||||
packing_requirements: String(this.formData.packing_requirements || '').trim(),
|
||||
images: this.extractImageUrls(this.formData.images),
|
||||
stock_unit: stockUnit,
|
||||
tag_price: String(normalizedTagPrice),
|
||||
retail_price: String(normalizedRetailPrice)
|
||||
box_gross_weight: Number(this.formData.box_gross_weight) || 0,
|
||||
box_net_weight: Number(this.formData.box_net_weight) || 0,
|
||||
box_length: Number(this.formData.box_length) || 0,
|
||||
box_width: Number(this.formData.box_width) || 0,
|
||||
box_height: Number(this.formData.box_height) || 0,
|
||||
box_volume: Number(this.formData.box_volume) || 0,
|
||||
box_unit: String((this.rawItem && this.rawItem.box_unit) || ''),
|
||||
goods_code: itemCode
|
||||
};
|
||||
|
||||
if (recordId) {
|
||||
@ -1368,7 +1377,6 @@ export default {
|
||||
}
|
||||
|
||||
// 保存商品条码:stock.warehouse.saveWarehouseStockBarcode
|
||||
const barcodeList = this.parseBarcodeInput(this.formData.barcodes);
|
||||
const targetStockId = recordId || this.extractSavedIdFromResponse(saveRes);
|
||||
if (targetStockId && barcodeList.length > 0) {
|
||||
const barcodeRes = await this.$http('stock.warehouse.saveWarehouseStockBarcode', {
|
||||
@ -1384,7 +1392,7 @@ export default {
|
||||
try {
|
||||
const refreshRes = await this.$http(
|
||||
'stock.warehouse.list',
|
||||
this.buildRefreshQuery(recordId, itemCode, storeId)
|
||||
this.buildRefreshQuery(recordId, saveItemCode, storeId)
|
||||
);
|
||||
if (refreshRes && Number(refreshRes.code) === 200) {
|
||||
latestItem = this.extractFirstListItem(refreshRes);
|
||||
@ -1405,7 +1413,7 @@ export default {
|
||||
product_name: itemName,
|
||||
name: itemName,
|
||||
goods_code: itemCode,
|
||||
item_code: itemCode,
|
||||
item_code: saveItemCode,
|
||||
barcodes: barcodeList,
|
||||
barcode: barcodeList[0] || (this.rawItem && this.rawItem.barcode) || '',
|
||||
brand_name: String(this.formData.brand_name || '').trim(),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user