signContract.vue 13 KB

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