You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
160 lines
3.4 KiB
160 lines
3.4 KiB
<template>
|
|
<view class="containers">
|
|
<view class="signwrap">
|
|
<l-signature disableScroll backgroundColor="#ddd" ref="signatureRef" :penColor="penColor"
|
|
:penSize="penSize"></l-signature>
|
|
</view>
|
|
<view class="signbtns justify-between">
|
|
<button type="primary" @click="onClick('clear')">清空</button>
|
|
<button type="primary" @click="onClick('undo')">撤消</button>
|
|
<button type="primary" @click="onClick('save')">保存</button>
|
|
<!-- <button @click="onClick('openSmooth')">压感{{openSmooth?'开':'关'}}</button> -->
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import {
|
|
base64ToPath
|
|
} from 'image-tools'
|
|
export default {
|
|
data() {
|
|
return {
|
|
id:"",
|
|
title: 'Hello',
|
|
penColor: 'black',
|
|
penSize: 5,
|
|
urls: '',
|
|
accept_admin_sign:"",
|
|
picForm:{},
|
|
host:''
|
|
}
|
|
},
|
|
onLoad(options){
|
|
this.id = options.id
|
|
this.host = this.util.HOST
|
|
this.loadDetail()
|
|
},
|
|
methods: {
|
|
onClick(type) {
|
|
if (type == 'save') {
|
|
this.$refs.signatureRef.canvasToTempFilePath({
|
|
success: (res) => {
|
|
// 是否为空画板 无签名
|
|
if (res.isEmpty) {
|
|
return
|
|
}
|
|
// 生成图片的临时路径
|
|
// app | H5 | 微信小程序 生成的是base64
|
|
this.urls = res.tempFilePath
|
|
base64ToPath(this.urls)
|
|
.then(path => {
|
|
this.uploadImg(path)
|
|
})
|
|
.catch(error => {
|
|
console.error(error)
|
|
})
|
|
}
|
|
})
|
|
return
|
|
}
|
|
if (this.$refs.signatureRef)
|
|
this.$refs.signatureRef[type]()
|
|
},
|
|
|
|
uploadImg(url) {
|
|
let that = this
|
|
uni.uploadFile({
|
|
url: this.host+'/api/admin/upload-file',
|
|
filePath: url,
|
|
name: 'file',
|
|
header:{
|
|
token:uni.getStorageSync('userInfo_BD_token').token
|
|
},
|
|
success: (res) => {
|
|
console.log("respic",res.data)
|
|
let data = JSON.parse(res.data)
|
|
that.picForm.accept_admin_sign = data.response?data.response.id:data.id
|
|
console.log("that.accept_admin_sign",that.picForm)
|
|
that.picSubmit()
|
|
}
|
|
});
|
|
},
|
|
loadDetail() {
|
|
let that = this
|
|
console.log("that.id",that.id)
|
|
this.util.request({
|
|
api: '/api/admin/visit/show',
|
|
method: "get",
|
|
requestType: 'bd',
|
|
data: {
|
|
id: that.id
|
|
},
|
|
utilSuccess: function(res) {
|
|
that.picForm = res
|
|
},
|
|
utilFail: function(res) {
|
|
uni.showToast({
|
|
title: res.errmsg,
|
|
duration: 2000,
|
|
icon: 'none'
|
|
})
|
|
}
|
|
})
|
|
},
|
|
picSubmit() {
|
|
let that = this
|
|
// return
|
|
this.util.request({
|
|
api: '/api/admin/visit/save',
|
|
method: "POST",
|
|
requestType:'bd',
|
|
data: that.picForm,
|
|
utilSuccess: function(res) {
|
|
uni.showToast({
|
|
title: res.msg,
|
|
duration: 2000,
|
|
icon: 'none'
|
|
})
|
|
uni.navigateTo({
|
|
url:'/pages/bd/record?type=myrecord'
|
|
})
|
|
},
|
|
utilFail: function(res) {
|
|
uni.showToast({
|
|
title: res.errmsg,
|
|
duration: 2000,
|
|
icon: 'none'
|
|
})
|
|
}
|
|
})
|
|
},
|
|
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.signwrap {
|
|
width: 100%;
|
|
height: 100vh;
|
|
position: relative;
|
|
}
|
|
|
|
.signbtns {
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
}
|
|
|
|
.signbtns button {
|
|
background: #fff;
|
|
border: none;
|
|
width: 25%;
|
|
margin-top: 20rpx;
|
|
/* padding: 40rpx; */
|
|
color: #333;
|
|
}
|
|
</style>
|