实现签名确认功能,支持生成签名图片并上传至服务器 添加图片预览和保存功能,优化用户交互体验 重构页面布局和样式,增加时间戳显示 集成API调用处理签名数据的获取和提交
59 lines
1.5 KiB
JavaScript
59 lines
1.5 KiB
JavaScript
|
||
function v(a, b) {
|
||
return +((1000 * a - 1000 * b) / 1000).toFixed(1)
|
||
}
|
||
module.exports = {
|
||
created() {
|
||
if (this._setTransform) {
|
||
this._setTransform = (x, y, scale, source = '', r, o) => {
|
||
if (!(x !== null && x.toString() !== 'NaN' && typeof x === 'number')) {
|
||
x = this._translateX || 0
|
||
}
|
||
if (!(y !== null && y.toString() !== 'NaN' && typeof y === 'number')) {
|
||
y = this._translateY || 0
|
||
}
|
||
x = Number(x.toFixed(1))
|
||
y = Number(y.toFixed(1))
|
||
scale = Number(scale.toFixed(1))
|
||
if (!(this._translateX === x && this._translateY === y)) {
|
||
if (!r) {
|
||
this.$trigger('change', {}, {
|
||
x: v(x, this._scaleOffset.x),
|
||
y: v(y, this._scaleOffset.y),
|
||
source: source
|
||
})
|
||
}
|
||
}
|
||
if (!this.scale) {
|
||
scale = this._scale
|
||
}
|
||
scale = this._adjustScale(scale)
|
||
scale = +scale.toFixed(3)
|
||
if (o && scale !== this._scale) {
|
||
this.$trigger('scale', {}, {
|
||
x: x,
|
||
y: y,
|
||
scale: scale
|
||
})
|
||
}
|
||
var transform = 'translateX(' + x + 'px) translateY(' + y + 'px) scale(' + scale + ')'
|
||
this.$el.style.transform = transform
|
||
this.$el.style.webkitTransform = transform
|
||
this._translateX = x
|
||
this._translateY = y
|
||
this._scale = scale
|
||
}
|
||
}
|
||
},
|
||
destroyed() {
|
||
//解决预览模式关闭后,和重复开关预览模式this._setTransform函数无限次执行导致手机卡顿的问题
|
||
if (this._FA) {
|
||
this._FA.cancel()
|
||
}
|
||
if (this._SFA) {
|
||
this._SFA.cancel()
|
||
}
|
||
},
|
||
methods: {
|
||
}
|
||
} |