sign.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789
  1. <template>
  2. <view class="sign">
  3. <view class="wrapper">
  4. <view class="handBtn">
  5. <!-- <image @click="selectColorEvent('black','#1A1A1A')" :src="selectColor === 'black' ? '../static/other/color_black_selected.png' : '../static/other/color_black.png'"
  6. :class="[selectColor === 'black' ? 'color_select' : '', 'black-select']"></image>
  7. <image @click="selectColorEvent('red','#ca262a')" :src="selectColor === 'red' ? '../static/other/color_red_selected.png' : '../static/other/color_red.png'"
  8. :class="[selectColor === 'red' ? 'color_select' : '', 'black-select']"></image> -->
  9. <!-- <button @click="retDraw" class="delBtn">重写</button>
  10. <button @click="saveCanvasAsImg" class="saveBtn">保存</button>
  11. <button @click="previewCanvasImg" class="previewBtn">预览</button>
  12. <button @click="uploadCanvasImg" class="uploadBtn">上传</button>
  13. <button @click="subCanvas" class="subBtn">完成</button> -->
  14. <view class="signtit">请在上方空白处书写您的签名</view>
  15. <view class="sinbtns bgb" @click="retDraw">清除重写</view>
  16. <view class="sinbtns bga" @click="saveCanvasAsImg">提交签名</view>
  17. </view>
  18. <view class="handCenter">
  19. <canvas class="handWriting" :disable-scroll="true" @touchstart="uploadScaleStart" @touchmove="uploadScaleMove"
  20. @touchend="uploadScaleEnd" canvas-id="handWriting"></canvas>
  21. </view>
  22. <!-- <view class="handRight">
  23. <view class="handTitle">请签名</view>
  24. </view> -->
  25. </view>
  26. <!-- 旋转图片canvas -->
  27. <canvas canvas-id="hcamCacnvs" :style="{width:canvasHeight +'rpx',height:canvasWidth +'rpx'}" class="canvsborder"></canvas>
  28. </view>
  29. </template>
  30. <script>
  31. export default {
  32. data() {
  33. return {
  34. canvasName: 'handWriting',
  35. ctx: '',
  36. canvasWidth: 300,
  37. canvasHeight: 150,
  38. transparent: 1, // 透明度
  39. selectColor: 'black',
  40. lineColor: '#1A1A1A', // 颜色
  41. lineSize: 1.5, // 笔记倍数
  42. lineMin: 0.5, // 最小笔画半径
  43. lineMax: 4, // 最大笔画半径
  44. pressure: 1, // 默认压力
  45. smoothness: 60, //顺滑度,用60的距离来计算速度
  46. currentPoint: {},
  47. currentLine: [], // 当前线条
  48. firstTouch: true, // 第一次触发
  49. radius: 1, //画圆的半径
  50. cutArea: {
  51. top: 0,
  52. right: 0,
  53. bottom: 0,
  54. left: 0
  55. }, //裁剪区域
  56. bethelPoint: [], //保存所有线条 生成的贝塞尔点;
  57. lastPoint: 0,
  58. chirography: [], //笔迹
  59. currentChirography: {}, //当前笔迹
  60. linePrack: [] //划线轨迹 , 生成线条的实际点
  61. };
  62. },
  63. mounted() {
  64. let canvasName = this.canvasName;
  65. let ctx = wx.createCanvasContext(canvasName);
  66. this.ctx = ctx;
  67. var that=this;
  68. let query = uni.createSelectorQuery().in(this);;
  69. query.select('.handCenter').boundingClientRect(rect => {
  70. // console.log(rect,1)
  71. that.canvasWidth =Math.floor(rect.width)||300 ;
  72. that.canvasHeight = Math.floor(rect.height)||150;
  73. console.log(that.canvasWidth)
  74. console.log(that.canvasHeight)
  75. /* 将canvas背景设置为 白底,不设置 导出的canvas的背景为透明 */
  76. that.setCanvasBg('#fff');
  77. })
  78. .exec();
  79. },
  80. methods: {
  81. // 笔迹开始
  82. uploadScaleStart(e) {
  83. if (e.type != 'touchstart') return false;
  84. let ctx = this.ctx;
  85. ctx.setFillStyle(this.lineColor); // 初始线条设置颜色
  86. ctx.setGlobalAlpha(this.transparent); // 设置半透明
  87. let currentPoint = {
  88. x: e.touches[0].x,
  89. y: e.touches[0].y
  90. };
  91. let currentLine = this.currentLine;
  92. currentLine.unshift({
  93. time: new Date().getTime(),
  94. dis: 0,
  95. x: currentPoint.x,
  96. y: currentPoint.y
  97. });
  98. this.currentPoint = currentPoint;
  99. // currentLine
  100. if (this.firstTouch) {
  101. this.cutArea = {
  102. top: currentPoint.y,
  103. right: currentPoint.x,
  104. bottom: currentPoint.y,
  105. left: currentPoint.x
  106. };
  107. this.firstTouch = false;
  108. }
  109. this.pointToLine(currentLine);
  110. },
  111. // 笔迹移动
  112. uploadScaleMove(e) {
  113. if (e.type != 'touchmove') return false;
  114. if (e.cancelable) {
  115. // 判断默认行为是否已经被禁用
  116. if (!e.defaultPrevented) {
  117. e.preventDefault();
  118. }
  119. }
  120. let point = {
  121. x: e.touches[0].x,
  122. y: e.touches[0].y
  123. };
  124. //测试裁剪
  125. if (point.y < this.cutArea.top) {
  126. this.cutArea.top = point.y;
  127. }
  128. if (point.y < 0) this.cutArea.top = 0;
  129. if (point.x > this.cutArea.right) {
  130. this.cutArea.right = point.x;
  131. }
  132. if (this.canvasWidth - point.x <= 0) {
  133. this.cutArea.right = this.canvasWidth;
  134. }
  135. if (point.y > this.cutArea.bottom) {
  136. this.cutArea.bottom = point.y;
  137. }
  138. if (this.canvasHeight - point.y <= 0) {
  139. this.cutArea.bottom = this.canvasHeight;
  140. }
  141. if (point.x < this.cutArea.left) {
  142. this.cutArea.left = point.x;
  143. }
  144. if (point.x < 0) this.cutArea.left = 0;
  145. this.lastPoint = this.currentPoint;
  146. this.currentPoint = point;
  147. let currentLine = this.currentLine;
  148. currentLine.unshift({
  149. time: new Date().getTime(),
  150. dis: this.distance(this.currentPoint, this.lastPoint),
  151. x: point.x,
  152. y: point.y
  153. });
  154. this.pointToLine(currentLine);
  155. },
  156. // 笔迹结束
  157. uploadScaleEnd(e) {
  158. if (e.type != 'touchend') return 0;
  159. let point = {
  160. x: e.changedTouches[0].x,
  161. y: e.changedTouches[0].y
  162. };
  163. this.lastPoint = this.currentPoint;
  164. this.currentPoint = point;
  165. let currentLine = this.currentLine;
  166. currentLine.unshift({
  167. time: new Date().getTime(),
  168. dis: this.distance(this.currentPoint, this.lastPoint),
  169. x: point.x,
  170. y: point.y
  171. });
  172. if (currentLine.length > 2) {
  173. var info = (currentLine[0].time - currentLine[currentLine.length - 1].time) / currentLine.length;
  174. //$("#info").text(info.toFixed(2));
  175. }
  176. //一笔结束,保存笔迹的坐标点,清空,当前笔迹
  177. //增加判断是否在手写区域;
  178. this.pointToLine(currentLine);
  179. var currentChirography = {
  180. lineSize: this.lineSize,
  181. lineColor: this.lineColor
  182. };
  183. var chirography = this.chirography;
  184. chirography.unshift(currentChirography);
  185. this.chirography = chirography;
  186. var linePrack = this.linePrack;
  187. linePrack.unshift(this.currentLine);
  188. this.linePrack = linePrack;
  189. this.currentLine = [];
  190. },
  191. retDraw() {
  192. this.ctx.clearRect(0, 0, 700, 730);
  193. this.ctx.draw();
  194. //设置canvas背景
  195. this.setCanvasBg('#fff');
  196. },
  197. //画两点之间的线条;参数为:line,会绘制最近的开始的两个点;
  198. pointToLine(line) {
  199. this.calcBethelLine(line);
  200. return;
  201. },
  202. //计算插值的方式;
  203. calcBethelLine(line) {
  204. if (line.length <= 1) {
  205. line[0].r = this.radius;
  206. return;
  207. }
  208. let x0,
  209. x1,
  210. x2,
  211. y0,
  212. y1,
  213. y2,
  214. r0,
  215. r1,
  216. r2,
  217. len,
  218. lastRadius,
  219. dis = 0,
  220. time = 0,
  221. curveValue = 0.5;
  222. if (line.length <= 2) {
  223. x0 = line[1].x;
  224. y0 = line[1].y;
  225. x2 = line[1].x + (line[0].x - line[1].x) * curveValue;
  226. y2 = line[1].y + (line[0].y - line[1].y) * curveValue;
  227. //x2 = line[1].x;
  228. //y2 = line[1].y;
  229. x1 = x0 + (x2 - x0) * curveValue;
  230. y1 = y0 + (y2 - y0) * curveValue;
  231. } else {
  232. x0 = line[2].x + (line[1].x - line[2].x) * curveValue;
  233. y0 = line[2].y + (line[1].y - line[2].y) * curveValue;
  234. x1 = line[1].x;
  235. y1 = line[1].y;
  236. x2 = x1 + (line[0].x - x1) * curveValue;
  237. y2 = y1 + (line[0].y - y1) * curveValue;
  238. }
  239. //从计算公式看,三个点分别是(x0,y0),(x1,y1),(x2,y2) ;(x1,y1)这个是控制点,控制点不会落在曲线上;实际上,这个点还会手写获取的实际点,却落在曲线上
  240. len = this.distance({
  241. x: x2,
  242. y: y2
  243. }, {
  244. x: x0,
  245. y: y0
  246. });
  247. lastRadius = this.radius;
  248. for (let n = 0; n < line.length - 1; n++) {
  249. dis += line[n].dis;
  250. time += line[n].time - line[n + 1].time;
  251. if (dis > this.smoothness) break;
  252. }
  253. this.radius = Math.min((time / len) * this.pressure + this.lineMin, this.lineMax) * this.lineSize;
  254. line[0].r = this.radius;
  255. //计算笔迹半径;
  256. if (line.length <= 2) {
  257. r0 = (lastRadius + this.radius) / 2;
  258. r1 = r0;
  259. r2 = r1;
  260. //return;
  261. } else {
  262. r0 = (line[2].r + line[1].r) / 2;
  263. r1 = line[1].r;
  264. r2 = (line[1].r + line[0].r) / 2;
  265. }
  266. let n = 5;
  267. let point = [];
  268. for (let i = 0; i < n; i++) {
  269. let t = i / (n - 1);
  270. let x = (1 - t) * (1 - t) * x0 + 2 * t * (1 - t) * x1 + t * t * x2;
  271. let y = (1 - t) * (1 - t) * y0 + 2 * t * (1 - t) * y1 + t * t * y2;
  272. let r = lastRadius + ((this.radius - lastRadius) / n) * i;
  273. point.push({
  274. x: x,
  275. y: y,
  276. r: r
  277. });
  278. if (point.length == 3) {
  279. let a = this.ctaCalc(point[0].x, point[0].y, point[0].r, point[1].x, point[1].y, point[1].r, point[2].x, point[2]
  280. .y, point[2].r);
  281. a[0].color = this.lineColor;
  282. // let bethelPoint = this.bethelPoint;
  283. // bethelPoint = bethelPoint.push(a);
  284. this.bethelDraw(a, 1);
  285. point = [{
  286. x: x,
  287. y: y,
  288. r: r
  289. }];
  290. }
  291. }
  292. this.currentLine = line;
  293. },
  294. //求两点之间距离
  295. distance(a, b) {
  296. let x = b.x - a.x;
  297. let y = b.y - a.y;
  298. return Math.sqrt(x * x + y * y);
  299. },
  300. ctaCalc(x0, y0, r0, x1, y1, r1, x2, y2, r2) {
  301. let a = [],
  302. vx01,
  303. vy01,
  304. norm,
  305. n_x0,
  306. n_y0,
  307. vx21,
  308. vy21,
  309. n_x2,
  310. n_y2;
  311. vx01 = x1 - x0;
  312. vy01 = y1 - y0;
  313. norm = Math.sqrt(vx01 * vx01 + vy01 * vy01 + 0.0001) * 2;
  314. vx01 = (vx01 / norm) * r0;
  315. vy01 = (vy01 / norm) * r0;
  316. n_x0 = vy01;
  317. n_y0 = -vx01;
  318. vx21 = x1 - x2;
  319. vy21 = y1 - y2;
  320. norm = Math.sqrt(vx21 * vx21 + vy21 * vy21 + 0.0001) * 2;
  321. vx21 = (vx21 / norm) * r2;
  322. vy21 = (vy21 / norm) * r2;
  323. n_x2 = -vy21;
  324. n_y2 = vx21;
  325. a.push({
  326. mx: x0 + n_x0,
  327. my: y0 + n_y0,
  328. color: '#1A1A1A'
  329. });
  330. a.push({
  331. c1x: x1 + n_x0,
  332. c1y: y1 + n_y0,
  333. c2x: x1 + n_x2,
  334. c2y: y1 + n_y2,
  335. ex: x2 + n_x2,
  336. ey: y2 + n_y2
  337. });
  338. a.push({
  339. c1x: x2 + n_x2 - vx21,
  340. c1y: y2 + n_y2 - vy21,
  341. c2x: x2 - n_x2 - vx21,
  342. c2y: y2 - n_y2 - vy21,
  343. ex: x2 - n_x2,
  344. ey: y2 - n_y2
  345. });
  346. a.push({
  347. c1x: x1 - n_x2,
  348. c1y: y1 - n_y2,
  349. c2x: x1 - n_x0,
  350. c2y: y1 - n_y0,
  351. ex: x0 - n_x0,
  352. ey: y0 - n_y0
  353. });
  354. a.push({
  355. c1x: x0 - n_x0 - vx01,
  356. c1y: y0 - n_y0 - vy01,
  357. c2x: x0 + n_x0 - vx01,
  358. c2y: y0 + n_y0 - vy01,
  359. ex: x0 + n_x0,
  360. ey: y0 + n_y0
  361. });
  362. a[0].mx = a[0].mx.toFixed(1);
  363. a[0].mx = parseFloat(a[0].mx);
  364. a[0].my = a[0].my.toFixed(1);
  365. a[0].my = parseFloat(a[0].my);
  366. for (let i = 1; i < a.length; i++) {
  367. a[i].c1x = a[i].c1x.toFixed(1);
  368. a[i].c1x = parseFloat(a[i].c1x);
  369. a[i].c1y = a[i].c1y.toFixed(1);
  370. a[i].c1y = parseFloat(a[i].c1y);
  371. a[i].c2x = a[i].c2x.toFixed(1);
  372. a[i].c2x = parseFloat(a[i].c2x);
  373. a[i].c2y = a[i].c2y.toFixed(1);
  374. a[i].c2y = parseFloat(a[i].c2y);
  375. a[i].ex = a[i].ex.toFixed(1);
  376. a[i].ex = parseFloat(a[i].ex);
  377. a[i].ey = a[i].ey.toFixed(1);
  378. a[i].ey = parseFloat(a[i].ey);
  379. }
  380. return a;
  381. },
  382. bethelDraw(point, is_fill, color) {
  383. let ctx = this.ctx;
  384. ctx.beginPath();
  385. ctx.moveTo(point[0].mx, point[0].my);
  386. if (undefined != color) {
  387. ctx.setFillStyle(color);
  388. ctx.setStrokeStyle(color);
  389. } else {
  390. ctx.setFillStyle(point[0].color);
  391. ctx.setStrokeStyle(point[0].color);
  392. }
  393. for (let i = 1; i < point.length; i++) {
  394. ctx.bezierCurveTo(point[i].c1x, point[i].c1y, point[i].c2x, point[i].c2y, point[i].ex, point[i].ey);
  395. }
  396. ctx.stroke();
  397. if (undefined != is_fill) {
  398. ctx.fill(); //填充图形 ( 后绘制的图形会覆盖前面的图形, 绘制时注意先后顺序 )
  399. }
  400. ctx.draw(true);
  401. },
  402. selectColorEvent(str, color) {
  403. this.selectColor = str;
  404. this.lineColor = color;
  405. },
  406. //将Canvas内容转成 临时图片 --> cb 为回调函数 形参 tempImgPath 为 生成的图片临时路径
  407. canvasToImg(cb) {
  408. //这种写法移动端 出不来
  409. this.ctx.draw(true, () => {
  410. wx.canvasToTempFilePath({
  411. canvasId: 'handWriting',
  412. fileType: 'png',
  413. quality: 1, //图片质量
  414. success(res) {
  415. // console.log(res.tempFilePath, 'canvas生成图片地址');
  416. wx.showToast({
  417. title: '执行了吗?'
  418. });
  419. cb(res.tempFilePath);
  420. }
  421. });
  422. });
  423. },
  424. //完成
  425. subCanvas() {
  426. this.ctx.draw(true, () => {
  427. wx.canvasToTempFilePath({
  428. canvasId: 'handWriting',
  429. fileType: 'png',
  430. quality: 1, //图片质量
  431. success(res) {
  432. // console.log(res.tempFilePath, 'canvas生成图片地址');
  433. wx.showToast({
  434. title: '以保存'
  435. });
  436. //保存到系统相册
  437. wx.saveImageToPhotosAlbum({
  438. filePath: res.tempFilePath,
  439. success(res) {
  440. wx.showToast({
  441. title: '已成功保存到相册',
  442. duration: 2000
  443. });
  444. }
  445. });
  446. }
  447. });
  448. });
  449. },
  450. //保存到相册
  451. saveCanvasAsImg() {
  452. /*
  453. this.canvasToImg( tempImgPath=>{
  454. // console.log(tempImgPath, '临时路径');
  455. wx.saveImageToPhotosAlbum({
  456. filePath: tempImgPath,
  457. success(res) {
  458. wx.showToast({
  459. title: '已保存到相册',
  460. duration: 2000
  461. });
  462. }
  463. })
  464. } );
  465. */
  466. var that=this;
  467. wx.canvasToTempFilePath({
  468. canvasId: 'handWriting',
  469. fileType: 'png',
  470. quality: 1, //图片质量
  471. success(res) {
  472. // 旋转图片90度在上传
  473. //绘制canvas 旋转图片
  474. let tempFilePaths = res.tempFilePath;
  475. wx.getImageInfo({ // 获取图片的信息
  476. src: tempFilePaths,
  477. success: (msg) => {
  478. let canvas = wx.createCanvasContext('hcamCacnvs',that);
  479. canvas.fillStyle = '#fff';
  480. var canvasWidth=that.canvasWidth/2
  481. var canvasHeight=that.canvasHeight/2
  482. // 逆时针旋转90度
  483. // 由于缩小到一半,所以都需要 /2
  484. canvas.translate(0, that.canvasWidth / 2)
  485. canvas.rotate(270 * Math.PI / 180)
  486. //如果你修改了画布后不能完全展示出来,可以调整这下面四个参数
  487. //因为翻转了,所以分别是 靠上,靠左,高,宽,慢慢修改,不然很容易就超出界面了,然而以为没显示出来
  488. canvas.drawImage(msg.path, 0, 0, canvasWidth, canvasHeight)
  489. canvas.draw(false,() => {
  490. uni.canvasToTempFilePath({
  491. canvasId: 'hcamCacnvs',
  492. fileType: 'png',
  493. quality: 1, //图片质量
  494. success(vas) {
  495. uni.saveImageToPhotosAlbum({
  496. filePath: vas.tempFilePath,
  497. success(res) {
  498. wx.showToast({
  499. title: '已保存到相册',
  500. duration: 2000
  501. });
  502. }
  503. });
  504. // uni.uploadFile({
  505. // url: uni.getStorageSync(
  506. // 'requestPath') +
  507. // '/app/contract/getSign', //仅为示例,非真实的接口地址
  508. // filePath: vas.tempFilePath,
  509. // name: 'file',
  510. // formData: {
  511. // 'contractId': that
  512. // .contractId // 上传附带参数
  513. // },
  514. // success: (
  515. // uploadFileRes) => {
  516. // // 根据接口具体返回格式 赋值具体对应url
  517. // console.log(
  518. // uploadFileRes
  519. // )
  520. // uni.showToast({
  521. // title: '签名成功',
  522. // duration: 500
  523. // });
  524. // setTimeout(() => {
  525. // uni.navigateBack({
  526. // delta: 1
  527. // });
  528. // }, 500)
  529. // }
  530. // });
  531. },
  532. fail(err){
  533. console.log(err)
  534. }
  535. })
  536. })
  537. }
  538. })
  539. return
  540. // console.log(res.tempFilePath, 'canvas生成图片地址');
  541. wx.saveImageToPhotosAlbum({
  542. filePath: res.tempFilePath,
  543. success(res) {
  544. wx.showToast({
  545. title: '已保存到相册',
  546. duration: 2000
  547. });
  548. }
  549. });
  550. }
  551. });
  552. },
  553. //预览
  554. previewCanvasImg() {
  555. wx.canvasToTempFilePath({
  556. canvasId: 'handWriting',
  557. fileType: 'jpg',
  558. quality: 1, //图片质量
  559. success(res) {
  560. // console.log(res.tempFilePath, 'canvas生成图片地址');
  561. wx.previewImage({
  562. urls: [res.tempFilePath] //预览图片 数组
  563. });
  564. }
  565. });
  566. /* //移动端出不来 ^~^!!
  567. this.canvasToImg( tempImgPath=>{
  568. wx.previewImage({
  569. urls: [tempImgPath], //预览图片 数组
  570. })
  571. } );
  572. */
  573. },
  574. //上传
  575. uploadCanvasImg() {
  576. wx.canvasToTempFilePath({
  577. canvasId: 'handWriting',
  578. fileType: 'png',
  579. quality: 1, //图片质量
  580. success(res) {
  581. // console.log(res.tempFilePath, 'canvas生成图片地址');
  582. //上传
  583. wx.uploadFile({
  584. url: 'https://example.weixin.qq.com/upload', // 仅为示例,非真实的接口地址
  585. filePath: res.tempFilePath,
  586. name: 'file_signature',
  587. formData: {
  588. user: 'test'
  589. },
  590. success(res) {
  591. const data = res.data;
  592. // do something
  593. }
  594. });
  595. }
  596. });
  597. },
  598. //设置canvas背景色 不设置 导出的canvas的背景为透明
  599. //@params:字符串 color
  600. setCanvasBg(color) {
  601. /* 将canvas背景设置为 白底,不设置 导出的canvas的背景为透明 */
  602. //rect() 参数说明 矩形路径左上角的横坐标,左上角的纵坐标, 矩形路径的宽度, 矩形路径的高度
  603. //这里是 canvasHeight - 4 是因为下边盖住边框了,所以手动减了写
  604. this.ctx.rect(0, 0, this.canvasWidth, this.canvasHeight - 4);
  605. // ctx.setFillStyle('red')
  606. this.ctx.setFillStyle(color);
  607. this.ctx.fill(); //设置填充
  608. this.ctx.draw(); //开画
  609. }
  610. }
  611. };
  612. </script>
  613. <style>
  614. page {
  615. background: #fbfbfb;
  616. height: auto;
  617. overflow: hidden;
  618. }
  619. </style>
  620. <style lang="scss" scoped>
  621. .sign{width: 100%;height: 100vh;padding: 24rpx;}
  622. .signtit{font-weight: 500;font-size: 30rpx;position: absolute;top: 220rpx;word-break: keep-all;transform: rotate(90deg);
  623. color: #666666;left: -140rpx;}
  624. .sinbtns{width: 214rpx;height: 74rpx;display: flex;align-items: center;justify-content: center;font-weight: 500;
  625. font-size: 30rpx;border-radius: 20rpx;position: absolute;left: -46rpx;transform: rotate(90deg);
  626. &.bga{background: #00A9F0;color: #FFFFFF;bottom: 126rpx;}
  627. &.bgb{background: #FFDEDE;color: #FF6969;bottom: 380rpx;}
  628. }
  629. .canvsborder{position:absolute;top:-2000%;}
  630. .wrapper {
  631. border: 2rpx solid #DADADA;;
  632. overflow: hidden;
  633. display: flex;
  634. align-content: center;
  635. flex-direction: row;
  636. justify-content: center;
  637. font-size: 28rpx;
  638. width: 100%;height: 100%;
  639. }
  640. .handWriting {
  641. background: #fff;
  642. width: 100%;
  643. height: 100%;
  644. }
  645. .handRight {
  646. display: inline-flex;
  647. align-items: center;
  648. }
  649. .handCenter {
  650. /* border: 4rpx dashed #e9e9e9; */
  651. flex: 1;
  652. overflow: hidden;
  653. box-sizing: border-box;
  654. }
  655. .handTitle {
  656. transform: rotate(90deg);
  657. flex: 1;
  658. color: #666;
  659. }
  660. .handBtn button {
  661. font-size: 28rpx;
  662. }
  663. .handBtn {
  664. position: relative;
  665. height: 100%;
  666. width: 60px;
  667. display: inline-flex;
  668. flex-direction: column;
  669. justify-content: space-between;
  670. align-content: space-between;
  671. flex: 0 0 auto;
  672. border-right: 2rpx solid #DADADA;
  673. }
  674. .delBtn {
  675. position: absolute;
  676. top: 250rpx;
  677. left: 0rpx;
  678. transform: rotate(90deg);
  679. color: #666;
  680. }
  681. .delBtn image {
  682. position: absolute;
  683. top: 13rpx;
  684. left: 25rpx;
  685. }
  686. .subBtn {
  687. position: absolute;
  688. bottom: 52rpx;
  689. left: -3rpx;
  690. display: inline-flex;
  691. transform: rotate(90deg);
  692. background: #008ef6;
  693. color: #fff;
  694. margin-bottom: 30rpx;
  695. text-align: center;
  696. justify-content: center;
  697. }
  698. /*Peach - 新增 - 保存*/
  699. .saveBtn {
  700. position: absolute;
  701. top: 375rpx;
  702. left: 0rpx;
  703. transform: rotate(90deg);
  704. color: #666;
  705. }
  706. .previewBtn {
  707. position: absolute;
  708. top: 500rpx;
  709. left: 0rpx;
  710. transform: rotate(90deg);
  711. color: #666;
  712. }
  713. .uploadBtn {
  714. position: absolute;
  715. top: 625rpx;
  716. left: 0rpx;
  717. transform: rotate(90deg);
  718. color: #666;
  719. }
  720. /*Peach - 新增 - 保存*/
  721. .black-select {
  722. width: 60rpx;
  723. height: 60rpx;
  724. position: absolute;
  725. top: 30rpx;
  726. left: 25rpx;
  727. }
  728. .black-select.color_select {
  729. width: 90rpx;
  730. height: 90rpx;
  731. top: 100rpx;
  732. left: 10rpx;
  733. }
  734. .red-select {
  735. width: 60rpx;
  736. height: 60rpx;
  737. position: absolute;
  738. top: 140rpx;
  739. left: 25rpx;
  740. }
  741. .red-select.color_select {
  742. width: 90rpx;
  743. height: 90rpx;
  744. top: 120rpx;
  745. left: 10rpx;
  746. }
  747. </style>