signContract.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910
  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.carrierInfo.carNo)) {
  387. that.$refs.uToast.show({
  388. type: 'error',
  389. message: "车牌号不能为空!",
  390. })
  391. return
  392. }
  393. if (uni.$u.test.isEmpty(that.dataDetails.weight)) {
  394. that.$refs.uToast.show({
  395. type: 'error',
  396. message: "装车净重不能为空!",
  397. })
  398. return
  399. }
  400. if (uni.$u.test.isEmpty(that.dataDetails.freight)) {
  401. that.$refs.uToast.show({
  402. type: 'error',
  403. message: "运费不能为空!",
  404. })
  405. return
  406. }
  407. if (uni.$u.test.isEmpty(that.dataDetails.tranStartDate)) {
  408. that.$refs.uToast.show({
  409. type: 'error',
  410. message: "运输起始日期不能为空!",
  411. })
  412. return
  413. }
  414. if (uni.$u.test.isEmpty(that.dataDetails.tranEndDate)) {
  415. that.$refs.uToast.show({
  416. type: 'error',
  417. message: "运输截止日期不能为空!",
  418. })
  419. return
  420. }
  421. if (uni.$u.test.isEmpty(that.dataDetails.driverName)) {
  422. that.$refs.uToast.show({
  423. type: 'error',
  424. message: "联络人姓名不能为空!",
  425. })
  426. return
  427. }
  428. if (uni.$u.test.isEmpty(that.dataDetails.driverPhone)) {
  429. that.$refs.uToast.show({
  430. type: 'error',
  431. message: "联络人电话不能为空!",
  432. })
  433. return
  434. }
  435. console.log(that.dataDetails.advanceCharge)
  436. if (uni.$u.test.isEmpty(that.dataDetails.advanceCharge)&&that.dataDetails.advanceCharge!=0) {
  437. that.$refs.uToast.show({
  438. type: 'error',
  439. message: "装车后预付款不能为空!",
  440. })
  441. return
  442. }
  443. if (uni.$u.test.isEmpty(that.dataDetails.bankDeposit)) {
  444. that.$refs.uToast.show({
  445. type: 'error',
  446. message: "收款账号不能为空!",
  447. })
  448. return
  449. }
  450. _obj.trailerNumber = that.dataDetails.trailerNumber
  451. _obj.tranStartDate = that.dataDetails.tranStartDate
  452. _obj.tranEndDate = that.dataDetails.tranEndDate
  453. _obj.contactPersonName = that.dataDetails.driverName
  454. _obj.contactPersonPhone = that.dataDetails.driverPhone
  455. _obj.freightCars = that.dataDetails.freight
  456. // _obj.advanceCharge = that.dataDetails.advanceCharge
  457. _obj.id = that.dataDetails.id
  458. _obj.carNumber = that.dataDetails.carrierInfo.carNo
  459. _obj.weight = that.dataDetails.weight
  460. _obj.advanceCharge = that.dataDetails.advanceCharge
  461. _obj.typeFlag = 2
  462. uni.canvasToTempFilePath({
  463. canvasId: 'handWriting',
  464. fileType: 'png',
  465. quality: 1, //图片质量
  466. success(res) {
  467. uploadImage('image', res.tempFilePath, 'appData/',
  468. result => {
  469. // 上传成功
  470. that.dataDetails.cargoOwnerAutograph = result
  471. _obj.driverAutograph = result
  472. uni.showLoading({
  473. title: '加载中',
  474. mask: true
  475. })
  476. that.$request.baseRequest('get', '/orderInfo/setPdf', _obj).then(
  477. res => {
  478. if (res.code == 200) {
  479. uni.hideLoading()
  480. that.contractSrc = res.data
  481. uni.downloadFile({
  482. url: res.data,
  483. success: function(res) {
  484. var filePath = res.tempFilePath;
  485. uni.openDocument({
  486. filePath: filePath,
  487. showMenu: true,
  488. success: function(res) {
  489. console.log('打开文档成功');
  490. }
  491. });
  492. }
  493. });
  494. if(that.contractCheck){//提交
  495. that.$refs.uToast.show({
  496. type: 'success',
  497. message: "提交成功",
  498. complete() {
  499. uni.removeStorageSync("payInfo") //如果要有银行卡缓存就删除
  500. uni.$u.route('/pages/order/confirmLoading', {
  501. obj: JSON.stringify(that
  502. .dataDetails),
  503. });
  504. // that.upCallback({
  505. // size: 10,
  506. // num: 1
  507. // })
  508. }
  509. })
  510. }
  511. }else{
  512. uni.$u.toast(res.message);
  513. uni.hideLoading()
  514. }
  515. })
  516. .catch(res => {
  517. uni.$u.toast(res.message);
  518. });
  519. }
  520. )
  521. }
  522. });
  523. },
  524. // change(e){
  525. // if(this.value){
  526. // this.$set(this.dataDetails,'advanceFreightService',1)
  527. // }else{
  528. // this.$set(this.dataDetails,'advanceFreightService',0)
  529. // }
  530. // },
  531. // 笔迹开始
  532. uploadScaleStart(e) {
  533. this.isScaleStart = true
  534. this.startX = e.changedTouches[0].x
  535. this.startY = e.changedTouches[0].y
  536. //设置画笔参数
  537. //画笔颜色
  538. this.ctx.setStrokeStyle(this.lineColor)
  539. //设置线条粗细
  540. this.ctx.setLineWidth(this.lineSize)
  541. //设置线条的结束端点样式
  542. this.ctx.setLineCap("round") //'butt'、'round'、'square'
  543. //开始画笔
  544. this.ctx.beginPath()
  545. },
  546. // 笔迹移动
  547. uploadScaleMove(e) {
  548. //取点
  549. let temX = e.changedTouches[0].x
  550. let temY = e.changedTouches[0].y
  551. //画线条
  552. this.ctx.moveTo(this.startX, this.startY)
  553. this.ctx.lineTo(temX, temY)
  554. this.ctx.stroke()
  555. this.startX = temX
  556. this.startY = temY
  557. this.ctx.draw(true)
  558. },
  559. /**
  560. * 重写
  561. */
  562. retDraw() {
  563. this.ctx.clearRect(0, 0, 700, 730);
  564. this.ctx.draw();
  565. //设置canvas背景
  566. this.setCanvasBg('#fff');
  567. },
  568. /**
  569. * @param {Object} str
  570. * @param {Object} color
  571. * 选择颜色
  572. */
  573. selectColorEvent(str, color) {
  574. this.selectColor = str;
  575. this.lineColor = color;
  576. },
  577. //完成
  578. subCanvas() {
  579. uni.canvasToTempFilePath({
  580. canvasId: 'handWriting',
  581. fileType: 'png',
  582. quality: 1, //图片质量
  583. success(res) {
  584. // console.log(res.tempFilePath, 'canvas生成图片地址');
  585. uni.showToast({
  586. title: '以保存'
  587. });
  588. //保存到系统相册
  589. uni.saveImageToPhotosAlbum({
  590. filePath: res.tempFilePath,
  591. success(res) {
  592. uni.showToast({
  593. title: '已成功保存到相册',
  594. duration: 2000
  595. });
  596. }
  597. });
  598. }
  599. });
  600. },
  601. //保存到相册
  602. saveCanvasAsImg() {
  603. uni.canvasToTempFilePath({
  604. canvasId: 'handWriting',
  605. fileType: 'png',
  606. quality: 1, //图片质量
  607. success(res) {
  608. console.log(res.tempFilePath, 'canvas生成图片地址');
  609. uni.saveImageToPhotosAlbum({
  610. filePath: res.tempFilePath,
  611. success(res) {
  612. uni.showToast({
  613. title: '已保存到相册',
  614. duration: 2000
  615. });
  616. }
  617. });
  618. }
  619. });
  620. },
  621. //预览
  622. previewCanvasImg() {
  623. uni.canvasToTempFilePath({
  624. canvasId: 'handWriting',
  625. fileType: 'jpg',
  626. quality: 1, //图片质量
  627. success(res) {
  628. uni.previewImage({
  629. urls: [res.tempFilePath] //预览图片 数组
  630. });
  631. }
  632. });
  633. },
  634. //设置canvas背景色 不设置 导出的canvas的背景为透明
  635. //@params:字符串 color
  636. setCanvasBg(color) {
  637. /* 将canvas背景设置为 白底,不设置 导出的canvas的背景为透明 */
  638. //rect() 参数说明 矩形路径左上角的横坐标,左上角的纵坐标, 矩形路径的宽度, 矩形路径的高度
  639. //这里是 canvasHeight - 4 是因为下边盖住边框了,所以手动减了写
  640. this.ctx.rect(0, 0, this.canvasWidth, this.canvasHeight - 4);
  641. // ctx.setFillStyle('red')
  642. this.ctx.setFillStyle(color);
  643. this.ctx.fill(); //设置填充
  644. this.ctx.draw(); //开画
  645. }
  646. }
  647. };
  648. </script>
  649. <style lang="scss" scoped>
  650. page {
  651. background: #fbfbfb;
  652. height: auto;
  653. }
  654. .content1 {
  655. background: white;
  656. border-radius: 20rpx;
  657. margin: 20rpx;
  658. padding: 30rpx 20rpx;
  659. display: flex;
  660. justify-content: space-between;
  661. .right {
  662. display: flex;
  663. }
  664. }
  665. .content2 {
  666. background: white;
  667. border-radius: 20rpx;
  668. margin: 20rpx;
  669. padding: 30rpx 20rpx;
  670. .title {
  671. font-size: 36rpx;
  672. font-weight: 700;
  673. margin-bottom: 20rpx;
  674. width: 50%;
  675. }
  676. .preview{
  677. width: 50%;
  678. text-align: right;
  679. color: #2772FB;
  680. font-size: 26rpx;
  681. }
  682. .row-between {
  683. margin-bottom: 20rpx;
  684. }
  685. .left-text {
  686. margin-right: 20rpx;
  687. }
  688. .yf-input {
  689. padding-right: 10rpx;
  690. }
  691. }
  692. .content3 {
  693. background: white;
  694. border-radius: 20rpx;
  695. margin: 20rpx;
  696. padding: 30rpx 20rpx;
  697. }
  698. .place {
  699. width: 80%;
  700. text-align: right;
  701. }
  702. .handCenter {
  703. border: 4rpx dashed #e9e9e9;
  704. overflow: hidden;
  705. box-sizing: border-box;
  706. height: 500rpx;
  707. }
  708. .handWriting {
  709. background: #F9F9FB;
  710. width: 100%;
  711. height: 100%;
  712. }
  713. .handRight {
  714. display: inline-flex;
  715. align-items: center;
  716. }
  717. .handCenter {
  718. border: 4rpx dashed #e9e9e9;
  719. flex: 5;
  720. overflow: hidden;
  721. box-sizing: border-box;
  722. }
  723. .handTitle {
  724. font-size: 36rpx;
  725. color: #666;
  726. font-weight: 700;
  727. color: #333333;
  728. margin-bottom: 20rpx;
  729. }
  730. .retDraw-image {
  731. width: 50rpx;
  732. }
  733. .qm-row {
  734. display: flex;
  735. justify-content: space-between;
  736. }
  737. .saveBtn {
  738. width: 80%;
  739. background: #2772FB;
  740. color: white;
  741. text-align: center;
  742. border-radius: 50rpx;
  743. padding: 20rpx;
  744. }
  745. .handBtn {
  746. display: flex;
  747. justify-content: center;
  748. }
  749. /*
  750. .wrapper {
  751. width: 100%;
  752. height: 95vh;
  753. margin: 30rpx 0;
  754. overflow: hidden;
  755. display: flex;
  756. align-content: center;
  757. flex-direction: row;
  758. justify-content: center;
  759. font-size: 28rpx;
  760. }
  761. .handBtn button {
  762. font-size: 28rpx;
  763. }
  764. .handBtn {
  765. height: 95vh;
  766. display: inline-flex;
  767. flex-direction: column;
  768. justify-content: space-between;
  769. align-content: space-between;
  770. flex: 1;
  771. }
  772. .delBtn {
  773. position: absolute;
  774. top: 250rpx;
  775. left: 0rpx;
  776. transform: rotate(90deg);
  777. color: #666;
  778. }
  779. .delBtn image {
  780. position: absolute;
  781. top: 13rpx;
  782. left: 25rpx;
  783. }
  784. .subBtn {
  785. position: absolute;
  786. bottom: 52rpx;
  787. left: -3rpx;
  788. display: inline-flex;
  789. transform: rotate(90deg);
  790. background: #008ef6;
  791. color: #fff;
  792. margin-bottom: 30rpx;
  793. text-align: center;
  794. justify-content: center;
  795. }
  796. .saveBtn {
  797. position: absolute;
  798. top: 375rpx;
  799. left: 0rpx;
  800. transform: rotate(90deg);
  801. color: #666;
  802. }
  803. .previewBtn {
  804. position: absolute;
  805. top: 500rpx;
  806. left: 0rpx;
  807. transform: rotate(90deg);
  808. color: #666;
  809. }
  810. .uploadBtn {
  811. position: absolute;
  812. top: 625rpx;
  813. left: 0rpx;
  814. transform: rotate(90deg);
  815. color: #666;
  816. }
  817. .black-select {
  818. width: 60rpx;
  819. height: 60rpx;
  820. position: absolute;
  821. top: 30rpx;
  822. left: 25rpx;
  823. }
  824. .black-select.color_select {
  825. width: 90rpx;
  826. height: 90rpx;
  827. top: 100rpx;
  828. left: 10rpx;
  829. }
  830. .red-select {
  831. width: 60rpx;
  832. height: 60rpx;
  833. position: absolute;
  834. top: 140rpx;
  835. left: 25rpx;
  836. }
  837. .red-select.color_select {
  838. width: 90rpx;
  839. height: 90rpx;
  840. top: 120rpx;
  841. left: 10rpx;
  842. } */
  843. // /deep/.uni-input-input:disabled {
  844. // background:#fff;
  845. // }
  846. </style>