|
@@ -6,7 +6,7 @@ Page({
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
- attachmentids:[],
|
|
|
+ attachmentids: [],
|
|
|
canvasName: 'signCanvas',
|
|
|
ctx: '', // 上下文实例
|
|
|
canvas: '', // 画布实例
|
|
@@ -24,7 +24,12 @@ Page({
|
|
|
currentLine: [], // 当前线条
|
|
|
firstTouch: true, // 第一次触发
|
|
|
radius: 1, //画圆的半径
|
|
|
- cutArea: { top: 0, right: 0, bottom: 0, left: 0 }, //裁剪区域
|
|
|
+ cutArea: {
|
|
|
+ top: 0,
|
|
|
+ right: 0,
|
|
|
+ bottom: 0,
|
|
|
+ left: 0
|
|
|
+ }, //裁剪区域
|
|
|
bethelPoint: [], //保存所有线条 生成的贝塞尔点;
|
|
|
lastPoint: 0,
|
|
|
chirography: [], //笔迹
|
|
@@ -42,7 +47,7 @@ Page({
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
this.setData({
|
|
|
- id:options.id
|
|
|
+ id: options.id
|
|
|
})
|
|
|
this.data.dpr = wx.getSystemInfoSync().pixelRatio
|
|
|
const query = wx.createSelectorQuery()
|
|
@@ -56,7 +61,10 @@ Page({
|
|
|
const query1 = wx.createSelectorQuery()
|
|
|
query1
|
|
|
.select('#signCanvas')
|
|
|
- .fields({ node: true, size: true })
|
|
|
+ .fields({
|
|
|
+ node: true,
|
|
|
+ size: true
|
|
|
+ })
|
|
|
.exec(res => {
|
|
|
const canvas = res[0].node
|
|
|
this.data.ctx = canvas.getContext('2d')
|
|
@@ -65,14 +73,17 @@ Page({
|
|
|
/* 将canvas背景设置为 白底,不设置 导出的canvas的背景为透明 */
|
|
|
// console.log(this, 'hahah');
|
|
|
this.data.canvas = canvas
|
|
|
-
|
|
|
+
|
|
|
this.data.ctx.scale(this.data.dpr, this.data.dpr)
|
|
|
this.setCanvasBg('#fff')
|
|
|
})
|
|
|
const query2 = wx.createSelectorQuery()
|
|
|
query2
|
|
|
.select('#offCanvas')
|
|
|
- .fields({ node: true, size: true })
|
|
|
+ .fields({
|
|
|
+ node: true,
|
|
|
+ size: true
|
|
|
+ })
|
|
|
.exec(res => {
|
|
|
const canvas = res[0].node
|
|
|
const ctx = canvas.getContext('2d')
|
|
@@ -113,7 +124,7 @@ Page({
|
|
|
console.log('========subOver')
|
|
|
},
|
|
|
|
|
|
-
|
|
|
+
|
|
|
//画两点之间的线条;参数为:line,会绘制最近的开始的两个点;
|
|
|
pointToLine(line) {
|
|
|
this.calcBethelLine(line)
|
|
@@ -291,7 +302,13 @@ Page({
|
|
|
y2 = y1 + (line[0].y - y1) * curveValue
|
|
|
}
|
|
|
//从计算公式看,三个点分别是(x0,y0),(x1,y1),(x2,y2) ;(x1,y1)这个是控制点,控制点不会落在曲线上;实际上,这个点还会手写获取的实际点,却落在曲线上
|
|
|
- len = this.distance({ x: x2, y: y2 }, { x: x0, y: y0 })
|
|
|
+ len = this.distance({
|
|
|
+ x: x2,
|
|
|
+ y: y2
|
|
|
+ }, {
|
|
|
+ x: x0,
|
|
|
+ y: y0
|
|
|
+ })
|
|
|
lastRadius = this.data.radius
|
|
|
for (let n = 0; n < line.length - 1; n++) {
|
|
|
dis += line[n].dis
|
|
@@ -299,8 +316,7 @@ Page({
|
|
|
if (dis > this.data.smoothness) break
|
|
|
}
|
|
|
this.setData({
|
|
|
- radius:
|
|
|
- Math.min((time / len) * this.data.pressure + this.data.lineMin, this.data.lineMax) *
|
|
|
+ radius: Math.min((time / len) * this.data.pressure + this.data.lineMin, this.data.lineMax) *
|
|
|
this.data.lineSize
|
|
|
})
|
|
|
line[0].r = this.data.radius
|
|
@@ -322,7 +338,11 @@ Page({
|
|
|
let x = (1 - t) * (1 - t) * x0 + 2 * t * (1 - t) * x1 + t * t * x2
|
|
|
let y = (1 - t) * (1 - t) * y0 + 2 * t * (1 - t) * y1 + t * t * y2
|
|
|
let r = lastRadius + ((this.data.radius - lastRadius) / n) * i
|
|
|
- point.push({ x: x, y: y, r: r })
|
|
|
+ point.push({
|
|
|
+ x: x,
|
|
|
+ y: y,
|
|
|
+ r: r
|
|
|
+ })
|
|
|
if (point.length == 3) {
|
|
|
let a = this.ctaCalc(
|
|
|
point[0].x,
|
|
@@ -341,7 +361,11 @@ Page({
|
|
|
// console.log(this.data.bethelPoint)
|
|
|
// bethelPoint = bethelPoint.push(a);
|
|
|
this.bethelDraw(a, 1)
|
|
|
- point = [{ x: x, y: y, r: r }]
|
|
|
+ point = [{
|
|
|
+ x: x,
|
|
|
+ y: y,
|
|
|
+ r: r
|
|
|
+ }]
|
|
|
}
|
|
|
}
|
|
|
this.setData({
|
|
@@ -379,7 +403,11 @@ Page({
|
|
|
vy21 = (vy21 / norm) * r2
|
|
|
n_x2 = -vy21
|
|
|
n_y2 = vx21
|
|
|
- a.push({ mx: x0 + n_x0, my: y0 + n_y0, color: '#1A1A1A' })
|
|
|
+ a.push({
|
|
|
+ mx: x0 + n_x0,
|
|
|
+ my: y0 + n_y0,
|
|
|
+ color: '#1A1A1A'
|
|
|
+ })
|
|
|
a.push({
|
|
|
c1x: x1 + n_x0,
|
|
|
c1y: y1 + n_y0,
|
|
@@ -543,8 +571,7 @@ Page({
|
|
|
"content": {
|
|
|
"filename": '客户签字',
|
|
|
"filetype": 'jpg',
|
|
|
- "parentid": 2
|
|
|
- // this.data.parentid
|
|
|
+ "parentid": wx.getStorageSync('siteP').appfolderid
|
|
|
}
|
|
|
}).then(res => {
|
|
|
if (res.msg == "成功") {
|
|
@@ -585,7 +612,7 @@ Page({
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- async filebindData () {
|
|
|
+ async filebindData() {
|
|
|
let pages = getCurrentPages()[getCurrentPages().length - 2]
|
|
|
const res = await api._post({
|
|
|
"classname": "system.attachment.Attachment",
|