Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
custom_form
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
hookehuyr
2023-04-17 16:01:34 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
cca3afa97dd70e606481e0db5782dc46a6571248
cca3afa9
1 parent
c69c6d76
fix 小程序更新检查
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
10 deletions
src/app.js
src/pages/index/index.vue
src/app.js
View file @
cca3afa
/*
* @Date: 2023-03-23 11:17:54
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2023-0
3-24 16:04:21
* @LastEditTime: 2023-0
4-17 16:01:15
* @FilePath: /custom_form/src/app.js
* @Description: 文件描述
*/
...
...
@@ -19,15 +19,15 @@ const App = createApp({
const
code
=
getUrlParams
(
location
.
href
)
?
getUrlParams
(
location
.
href
).
code
:
''
const
store
=
mainStore
()
;
const
store
=
mainStore
()
// 数据收集设置
const
{
data
}
=
await
getFormSettingAPI
({
form_code
:
code
})
;
const
form_setting
=
{}
;
const
{
data
}
=
await
getFormSettingAPI
({
form_code
:
code
})
const
form_setting
=
{}
if
(
data
.
length
)
{
Object
.
assign
(
form_setting
,
data
[
0
][
'property_list'
],
data
[
0
][
'extend'
])
;
Object
.
assign
(
form_setting
,
data
[
0
][
'property_list'
],
data
[
0
][
'extend'
])
}
// 缓存表单设置
store
.
changeFormSetting
(
form_setting
)
;
store
.
changeFormSetting
(
form_setting
)
}
},
...
...
@@ -46,11 +46,10 @@ const App = createApp({
},
// 对应 onShow
onShow
(
options
)
{
},
onShow
(
options
)
{},
// 对应 onHide
onHide
()
{
},
onHide
()
{},
// 入口组件不需要实现 render 方法,即使实现了也会被 taro 所覆盖
})
...
...
src/pages/index/index.vue
View file @
cca3afa
...
...
@@ -16,7 +16,7 @@ import { apiList } from '@/api/wx/jsApiList.js'
import { styleColor } from "@/constant.js";
import { mainStore } from '@/stores'
import { getFormSettingAPI } from '@/api/form.js'
import Taro from '@tarojs/taro'
import Taro
, { useReady }
from '@tarojs/taro'
// TAG: 自定义主题颜色
const themeVars = {
...
...
@@ -114,6 +114,47 @@ onMounted(async () => {
})
});
// 对应 onReady
useReady(() => {
if (!Taro.canIUse('getUpdateManager')) {
Taro.showModal({
title: '提示',
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试',
showCancel: false,
})
return
}
// https://developers.weixin.qq.com/miniprogram/dev/api/base/update/UpdateManager.html
const updateManager = Taro.getUpdateManager()
updateManager.onCheckForUpdate((res) => {
// 请求完新版本信息的回调
if (res.hasUpdate) {
updateManager.onUpdateReady(function () {
Taro.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success: function (res) {
if (res.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate()
}
},
})
})
updateManager.onUpdateFailed(function () {
// 新版本下载失败
Taro.showModal({
title: '更新提示',
content: '新版本已上线,请删除当前小程序,重新搜索打开',
})
})
}
})
})
</script>
<style lang="less">
...
...
Please
register
or
login
to post a comment