signContract.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  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 class="left">
  11. 付款方式
  12. </view>
  13. <view class="right">
  14. <view class="left-text">平台垫付运费</view>
  15. <u-switch @change="change" v-model="value" inactiveColor='#ABB0BB' size="20" ></u-switch>
  16. </view> -->
  17. <!-- </view> -->
  18. <view class="content2">
  19. <view class="title">
  20. 合同摘要
  21. </view>
  22. <view class='row-between'>
  23. <view class="gray">发货单位</view>
  24. <view class="">{{dataDetails.compName?dataDetails.compName:'个人货主'}}</view>
  25. </view>
  26. <view class='row-between'>
  27. <view class="gray">发货地</view>
  28. <view class="place">
  29. {{dataDetails.sendPrivate}}{{dataDetails.sendCity}}{{dataDetails.sendArea}}{{dataDetails.sendDetailedAddress}}
  30. </view>
  31. </view>
  32. <view class='row-between'>
  33. <view class="gray">卸货地</view>
  34. <view class=" place">
  35. {{dataDetails.unloadPrivate}}{{dataDetails.unloadCity}}{{dataDetails.unloadArea}}{{dataDetails.unloadDetailedAddress}}
  36. </view>
  37. </view>
  38. <view class='row-between'>
  39. <view class="gray">货名</view>
  40. <view class="">{{dataDetails.goodsName}}</view>
  41. </view>
  42. <view class='row-between'>
  43. <view class="gray">距离</view>
  44. <view class="">约{{dataDetails.distance}}公里</view>
  45. </view>
  46. <!-- <view class='row-between'>
  47. <view class="gray">运费</view>
  48. <view class="">{{dataDetails.freightInfo.freight}}{{dataDetails.illingMethod==0?'元/吨':'元/车'}}</view>
  49. </view> -->
  50. <view class='row-between'>
  51. <!-- 后加 -->
  52. <view class="gray">服务费(元)</view>
  53. <view class="">{{dataDetails.serviceCharge}}</view>
  54. </view>
  55. </view>
  56. <view class="wrapper content3">
  57. <view class="qm-row">
  58. <view class="handTitle">手写签名</view>
  59. <image src="@/static/xiangpica@2x.png" mode="widthFix" @click="retDraw" class="retDraw-image"></image>
  60. <!-- <button @click="retDraw" class="delBtn">重写</button> -->
  61. </view>
  62. <view class="handCenter">
  63. <canvas class="handWriting" :disable-scroll="true" @touchstart="uploadScaleStart"
  64. @touchmove="uploadScaleMove" canvas-id="handWriting"></canvas>
  65. </view>
  66. <view class="handRight">
  67. </view>
  68. <view class="handBtn">
  69. <!-- <image @click="selectColorEvent('black','#1A1A1A')"
  70. :src="selectColor === 'black' ? '/static/other/color_black_selected.png' : '/static/other/color_black.png'"
  71. :class="[selectColor === 'black' ? 'color_select' : '', 'black-select']"></image>
  72. <image @click="selectColorEvent('red','#ca262a')"
  73. :src="selectColor === 'red' ? '/static/other/color_red_selected.png' : '/static/other/color_red.png'"
  74. :class="[selectColor === 'red' ? 'color_select' : '', 'black-select']"></image> -->
  75. <!-- <button @click="saveCanvasAsImg" class="saveBtn">保存</button> -->
  76. <view @click="submit" class="saveBtn">提交</view>
  77. <!-- <button @click="previewCanvasImg" class="previewBtn">预览</button> -->
  78. <!-- <button @click="subCanvas" class="subBtn">完成</button> -->
  79. </view>
  80. </view>
  81. <u-toast ref="uToast"></u-toast>
  82. </view>
  83. </template>
  84. <script>
  85. var that;
  86. import uploadImage from '@/components/ossutil/uploadFile.js';
  87. export default {
  88. data() {
  89. return {
  90. isScaleStart: false,
  91. radioCustomStyle: {
  92. margin: '0 0 0 10rpx'
  93. },
  94. canvasName: 'handWriting',
  95. ctx: '',
  96. startX: null,
  97. startY: null,
  98. canvasWidth: 0,
  99. canvasHeight: 0,
  100. selectColor: 'black',
  101. lineColor: '#1A1A1A', // 颜色
  102. lineSize: 5, // 笔记倍数
  103. value: true,
  104. dataDetails: {
  105. carrierInfo: {},
  106. serviceCharge:'50'
  107. },
  108. radiolist1: [{
  109. name: '平台垫付运费',
  110. disabled: false
  111. },
  112. {
  113. name: '无需平台垫付运费',
  114. disabled: false
  115. },
  116. ],
  117. };
  118. },
  119. onLoad(options) {
  120. that = this
  121. console.log(options)
  122. this.dataDetails = JSON.parse(decodeURIComponent(options.obj))
  123. // this.dataDetails.advanceFreightService = '平台垫付运费'
  124. this.ctx = uni.createCanvasContext("handWriting");
  125. this.$nextTick(() => {
  126. uni.createSelectorQuery().select('.handCenter').boundingClientRect(rect => {
  127. this.canvasWidth = rect.width;
  128. this.canvasHeight = rect.height;
  129. /* 将canvas背景设置为 白底,不设置 导出的canvas的背景为透明 */
  130. this.setCanvasBg('#fff');
  131. })
  132. .exec();
  133. });
  134. },
  135. methods: {
  136. submit() {
  137. if (!that.isScaleStart) {
  138. that.$refs.uToast.show({
  139. type: 'error',
  140. message: "手写签名不能为空!",
  141. })
  142. return
  143. }
  144. // if (uni.$u.test.isEmpty(that.dataDetails.freight)) {
  145. // that.$refs.uToast.show({
  146. // type: 'error',
  147. // message: "运费不能为空!",
  148. // })
  149. // return
  150. // }
  151. uni.canvasToTempFilePath({
  152. canvasId: 'handWriting',
  153. fileType: 'png',
  154. quality: 1, //图片质量
  155. success(res) {
  156. console.log(res.tempFilePath, 'canvas生成图片地址');
  157. uploadImage('image', res.tempFilePath, 'appData/',
  158. result => {
  159. // 上传成功
  160. console.log('图片地址', result)
  161. that.dataDetails.cargoOwnerAutograph = result
  162. uni.showLoading({
  163. title: '加载中',
  164. mask: true
  165. })
  166. let _obj = {}
  167. _obj.id = that.dataDetails.id
  168. _obj.typeFlag = 1
  169. _obj.cargoOwnerAutograph = that.dataDetails.cargoOwnerAutograph
  170. that.$request.baseRequest('get', '/orderInfo/setPdf', _obj).then(
  171. res => {
  172. uni.hideLoading()
  173. uni.navigateBack({
  174. delta:1
  175. })
  176. if (res.code == 200) {
  177. // that.contractSrc = res.data
  178. // uni.downloadFile({
  179. // url: res.data,
  180. // success: function(res) {
  181. // var filePath = res.tempFilePath;
  182. // uni.openDocument({
  183. // filePath: filePath,
  184. // showMenu: true,
  185. // success: function(res) {
  186. // console.log('打开文档成功');
  187. // }
  188. // });
  189. // }
  190. // });
  191. // this.$refs.uToast.show({
  192. // type: 'success',
  193. // message: "提交成功",
  194. // complete() {
  195. // that.upCallback({
  196. // size: 10,
  197. // num: 1
  198. // })
  199. // }
  200. // })
  201. }
  202. })
  203. .catch(res => {
  204. uni.$u.toast(res.message);
  205. });
  206. }
  207. )
  208. }
  209. });
  210. },
  211. // change(e){
  212. // if(this.value){
  213. // this.$set(this.dataDetails,'advanceFreightService',1)
  214. // }else{
  215. // this.$set(this.dataDetails,'advanceFreightService',0)
  216. // }
  217. // },
  218. // 笔迹开始
  219. uploadScaleStart(e) {
  220. this.isScaleStart = true
  221. this.startX = e.changedTouches[0].x
  222. this.startY = e.changedTouches[0].y
  223. //设置画笔参数
  224. //画笔颜色
  225. this.ctx.setStrokeStyle(this.lineColor)
  226. //设置线条粗细
  227. this.ctx.setLineWidth(this.lineSize)
  228. //设置线条的结束端点样式
  229. this.ctx.setLineCap("round") //'butt'、'round'、'square'
  230. //开始画笔
  231. this.ctx.beginPath()
  232. },
  233. // 笔迹移动
  234. uploadScaleMove(e) {
  235. //取点
  236. let temX = e.changedTouches[0].x
  237. let temY = e.changedTouches[0].y
  238. //画线条
  239. this.ctx.moveTo(this.startX, this.startY)
  240. this.ctx.lineTo(temX, temY)
  241. this.ctx.stroke()
  242. this.startX = temX
  243. this.startY = temY
  244. this.ctx.draw(true)
  245. },
  246. /**
  247. * 重写
  248. */
  249. retDraw() {
  250. this.ctx.clearRect(0, 0, 700, 730);
  251. this.ctx.draw();
  252. //设置canvas背景
  253. this.setCanvasBg('#fff');
  254. },
  255. /**
  256. * @param {Object} str
  257. * @param {Object} color
  258. * 选择颜色
  259. */
  260. selectColorEvent(str, color) {
  261. this.selectColor = str;
  262. this.lineColor = color;
  263. },
  264. //完成
  265. subCanvas() {
  266. uni.canvasToTempFilePath({
  267. canvasId: 'handWriting',
  268. fileType: 'png',
  269. quality: 1, //图片质量
  270. success(res) {
  271. // console.log(res.tempFilePath, 'canvas生成图片地址');
  272. uni.showToast({
  273. title: '以保存'
  274. });
  275. //保存到系统相册
  276. uni.saveImageToPhotosAlbum({
  277. filePath: res.tempFilePath,
  278. success(res) {
  279. uni.showToast({
  280. title: '已成功保存到相册',
  281. duration: 2000
  282. });
  283. }
  284. });
  285. }
  286. });
  287. },
  288. //保存到相册
  289. saveCanvasAsImg() {
  290. uni.canvasToTempFilePath({
  291. canvasId: 'handWriting',
  292. fileType: 'png',
  293. quality: 1, //图片质量
  294. success(res) {
  295. console.log(res.tempFilePath, 'canvas生成图片地址');
  296. uni.saveImageToPhotosAlbum({
  297. filePath: res.tempFilePath,
  298. success(res) {
  299. uni.showToast({
  300. title: '已保存到相册',
  301. duration: 2000
  302. });
  303. }
  304. });
  305. }
  306. });
  307. },
  308. //预览
  309. previewCanvasImg() {
  310. uni.canvasToTempFilePath({
  311. canvasId: 'handWriting',
  312. fileType: 'jpg',
  313. quality: 1, //图片质量
  314. success(res) {
  315. uni.previewImage({
  316. urls: [res.tempFilePath] //预览图片 数组
  317. });
  318. }
  319. });
  320. },
  321. //设置canvas背景色 不设置 导出的canvas的背景为透明
  322. //@params:字符串 color
  323. setCanvasBg(color) {
  324. /* 将canvas背景设置为 白底,不设置 导出的canvas的背景为透明 */
  325. //rect() 参数说明 矩形路径左上角的横坐标,左上角的纵坐标, 矩形路径的宽度, 矩形路径的高度
  326. //这里是 canvasHeight - 4 是因为下边盖住边框了,所以手动减了写
  327. this.ctx.rect(0, 0, this.canvasWidth, this.canvasHeight - 4);
  328. // ctx.setFillStyle('red')
  329. this.ctx.setFillStyle(color);
  330. this.ctx.fill(); //设置填充
  331. this.ctx.draw(); //开画
  332. }
  333. }
  334. };
  335. </script>
  336. <style lang="scss" scoped>
  337. page {
  338. background: #fbfbfb;
  339. height: auto;
  340. }
  341. .content1 {
  342. background: white;
  343. border-radius: 20rpx;
  344. margin: 20rpx;
  345. padding: 30rpx 20rpx;
  346. display: flex;
  347. justify-content: space-between;
  348. .right {
  349. display: flex;
  350. }
  351. }
  352. .content2 {
  353. background: white;
  354. border-radius: 20rpx;
  355. margin: 20rpx;
  356. padding: 30rpx 20rpx;
  357. .title {
  358. font-size: 36rpx;
  359. font-weight: 700;
  360. margin-bottom: 20rpx;
  361. }
  362. .row-between {
  363. margin-bottom: 20rpx;
  364. }
  365. .left-text {
  366. margin-right: 20rpx;
  367. }
  368. .yf-input {
  369. padding-right: 10rpx;
  370. }
  371. }
  372. .content3 {
  373. background: white;
  374. border-radius: 20rpx;
  375. margin: 20rpx;
  376. padding: 30rpx 20rpx;
  377. }
  378. .place {
  379. width: 80%;
  380. text-align: right;
  381. }
  382. .handCenter {
  383. border: 4rpx dashed #e9e9e9;
  384. overflow: hidden;
  385. box-sizing: border-box;
  386. height: 500rpx;
  387. }
  388. .handWriting {
  389. background: #F9F9FB;
  390. width: 100%;
  391. height: 100%;
  392. }
  393. .handRight {
  394. display: inline-flex;
  395. align-items: center;
  396. }
  397. .handCenter {
  398. border: 4rpx dashed #e9e9e9;
  399. flex: 5;
  400. overflow: hidden;
  401. box-sizing: border-box;
  402. }
  403. .handTitle {
  404. font-size: 36rpx;
  405. color: #666;
  406. font-weight: 700;
  407. color: #333333;
  408. margin-bottom: 20rpx;
  409. }
  410. .retDraw-image {
  411. width: 50rpx;
  412. }
  413. .qm-row {
  414. display: flex;
  415. justify-content: space-between;
  416. }
  417. .saveBtn {
  418. width: 80%;
  419. background: #2772FB;
  420. color: white;
  421. text-align: center;
  422. border-radius: 50rpx;
  423. padding: 20rpx;
  424. }
  425. .handBtn {
  426. display: flex;
  427. justify-content: center;
  428. }
  429. /*
  430. .wrapper {
  431. width: 100%;
  432. height: 95vh;
  433. margin: 30rpx 0;
  434. overflow: hidden;
  435. display: flex;
  436. align-content: center;
  437. flex-direction: row;
  438. justify-content: center;
  439. font-size: 28rpx;
  440. }
  441. .handBtn button {
  442. font-size: 28rpx;
  443. }
  444. .handBtn {
  445. height: 95vh;
  446. display: inline-flex;
  447. flex-direction: column;
  448. justify-content: space-between;
  449. align-content: space-between;
  450. flex: 1;
  451. }
  452. .delBtn {
  453. position: absolute;
  454. top: 250rpx;
  455. left: 0rpx;
  456. transform: rotate(90deg);
  457. color: #666;
  458. }
  459. .delBtn image {
  460. position: absolute;
  461. top: 13rpx;
  462. left: 25rpx;
  463. }
  464. .subBtn {
  465. position: absolute;
  466. bottom: 52rpx;
  467. left: -3rpx;
  468. display: inline-flex;
  469. transform: rotate(90deg);
  470. background: #008ef6;
  471. color: #fff;
  472. margin-bottom: 30rpx;
  473. text-align: center;
  474. justify-content: center;
  475. }
  476. .saveBtn {
  477. position: absolute;
  478. top: 375rpx;
  479. left: 0rpx;
  480. transform: rotate(90deg);
  481. color: #666;
  482. }
  483. .previewBtn {
  484. position: absolute;
  485. top: 500rpx;
  486. left: 0rpx;
  487. transform: rotate(90deg);
  488. color: #666;
  489. }
  490. .uploadBtn {
  491. position: absolute;
  492. top: 625rpx;
  493. left: 0rpx;
  494. transform: rotate(90deg);
  495. color: #666;
  496. }
  497. .black-select {
  498. width: 60rpx;
  499. height: 60rpx;
  500. position: absolute;
  501. top: 30rpx;
  502. left: 25rpx;
  503. }
  504. .black-select.color_select {
  505. width: 90rpx;
  506. height: 90rpx;
  507. top: 100rpx;
  508. left: 10rpx;
  509. }
  510. .red-select {
  511. width: 60rpx;
  512. height: 60rpx;
  513. position: absolute;
  514. top: 140rpx;
  515. left: 25rpx;
  516. }
  517. .red-select.color_select {
  518. width: 90rpx;
  519. height: 90rpx;
  520. top: 120rpx;
  521. left: 10rpx;
  522. } */
  523. </style>