Commit 0766a971 by 张立顺

签名功能开发

1 parent abd60335
...@@ -57,7 +57,8 @@ ...@@ -57,7 +57,8 @@
"name": "packageEquity", "name": "packageEquity",
"pages": [ "pages": [
"pages/carQuotation/signature/signature", "pages/carQuotation/signature/signature",
"pages/carQuotation/index/index" "pages/carQuotation/index/index",
"pages/carQuotation/fullSignture/fullSignture"
] ]
}, },
{ {
......
...@@ -65,3 +65,7 @@ image { ...@@ -65,3 +65,7 @@ image {
font-size: 24rpx; font-size: 24rpx;
height: 100%; height: 100%;
} }
.bgcw {
background-color: #fff;
}
\ No newline at end of file \ No newline at end of file
// packageEquity/components/GlButton/GlButton.js
Component({
/**
* 组件的属性列表
*/
properties: {
textNameObj: {
type: Object,
value: false,
value: {
confirmName: '确认',
editName: '修改',
cancelName: '取消'
}
}
},
/**
* 组件的初始数据
*/
data: {},
/**
* 组件的方法列表
*/
methods: {
btnTap(e) {
console.log(e)
let { name } = e.currentTarget.dataset
console.log(name)
// this.
this.triggerEvent('btnTap', { name })
}
}
})
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
/* packageEquity/components/GlButton/GlButton.wxss */
.btnCom {
.btn {
width: 622rpx;
height: 88rpx;
margin: 20rpx auto 0;
// background: #3582EE;
// margin-top: 20rpx;
border-radius: 12rpx;
text-align: center;
line-height: 88rpx;
font-family: PingFangSC-Medium;
font-weight: 500;
font-size: 32rpx;
background: #FFFFFF;
color: #222222;
}
.confirmBtn {
// confirm
background: #3582EE;
margin-top: 40rpx;
color: #FFFFFF;
}
}
\ No newline at end of file \ No newline at end of file
<!-- packageEquity/components/GlButton/GlButton.wxml -->
<!-- <text>packageEquity/components/GlButton/GlButton.wxml</text> -->
<view class="btnCom">
<view class="btn confirmBtn" data-name="confirm" bindtap="btnTap">
{{textNameObj.confirmName}}
</view>
<view
class="btn editBtn"
data-name="edit"
bindtap="btnTap"
wx:if="{{textNameObj.editName}}">
{{textNameObj.editName}}
</view>
<view class="btn cancleBtn" data-name="cancle" bindtap="btnTap">{{textNameObj.cancelName}}</view>
</view>
// import { commonApi, equityApi } from '../../../api/api'
Page({
data: {
tempFilePath: '',
hideModal: true,
hasDraw: false,
canvasName: '#handWriting',
ctx: '',
canvasWidth: 0,
canvasHeight: 0,
startPoint: {
x: 0,
y: 0
},
selectColor: 'black',
lineColor: '#282829', // 颜色
lineSize: 3, // 笔记倍数
radius: 1.5, //画圆的半径
showPlaceHoder: true,
signImage: ''
},
onLoad(options) {
if (options.writeOffCode) {
this.writeOffCode = options.writeOffCode
}
let that = this
let query = wx.createSelectorQuery().in(this) //获取自定义组件的SelectQuery对象
this.canvasCtx = wx.createCanvasContext('signature', that)
// 设置线的样式
this.canvasCtx.setFillStyle('white')
this.canvasCtx.fillRect(0, 0, 600, 600)
this.canvasCtx.setLineCap('round')
this.canvasCtx.setLineJoin('round')
// 初始化颜色
this.canvasCtx.setStrokeStyle(that.data.selectColor)
query
.select('.modal-canvas')
.boundingClientRect(rect => {
this.setData({
canvasWidth: rect.width,
canvasHeight: rect.height
})
})
.exec()
},
scaleStart(event) {
if (event.type != 'touchstart') return false
let currentPoint = {
x: event.touches[0].x,
y: event.touches[0].y
}
this.drawCircle(currentPoint)
this.setData({
startPoint: currentPoint,
hasDraw: true,
showPlaceHoder: false
})
},
scaleMove(event) {
if (event.type != 'touchmove') return false
let { startPoint } = this.data
let currentPoint = {
x: event.touches[0].x,
y: event.touches[0].y
}
this.drawLine(startPoint, currentPoint)
this.setData({
startPoint: currentPoint
})
},
scaleEnd(e) {
this.setData({
isStart: true
})
},
drawCircle(point) {
//这里负责点
let ctx = this.canvasCtx
ctx.beginPath()
// ctx.fillStyle = this.data.lineColor;
ctx.setFillStyle(this.data.lineColor)
//笔迹粗细由圆的大小决定
ctx.arc(point.x, point.y, this.data.radius, 0, 2 * Math.PI)
ctx.fill()
ctx.closePath()
ctx.draw(true)
},
drawLine(sourcePoint, targetPoint) {
let ctx = this.canvasCtx
this.drawCircle(targetPoint)
ctx.beginPath()
// ctx.strokeStyle = this.data.lineColor;
ctx.setStrokeStyle(this.data.lineColor)
// ctx.lineWidth = this.data.radius * 2; //这里乘2是因为线条的粗细要和圆的直径相等
ctx.setLineWidth(this.data.radius * 2)
ctx.moveTo(sourcePoint.x, sourcePoint.y)
ctx.lineTo(targetPoint.x, targetPoint.y)
ctx.stroke()
ctx.closePath()
},
clearCanvas() {
//清空画布
let ctx = this.canvasCtx
ctx.clearRect(0, 0, this.data.canvasWidth, this.data.canvasHeight)
ctx.fillStyle = 'rgba(0, 0, 0, .1)'
ctx.draw()
this.setData({
hasDraw: false, //未签字
showPlaceHoder: true,
signImage: ''
})
},
getTempFile() {
return {
tempFilePath: this.data.tempFilePath
}
},
saveToImage() {
let { hasDraw, canvasHeight, canvasWidth } = this.data
let that = this
if (!hasDraw) {
wx.showToast({
title: '还未签字哟!',
icon: 'none',
mask: true
})
return
}
wx.canvasToTempFilePath(
{
x: 0,
y: 0,
width: canvasWidth,
height: canvasHeight,
canvasId: 'signature',
fileType: 'jpg',
success(res) {
if (res.tempFilePath) {
that.toUploadImage(res.tempFilePath)
}
},
fail(err) {
console.log(err)
}
},
that
)
},
toBack() {
wx.navigateBack({
delta: 1
})
},
// 上传图片
toUploadImage(tempFilePaths) {
let _this = this
const tempFiles = tempFilePaths
let imgType = tempFiles.split('.')[1]
let type = imgType == 'unknown' ? 'jpg' : imgType
wx.getFileSystemManager().readFile({
filePath: tempFiles, //选择图片返回的相对路径
encoding: 'base64', //编码格式
success(_res) {
wx.$util.showLoading('上传中...')
wx.$api
.uploadImg({
file: `${type}@${_res.data}`
})
.then(img => {
_this.saveToHttp(img)
})
},
fail() {
wx.$util.hideLoading()
}
})
},
// 上传签名到后端
saveToHttp(signUrl) {
let para = {
writeOffCode: this.writeOffCode,
signUrl
}
// equityApi.signSumbit(para).then(res => {
// wx.$util.hideLoading()
// wx.navigateBack({
// delta: 2
// });
// })
}
})
{
"navigationBarTitleText": "客户签字"
}
<view class="full-container flex_cc">
<cover-view class="header_text" bind:tap="toBack">取消</cover-view>
<cover-view class="text_comfirm" bind:tap="saveToImage">确定</cover-view>
<cover-view class="footer_btn flex_sc">
<cover-image
bind:tap="clearCanvas"
webp
class="circle_wrap_icon"
src="../../../images/sign_del.png" />
</cover-view>
<view class="can_wrap">
<canvas
canvas-id="signature"
class="modal-canvas"
disable-scroll="{{true}}"
id="handWriting"
bindtouchstart="scaleStart"
bindtouchmove="scaleMove"
bindtouchend="scaleEnd" />
</view>
<view wx:if="{{showPlaceHoder}}" class="placehoder">签字区</view>
</view>
page {
background: white;
}
.full-container {
position: relative;
height: 100vh;
}
.header_text {
position: absolute;
top: 36rpx;
right: 32rpx;
z-index: 10000;
font-size: 32rpx;
font-weight: 500;
color: #282829;
transform: rotate(90deg);
background: white;
}
.text_comfirm {
position: absolute;
right: 32rpx;
bottom: 106rpx;
z-index: 10000;
font-size: 32rpx;
font-weight: 500;
color: #282829;
transform: rotate(90deg);
color: #3582EE;
background: white;
}
.footer_btn {
position: absolute;
left: 48rpx;
bottom: 106rpx;
z-index: 10000;
width: 106rpx;
height: 106rpx;
}
.circle_wrap_icon {
width: 106rpx;
height: 106rpx;
}
.placehoder {
font-size: 32rpx;
font-weight: 500;
color: #DFDFDF;
transform: rotate(90deg);
}
.can_wrap {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
.coverImage {
width: 100%;
height: 100%;
}
.modal-canvas {
width: 100%;
height: 100vh;
}
.flex_sc {
display: flex;
flex-direction: column;
}
.flex_cc {
display: flex;
align-items: center;
justify-content: center;
}
\ No newline at end of file \ No newline at end of file
...@@ -12,6 +12,11 @@ Page({ ...@@ -12,6 +12,11 @@ Page({
x: 0, x: 0,
y: 0 y: 0
}, },
textNameObj: {
confirmName: '下一步·去支付(4/4)',
// editName: '修改',
cancelName: '取消'
},
selectColor: 'black', selectColor: 'black',
lineColor: '#282829', // 颜色 lineColor: '#282829', // 颜色
lineSize: 3, // 笔记倍数 lineSize: 3, // 笔记倍数
...@@ -20,7 +25,7 @@ Page({ ...@@ -20,7 +25,7 @@ Page({
signImage: '' signImage: ''
}, },
onLoad(options) { onLoad(options) {
let carInfo = JSON.parse(decodeURIComponent(options.carInfo)) let carInfo = options.carInfo ? JSON.parse(decodeURIComponent(options.carInfo)) : ''
let that = this let that = this
let query = wx.createSelectorQuery().in(this) //获取自定义组件的SelectQuery对象 let query = wx.createSelectorQuery().in(this) //获取自定义组件的SelectQuery对象
this.canvasCtx = wx.createCanvasContext('signature', that) this.canvasCtx = wx.createCanvasContext('signature', that)
...@@ -125,7 +130,7 @@ Page({ ...@@ -125,7 +130,7 @@ Page({
tempFilePath: this.data.tempFilePath tempFilePath: this.data.tempFilePath
} }
}, },
saveToImage() { confirm() {
let { hasDraw, canvasHeight, canvasWidth } = this.data let { hasDraw, canvasHeight, canvasWidth } = this.data
let that = this let that = this
if (!hasDraw) { if (!hasDraw) {
...@@ -156,15 +161,23 @@ Page({ ...@@ -156,15 +161,23 @@ Page({
that that
) )
}, },
btnTap(e) {
// console.log(e.detail)
// console.log(e.currentTarget.dataset)
// console.log(name)
let { name } = e.detail
this[name]()
},
toRedirect() { toRedirect() {
wx.redirectTo({ wx.redirectTo({
url: '/packageEquity/pages/claimsNoteDetail/claimsNoteDetail' url: '/packageEquity/pages/claimsNoteDetail/claimsNoteDetail'
}) })
}, },
toFullPage() { toFullPage() {
wx.navigateTo({ // wx.navigateTo({
url: '/packageEquity/pages/fullSignture/fullSignture?writeOffCode=' + this.data.carInfo.writeOffCode // url: '/packageEquity/pages/fullSignture/fullSignture?writeOffCode=' + this.data.carInfo.writeOffCode
}) // })
wx.$router.go('fullSignture')
}, },
// 上传图片 // 上传图片
toUploadImage(tempFilePaths) { toUploadImage(tempFilePaths) {
...@@ -177,11 +190,13 @@ Page({ ...@@ -177,11 +190,13 @@ Page({
encoding: 'base64', //编码格式 encoding: 'base64', //编码格式
success(_res) { success(_res) {
wx.$util.showLoading('上传中...') wx.$util.showLoading('上传中...')
// commonApi.uploadImg({ wx.$api
// file: `${type}@${_res.data}` .uploadImg({
// }).then(img => { file: `${type}@${_res.data}`
// _this.saveToHttp(img) })
// }) .then(img => {
_this.saveToHttp(img)
})
}, },
fail() { fail() {
wx.$util.hideLoading() wx.$util.hideLoading()
...@@ -194,11 +209,11 @@ Page({ ...@@ -194,11 +209,11 @@ Page({
writeOffCode: this.data.carInfo.writeOffCode, writeOffCode: this.data.carInfo.writeOffCode,
signUrl signUrl
} }
// equityApi.signSumbit(para).then(res => { equityApi.signSumbit(para).then(res => {
// wx.$util.hideLoading() wx.$util.hideLoading()
// wx.navigateBack({ wx.navigateBack({
// delta: 1 delta: 1
// }); })
// }) })
} }
}) })
{ {
"usingComponents": {} "usingComponents": {
"Gl-Button-Group": "../../../components/GlButtonGroup/GlButtonGroup"
},
"navigationBarTitleText": "客户签字"
} }
page { page {
background: white; // background: white;
background-color: #F4F5F7
} }
.signature-wrap { .signature-wrap {
padding: 16rpx 32rpx; padding: 20rpx;
.descprion_wrap {
box-sizing: border-box;
padding: 32rpx;
box-shadow: 0 6rpx 16rpx 0 #cdcdd159;
border-radius: 16rpx;
}
} }
.h3 { .h3 {
text-indent: 2em; text-indent: 2em;
} }
.descTextTitle {
font-family: PingFangSC-Medium;
font-weight: 500;
font-size: 32rpx;
color: #222222;
line-height: 48rpx;
margin-bottom: 20rpx;
}
.descText { .descText {
font-size: 28rpx; font-size: 28rpx;
font-weight: 400; }
color: #282829;
line-height: 44rpx; .signCom {
position: relative;
box-sizing: border-box;
padding: 32rpx;
margin-top: 20rpx;
box-shadow: 0 6rpx 16rpx 0 #cdcdd159;
border-radius: 16rpx;
} }
.title { .title {
...@@ -27,11 +51,12 @@ page { ...@@ -27,11 +51,12 @@ page {
} }
.canvas_wrap { .canvas_wrap {
width: 686rpx;
height: 560rpx;
border-radius: 8rpx;
border: 2rpx solid rgba(201, 202, 204, 0.3);
position: relative; position: relative;
width: 646rpx;
height: 400rpx;
background: #F4F5F7;
border: 2rpx solid #EFF0F2;
border-radius: 12rpx;
} }
.coverImage { .coverImage {
...@@ -41,8 +66,9 @@ page { ...@@ -41,8 +66,9 @@ page {
.full_icon { .full_icon {
position: absolute; position: absolute;
right: 16rpx; right: 26rpx;
top: 16rpx; // top: 16rpx;
bottom: 26rpx;
z-index: 10000; z-index: 10000;
} }
...@@ -100,12 +126,12 @@ page { ...@@ -100,12 +126,12 @@ page {
} }
.modal-canvas { .modal-canvas {
width: 686rpx; width: 646rpx;
height: 560rpx; height: 400rpx;
background: #F4F5F7;
margin: 0 auto; margin: 0 auto;
margin-bottom: 30rpx; border: 2rpx solid #EFF0F2;
border-radius: 18rpx; border-radius: 12rpx;
box-sizing: border-box; box-sizing: border-box;
overflow: hidden; overflow: hidden;
background-color: #FFFFFF;
} }
\ No newline at end of file \ No newline at end of file
<view class="signature-wrap"> <view class="signature-wrap">
<view class="descprion_wrap"> <view class="descprion_wrap bgcw">
<view class="descText">尊敬的客户,您好!</view> <view class="descTextTitle">尊敬的客户,您好!</view>
<view class="h3 descText">感谢您对我们的数字化无忧卡权益服务的认可与支持!</view>
<view class="h3 descText"> <view class="h3 descText">
本人自愿店方购买保险。新车投保项目我司进行了说明,本人完全理解保险公司在理赔上赔付差额或不赔付问题。本告知书对条款进行了简要介绍,作为投保参考,具体约定以保单及条款为准。
</view>
<!-- <view class="h3 descText">
为进一步提高权益服务质量,您申请的{{serviceItemStr}}已被受理,请确认您的爱车(车架号:{{carInfo.vin}},车型:{{carInfo.vehicleBrandName || ''}}{{carInfo.vehicleSeriesName || ''}}{{carInfo.vehicleShapeName || ''}}),是否已到{{carInfo.merchantName}}进行服务。 为进一步提高权益服务质量,您申请的{{serviceItemStr}}已被受理,请确认您的爱车(车架号:{{carInfo.vin}},车型:{{carInfo.vehicleBrandName || ''}}{{carInfo.vehicleSeriesName || ''}}{{carInfo.vehicleShapeName || ''}}),是否已到{{carInfo.merchantName}}进行服务。
</view> </view>
<view class="h3 descText"> <view class="h3 descText">
为保障您的权益,与您约定如下,您同意本次权益服务申请,以实物赔付形式,完成此次权益服务赔付,保障范围内的补偿费用由我司直接与程辉丰田店结算。 感谢您的配合,请在确认以上信息后在下面的空白框内签字确认,谢谢! 为保障您的权益,与您约定如下,您同意本次权益服务申请,以实物赔付形式,完成此次权益服务赔付,保障范围内的补偿费用由我司直接与程辉丰田店结算。 感谢您的配合,请在确认以上信息后在下面的空白框内签字确认,谢谢!
</view> -->
</view> </view>
</view> <view class="signCom bgcw">
<view class="title">签字处</view> <view class="tips descText">感谢您的配合,请在确认以上信息后,在下方的签字区内签字确认,谢谢!</view>
<view class="title descTextTitle">签字处</view>
<view wx:if="{{!signImage}}" class="canvas_wrap"> <view wx:if="{{!signImage}}" class="canvas_wrap">
<canvas canvas-id="signature" class="modal-canvas" disable-scroll="{{true}}" id="handWriting" bindtouchstart="scaleStart" bindtouchmove="scaleMove" bindtouchend="scaleEnd"></canvas> <canvas
<view wx:if="{{showPlaceHoder}}" class="placehoder">手写签名</view> canvas-id="signature"
class="modal-canvas"
disable-scroll="{{true}}"
id="handWriting"
bindtouchstart="scaleStart"
bindtouchmove="scaleMove"
bindtouchend="scaleEnd" />
<view wx:if="{{showPlaceHoder}}" class="placehoder">签字区</view>
<cover-view bind:tap="toFullPage" class="full_icon flex_scb"> <cover-view bind:tap="toFullPage" class="full_icon flex_scb">
<cover-image webp mode="widthFix" class="icon" src="{{IMGURL}}equity/claims/sign_full.png?v={{img_version}}" /> <cover-image
<cover-view class="full_text">全屏</cover-view> webp
mode="widthFix"
class="icon"
src="../../../images/fullScreen.png" />
<!-- <cover-view class="full_text">全屏</cover-view> -->
</cover-view> </cover-view>
</view> </view>
<view wx:else class="canvas_wrap"> <view wx:else class="canvas_wrap">
<image class="coverImage" src="{{signImage}}" /> <image class="coverImage" src="{{signImage}}" />
</view> </view>
<view class="btn_group flex_scb">
<view bind:tap="clearCanvas" class="btn flex_cc">重签</view>
<view bind:tap="saveToImage" class="btn flex_cc btn_active">确认</view>
</view> </view>
<view style="height:68rpx"></view> <Gl-Button-Group bindbtnTap="btnTap" textNameObj="{{textNameObj}}" />
</view> </view>
{ {
"navigationStyle":"custom" "navigationStyle": "custom"
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!