Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
XAMJW-Hospita
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wechatminiprogram
XAMJW-Hospita
Commits
7b5f3d67
Commit
7b5f3d67
authored
Oct 19, 2021
by
chenzhenan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
强制更新
parent
7ca97388
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
6 deletions
+47
-6
app.js
+39
-1
pages/index/index.js
+1
-1
project.config.json
+7
-4
No files found.
app.js
View file @
7b5f3d67
...
...
@@ -155,5 +155,42 @@ App({
// })
// }
}
},
onShow
(){
this
.
checkUpdateVersion
()
},
checkUpdateVersion
()
{
//判断微信版本是否 兼容小程序更新机制API的使用
if
(
wx
.
canIUse
(
'getUpdateManager'
))
{
//创建 UpdateManager 实例
const
updateManager
=
wx
.
getUpdateManager
();
console
.
log
(
'是否进入模拟更新'
);
//检测版本更新
updateManager
.
onCheckForUpdate
(
function
(
res
)
{
console
.
log
(
'是否获取版本'
,
res
);
// 请求完新版本信息的回调
if
(
res
.
hasUpdate
)
{
console
.
log
(
'是否有版本'
);
//监听小程序有版本更新事件
updateManager
.
onUpdateReady
(
function
()
{
//TODO 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 ( 此处进行了自动更新操作)
updateManager
.
applyUpdate
();
})
updateManager
.
onUpdateFailed
(
function
()
{
// 新版本下载失败
wx
.
showModal
({
title
:
'已经有新版本喽~'
,
content
:
'请您删除当前小程序,到微信 “发现-小程序” 页,重新搜索打开哦~'
,
})
})
}
})
}
else
{
//TODO 此时微信版本太低(一般而言版本都是支持的)
wx
.
showModal
({
title
:
'溫馨提示'
,
content
:
'当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
})
}
},
})
\ No newline at end of file
pages/index/index.js
View file @
7b5f3d67
...
...
@@ -33,7 +33,7 @@ Page({
otype
:
false
},
onLoad
:
function
(
options
)
{
this
.
checkUpdateVersion
()
//
this.checkUpdateVersion()
var
that
=
this
;
// var fenxiang = options.fenxiang;
var
userInfo
=
wx
.
getStorageSync
(
'userInfo'
)
...
...
project.config.json
View file @
7b5f3d67
...
...
@@ -21,9 +21,10 @@
"checkSiteMap"
:
true
,
"uploadWithSourceMap"
:
true
,
"compileHotReLoad"
:
false
,
"lazyloadPlaceholderEnable"
:
false
,
"useMultiFrameRuntime"
:
true
,
"useApiHook"
:
true
,
"useApiHostProcess"
:
fals
e
,
"useApiHostProcess"
:
tru
e
,
"babelSetting"
:
{
"ignore"
:
[],
"disablePlugins"
:
[],
...
...
@@ -31,12 +32,14 @@
},
"enableEngineNative"
:
false
,
"useIsolateContext"
:
true
,
"useCompilerModule"
:
true
,
"userConfirmedUseCompilerModuleSwitch"
:
false
,
"userConfirmedBundleSwitch"
:
false
,
"packNpmManually"
:
false
,
"packNpmRelationList"
:
[],
"minifyWXSS"
:
true
"minifyWXSS"
:
true
,
"disableUseStrict"
:
false
,
"showES6CompileOption"
:
false
,
"useCompilerPlugins"
:
false
,
"minifyWXML"
:
true
},
"compileType"
:
"miniprogram"
,
"libVersion"
:
"2.17.0"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment