diff --git a/App.vue b/App.vue
index f966503..664e51a 100644
--- a/App.vue
+++ b/App.vue
@@ -8,6 +8,7 @@ import IMSDK, {
import config from "./common/config";
import { getDbDir, toastWithCallback } from "@/util/common.js";
import { conversationSort } from "@/util/imCommon";
+import updateManager from "@/util/update.js";
import { PageEvents, UpdateMessageTypes } from "@/constant";
const openSdk = uni.requireNativePlugin('Tuoyun-OpenIMSDK');
const globalEvent = uni.requireNativePlugin('globalEvent');
@@ -15,11 +16,11 @@ const globalEvent = uni.requireNativePlugin('globalEvent');
export default {
onLaunch: function () {
console.log("App Launch");
- console.log(openSdk);
+ console.log(openSdk);
this.setGlobalIMlistener();
this.tryLogin();
// #ifdef APP-PLUS
- checkUpdate(); // 直接调用独立函数,避免this问题
+ updateManager.checkUpdate(); // 直接调用独立函数,避免this问题
// #endif
// #ifdef H5
console.error(
@@ -45,20 +46,20 @@ export default {
onShow: function () {
console.log("App Show");
IMSDK.asyncApi(IMSDK.IMMethods.SetAppBackgroundStatus, IMSDK.uuid(), false);
- //#ifdef APP-PLUS
- // var info = plus.push.getClientInfo()
- // plus.push.addEventListener("click", function(msg) {
- // console.log("click:" + JSON.stringify(msg));
- // console.log(msg.payload);
- // console.log(JSON.stringify(msg));
- // }, false);
- // // 监听在线消息事件
- // plus.push.addEventListener("receive", function(msg) {
- // //业务代码
- // console.log("recevice:" + JSON.stringify(msg))
- // }, false);
- //#endif
-
+ //#ifdef APP-PLUS
+ // var info = plus.push.getClientInfo()
+ // plus.push.addEventListener("click", function(msg) {
+ // console.log("click:" + JSON.stringify(msg));
+ // console.log(msg.payload);
+ // console.log(JSON.stringify(msg));
+ // }, false);
+ // // 监听在线消息事件
+ // plus.push.addEventListener("receive", function(msg) {
+ // //业务代码
+ // console.log("recevice:" + JSON.stringify(msg))
+ // }, false);
+ //#endif
+
},
onHide: function () {
@@ -498,245 +499,8 @@ export default {
},
};
-function checkUpdate(forceCheck = false) {
- const localVersion = plus.runtime.version;
- const localWgtVersion = uni.getStorageSync('wgtVersion') || localVersion;
- uni.request({
- url: 'http://47.117.71.33:11295/fadapp-update/version.json?t=' + Date.now(),
- success: (res) => {
- const remoteVersion = res.data.version;
- const wgtUrl = res.data.wgtUrl;
- // 取本地基座和本地wgt的最大版本
- 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: false,
- confirmText: '确定'
- });
- 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包安装成功');
- // 更新本地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 {
- // uni.showToast({title: '当前已是最新版本'});
- console.log('当前已是最新版本');
- }
- },
- fail: (error) => {
- console.error('检查更新失败:', error);
- uni.showToast({title: '网络异常,请稍后重试'});
- }
- });
-}
-function extractVersionNum(str) {
- // 匹配第一个出现的数字版本号
- const match = str.match(/(\d+\.\d+(?:\.\d+)?)/);
- return match ? match[1] : '0.0.0';
-}
-
-function compareVersion(v1, v2) {
- v1 = extractVersionNum(v1).split('.').map(Number);
- v2 = extractVersionNum(v2).split('.').map(Number);
- for (let i = 0; i < Math.max(v1.length, v2.length); i++) {
- const n1 = v1[i] || 0;
- const n2 = v2[i] || 0;
- if (n1 > n2) return 1;
- if (n1 < n2) return -1;
- }
- return 0;
-}
-
-// 更新管理工具函数
-function clearIgnoredVersion() {
- uni.removeStorageSync('ignoredVersion');
- console.log('已清除忽略的版本设置');
-}
-
-function getIgnoredVersion() {
- return uni.getStorageSync('ignoredVersion');
-}
-
-function setIgnoredVersion(version) {
- uni.setStorageSync('ignoredVersion', version);
- console.log('已设置忽略版本:', version);
-}
-
-// 检查版本兼容性
-function checkVersionCompatibility(wgtVersion, baseVersion) {
- console.log('检查版本兼容性:', { wgtVersion, baseVersion });
-
- // 提取主版本号进行比较
- const wgtMajor = extractVersionNum(wgtVersion).split('.')[0];
- const baseMajor = extractVersionNum(baseVersion).split('.')[0];
-
- // 主版本号必须匹配
- if (wgtMajor !== baseMajor) {
- console.warn('主版本号不匹配:', { wgtMajor, baseMajor });
- return false;
- }
-
- // 检查wgt版本是否高于基座版本
- if (compareVersion(wgtVersion, baseVersion) <= 0) {
- console.warn('wgt版本不高于基座版本');
- return false;
- }
-
- return true;
-}
-
-// 检查存储空间
-function checkStorageSpace() {
- return new Promise((resolve, reject) => {
- // #ifdef APP-PLUS
- if (typeof plus !== 'undefined' && plus.io) {
- plus.io.requestFileSystem(plus.io.PRIVATE_DOC, (fs) => {
- fs.root.getDirectory('temp', { create: true }, (dir) => {
- // 简单检查,实际项目中可能需要更复杂的空间检查
- resolve(true);
- }, (error) => {
- console.error('检查存储空间失败:', error);
- reject(error);
- });
- });
- } else {
- resolve(true);
- }
- // #endif
-
- // #ifndef APP-PLUS
- resolve(true);
- // #endif
- });
-}
-
// 导出更新管理函数供其他页面使用
-uni.$updateManager = {
- checkUpdate: (forceCheck = false) => checkUpdate(forceCheck),
- clearIgnoredVersion,
- getIgnoredVersion,
- setIgnoredVersion,
- checkVersionCompatibility,
- checkStorageSpace
-};
+uni.$updateManager = updateManager;
diff --git a/pages.json b/pages.json
index 73e6566..eddc4fb 100644
--- a/pages.json
+++ b/pages.json
@@ -349,6 +349,14 @@
"navigationBarTitleText" : "项目详情",
"navigationStyle": "default"
}
+ },
+ {
+ "path" : "pages/workbench/sales/sales",
+ "style" :
+ {
+ "navigationBarTitleText" : "线上营销",
+ "navigationStyle": "default"
+ }
}
],
"tabBar": {
diff --git a/pages/workbench/index/index.vue b/pages/workbench/index/index.vue
index 0c81569..36eebb1 100644
--- a/pages/workbench/index/index.vue
+++ b/pages/workbench/index/index.vue
@@ -6,34 +6,15 @@
-
-
- 每日报工
+
+
+ {{ item.text }}
-
-
- 施工进度
-
-
-
- 任务中心
-
-
-
- 项目排产
-
-
-
- 快递信息
-
-
-
- 项目中心
-
-
-
- 库存盘点
-
@@ -53,6 +34,52 @@ export default {
// 页面加载时调用getUserProfile
this.fetchUserProfile();
},
+ data() {
+ return {
+ entryList: [
+ {
+ text: '每日报工',
+ icon: '/static/images/baogong.png',
+ url: '/pages/workbench/reportWork/reportWork',
+ },
+ {
+ text: '施工进度',
+ icon: '/static/images/shigong.png',
+ url: '/pages/workbench/construction/construction',
+ },
+ {
+ text: '任务中心',
+ icon: '/static/images/task.png',
+ url: '/pages/workbench/task/task',
+ },
+ {
+ text: '项目排产',
+ icon: '/static/images/paichan.png',
+ url: '/pages/workbench/reportSchedule/reportSchedule',
+ },
+ {
+ text: '快递信息',
+ icon: '/static/images/express.svg',
+ url: '/pages/workbench/express/express',
+ },
+ {
+ text: '项目中心',
+ icon: '/static/images/project.png',
+ url: '/pages/workbench/project/project',
+ },
+ {
+ text: '库存盘点',
+ icon: '/static/images/stock.png',
+ url: '/pages/workbench/wms/wms',
+ },
+ {
+ text: '线上营销',
+ icon: '/static/images/yingxiao.png',
+ url: '/pages/workbench/sales/sales',
+ },
+ ],
+ };
+ },
methods: {
// 获取用户个人信息
async fetchUserProfile() {
@@ -66,41 +93,11 @@ export default {
console.error('获取用户个人信息失败:', error);
}
},
- goReportWork() {
- uni.navigateTo({
- url: '/pages/workbench/reportWork/reportWork'
- });
+ handleEntryClick(item) {
+ if (item.url) {
+ uni.navigateTo({ url: item.url });
+ }
},
- goConstruction() {
- uni.navigateTo({
- url: '/pages/workbench/construction/construction'
- });
- },
- goTask() {
- uni.navigateTo({
- url: '/pages/workbench/task/task'
- })
- },
- goSchedule() {
- uni.navigateTo({
- url: '/pages/workbench/reportSchedule/reportSchedule'
- })
- },
- goExpress() {
- uni.navigateTo({
- url: '/pages/workbench/express/express'
- })
- },
- goProject() {
- uni.navigateTo({
- url: '/pages/workbench/project/project'
- })
- },
- goStock() {
- uni.navigateTo({
- url: '/pages/workbench/wms/wms'
- })
- }
},
};
diff --git a/pages/workbench/sales/sales.vue b/pages/workbench/sales/sales.vue
new file mode 100644
index 0000000..1a49359
--- /dev/null
+++ b/pages/workbench/sales/sales.vue
@@ -0,0 +1,37 @@
+
+
+
+
+ 已选择文件:{{ fileInfo.name }}
+
+
+
+
+
+
+
+
diff --git a/static/images/yingxiao.png b/static/images/yingxiao.png
new file mode 100644
index 0000000..70b0445
Binary files /dev/null and b/static/images/yingxiao.png differ
diff --git a/util/update.js b/util/update.js
new file mode 100644
index 0000000..f2201eb
--- /dev/null
+++ b/util/update.js
@@ -0,0 +1,232 @@
+
+// 匹配第一个出现的数字版本号
+function extractVersionNum(str) {
+ const match = str.match(/(\d+\.\d+(?:\.\d+)?)/);
+ return match ? match[1] : '0.0.0';
+}
+
+function compareVersion(v1, v2) {
+ v1 = extractVersionNum(v1).split('.').map(Number);
+ v2 = extractVersionNum(v2).split('.').map(Number);
+ for (let i = 0; i < Math.max(v1.length, v2.length); i++) {
+ const n1 = v1[i] || 0;
+ const n2 = v2[i] || 0;
+ if (n1 > n2) return 1;
+ if (n1 < n2) return -1;
+ }
+ return 0;
+}
+
+function clearIgnoredVersion() {
+ uni.removeStorageSync('ignoredVersion');
+ console.log('已清除忽略的版本设置');
+}
+
+function getIgnoredVersion() {
+ return uni.getStorageSync('ignoredVersion');
+}
+
+function setIgnoredVersion(version) {
+ uni.setStorageSync('ignoredVersion', version);
+ console.log('已设置忽略版本:', version);
+}
+
+function checkVersionCompatibility(wgtVersion, baseVersion) {
+ console.log('检查版本兼容性:', { wgtVersion, baseVersion });
+ const wgtMajor = extractVersionNum(wgtVersion).split('.')[0];
+ const baseMajor = extractVersionNum(baseVersion).split('.')[0];
+ if (wgtMajor !== baseMajor) {
+ console.warn('主版本号不匹配:', { wgtMajor, baseMajor });
+ return false;
+ }
+ if (compareVersion(wgtVersion, baseVersion) <= 0) {
+ console.warn('wgt版本不高于基座版本');
+ return false;
+ }
+ return true;
+}
+
+function checkStorageSpace() {
+ return new Promise((resolve, reject) => {
+ // #ifdef APP-PLUS
+ if (typeof plus !== 'undefined' && plus.io) {
+ plus.io.requestFileSystem(plus.io.PRIVATE_DOC, (fs) => {
+ fs.root.getDirectory('temp', { create: true }, (dir) => {
+ resolve(true);
+ }, (error) => {
+ console.error('检查存储空间失败:', error);
+ reject(error);
+ });
+ });
+ } else {
+ resolve(true);
+ }
+ // #endif
+ // #ifndef APP-PLUS
+ resolve(true);
+ // #endif
+ });
+}
+
+function checkUpdate(forceCheck = false) {
+ const localVersion = plus.runtime.version;
+ const localWgtVersion = uni.getStorageSync('wgtVersion') || localVersion;
+ uni.request({
+ url: 'http://47.117.71.33:11295/fadapp-update/version.json?t=' + Date.now(),
+ success: (res) => {
+ const remoteVersion = res.data.version;
+ 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 = `http://47.117.71.33:11295/fadapp-update/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: '网络异常,请稍后重试'});
+ }
+ });
+}
+
+export default {
+ checkUpdate,
+ clearIgnoredVersion,
+ getIgnoredVersion,
+ setIgnoredVersion,
+ checkVersionCompatibility,
+ checkStorageSpace,
+ compareVersion,
+ extractVersionNum
+};
diff --git a/version.md b/version.md
new file mode 100644
index 0000000..6e997dd
--- /dev/null
+++ b/version.md
@@ -0,0 +1,5 @@
+## 4.5.1
++ 开始记录版本
++ 增加版本不兼容时可以从浏览器下载安装包的功能
++ 优化部分页面功能
++ 增加线上销售页面
\ No newline at end of file