Kaynağa Gözat

版本重启问题

shish 5 yıl önce
ebeveyn
işleme
85fafd92a4
3 değiştirilmiş dosya ile 92 ekleme ve 45 silme
  1. 32 15
      ghsApp/src/utils/auth.js
  2. 30 15
      hdApp/src/utils/auth.js
  3. 30 15
      mallApp/src/utils/auth.js

+ 32 - 15
ghsApp/src/utils/auth.js

@@ -118,27 +118,44 @@ export async function wxLoginFn(update) {
 
 
 					//启动更新逻辑 shish 2020.5.18
 					//启动更新逻辑 shish 2020.5.18
 					if (subRes.data.update == 1) {
 					if (subRes.data.update == 1) {
-						const updateManager = wx.getUpdateManager()
-						console.log('请求完新版本信息的回调')
-						updateManager.onCheckForUpdate(function (res) {
+
+						
+						const updateManager = uni.getUpdateManager();
+						updateManager.onCheckForUpdate(function(res) {
 							// 请求完新版本信息的回调
 							// 请求完新版本信息的回调
-							console.log(res.hasUpdate)
-						})
-						updateManager.onUpdateReady(function () {
-							wx.showModal({
-								title: '更新提示',
-								content: '新版本已经准备好,是否重启应用?',
+							if (res.hasUpdate) {
+								updateManager.onUpdateReady(function(res2) {
+									uni.showModal({
+										title: '更新提示',
+										content: '发现新版本,请重启应用',
+										cancelColor:'#eeeeee',
+										confirmColor:'#FF0000',
+										success(res2) {
+											if (res2.confirm) {
+												// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
+												updateManager.applyUpdate();
+											}
+										}
+									});
+								});
+							}
+						});
+			
+						updateManager.onUpdateFailed(function(res) {
+							// 新的版本下载失败
+							uni.showModal({
+								title: '提示',
+								content: '检查到有新版本,但下载失败,请检查网络连接',
 								success(res) {
 								success(res) {
 									if (res.confirm) {
 									if (res.confirm) {
 										// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
 										// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
-										updateManager.applyUpdate()
+										updateManager.applyUpdate();
 									}
 									}
 								}
 								}
-							})
-						})
-						updateManager.onUpdateFailed(function () {
-							// 新版本下载失败
-						})
+							});
+						});
+
+
 					}
 					}
 
 
 				})
 				})

+ 30 - 15
hdApp/src/utils/auth.js

@@ -118,27 +118,42 @@ export async function wxLoginFn(update) {
 
 
 					//启动更新逻辑 shish 2020.5.18
 					//启动更新逻辑 shish 2020.5.18
 					if (subRes.data.update == 1) {
 					if (subRes.data.update == 1) {
-						const updateManager = wx.getUpdateManager()
-						console.log('请求完新版本信息的回调')
-						updateManager.onCheckForUpdate(function (res) {
+
+						const updateManager = uni.getUpdateManager();
+						updateManager.onCheckForUpdate(function(res) {
 							// 请求完新版本信息的回调
 							// 请求完新版本信息的回调
-							console.log(res.hasUpdate)
-						})
-						updateManager.onUpdateReady(function () {
-							wx.showModal({
-								title: '更新提示',
-								content: '新版本已经准备好,是否重启应用?',
+							if (res.hasUpdate) {
+								updateManager.onUpdateReady(function(res2) {
+									uni.showModal({
+										title: '更新提示',
+										content: '发现新版本,请重启应用',
+										cancelColor:'#eeeeee',
+										confirmColor:'#FF0000',
+										success(res2) {
+											if (res2.confirm) {
+												// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
+												updateManager.applyUpdate();
+											}
+										}
+									});
+								});
+							}
+						});
+			
+						updateManager.onUpdateFailed(function(res) {
+							// 新的版本下载失败
+							uni.showModal({
+								title: '提示',
+								content: '检查到有新版本,但下载失败,请检查网络连接',
 								success(res) {
 								success(res) {
 									if (res.confirm) {
 									if (res.confirm) {
 										// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
 										// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
-										updateManager.applyUpdate()
+										updateManager.applyUpdate();
 									}
 									}
 								}
 								}
-							})
-						})
-						updateManager.onUpdateFailed(function () {
-							// 新版本下载失败
-						})
+							});
+						});
+
 					}
 					}
 
 
 				})
 				})

+ 30 - 15
mallApp/src/utils/auth.js

@@ -98,27 +98,42 @@ export async function wxLoginFn(update) {
 
 
         //启动更新逻辑 shish 2020.5.18
         //启动更新逻辑 shish 2020.5.18
 		if (subRes.data.update == 1) {
 		if (subRes.data.update == 1) {
-			const updateManager = wx.getUpdateManager()
-			console.log('请求完新版本信息的回调')
-			updateManager.onCheckForUpdate(function (res) {
+
+			const updateManager = uni.getUpdateManager();
+			updateManager.onCheckForUpdate(function(res) {
 				// 请求完新版本信息的回调
 				// 请求完新版本信息的回调
-				console.log(res.hasUpdate)
-			})
-			updateManager.onUpdateReady(function () {
-				wx.showModal({
-					title: '更新提示',
-					content: '新版本已经准备好,是否重启应用?',
+				if (res.hasUpdate) {
+					updateManager.onUpdateReady(function(res2) {
+						uni.showModal({
+							title: '更新提示',
+							content: '发现新版本,请重启应用',
+							cancelColor:'#eeeeee',
+							confirmColor:'#FF0000',
+							success(res2) {
+								if (res2.confirm) {
+									// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
+									updateManager.applyUpdate();
+								}
+							}
+						});
+					});
+				}
+			});
+
+			updateManager.onUpdateFailed(function(res) {
+				// 新的版本下载失败
+				uni.showModal({
+					title: '提示',
+					content: '检查到有新版本,但下载失败,请检查网络连接',
 					success(res) {
 					success(res) {
 						if (res.confirm) {
 						if (res.confirm) {
 							// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
 							// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
-							updateManager.applyUpdate()
+							updateManager.applyUpdate();
 						}
 						}
 					}
 					}
-				})
-			})
-			updateManager.onUpdateFailed(function () {
-				// 新版本下载失败
-			})
+				});
+			});
+
 		}
 		}
 	})
 	})