commit
This commit is contained in:
@@ -48,6 +48,13 @@ module.exports = {
|
|||||||
rotate() {
|
rotate() {
|
||||||
signature.getRotateCanvas(90)
|
signature.getRotateCanvas(90)
|
||||||
},
|
},
|
||||||
|
isLikelyMobile() {
|
||||||
|
const isTouchDevice = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
|
||||||
|
const isSmallScreen = window.screen.width <= 768;
|
||||||
|
const hasMobileUA = /Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
||||||
|
|
||||||
|
return hasMobileUA || (isTouchDevice && isSmallScreen);
|
||||||
|
},
|
||||||
save() {
|
save() {
|
||||||
if (signature.isEmpty()) {
|
if (signature.isEmpty()) {
|
||||||
alert("请签字后再保存")
|
alert("请签字后再保存")
|
||||||
@@ -56,7 +63,11 @@ module.exports = {
|
|||||||
// const png = signature.getPNG()
|
// const png = signature.getPNG()
|
||||||
//旋转一下 横过来
|
//旋转一下 横过来
|
||||||
const rotateCanvas = signature.getRotateCanvas(-90)
|
const rotateCanvas = signature.getRotateCanvas(-90)
|
||||||
|
if (this.isLikelyMobile()) {
|
||||||
this.$emit("save", rotateCanvas.toDataURL())
|
this.$emit("save", rotateCanvas.toDataURL())
|
||||||
|
} else {
|
||||||
|
this.$emit("save", signature.toDataURL())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
|||||||
@@ -69,8 +69,9 @@ module.exports = {
|
|||||||
|
|
||||||
// 可选:轮询或 watch ready 状态
|
// 可选:轮询或 watch ready 状态
|
||||||
const checkReady = () => {
|
const checkReady = () => {
|
||||||
if (window.webSocketPubSub.ws.readyState === 1) {
|
if (webSocketPubSub.ws && webSocketPubSub.ws.readyState === WebSocket.OPEN) {
|
||||||
this.loading = false; // 允许签字
|
console.info("ws.readyState is open");
|
||||||
|
this.loading = false;
|
||||||
} else {
|
} else {
|
||||||
setTimeout(checkReady, 100);
|
setTimeout(checkReady, 100);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -202,7 +202,7 @@
|
|||||||
// )
|
// )
|
||||||
// 连接建立时不立即发送 join,等待订阅完成
|
// 连接建立时不立即发送 join,等待订阅完成
|
||||||
this.ping()
|
this.ping()
|
||||||
console.log('websocket open success')
|
console.info('websocket open success')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user