sign.vue 20 KB

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