提交 24cd96ca authored 作者: 王鹏飞's avatar 王鹏飞

签名修改

上级 c6ded5f3
<template> <template>
<div style="height: 100%; width: 100%"> <div style="height: 100%; width: 100%">
<router-view></router-view> <router-view></router-view>
<el-dialog
:title="$t('components.learnSysLayout.navigation.dialogTitle')"
:width="dialogWidth"
:visible.sync="dialogVisible"
:center="true"
:append-to-body="true"
:close-on-click-modal="false"
:close-on-press-escape="false"
@closed="handleClose"
>
<div class="sign">
<p>
{{ $t('components.learnSysLayout.navigation.dialogMessage1')
}}<a :href="$t('components.learnSysLayout.navigation.dialogMessageHref')" target="_blank">{{
$t('components.learnSysLayout.navigation.dialogMessage2')
}}</a
>{{ $t('components.learnSysLayout.navigation.dialogMessage3') }}
</p>
<el-checkbox v-model="checked">{{ $t('components.learnSysLayout.navigation.dialogCheckbox') }}</el-checkbox>
</div>
<template #footer>
<el-button type="primary" :disabled="!checked" @click="handlePrimary">{{
$t('components.learnSysLayout.navigation.dialogButton')
}}</el-button>
</template>
</el-dialog>
</div> </div>
</template> </template>
<script>
import cAction from '@/action'
export default {
data() {
const UA = navigator.userAgent
return {
isMobile: /iphone/i.test(UA) || (/android/i.test(UA) && /mobile/i.test(UA)),
dialogVisible: false,
checked: false,
sign: {},
documentUrl: '',
timer: null
}
},
computed: {
dialogWidth() {
return this.isMobile ? '90%' : '460px'
}
},
methods: {
createSign() {
cAction.Other.createSign().then(response => {
const { code, data } = response
if (code === 1) {
this.sign = data
this.getSignDocument(data.flowid).then(() => {
if (!this.documentUrl) {
this.dialogVisible = true
}
})
} else {
this.$message.error('处理签名失败')
}
})
},
getSignDocument(flowid) {
return cAction.Other.getSignDocument({ flowid }).then(response => {
const { code, data } = response
if (code === 1) {
this.documentUrl = data.url
this.$store.commit('updateDocumentUrl', data.url)
}
return response
})
},
setTimer() {
this.timer = setInterval(() => {
this.getSignDocument(this.sign.flowid).then(response => {
if (response.code === 1) {
this.clearTimer()
this.dialogVisible = false
} else {
this.dialogVisible = true
}
})
}, 5000)
},
clearTimer() {
this.timer && clearInterval(this.timer)
},
handlePrimary() {
this.setTimer()
this.newWindowPreview(this.sign.shortUrl)
},
handleClose() {
if (!this.documentUrl) {
window.location.href = webConf.others.loginUrl
}
},
// 新窗口预览
newWindowPreview(url) {
const a = document.createElement('a')
a.href = url
a.target = '_blank'
document.body.appendChild(a)
a.click()
a.remove()
}
},
beforeMount() {
this.createSign()
},
destroyed() {
this.clearTimer()
}
}
</script>
<style lang="scss" scoped>
.sign {
p {
text-indent: 2em;
line-height: 24px;
}
}
</style>
...@@ -15,32 +15,6 @@ ...@@ -15,32 +15,6 @@
</div> </div>
<language-switch /> <language-switch />
</div> </div>
<el-dialog
:title="$t('components.learnSysLayout.navigation.dialogTitle')"
width="460px"
:visible.sync="dialogVisible"
:center="true"
:append-to-body="true"
:close-on-click-modal="false"
:close-on-press-escape="false"
@closed="handleClose"
>
<div class="sign">
<p>
{{ $t('components.learnSysLayout.navigation.dialogMessage1')
}}<a :href="$t('components.learnSysLayout.navigation.dialogMessageHref')" target="_blank">{{
$t('components.learnSysLayout.navigation.dialogMessage2')
}}</a
>{{ $t('components.learnSysLayout.navigation.dialogMessage3') }}
</p>
<el-checkbox v-model="checked">{{ $t('components.learnSysLayout.navigation.dialogCheckbox') }}</el-checkbox>
</div>
<template #footer>
<el-button type="primary" :disabled="!checked" @click="handlePrimary">{{
$t('components.learnSysLayout.navigation.dialogButton')
}}</el-button>
</template>
</el-dialog>
</div> </div>
</template> </template>
...@@ -52,12 +26,12 @@ export default { ...@@ -52,12 +26,12 @@ export default {
components: { LanguageSwitch }, components: { LanguageSwitch },
data() { data() {
return { return {
num: this.$store.getters.myMsg, num: this.$store.getters.myMsg
dialogVisible: false, }
checked: false, },
sign: {}, computed: {
documentUrl: '', documentUrl() {
timer: null return this.$store.state.documentUrl
} }
}, },
mounted() { mounted() {
...@@ -81,70 +55,7 @@ export default { ...@@ -81,70 +55,7 @@ export default {
this.status = true this.status = true
} }
this.$root.$emit('updateStatus', this.status) this.$root.$emit('updateStatus', this.status)
},
createSign() {
cAction.Other.createSign().then(response => {
const { code, data } = response
if (code === 1) {
this.sign = data
this.getSignDocument(data.flowid).then(() => {
if (!this.documentUrl) {
this.dialogVisible = true
}
})
} else {
this.$message.error('处理签名失败')
}
})
},
getSignDocument(flowid) {
return cAction.Other.getSignDocument({ flowid }).then(response => {
const { code, data } = response
if (code === 1) {
this.documentUrl = data.url
}
return response
})
},
setTimer() {
this.timer = setInterval(() => {
this.getSignDocument(this.sign.flowid).then(response => {
if (response.code === 1) {
this.clearTimer()
this.dialogVisible = false
} else {
this.dialogVisible = true
}
})
}, 5000)
},
clearTimer() {
this.timer && clearInterval(this.timer)
},
handlePrimary() {
this.setTimer()
this.newWindowPreview(this.sign.shortUrl)
},
handleClose() {
if (!this.documentUrl) {
window.location.href = webConf.others.loginUrl
}
},
// 新窗口预览
newWindowPreview(url) {
const a = document.createElement('a')
a.href = url
a.target = '_blank'
document.body.appendChild(a)
a.click()
a.remove()
} }
},
beforeMount() {
this.createSign()
},
destroyed() {
this.clearTimer()
} }
} }
</script> </script>
...@@ -214,12 +125,6 @@ export default { ...@@ -214,12 +125,6 @@ export default {
} }
} }
} }
.sign {
p {
text-indent: 2em;
line-height: 24px;
}
}
.nav-a { .nav-a {
a { a {
margin: 0 10px; margin: 0 10px;
......
...@@ -4,7 +4,8 @@ Vue.use(Vuex) ...@@ -4,7 +4,8 @@ Vue.use(Vuex)
export default new Vuex.Store({ export default new Vuex.Store({
state: { state: {
myMsg: 0 myMsg: 0,
documentUrl: ''
}, },
getters: { getters: {
myMsg(state) { myMsg(state) {
...@@ -14,6 +15,9 @@ export default new Vuex.Store({ ...@@ -14,6 +15,9 @@ export default new Vuex.Store({
mutations: { mutations: {
myMsg(state, sum) { myMsg(state, sum) {
state.myMsg = sum state.myMsg = sum
},
updateDocumentUrl(state, url) {
state.documentUrl = url
} }
}, },
actions: {} actions: {}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论