This commit is contained in:
@jyuhsin
2025-12-18 12:37:46 +08:00
parent 344229fc31
commit 5e13af047f
2 changed files with 86 additions and 73 deletions
@@ -2,8 +2,9 @@
<el-card shadow="never" class="pc-signature-card"> <el-card shadow="never" class="pc-signature-card">
<div class="pc-signature"> <div class="pc-signature">
<el-link type="primary">扫描下方二维码进行签字</el-link> <el-link type="primary">扫描下方二维码进行签字</el-link>
<div class="signature-body"> <div class="signature-body" v-loading="loading">
<QrCode v-if="!signatureContent" :options="{ width: 126 }" :value="signatureAddress" class="signature-qrcode"></QrCode> <QrCode v-if="!signatureContent" :options="{ width: 126 }" :value="signatureAddress"
class="signature-qrcode"></QrCode>
<el-image v-if="signatureContent" :src="signatureContent" class="signature-image"></el-image> <el-image v-if="signatureContent" :src="signatureContent" class="signature-image"></el-image>
</div> </div>
<el-link type="danger" icon="el-icon-edit" @click="signatureAgain" v-if="signatureContent">重签</el-link> <el-link type="danger" icon="el-icon-edit" @click="signatureAgain" v-if="signatureContent">重签</el-link>
@@ -24,7 +25,7 @@ module.exports = {
watch: { watch: {
value: { value: {
handler(val) { handler(val) {
if(val){ if (val) {
this.signatureContent = val this.signatureContent = val
this.$emit("input", this.signatureContent) this.$emit("input", this.signatureContent)
} }
@@ -38,12 +39,13 @@ module.exports = {
id: new Date().getTime() + Math.floor(Math.random() * 10000) + 1, id: new Date().getTime() + Math.floor(Math.random() * 10000) + 1,
signatureAddress: null, signatureAddress: null,
interval: null, interval: null,
signatureContent: null signatureContent: null,
loading: true,
} }
}, },
methods: { methods: {
async init() { async init() {
const { code, data } = await this.$axios.post("/platform/signature/get") const {code, data} = await this.$axios.post("/platform/signature/get")
if (code === 0) { if (code === 0) {
this.signatureContent = data && data.signature this.signatureContent = data && data.signature
this.$emit("input", this.signatureContent) this.$emit("input", this.signatureContent)
@@ -64,6 +66,16 @@ module.exports = {
this.signatureContent = data.value this.signatureContent = data.value
this.$emit("input", data.value) this.$emit("input", data.value)
}) })
// 可选:轮询或 watch ready 状态
const checkReady = () => {
if (window.webSocketPubSub.ws.readyState === 1) {
this.loading = false; // 允许签字
} else {
setTimeout(checkReady, 100);
}
};
checkReady();
} }
} }
</script> </script>
@@ -168,7 +168,7 @@
this.isSubscribed = true this.isSubscribed = true
this.sendJoinMessage() this.sendJoinMessage()
} }
}, 500) }, 1000)
} }
// 事件处理 // 事件处理
@@ -202,6 +202,7 @@
// ) // )
// 连接建立时不立即发送 join,等待订阅完成 // 连接建立时不立即发送 join,等待订阅完成
this.ping() this.ping()
console.log('websocket open success')
} }
} }
@@ -245,7 +246,7 @@
} }
}, 500) }, 500)
} }
}, 2000) // 延迟2秒重连 }, 1000) // 延迟2秒重连
} }
// 窗口事件处理 // 窗口事件处理