signContract.vue 13 KB

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