signContract.vue 26 KB

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