signContract.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888
  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.tranStartDate?dataDetails.tranStartDate:'请选择运输开始日期'}}
  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.tranEndDate?dataDetails.tranEndDate:'请选择运输截止日期'}}
  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.advanceCharge" inputAlign='right' clearable disabled></u--input>
  121. <u--input placeholder="请输入装车后预付款" v-else border="none" v-model="dataDetails.advanceCharge"
  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:'',loadingAdvancePayment:''},
  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. console.log(this.dataDetails.advanceCharge)
  236. this.$set(this.dataDetails.carrierInfo,'carNo',this.dataDetails.carNumber)
  237. this.preMoney()
  238. // this.$set(this.dataDetails,'advanceCharge',this.dataDetails.advanceCharge)
  239. // this.$set(this.dataDetails.carrierInfo,'carNo',this.dataDetails.carNo)
  240. console.log(this.dataDetails)
  241. },
  242. onLoad(options) {
  243. this.carList = []
  244. that = this
  245. // this.dataDetails = JSON.parse(options.obj)
  246. this.dataDetails = JSON.parse(options.obj)
  247. // console.log(this.dataDetails.carNo,this.dataDetails.carrierInfo)
  248. if(this.userInfo.signImg){
  249. // 获取远程图片,canvas无法直接绘制远程图片
  250. uni.getImageInfo({
  251. src:this.userInfo.signImg,
  252. success(res){
  253. var ctx=uni.createCanvasContext('handWriting')
  254. ctx.drawImage(res.path,0,0,330,244)
  255. ctx.save()
  256. ctx.draw()
  257. }
  258. })
  259. }
  260. // this.dataDetails.advanceFreightService = '平台垫付运费'
  261. this.dataDetails = JSON.parse(decodeURIComponent(options.obj))
  262. if(this.dataDetails.freightAdvance == 1){
  263. this.proportion = this.dataDetails.driverAdvancePayment >= this.dataDetails.ownerAdvancePayment ? this.dataDetails.ownerAdvancePayment:this.dataDetails.driverAdvancePayment
  264. }
  265. console.log(this.dataDetails)
  266. this.dataDetails.carrierInfo = {}
  267. this.ctx = uni.createCanvasContext("handWriting");
  268. this.$nextTick(() => {
  269. uni.createSelectorQuery().select('.handCenter').boundingClientRect(rect => {
  270. this.canvasWidth = rect.width;
  271. this.canvasHeight = rect.height;
  272. /* 将canvas背景设置为 白底,不设置 导出的canvas的背景为透明 */
  273. this.setCanvasBg('#fff');
  274. })
  275. .exec();
  276. });
  277. uni.showLoading({
  278. title: '加载中'
  279. })
  280. this.$request.baseRequest('get', '/driverCarInfo/selectDriverCar', {
  281. // driverId: that.userInfo.driverId,
  282. commonId:this.userInfo.id
  283. }).then(res => {
  284. if (res.code == '200') {
  285. uni.hideLoading()
  286. if (res.data.length > 0) {
  287. let _list = []
  288. for (let i = 0; i < res.data.length; i++) {
  289. if (res.data[i].status == '已通过') {
  290. _list.push(res.data[i].carNumber)
  291. }
  292. }
  293. that.carlistCopy = res.data
  294. that.carList = [_list]
  295. }
  296. } else {
  297. uni.$u.toast(res.message);
  298. }
  299. })
  300. .catch(res => {
  301. uni.$u.toast(res.message);
  302. });
  303. },
  304. methods: {
  305. preMoney(){
  306. if(this.dataDetails.freightAdvance == 1){
  307. this.dataDetails.advanceCharge = this.dataDetails.freight * this.proportion
  308. }
  309. },
  310. collection() {
  311. uni.$u.route('/pages/order/bankCard');
  312. },
  313. confirmBtn(e) {
  314. this.dataDetails.carrierInfo.carNo = e.value[0]
  315. for (let i = 0; i < this.carlistCopy.length; i++) {
  316. if (e.value[0] == this.carlistCopy[i].carNumber) {
  317. this.dataDetails.trailerNumber = this.carlistCopy[i].guaCarNumber
  318. }
  319. }
  320. this.showCarList = false
  321. },
  322. selectTypeClose() {
  323. this.showCarList = false
  324. },
  325. carClick() {
  326. this.showCarList = true
  327. },
  328. //车牌号弹出键盘
  329. handleShowKeyboard() {
  330. if (!this.dataDetails.carrierInfo.carNo) {
  331. this.carNumber = ''
  332. } else {
  333. this.carNumber = this.dataDetails.carrierInfo.carNo
  334. }
  335. if (this.$refs.keyboard.open) {
  336. this.$refs.keyboard.open(false) //true 键盘显示 false 键盘隐藏
  337. } else {
  338. this.$refs.keyboard[0].open(false)
  339. }
  340. if (this.$refs.keyboard.open) {
  341. this.$refs.keyboard.open(true) //true 键盘显示 false 键盘隐藏
  342. } else {
  343. this.$refs.keyboard[0].open(true)
  344. }
  345. },
  346. //车牌号弹出键盘
  347. handleClick(e) {
  348. this.carNumber = e.value
  349. this.dataDetails.carrierInfo.carNo = e.value //键盘输入值
  350. },
  351. dateShow() {
  352. this.startShow = true
  353. },
  354. removeStart() {
  355. this.startShow = false
  356. },
  357. removeEnd() {
  358. this.endShow = false
  359. },
  360. startDate(e) {
  361. this.startShow = false
  362. this.dataDetails.tranStartDate = e[0]
  363. },
  364. endDate(e) {
  365. this.dataDetails.tranEndDate = e[0]
  366. this.endShow = false
  367. },
  368. submit(num) {
  369. let _obj = {}
  370. if(num == 1){//预览合同
  371. _obj.submitFlag = 1
  372. this.contractCheck = false
  373. }else{//提交合同
  374. this.contractCheck = true
  375. _obj.submitFlag = 2
  376. }
  377. if (!that.isScaleStart) {
  378. if(!this.userInfo.signImg){
  379. that.$refs.uToast.show({
  380. type: 'error',
  381. message: "手写签名不能为空!",
  382. })
  383. return
  384. }
  385. }
  386. if (uni.$u.test.isEmpty(that.dataDetails.freight)) {
  387. that.$refs.uToast.show({
  388. type: 'error',
  389. message: "运费不能为空!",
  390. })
  391. return
  392. }
  393. if (uni.$u.test.isEmpty(that.dataDetails.tranStartDate)) {
  394. that.$refs.uToast.show({
  395. type: 'error',
  396. message: "运输起始日期不能为空!",
  397. })
  398. return
  399. }
  400. if (uni.$u.test.isEmpty(that.dataDetails.tranEndDate)) {
  401. that.$refs.uToast.show({
  402. type: 'error',
  403. message: "运输截止日期不能为空!",
  404. })
  405. return
  406. }
  407. if (uni.$u.test.isEmpty(that.dataDetails.driverName)) {
  408. that.$refs.uToast.show({
  409. type: 'error',
  410. message: "联络人姓名不能为空!",
  411. })
  412. return
  413. }
  414. if (uni.$u.test.isEmpty(that.dataDetails.driverPhone)) {
  415. that.$refs.uToast.show({
  416. type: 'error',
  417. message: "联络人电话不能为空!",
  418. })
  419. return
  420. }
  421. console.log(that.dataDetails.advanceCharge)
  422. if (uni.$u.test.isEmpty(that.dataDetails.advanceCharge)&&that.dataDetails.advanceCharge!=0) {
  423. that.$refs.uToast.show({
  424. type: 'error',
  425. message: "装车后预付款不能为空!",
  426. })
  427. return
  428. }
  429. _obj.trailerNumber = that.dataDetails.trailerNumber
  430. _obj.tranStartDate = that.dataDetails.tranStartDate
  431. _obj.tranEndDate = that.dataDetails.tranEndDate
  432. _obj.contactPersonName = that.dataDetails.driverName
  433. _obj.contactPersonPhone = that.dataDetails.driverPhone
  434. _obj.freightCars = that.dataDetails.freight
  435. // _obj.advanceCharge = that.dataDetails.advanceCharge
  436. _obj.id = that.dataDetails.id
  437. _obj.carNumber = that.dataDetails.carrierInfo.carNo
  438. _obj.weight = that.dataDetails.weight
  439. _obj.advanceCharge = that.dataDetails.advanceCharge
  440. _obj.typeFlag = 2
  441. uni.canvasToTempFilePath({
  442. canvasId: 'handWriting',
  443. fileType: 'png',
  444. quality: 1, //图片质量
  445. success(res) {
  446. uploadImage('image', res.tempFilePath, 'appData/',
  447. result => {
  448. // 上传成功
  449. that.dataDetails.cargoOwnerAutograph = result
  450. _obj.driverAutograph = result
  451. uni.showLoading({
  452. title: '加载中',
  453. mask: true
  454. })
  455. that.$request.baseRequest('get', '/orderInfo/setPdf', _obj).then(
  456. res => {
  457. if (res.code == 200) {
  458. uni.hideLoading()
  459. that.contractSrc = res.data
  460. uni.downloadFile({
  461. url: res.data,
  462. success: function(res) {
  463. var filePath = res.tempFilePath;
  464. uni.openDocument({
  465. filePath: filePath,
  466. showMenu: true,
  467. success: function(res) {
  468. console.log('打开文档成功');
  469. }
  470. });
  471. }
  472. });
  473. if(that.contractCheck){//提交
  474. that.$refs.uToast.show({
  475. type: 'success',
  476. message: "提交成功",
  477. complete() {
  478. uni.removeStorageSync("payInfo") //如果要有银行卡缓存就删除
  479. uni.$u.route('/pages/order/confirmLoading', {
  480. obj: JSON.stringify(that
  481. .dataDetails),
  482. });
  483. // that.upCallback({
  484. // size: 10,
  485. // num: 1
  486. // })
  487. }
  488. })
  489. }
  490. }else{
  491. uni.$u.toast(res.message);
  492. uni.hideLoading()
  493. }
  494. })
  495. .catch(res => {
  496. uni.$u.toast(res.message);
  497. });
  498. }
  499. )
  500. }
  501. });
  502. },
  503. // change(e){
  504. // if(this.value){
  505. // this.$set(this.dataDetails,'advanceFreightService',1)
  506. // }else{
  507. // this.$set(this.dataDetails,'advanceFreightService',0)
  508. // }
  509. // },
  510. // 笔迹开始
  511. uploadScaleStart(e) {
  512. this.isScaleStart = true
  513. this.startX = e.changedTouches[0].x
  514. this.startY = e.changedTouches[0].y
  515. //设置画笔参数
  516. //画笔颜色
  517. this.ctx.setStrokeStyle(this.lineColor)
  518. //设置线条粗细
  519. this.ctx.setLineWidth(this.lineSize)
  520. //设置线条的结束端点样式
  521. this.ctx.setLineCap("round") //'butt'、'round'、'square'
  522. //开始画笔
  523. this.ctx.beginPath()
  524. },
  525. // 笔迹移动
  526. uploadScaleMove(e) {
  527. //取点
  528. let temX = e.changedTouches[0].x
  529. let temY = e.changedTouches[0].y
  530. //画线条
  531. this.ctx.moveTo(this.startX, this.startY)
  532. this.ctx.lineTo(temX, temY)
  533. this.ctx.stroke()
  534. this.startX = temX
  535. this.startY = temY
  536. this.ctx.draw(true)
  537. },
  538. /**
  539. * 重写
  540. */
  541. retDraw() {
  542. this.ctx.clearRect(0, 0, 700, 730);
  543. this.ctx.draw();
  544. //设置canvas背景
  545. this.setCanvasBg('#fff');
  546. },
  547. /**
  548. * @param {Object} str
  549. * @param {Object} color
  550. * 选择颜色
  551. */
  552. selectColorEvent(str, color) {
  553. this.selectColor = str;
  554. this.lineColor = color;
  555. },
  556. //完成
  557. subCanvas() {
  558. uni.canvasToTempFilePath({
  559. canvasId: 'handWriting',
  560. fileType: 'png',
  561. quality: 1, //图片质量
  562. success(res) {
  563. // console.log(res.tempFilePath, 'canvas生成图片地址');
  564. uni.showToast({
  565. title: '以保存'
  566. });
  567. //保存到系统相册
  568. uni.saveImageToPhotosAlbum({
  569. filePath: res.tempFilePath,
  570. success(res) {
  571. uni.showToast({
  572. title: '已成功保存到相册',
  573. duration: 2000
  574. });
  575. }
  576. });
  577. }
  578. });
  579. },
  580. //保存到相册
  581. saveCanvasAsImg() {
  582. uni.canvasToTempFilePath({
  583. canvasId: 'handWriting',
  584. fileType: 'png',
  585. quality: 1, //图片质量
  586. success(res) {
  587. console.log(res.tempFilePath, 'canvas生成图片地址');
  588. uni.saveImageToPhotosAlbum({
  589. filePath: res.tempFilePath,
  590. success(res) {
  591. uni.showToast({
  592. title: '已保存到相册',
  593. duration: 2000
  594. });
  595. }
  596. });
  597. }
  598. });
  599. },
  600. //预览
  601. previewCanvasImg() {
  602. uni.canvasToTempFilePath({
  603. canvasId: 'handWriting',
  604. fileType: 'jpg',
  605. quality: 1, //图片质量
  606. success(res) {
  607. uni.previewImage({
  608. urls: [res.tempFilePath] //预览图片 数组
  609. });
  610. }
  611. });
  612. },
  613. //设置canvas背景色 不设置 导出的canvas的背景为透明
  614. //@params:字符串 color
  615. setCanvasBg(color) {
  616. /* 将canvas背景设置为 白底,不设置 导出的canvas的背景为透明 */
  617. //rect() 参数说明 矩形路径左上角的横坐标,左上角的纵坐标, 矩形路径的宽度, 矩形路径的高度
  618. //这里是 canvasHeight - 4 是因为下边盖住边框了,所以手动减了写
  619. this.ctx.rect(0, 0, this.canvasWidth, this.canvasHeight - 4);
  620. // ctx.setFillStyle('red')
  621. this.ctx.setFillStyle(color);
  622. this.ctx.fill(); //设置填充
  623. this.ctx.draw(); //开画
  624. }
  625. }
  626. };
  627. </script>
  628. <style lang="scss" scoped>
  629. page {
  630. background: #fbfbfb;
  631. height: auto;
  632. }
  633. .content1 {
  634. background: white;
  635. border-radius: 20rpx;
  636. margin: 20rpx;
  637. padding: 30rpx 20rpx;
  638. display: flex;
  639. justify-content: space-between;
  640. .right {
  641. display: flex;
  642. }
  643. }
  644. .content2 {
  645. background: white;
  646. border-radius: 20rpx;
  647. margin: 20rpx;
  648. padding: 30rpx 20rpx;
  649. .title {
  650. font-size: 36rpx;
  651. font-weight: 700;
  652. margin-bottom: 20rpx;
  653. width: 50%;
  654. }
  655. .preview{
  656. width: 50%;
  657. text-align: right;
  658. color: #2772FB;
  659. font-size: 26rpx;
  660. }
  661. .row-between {
  662. margin-bottom: 20rpx;
  663. }
  664. .left-text {
  665. margin-right: 20rpx;
  666. }
  667. .yf-input {
  668. padding-right: 10rpx;
  669. }
  670. }
  671. .content3 {
  672. background: white;
  673. border-radius: 20rpx;
  674. margin: 20rpx;
  675. padding: 30rpx 20rpx;
  676. }
  677. .place {
  678. width: 80%;
  679. text-align: right;
  680. }
  681. .handCenter {
  682. border: 4rpx dashed #e9e9e9;
  683. overflow: hidden;
  684. box-sizing: border-box;
  685. height: 500rpx;
  686. }
  687. .handWriting {
  688. background: #F9F9FB;
  689. width: 100%;
  690. height: 100%;
  691. }
  692. .handRight {
  693. display: inline-flex;
  694. align-items: center;
  695. }
  696. .handCenter {
  697. border: 4rpx dashed #e9e9e9;
  698. flex: 5;
  699. overflow: hidden;
  700. box-sizing: border-box;
  701. }
  702. .handTitle {
  703. font-size: 36rpx;
  704. color: #666;
  705. font-weight: 700;
  706. color: #333333;
  707. margin-bottom: 20rpx;
  708. }
  709. .retDraw-image {
  710. width: 50rpx;
  711. }
  712. .qm-row {
  713. display: flex;
  714. justify-content: space-between;
  715. }
  716. .saveBtn {
  717. width: 80%;
  718. background: #2772FB;
  719. color: white;
  720. text-align: center;
  721. border-radius: 50rpx;
  722. padding: 20rpx;
  723. }
  724. .handBtn {
  725. display: flex;
  726. justify-content: center;
  727. }
  728. /*
  729. .wrapper {
  730. width: 100%;
  731. height: 95vh;
  732. margin: 30rpx 0;
  733. overflow: hidden;
  734. display: flex;
  735. align-content: center;
  736. flex-direction: row;
  737. justify-content: center;
  738. font-size: 28rpx;
  739. }
  740. .handBtn button {
  741. font-size: 28rpx;
  742. }
  743. .handBtn {
  744. height: 95vh;
  745. display: inline-flex;
  746. flex-direction: column;
  747. justify-content: space-between;
  748. align-content: space-between;
  749. flex: 1;
  750. }
  751. .delBtn {
  752. position: absolute;
  753. top: 250rpx;
  754. left: 0rpx;
  755. transform: rotate(90deg);
  756. color: #666;
  757. }
  758. .delBtn image {
  759. position: absolute;
  760. top: 13rpx;
  761. left: 25rpx;
  762. }
  763. .subBtn {
  764. position: absolute;
  765. bottom: 52rpx;
  766. left: -3rpx;
  767. display: inline-flex;
  768. transform: rotate(90deg);
  769. background: #008ef6;
  770. color: #fff;
  771. margin-bottom: 30rpx;
  772. text-align: center;
  773. justify-content: center;
  774. }
  775. .saveBtn {
  776. position: absolute;
  777. top: 375rpx;
  778. left: 0rpx;
  779. transform: rotate(90deg);
  780. color: #666;
  781. }
  782. .previewBtn {
  783. position: absolute;
  784. top: 500rpx;
  785. left: 0rpx;
  786. transform: rotate(90deg);
  787. color: #666;
  788. }
  789. .uploadBtn {
  790. position: absolute;
  791. top: 625rpx;
  792. left: 0rpx;
  793. transform: rotate(90deg);
  794. color: #666;
  795. }
  796. .black-select {
  797. width: 60rpx;
  798. height: 60rpx;
  799. position: absolute;
  800. top: 30rpx;
  801. left: 25rpx;
  802. }
  803. .black-select.color_select {
  804. width: 90rpx;
  805. height: 90rpx;
  806. top: 100rpx;
  807. left: 10rpx;
  808. }
  809. .red-select {
  810. width: 60rpx;
  811. height: 60rpx;
  812. position: absolute;
  813. top: 140rpx;
  814. left: 25rpx;
  815. }
  816. .red-select.color_select {
  817. width: 90rpx;
  818. height: 90rpx;
  819. top: 120rpx;
  820. left: 10rpx;
  821. } */
  822. // /deep/.uni-input-input:disabled {
  823. // background:#fff;
  824. // }
  825. </style>