signContract.vue 27 KB

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