Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
take_order
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
和慭琛
take_order
Commits
fee2dee1
Commit
fee2dee1
authored
May 12, 2021
by
Damon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
请求更新逻辑
parent
ac2fe61f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
7 deletions
+27
-7
App.vue
take-order/App.vue
+6
-3
index.vue
take-order/pages/photo/index.vue
+16
-0
list.vue
take-order/pages/photo/list.vue
+5
-4
No files found.
take-order/App.vue
View file @
fee2dee1
...
@@ -8,7 +8,7 @@ import {
...
@@ -8,7 +8,7 @@ import {
AnalysysAgent
AnalysysAgent
}
from
'@/utils/analysys_paas.js'
}
from
'@/utils/analysys_paas.js'
import
util
from
'@/utils/util.js'
import
util
from
'@/utils/util.js'
import
cache
from
'@/common/cache.js'
export
default
{
export
default
{
globalData
:
{
globalData
:
{
...
@@ -123,7 +123,8 @@ export default {
...
@@ -123,7 +123,8 @@ export default {
}
}
},
},
// 用户信息
// 用户信息
tempUserInfo
:
''
,
// 临时用户选项
tempUserInfo
:
''
,
// 临时用户选项
cacheUpdate
:
false
,
// 是否更新缓存
},
},
onLaunch
:
function
()
{
onLaunch
:
function
()
{
...
@@ -185,7 +186,9 @@ export default {
...
@@ -185,7 +186,9 @@ export default {
content
:
'新版本已经准备好,是否重启应用?'
,
content
:
'新版本已经准备好,是否重启应用?'
,
success
(
res
)
{
success
(
res
)
{
if
(
res
.
confirm
)
{
if
(
res
.
confirm
)
{
uni
.
clearStorageSync
()
// 清空本地缓存
const
version
=
cache
.
getCache
(
'version'
)
uni
.
clearStorageSync
()
// 清空本地缓存
cache
.
setCache
(
'version'
,
version
)
// 保存图片更新的版本号
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager
.
applyUpdate
()
updateManager
.
applyUpdate
()
}
}
...
...
take-order/pages/photo/index.vue
View file @
fee2dee1
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
</template>
</template>
<
script
>
<
script
>
import
cache
from
'../../common/cache.js'
export
default
{
export
default
{
data
()
{
data
()
{
return
{
return
{
...
@@ -68,6 +69,7 @@
...
@@ -68,6 +69,7 @@
},
},
onLoad
(
e
)
{
onLoad
(
e
)
{
getApp
().
trackPage
(
'选择产品页'
)
getApp
().
trackPage
(
'选择产品页'
)
this
.
getPhotoUpdate
()
this
.
getRelationDictionaryV2
()
this
.
getRelationDictionaryV2
()
},
},
onShareAppMessage
(
res
)
{
onShareAppMessage
(
res
)
{
...
@@ -81,6 +83,20 @@
...
@@ -81,6 +83,20 @@
return
shareObj
return
shareObj
},
},
methods
:
{
methods
:
{
getPhotoUpdate
:
function
()
{
const
globalData
=
getApp
().
globalData
const
version
=
cache
.
getCache
(
'version'
)
this
.
$u
.
cloudApi
.
isUpdateImageCache
({
version
:
version
||
0
}).
then
(
res
=>
{
if
(
res
.
result
)
{
if
(
!
version
)
{
cache
.
setCache
(
'version'
,
1
)
}
else
{
cache
.
setCache
(
'version'
,
parseInt
(
version
)
+
1
)
}
globalData
.
cacheUpdate
=
true
}
})
},
getRelationDictionaryV2
:
function
()
{
getRelationDictionaryV2
:
function
()
{
this
.
$u
.
cloudApi
.
getRelationDictionaryV2
().
then
(
res
=>
{
this
.
$u
.
cloudApi
.
getRelationDictionaryV2
().
then
(
res
=>
{
if
(
res
&&
res
.
result
)
{
if
(
res
&&
res
.
result
)
{
...
...
take-order/pages/photo/list.vue
View file @
fee2dee1
...
@@ -140,19 +140,20 @@
...
@@ -140,19 +140,20 @@
},
},
methods
:
{
methods
:
{
checkData
:
function
()
{
checkData
:
function
()
{
const
checkResult
=
cache
.
checkCache
(
this
.
systemId
)
const
checkResult
=
cache
.
checkCache
(
this
.
systemId
)
// 没有缓存数据则请求
if
(
!
checkResult
)
{
if
(
!
checkResult
)
{
this
.
getListData
()
this
.
getListData
()
return
return
}
}
const
data
=
cache
.
getCache
(
this
.
systemId
)
const
data
=
cache
.
getCache
(
this
.
systemId
)
const
validityTime
=
3600000
*
24
*
30
// 30天重新获取一次最新规范
const
globalData
=
getApp
().
globalData
this
.
loading
=
false
if
(
!
globalData
.
cacheUpdate
)
{
// 无需更新,读取缓存
if
(
data
.
loadTime
-
Date
.
now
()
<
validityTime
)
{
// 有效期内,读取缓存
this
.
loading
=
false
this
.
handleData
(
data
.
result
)
this
.
handleData
(
data
.
result
)
}
else
{
}
else
{
globalData
.
cacheUpdate
=
false
// 重置更新
this
.
getListData
()
this
.
getListData
()
}
}
...
...
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