signContract.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881
  1. <template>
  2. <view class="content">
  3. <!-- <view class="content1">
  4. <view style='width:70px'>付款方式</view>
  5. <u-radio-group v-model="dataDetails.advanceFreightService" placement="row">
  6. <u-radio :customStyle="radioCustomStyle" v-for="(item, index) in radiolist1" :key="index"
  7. :label="item.name" :name="item.name" @change="radioChange">
  8. </u-radio>
  9. </u-radio-group>
  10. </view> -->
  11. <view class="content2">
  12. <view class="flex">
  13. <view class="title">合同摘要</view>
  14. <view class="preview" @click="submit(1)">预览合同</view>
  15. </view>
  16. <view class='row-between'>
  17. <view class="gray">发货单位</view>
  18. <view class="">{{dataDetails.compName?dataDetails.compName:'个人货主'}}</view>
  19. </view>
  20. <view class='row-between'>
  21. <view class="gray">发货地</view>
  22. <view class="place">
  23. {{dataDetails.sendPrivate}}{{dataDetails.sendCity}}{{dataDetails.sendArea}}{{dataDetails.sendDetailedAddress}}
  24. </view>
  25. </view>
  26. <view class='row-between'>
  27. <view class="gray">卸货地</view>
  28. <view class=" place">
  29. {{dataDetails.unloadPrivate}}{{dataDetails.unloadCity}}{{dataDetails.unloadArea}}{{dataDetails.unloadDetailedAddress}}
  30. </view>
  31. </view>
  32. <view class='row-between'>
  33. <view class="gray">货名</view>
  34. <view class="">{{dataDetails.goodsName}}</view>
  35. </view>
  36. <view class='row-between'>
  37. <view class="gray">距离</view>
  38. <view class="">约{{dataDetails.distance}}公里</view>
  39. </view>
  40. <view class='row-between'>
  41. <!-- 后加 -->
  42. <view class="gray">服务费(元)</view>
  43. <view class="">{{dataDetails.serviceCharge}}</view>
  44. </view>
  45. <view class="title">
  46. 完善信息
  47. </view>
  48. <view class='row-between'>
  49. <view class="gray">运费(元/车)</view>
  50. <!-- <view class="">{{dataDetails.freight}}{{dataDetails.illingMethod==0?'元/吨':'元/车'}}</view> -->
  51. <!-- <view class="flex"><input type="text" placeholder="请输入运费" v-model="dataDetails.freight"
  52. class="text-align-right yf-input">{{dataDetails.freight}}元/车</view> -->
  53. <view class="flex">
  54. <u--input placeholder="请输入运费" border="none" type="number" v-model="dataDetails.freight"
  55. inputAlign='right' clearable @input="preMoney"></u--input>
  56. <!-- <span> 元/车</span> -->
  57. </view>
  58. </view>
  59. <view class='row-between'>
  60. <view class="gray">车牌号</view>
  61. <view class="" style="color:#BBBBBB;" @click="carClick">
  62. {{dataDetails.carrierInfo.carNo?dataDetails.carrierInfo.carNo:'请选择车牌号'}}
  63. </view>
  64. <!-- <view class="flex">
  65. <input class="" v-model='dataDetails.carrierInfo.carNo' @click.stop="handleShowKeyboard"
  66. :disabled="true" placeholder="输入车牌号" name="input" style="text-align: right;"></input>
  67. </view> -->
  68. </view>
  69. <view class='row-between'>
  70. <view class="gray">挂车号(选填)</view>
  71. <view class="flex">
  72. <u--input placeholder="请输入挂车号" border="none" disabled v-model="dataDetails.trailerNumber"
  73. inputAlign='right' clearable></u--input>
  74. </view>
  75. </view>
  76. <view class='row-between'>
  77. <view class="gray">装车净重(吨)</view>
  78. <view class="flex">
  79. <u--input placeholder="请输入装车净重" border="none" v-model="dataDetails.weight" inputAlign='right'
  80. clearable></u--input>
  81. </view>
  82. </view>
  83. <view class='row-between'>
  84. <view class="gray">运输开始日期</view>
  85. <view class="">
  86. <view @click="dateShow">{{dataDetails.startDates?dataDetails.startDates:'请选择运输开始日期'}}
  87. </view>
  88. <u-calendar :show="startShow" mode="single" @confirm="startDate" @close="startShow= false">
  89. </u-calendar>
  90. </view>
  91. </view>
  92. <view class='row-between'>
  93. <view class="gray">运输截止日期</view>
  94. <view class="">
  95. <!-- <u--input placeholder="请输入内容" border="none" v-model="dataDetails.value" inputAlign='right'
  96. clearable></u--input> -->
  97. <view class="" @click="endShow = true">{{dataDetails.endDates?dataDetails.endDates:'请选择运输截止日期'}}
  98. </view>
  99. <u-calendar :show="endShow" mode="single" @confirm="endDate" @close="endShow= false"></u-calendar>
  100. </view>
  101. </view>
  102. <view class='row-between'>
  103. <view class="gray">联络人姓名</view>
  104. <view class="">
  105. <u--input placeholder="请输入联络人姓名" border="none" v-model="dataDetails.driverName" inputAlign='right'
  106. clearable></u--input>
  107. </view>
  108. </view>
  109. <view class='row-between'>
  110. <view class="gray">联络人电话</view>
  111. <view class="">
  112. <u--input placeholder="请输入联络人电话" border="none" type="number" maxlength="11"
  113. v-model="dataDetails.driverPhone" inputAlign='right' clearable></u--input>
  114. </view>
  115. </view>
  116. <view class='row-between'>
  117. <view class="gray">装车后预付款</view>
  118. <view class="">
  119. <u--input placeholder="自动获取,不可编辑" v-if="dataDetails.freightAdvance == 1" border="none"
  120. v-model="dataDetails.loadingAdvancePayment" inputAlign='right' clearable disabled></u--input>
  121. <u--input placeholder="请输入装车后预付款" v-else border="none" v-model="dataDetails.loadingAdvancePayment"
  122. inputAlign='right' clearable></u--input>
  123. </view>
  124. </view>
  125. <view class='row-between'>
  126. <view class="gray">收款账户</view>
  127. <view class="" @click="collection">
  128. {{dataDetails.bankDeposit?dataDetails.bankDeposit:"请选择收款账户"}}
  129. (尾号{{dataDetails.bankCard?dataDetails.bankCard.substring(dataDetails.bankCard.length - 4):""}})
  130. </view>
  131. </view>
  132. </view>
  133. <view class="wrapper content3">
  134. <view class="qm-row">
  135. <view class="handTitle">手写签名</view>
  136. <image src="@/static/xiangpica@2x.png" mode="widthFix" @click="retDraw" class="retDraw-image"></image>
  137. <!-- <button @click="retDraw" class="delBtn">重写</button> -->
  138. </view>
  139. <view class="handCenter">
  140. <canvas class="handWriting" :disable-scroll="true" @touchstart="uploadScaleStart"
  141. @touchmove="uploadScaleMove" canvas-id="handWriting"></canvas>
  142. </view>
  143. <view class="handRight">
  144. </view>
  145. <view class="handBtn">
  146. <!-- <image @click="selectColorEvent('black','#1A1A1A')"
  147. :src="selectColor === 'black' ? '/static/other/color_black_selected.png' : '/static/other/color_black.png'"
  148. :class="[selectColor === 'black' ? 'color_select' : '', 'black-select']"></image>
  149. <image @click="selectColorEvent('red','#ca262a')"
  150. :src="selectColor === 'red' ? '/static/other/color_red_selected.png' : '/static/other/color_red.png'"
  151. :class="[selectColor === 'red' ? 'color_select' : '', 'black-select']"></image> -->
  152. <!-- <button @click="saveCanvasAsImg" class="saveBtn">保存</button> -->
  153. <view @click="submit" class="saveBtn">提交</view>
  154. <!-- <button @click="previewCanvasImg" class="previewBtn">预览</button> -->
  155. <!-- <button @click="subCanvas" class="subBtn">完成</button> -->
  156. </view>
  157. </view>
  158. <u-picker :show="showCarList" :columns="carList" :closeOnClickOverlay='true' @close='selectTypeClose'
  159. @cancel='selectTypeClose' @confirm='confirmBtn'></u-picker>
  160. <master-keyboard ref="keyboard" keyboardtype="car" :show="keyShow" :randomNumber="true" :newCar="false"
  161. :defaultValue="carNumber" @keyboardClick="handleClick"></master-keyboard>
  162. <u-toast ref="uToast"></u-toast>
  163. <u-toast ref="uToast"></u-toast>
  164. </view>
  165. </template>
  166. <script>
  167. import {
  168. mapState
  169. } from 'vuex';
  170. var that;
  171. import uploadImage from '@/components/ossutil/uploadFile.js';
  172. export default {
  173. data() {
  174. return {
  175. showCarList: false,
  176. carList: [],
  177. carlistCopy: [],
  178. keyShow: false,
  179. carNumber: '',
  180. isScaleStart: false,
  181. radioCustomStyle: {
  182. margin: '0 0 0 10rpx'
  183. },
  184. canvasName: 'handWriting',
  185. ctx: "",
  186. startX: null,
  187. startY: null,
  188. canvasWidth: 0,
  189. canvasHeight: 0,
  190. selectColor: 'black',
  191. lineColor: '#1A1A1A', // 颜色
  192. lineSize: 5, // 笔记倍数
  193. value: true,
  194. dataDetails: {
  195. carrierInfo: {carNo:''},
  196. serviceCharge:'50'
  197. },
  198. radiolist1: [{
  199. name: '平台垫付运费',
  200. disabled: false
  201. },
  202. {
  203. name: '无需平台垫付运费',
  204. disabled: false
  205. },
  206. ],
  207. startShow: false,
  208. endShow: false,
  209. contractCheck:false,//判断合同是否提交
  210. proportion:"",//垫付比例
  211. };
  212. },
  213. computed: {
  214. ...mapState(['hasLogin', 'userInfo', 'firstAuthentication']),
  215. },
  216. onShow() {
  217. let payInfo = uni.getStorageSync("payInfo")
  218. if (payInfo) {
  219. this.dataDetails.bankCard = payInfo.bankCard
  220. this.dataDetails.bankDeposit = payInfo.bankDeposit
  221. this.dataDetails.bankDepositBranch = payInfo.bankDepositBranch
  222. this.dataDetails.payeeName = payInfo.payeeName
  223. } else {
  224. this.$request.baseRequest('get', '/driverPayeeInfo/getDriverPayee', {
  225. commonId: that.firstAuthentication.commonId
  226. }).then(res => {
  227. if(res.data){
  228. this.dataDetails.bankCard = res.data.bankCard
  229. this.dataDetails.bankDeposit = res.data.bankDeposit
  230. this.dataDetails.bankDepositBranch = res.data.bankDepositBranch
  231. this.dataDetails.payeeName = res.data.payeeName
  232. }
  233. })
  234. }
  235. this.$set(this.dataDetails.carrierInfo,'carNo',this.dataDetails.carNo)
  236. console.log(this.dataDetails)
  237. },
  238. onLoad(options) {
  239. this.carList = []
  240. that = this
  241. // this.dataDetails = JSON.parse(options.obj)
  242. this.dataDetails = JSON.parse(options.obj)
  243. // console.log(this.dataDetails.carNo,this.dataDetails.carrierInfo)
  244. if(this.userInfo.signImg){
  245. // 获取远程图片,canvas无法直接绘制远程图片
  246. uni.getImageInfo({
  247. src:this.userInfo.signImg,
  248. success(res){
  249. var ctx=uni.createCanvasContext('handWriting')
  250. ctx.drawImage(res.path,0,0,330,244)
  251. ctx.save()
  252. ctx.draw()
  253. }
  254. })
  255. }
  256. // this.dataDetails.advanceFreightService = '平台垫付运费'
  257. this.dataDetails = JSON.parse(decodeURIComponent(options.obj))
  258. if(this.dataDetails.freightAdvance == 1){
  259. this.proportion = this.dataDetails.driverAdvancePayment > this.dataDetails.ownerAdvancePayment ? this.dataDetails.ownerAdvancePayment:this.dataDetails.driverAdvancePayment
  260. }
  261. console.log(this.dataDetails)
  262. this.dataDetails.carrierInfo = {}
  263. this.ctx = uni.createCanvasContext("handWriting");
  264. this.$nextTick(() => {
  265. uni.createSelectorQuery().select('.handCenter').boundingClientRect(rect => {
  266. this.canvasWidth = rect.width;
  267. this.canvasHeight = rect.height;
  268. /* 将canvas背景设置为 白底,不设置 导出的canvas的背景为透明 */
  269. this.setCanvasBg('#fff');
  270. })
  271. .exec();
  272. });
  273. uni.showLoading({
  274. title: '加载中'
  275. })
  276. this.$request.baseRequest('get', '/driverCarInfo/selectDriverCar', {
  277. // driverId: that.userInfo.driverId,
  278. commonId:this.userInfo.id
  279. }).then(res => {
  280. if (res.code == '200') {
  281. uni.hideLoading()
  282. if (res.data.length > 0) {
  283. let _list = []
  284. for (let i = 0; i < res.data.length; i++) {
  285. if (res.data[i].status == '已通过') {
  286. _list.push(res.data[i].carNumber)
  287. }
  288. }
  289. that.carlistCopy = res.data
  290. that.carList = [_list]
  291. }
  292. } else {
  293. uni.$u.toast(res.message);
  294. }
  295. })
  296. .catch(res => {
  297. uni.$u.toast(res.message);
  298. });
  299. },
  300. methods: {
  301. preMoney(){
  302. if(this.dataDetails.freightAdvance == 1){
  303. this.dataDetails.loadingAdvancePayment = this.dataDetails.freight * this.proportion
  304. }
  305. },
  306. collection() {
  307. uni.$u.route('/pages/order/bankCard');
  308. },
  309. confirmBtn(e) {
  310. this.dataDetails.carrierInfo.carNo = e.value[0]
  311. for (let i = 0; i < this.carlistCopy.length; i++) {
  312. if (e.value[0] == this.carlistCopy[i].carNumber) {
  313. this.dataDetails.trailerNumber = this.carlistCopy[i].guaCarNumber
  314. }
  315. }
  316. this.showCarList = false
  317. },
  318. selectTypeClose() {
  319. this.showCarList = false
  320. },
  321. carClick() {
  322. this.showCarList = true
  323. },
  324. //车牌号弹出键盘
  325. handleShowKeyboard() {
  326. if (!this.dataDetails.carrierInfo.carNo) {
  327. this.carNumber = ''
  328. } else {
  329. this.carNumber = this.dataDetails.carrierInfo.carNo
  330. }
  331. if (this.$refs.keyboard.open) {
  332. this.$refs.keyboard.open(false) //true 键盘显示 false 键盘隐藏
  333. } else {
  334. this.$refs.keyboard[0].open(false)
  335. }
  336. if (this.$refs.keyboard.open) {
  337. this.$refs.keyboard.open(true) //true 键盘显示 false 键盘隐藏
  338. } else {
  339. this.$refs.keyboard[0].open(true)
  340. }
  341. },
  342. //车牌号弹出键盘
  343. handleClick(e) {
  344. this.carNumber = e.value
  345. this.dataDetails.carrierInfo.carNo = e.value //键盘输入值
  346. },
  347. dateShow() {
  348. this.startShow = true
  349. },
  350. removeStart() {
  351. this.startShow = false
  352. },
  353. removeEnd() {
  354. this.endShow = false
  355. },
  356. startDate(e) {
  357. this.startShow = false
  358. this.dataDetails.startDates = e[0]
  359. },
  360. endDate(e) {
  361. this.dataDetails.endDates = e[0]
  362. this.endShow = false
  363. },
  364. submit(num) {
  365. let _obj = {}
  366. if(num == 1){//预览合同
  367. _obj.submitFlag = 1
  368. this.contractCheck = false
  369. }else{//提交合同
  370. this.contractCheck = true
  371. _obj.submitFlag = 2
  372. }
  373. if (!that.isScaleStart) {
  374. if(!this.userInfo.signImg){
  375. that.$refs.uToast.show({
  376. type: 'error',
  377. message: "手写签名不能为空!",
  378. })
  379. return
  380. }
  381. }
  382. if (uni.$u.test.isEmpty(that.dataDetails.freight)) {
  383. that.$refs.uToast.show({
  384. type: 'error',
  385. message: "运费不能为空!",
  386. })
  387. return
  388. }
  389. if (uni.$u.test.isEmpty(that.dataDetails.startDates)) {
  390. that.$refs.uToast.show({
  391. type: 'error',
  392. message: "运输起始日期不能为空!",
  393. })
  394. return
  395. }
  396. if (uni.$u.test.isEmpty(that.dataDetails.endDates)) {
  397. that.$refs.uToast.show({
  398. type: 'error',
  399. message: "运输截止日期不能为空!",
  400. })
  401. return
  402. }
  403. if (uni.$u.test.isEmpty(that.dataDetails.driverName)) {
  404. that.$refs.uToast.show({
  405. type: 'error',
  406. message: "联络人姓名不能为空!",
  407. })
  408. return
  409. }
  410. if (uni.$u.test.isEmpty(that.dataDetails.driverPhone)) {
  411. that.$refs.uToast.show({
  412. type: 'error',
  413. message: "联络人电话不能为空!",
  414. })
  415. return
  416. }
  417. if (uni.$u.test.isEmpty(that.dataDetails.loadingAdvancePayment)) {
  418. that.$refs.uToast.show({
  419. type: 'error',
  420. message: "装车后预付款不能为空!",
  421. })
  422. return
  423. }
  424. _obj.trailerNumber = that.dataDetails.trailerNumber
  425. _obj.startDates = that.dataDetails.startDates
  426. _obj.endDates = that.dataDetails.endDates
  427. _obj.contactPersonName = that.dataDetails.driverName
  428. _obj.contactPersonPhone = that.dataDetails.driverPhone
  429. _obj.freightCars = that.dataDetails.freight
  430. // _obj.advanceCharge = that.dataDetails.advanceCharge
  431. _obj.id = that.dataDetails.id
  432. _obj.carNumber = that.dataDetails.carrierInfo.carNo
  433. _obj.weight = that.dataDetails.weight
  434. _obj.loadingAdvancePayment = that.dataDetails.loadingAdvancePayment
  435. _obj.typeFlag = 2
  436. uni.canvasToTempFilePath({
  437. canvasId: 'handWriting',
  438. fileType: 'png',
  439. quality: 1, //图片质量
  440. success(res) {
  441. uploadImage('image', res.tempFilePath, 'appData/',
  442. result => {
  443. // 上传成功
  444. that.dataDetails.cargoOwnerAutograph = result
  445. _obj.driverAutograph = result
  446. uni.showLoading({
  447. title: '加载中',
  448. mask: true
  449. })
  450. that.$request.baseRequest('get', '/orderInfo/setPdf', _obj).then(
  451. res => {
  452. if (res.code == 200) {
  453. uni.hideLoading()
  454. that.contractSrc = res.data
  455. uni.downloadFile({
  456. url: res.data,
  457. success: function(res) {
  458. var filePath = res.tempFilePath;
  459. uni.openDocument({
  460. filePath: filePath,
  461. showMenu: true,
  462. success: function(res) {
  463. console.log('打开文档成功');
  464. }
  465. });
  466. }
  467. });
  468. if(that.contractCheck){//提交
  469. that.$refs.uToast.show({
  470. type: 'success',
  471. message: "提交成功",
  472. complete() {
  473. uni.removeStorageSync("payInfo") //如果要有银行卡缓存就删除
  474. uni.$u.route('/pages/order/confirmLoading', {
  475. obj: JSON.stringify(that
  476. .dataDetails),
  477. });
  478. // that.upCallback({
  479. // size: 10,
  480. // num: 1
  481. // })
  482. }
  483. })
  484. }
  485. }else{
  486. uni.$u.toast(res.message);
  487. uni.hideLoading()
  488. }
  489. })
  490. .catch(res => {
  491. uni.$u.toast(res.message);
  492. });
  493. }
  494. )
  495. }
  496. });
  497. },
  498. // change(e){
  499. // if(this.value){
  500. // this.$set(this.dataDetails,'advanceFreightService',1)
  501. // }else{
  502. // this.$set(this.dataDetails,'advanceFreightService',0)
  503. // }
  504. // },
  505. // 笔迹开始
  506. uploadScaleStart(e) {
  507. this.isScaleStart = true
  508. this.startX = e.changedTouches[0].x
  509. this.startY = e.changedTouches[0].y
  510. //设置画笔参数
  511. //画笔颜色
  512. this.ctx.setStrokeStyle(this.lineColor)
  513. //设置线条粗细
  514. this.ctx.setLineWidth(this.lineSize)
  515. //设置线条的结束端点样式
  516. this.ctx.setLineCap("round") //'butt'、'round'、'square'
  517. //开始画笔
  518. this.ctx.beginPath()
  519. },
  520. // 笔迹移动
  521. uploadScaleMove(e) {
  522. //取点
  523. let temX = e.changedTouches[0].x
  524. let temY = e.changedTouches[0].y
  525. //画线条
  526. this.ctx.moveTo(this.startX, this.startY)
  527. this.ctx.lineTo(temX, temY)
  528. this.ctx.stroke()
  529. this.startX = temX
  530. this.startY = temY
  531. this.ctx.draw(true)
  532. },
  533. /**
  534. * 重写
  535. */
  536. retDraw() {
  537. this.ctx.clearRect(0, 0, 700, 730);
  538. this.ctx.draw();
  539. //设置canvas背景
  540. this.setCanvasBg('#fff');
  541. },
  542. /**
  543. * @param {Object} str
  544. * @param {Object} color
  545. * 选择颜色
  546. */
  547. selectColorEvent(str, color) {
  548. this.selectColor = str;
  549. this.lineColor = color;
  550. },
  551. //完成
  552. subCanvas() {
  553. uni.canvasToTempFilePath({
  554. canvasId: 'handWriting',
  555. fileType: 'png',
  556. quality: 1, //图片质量
  557. success(res) {
  558. // console.log(res.tempFilePath, 'canvas生成图片地址');
  559. uni.showToast({
  560. title: '以保存'
  561. });
  562. //保存到系统相册
  563. uni.saveImageToPhotosAlbum({
  564. filePath: res.tempFilePath,
  565. success(res) {
  566. uni.showToast({
  567. title: '已成功保存到相册',
  568. duration: 2000
  569. });
  570. }
  571. });
  572. }
  573. });
  574. },
  575. //保存到相册
  576. saveCanvasAsImg() {
  577. uni.canvasToTempFilePath({
  578. canvasId: 'handWriting',
  579. fileType: 'png',
  580. quality: 1, //图片质量
  581. success(res) {
  582. console.log(res.tempFilePath, 'canvas生成图片地址');
  583. uni.saveImageToPhotosAlbum({
  584. filePath: res.tempFilePath,
  585. success(res) {
  586. uni.showToast({
  587. title: '已保存到相册',
  588. duration: 2000
  589. });
  590. }
  591. });
  592. }
  593. });
  594. },
  595. //预览
  596. previewCanvasImg() {
  597. uni.canvasToTempFilePath({
  598. canvasId: 'handWriting',
  599. fileType: 'jpg',
  600. quality: 1, //图片质量
  601. success(res) {
  602. uni.previewImage({
  603. urls: [res.tempFilePath] //预览图片 数组
  604. });
  605. }
  606. });
  607. },
  608. //设置canvas背景色 不设置 导出的canvas的背景为透明
  609. //@params:字符串 color
  610. setCanvasBg(color) {
  611. /* 将canvas背景设置为 白底,不设置 导出的canvas的背景为透明 */
  612. //rect() 参数说明 矩形路径左上角的横坐标,左上角的纵坐标, 矩形路径的宽度, 矩形路径的高度
  613. //这里是 canvasHeight - 4 是因为下边盖住边框了,所以手动减了写
  614. this.ctx.rect(0, 0, this.canvasWidth, this.canvasHeight - 4);
  615. // ctx.setFillStyle('red')
  616. this.ctx.setFillStyle(color);
  617. this.ctx.fill(); //设置填充
  618. this.ctx.draw(); //开画
  619. }
  620. }
  621. };
  622. </script>
  623. <style lang="scss" scoped>
  624. page {
  625. background: #fbfbfb;
  626. height: auto;
  627. }
  628. .content1 {
  629. background: white;
  630. border-radius: 20rpx;
  631. margin: 20rpx;
  632. padding: 30rpx 20rpx;
  633. display: flex;
  634. justify-content: space-between;
  635. .right {
  636. display: flex;
  637. }
  638. }
  639. .content2 {
  640. background: white;
  641. border-radius: 20rpx;
  642. margin: 20rpx;
  643. padding: 30rpx 20rpx;
  644. .title {
  645. font-size: 36rpx;
  646. font-weight: 700;
  647. margin-bottom: 20rpx;
  648. width: 50%;
  649. }
  650. .preview{
  651. width: 50%;
  652. text-align: right;
  653. color: #2772FB;
  654. font-size: 26rpx;
  655. }
  656. .row-between {
  657. margin-bottom: 20rpx;
  658. }
  659. .left-text {
  660. margin-right: 20rpx;
  661. }
  662. .yf-input {
  663. padding-right: 10rpx;
  664. }
  665. }
  666. .content3 {
  667. background: white;
  668. border-radius: 20rpx;
  669. margin: 20rpx;
  670. padding: 30rpx 20rpx;
  671. }
  672. .place {
  673. width: 80%;
  674. text-align: right;
  675. }
  676. .handCenter {
  677. border: 4rpx dashed #e9e9e9;
  678. overflow: hidden;
  679. box-sizing: border-box;
  680. height: 500rpx;
  681. }
  682. .handWriting {
  683. background: #F9F9FB;
  684. width: 100%;
  685. height: 100%;
  686. }
  687. .handRight {
  688. display: inline-flex;
  689. align-items: center;
  690. }
  691. .handCenter {
  692. border: 4rpx dashed #e9e9e9;
  693. flex: 5;
  694. overflow: hidden;
  695. box-sizing: border-box;
  696. }
  697. .handTitle {
  698. font-size: 36rpx;
  699. color: #666;
  700. font-weight: 700;
  701. color: #333333;
  702. margin-bottom: 20rpx;
  703. }
  704. .retDraw-image {
  705. width: 50rpx;
  706. }
  707. .qm-row {
  708. display: flex;
  709. justify-content: space-between;
  710. }
  711. .saveBtn {
  712. width: 80%;
  713. background: #2772FB;
  714. color: white;
  715. text-align: center;
  716. border-radius: 50rpx;
  717. padding: 20rpx;
  718. }
  719. .handBtn {
  720. display: flex;
  721. justify-content: center;
  722. }
  723. /*
  724. .wrapper {
  725. width: 100%;
  726. height: 95vh;
  727. margin: 30rpx 0;
  728. overflow: hidden;
  729. display: flex;
  730. align-content: center;
  731. flex-direction: row;
  732. justify-content: center;
  733. font-size: 28rpx;
  734. }
  735. .handBtn button {
  736. font-size: 28rpx;
  737. }
  738. .handBtn {
  739. height: 95vh;
  740. display: inline-flex;
  741. flex-direction: column;
  742. justify-content: space-between;
  743. align-content: space-between;
  744. flex: 1;
  745. }
  746. .delBtn {
  747. position: absolute;
  748. top: 250rpx;
  749. left: 0rpx;
  750. transform: rotate(90deg);
  751. color: #666;
  752. }
  753. .delBtn image {
  754. position: absolute;
  755. top: 13rpx;
  756. left: 25rpx;
  757. }
  758. .subBtn {
  759. position: absolute;
  760. bottom: 52rpx;
  761. left: -3rpx;
  762. display: inline-flex;
  763. transform: rotate(90deg);
  764. background: #008ef6;
  765. color: #fff;
  766. margin-bottom: 30rpx;
  767. text-align: center;
  768. justify-content: center;
  769. }
  770. .saveBtn {
  771. position: absolute;
  772. top: 375rpx;
  773. left: 0rpx;
  774. transform: rotate(90deg);
  775. color: #666;
  776. }
  777. .previewBtn {
  778. position: absolute;
  779. top: 500rpx;
  780. left: 0rpx;
  781. transform: rotate(90deg);
  782. color: #666;
  783. }
  784. .uploadBtn {
  785. position: absolute;
  786. top: 625rpx;
  787. left: 0rpx;
  788. transform: rotate(90deg);
  789. color: #666;
  790. }
  791. .black-select {
  792. width: 60rpx;
  793. height: 60rpx;
  794. position: absolute;
  795. top: 30rpx;
  796. left: 25rpx;
  797. }
  798. .black-select.color_select {
  799. width: 90rpx;
  800. height: 90rpx;
  801. top: 100rpx;
  802. left: 10rpx;
  803. }
  804. .red-select {
  805. width: 60rpx;
  806. height: 60rpx;
  807. position: absolute;
  808. top: 140rpx;
  809. left: 25rpx;
  810. }
  811. .red-select.color_select {
  812. width: 90rpx;
  813. height: 90rpx;
  814. top: 120rpx;
  815. left: 10rpx;
  816. } */
  817. </style>