Browse Source

网络更新判断

zaijin 3 years ago
parent
commit
2422e1c290
3 changed files with 31 additions and 14 deletions
  1. 28 11
      App.vue
  2. 2 2
      common/config.js
  3. 1 1
      vue.config.js

+ 28 - 11
App.vue

@@ -25,17 +25,35 @@
 				}).then(res => {
 					if (res.code === 200) {
 						if (res.msg !== config.version) {
-							uni.showModal({
-								title: '版本发布更新',
-								content: '发现新版本,请进行更新',
-								confirmText: '更新',
-								confirmColor: '#EE8F57',
-								success: (res) => {
-									if (res.confirm) {
-										this.downloadAppFile()
+							uni.getNetworkType({
+								success: function (res) {
+									if (res.networkType === 'wifi') {
+										uni.showModal({
+											title: '版本发布更新',
+											content: '发现新版本且您使用的是无限网络,是否进行更新?',
+											confirmText: '更新',
+											confirmColor: '#EE8F57',
+											success: (res) => {
+												if (res.confirm) {
+													this.downloadAppFile()
+												}
+											}
+										})
+									} else {
+										uni.showModal({
+											title: '版本发布更新',
+											content: '发现新版本,是否继续消耗流量进行更新?',
+											confirmText: '更新',
+											confirmColor: '#EE8F57',
+											success: (res) => {
+												if (res.confirm) {
+													this.downloadAppFile()
+												}
+											}
+										})
 									}
 								}
-							})
+							});
 						}
 					}
 				})
@@ -68,7 +86,7 @@
 						if (downloadResult.statusCode === 200) {
 							uni.showModal({
 								title: '',
-								content: '下载成功,确定现在更新吗?',
+								content: '下载成功,确定现在安装吗?',
 								confirmText: '安装',
 								confirmColor: '#EE8F57',
 								success: function(res) {
@@ -108,7 +126,6 @@
 </script>
 
 <style lang="scss">
-	/*每个页面公共css */
 	/*每个页面公共css */
 	@import "@/uni_modules/uview-ui/index.scss";
 </style>

+ 2 - 2
common/config.js

@@ -1,8 +1,8 @@
-let baseUrl = 'http://wx.hw.hongweisoft.com/parking/'
+let baseUrl = 'https://wx.hw.hongweisoft.com/parking/'
 if (process.env.NODE_ENV === 'development') {
 	baseUrl = '/api'
 }
 export const config = {
 	baseUrl,
-	version: '0.1.6'
+	version: '0.1.7'
 }

+ 1 - 1
vue.config.js

@@ -4,7 +4,7 @@ module.exports = {
 		disableHostCheck:true,
 		proxy:{
 			'/api':{
-				target: 'http://wx.hw.hongweisoft.com/parking/',
+				target: 'https://wx.hw.hongweisoft.com/parking/',
 				changeOrigin: true,
 				pathRewrite:{
 					'^/api': ''