sign.vue 20 KB

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