【GFRS-3645】解决当点击页面刷新时,vue的store数据丢失问题

This commit is contained in:
liu.xiaofeng@ebiz-digits.com
2023-08-10 14:42:19 +08:00
parent 005630da8c
commit fc3ec41ea0
2 changed files with 15 additions and 5 deletions

View File

@@ -26,6 +26,16 @@ export default {
reload: this.reload
}
},
created () {
// 在页面加载时读取sessionStorage
if (sessionStorage.getItem('store')) {
this.$store.replaceState(Object.assign({}, this.$store.state, JSON.parse(sessionStorage.getItem('store'))))
}
// 在页面刷新时将store保存到sessionStorage里
window.addEventListener('beforeunload', () => {
sessionStorage.setItem('store', JSON.stringify(this.$store.state))
})
},
mounted(){
},
methods: {

View File

@@ -12,7 +12,7 @@
<div class='pt30 pl30 flex align-items-c'>
<span class='mr10'>投保人签名 :</span>
<van-button type='danger' size='small' :disabled="signBtnDisable" @click="sign" v-no-more-click='1000'>
{{signInfo.status == '0' ? '签名' : '已签名' }}
{{signInfo.status == '1' ? '签名' : '已签名' }}
</van-button>
</div>
<div class='bg-white bottom-btn'>
@@ -40,7 +40,7 @@
isDisabledComplite:true,
isOver: false,
signInfo: {
status: '0'
status: '1'
},
}
},
@@ -64,9 +64,9 @@
if(res.result == 0){
this.pdfUrl = config.assetsUpUrl + res.content.rgssUrl
let signInfo = JSON.parse(localStorage.getItem('signInfo'))
if (signInfo && signInfo.status == '0') {
if (signInfo && signInfo.status == '1') {
this.base64 = sessionStorage.getItem('twoimgBase64Data')
this.$set(this.signInfo, 'status', '1')
this.$set(this.signInfo, 'status', '2')
}
}else{
this.$toast(res.resultMessage)
@@ -141,7 +141,7 @@
} else {
that.signBtnDisable = true
}
if (that.radio == '1' && val.signInfo.status == '1') {
if (that.radio == '1' && val.signInfo.status == '2') {
that.isDisabledComplite = false
} else {
that.isDisabledComplite = true