|
@@ -6,7 +6,7 @@
|
|
<view class="canvas-container" slot="label">
|
|
<view class="canvas-container" slot="label">
|
|
<canvas canvas-id="canvas" id="canvas" :disable-scroll="true" style="width: 100%; height: 260px;background-color: #FFFFFF;border:1px solid #aaa;border-radius: 5px;"
|
|
<canvas canvas-id="canvas" id="canvas" :disable-scroll="true" style="width: 100%; height: 260px;background-color: #FFFFFF;border:1px solid #aaa;border-radius: 5px;"
|
|
@touchstart="handleTouchStart($event)" @touchmove="handleTouchMove($event)" @touchend="handleTouchEnd($event)"
|
|
@touchstart="handleTouchStart($event)" @touchmove="handleTouchMove($event)" @touchend="handleTouchEnd($event)"
|
|
- @touchcancel="handleEnd($event)"></canvas>
|
|
|
|
|
|
+ ></canvas>
|
|
</view>
|
|
</view>
|
|
</u-cell-item>
|
|
</u-cell-item>
|
|
<view style="width:80px;height:30px;text-align: center;line-height: 30px;background-color: #ff6e3e;color:#fff;border-radius: 5px;position: absolute;right:0;z-index:5;" @click="reset">重新签名</view>
|
|
<view style="width:80px;height:30px;text-align: center;line-height: 30px;background-color: #ff6e3e;color:#fff;border-radius: 5px;position: absolute;right:0;z-index:5;" @click="reset">重新签名</view>
|
|
@@ -45,7 +45,12 @@
|
|
ifSign: false,
|
|
ifSign: false,
|
|
signUrl: '',
|
|
signUrl: '',
|
|
realPayAmount: '',
|
|
realPayAmount: '',
|
|
- canvasData: []
|
|
|
|
|
|
+ canvasData: [],
|
|
|
|
+ canvas: null,
|
|
|
|
+ context: null,
|
|
|
|
+ isDrawing: false,
|
|
|
|
+ lastX: 0,
|
|
|
|
+ lastY: 0
|
|
}
|
|
}
|
|
},
|
|
},
|
|
watch: {
|
|
watch: {
|
|
@@ -68,6 +73,7 @@
|
|
console.log(this.realPayAmount);
|
|
console.log(this.realPayAmount);
|
|
this.getContractInfo(options.parentName, options.sex)
|
|
this.getContractInfo(options.parentName, options.sex)
|
|
context = uni.createCanvasContext('canvas')
|
|
context = uni.createCanvasContext('canvas')
|
|
|
|
+ //this.canvas = uni.createCanvasContext('canvas', this);
|
|
context.setLineWidth(3)
|
|
context.setLineWidth(3)
|
|
context.setStrokeStyle("#000000")
|
|
context.setStrokeStyle("#000000")
|
|
this.reset()
|
|
this.reset()
|
|
@@ -94,28 +100,62 @@
|
|
this.ifSign = false
|
|
this.ifSign = false
|
|
context.draw()
|
|
context.draw()
|
|
},
|
|
},
|
|
|
|
+ drawPoint( x, y,) {
|
|
|
|
+ context.beginPath();
|
|
|
|
+ context.arc(x, y, 2, 0, 2 * Math.PI);
|
|
|
|
+ context.setFillStyle('#000000');
|
|
|
|
+ context.fill();
|
|
|
|
+ context.stroke()
|
|
|
|
+ context.draw(true)
|
|
|
|
+ },
|
|
handleTouchStart(e) {
|
|
handleTouchStart(e) {
|
|
this.ifSign = true
|
|
this.ifSign = true
|
|
- this.canvasData = []
|
|
|
|
|
|
+ this.isDrawing = true;
|
|
|
|
+ const a = e.changedTouches[0]
|
|
|
|
+ const x = a.x;
|
|
|
|
+ const y = a.y;
|
|
|
|
+ this.lastX = x;
|
|
|
|
+ this.lastY = y;
|
|
|
|
+ //this.drawPoint(x, y)
|
|
|
|
+ context.beginPath();
|
|
|
|
+ context.moveTo(x, y);
|
|
|
|
+ /*this.canvasData = []
|
|
const a = e.changedTouches[0]
|
|
const a = e.changedTouches[0]
|
|
this.canvasData.push({
|
|
this.canvasData.push({
|
|
x: a.x,
|
|
x: a.x,
|
|
y: a.y
|
|
y: a.y
|
|
- })
|
|
|
|
|
|
+ })*/
|
|
},
|
|
},
|
|
handleTouchMove(e) {
|
|
handleTouchMove(e) {
|
|
- const a = e.changedTouches[0]
|
|
|
|
|
|
+ if (this.isDrawing) {
|
|
|
|
+ const x = e.changedTouches[0].x;
|
|
|
|
+ const y = e.changedTouches[0].y;
|
|
|
|
+ //this.drawPoint(x, y)
|
|
|
|
+ context.lineTo(x, y);
|
|
|
|
+ context.stroke()
|
|
|
|
+ context.draw(true)
|
|
|
|
+ context.beginPath();
|
|
|
|
+ context.moveTo(x, y);
|
|
|
|
+ }
|
|
|
|
+ /*const a = e.changedTouches[0]
|
|
this.canvasData.push({
|
|
this.canvasData.push({
|
|
x: a.x,
|
|
x: a.x,
|
|
y: a.y
|
|
y: a.y
|
|
- })
|
|
|
|
|
|
+ })*/
|
|
},
|
|
},
|
|
handleTouchEnd(e) {
|
|
handleTouchEnd(e) {
|
|
- const a = e.changedTouches[0]
|
|
|
|
|
|
+ this.isDrawing = false;
|
|
|
|
+ const x = e.changedTouches[0].x;
|
|
|
|
+ const y = e.changedTouches[0].y;
|
|
|
|
+ //this.drawPoint(x, y)
|
|
|
|
+ context.lineTo(x, y);
|
|
|
|
+ context.stroke()
|
|
|
|
+ context.draw(true)
|
|
|
|
+ /*const a = e.changedTouches[0]
|
|
this.canvasData.push({
|
|
this.canvasData.push({
|
|
x: a.x,
|
|
x: a.x,
|
|
y: a.y
|
|
y: a.y
|
|
- })
|
|
|
|
|
|
+ })*/
|
|
},
|
|
},
|
|
handleEnd() {
|
|
handleEnd() {
|
|
context.stroke()
|
|
context.stroke()
|