diff --git a/App.vue b/App.vue index c0b2923..8221163 100644 --- a/App.vue +++ b/App.vue @@ -78,6 +78,7 @@ // #ifdef APP-PLUS //初始化uniMP小程序发送的事件以及其他操作 initEvent(); + this.$store.dispatch('INIT_CONFIG'); // #endif //#ifdef APP-PLUS diff --git a/api/user.js b/api/user.js index 86d32b2..4dd6776 100644 --- a/api/user.js +++ b/api/user.js @@ -8,7 +8,15 @@ // | Author: CRMEB Team // +---------------------------------------------------------------------- import request from "@/utils/request.js"; -import Cache from '@/utils/cache' +import Cache from '@/utils/cache'; +/** + * 获取版本信息 + */ +export function Appversion(data) { + return request.get(`app/version`, data, { + noAuth: true + }); +} /** * 获取用户信息 * diff --git a/pages/users/order_confirm/index.vue b/pages/users/order_confirm/index.vue index 19b972c..f8f9fb9 100644 --- a/pages/users/order_confirm/index.vue +++ b/pages/users/order_confirm/index.vue @@ -191,7 +191,7 @@ - + @@ -1679,6 +1679,7 @@ }); } } + this.order_form = []; // 取消表单 for (var i = 0; i < that.order_form.length; i++) { let curdata = that.order_form[i] if (['radios'].indexOf(curdata.name) == -1 && (curdata.titleShow.val || (['uploadPicture', diff --git a/store/modules/app.js b/store/modules/app.js index 59003fe..7d8e6fd 100644 --- a/store/modules/app.js +++ b/store/modules/app.js @@ -8,7 +8,8 @@ // | Author: CRMEB Team // +---------------------------------------------------------------------- import { - getUserInfo + getUserInfo, + Appversion } from "../../api/user.js"; import { LOGIN_STATUS, @@ -114,7 +115,81 @@ const actions = { }).catch(() => { }); - } + }, + async INIT_CONFIG({ + state, + commit + }, data = false) { + if(data) { + uni.showLoading({ + title: '加载中' + }) + await uni.$u.sleep(500) + } + const wgt_v = uni.getStorageSync('wgt_version') || '1.0.0'; + // #ifdef APP-PLUS + let os = uni.getSystemInfoSync(); + let apptype; + if (os.osName == 'ios') { + apptype = 2 + } else { + apptype = 1 + } + console.log({ + version: os.appWgtVersion, + type: apptype, + phone_brand:os.brand + }); + Appversion({ + version: os.appWgtVersion, + type: apptype, + phone_brand:os.brand + }).then((res) => { + console.log(res); + if(data) uni.hideLoading() + if (Object.keys(res.data.appInfo).length > 0) { + // if(res.data.appInfo.version) uni.showLoading({ + // title: '检查更新中' + // }) + // 版本更新 + if (compareVersions(res.data.appInfo.version, os.appWgtVersion || wgt_v) == 1 && + compareVersions(res.data.appInfo.version, + wgt_v) == 1) { + try { + let info = res.data.appInfo || {}; + let version = { + title: info.title || '发现新版本', + content: info.content || '修复了部分BUG', + versionName: info.version || '1.0.1', + brand:res.data.appInfo.phone_brand, + downUrl: info.dow_url || '', + force: info.force == 1 ? true : false, // 是否强制更新 + quiet: info.quiet == 1 ? true : false // 是否静默更新 + } + + Updater.update(version,res.data.appInfo); + } catch (e) { + console.log(e); + Toast(e) + } + // uni.hideLoading(); + } + else { + if(data) Toast('已经是最新版本了') + } + + } else { + if(data) Toast('已经是最新版本了') + } + }).catch((err) => { + if(data) uni.hideLoading() + Toast(err.msg||err.message||err) + // console.log(err) + }) + + + // #endif + } }; export default {