作者 曹东东

审核

... ... @@ -311,6 +311,8 @@ class Ajax extends TeacherBase
}
//手写签名板
public function canvas(){
$id = input('id');
if ($this->request->isPost()){
... ...
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html>
<!--<![endif]-->
<head>
<meta name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0,user-scalable=no,viewport-fit=cover">
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache" content="no-cache">
<meta http-equiv="Expires" content="0">
<meta charset="utf-8">
<title>签名页</title>
<script src="__CDN__/assets/js/signature.js"></script>
<script src="__CDN__/assets/js/jquery-3.4.1.min.js"></script>
<title>项目审核</title>
<link rel="stylesheet" href="http://i.gtimg.cn/vipstyle/frozenui/2.0.0/css/frozen.css">
<style>
[v-cloak] {
display: none;
}
canvas{
width: 100vh;
}
* {
margin: 0;
padding: 0;
}
html,
body {
width: 100%;
height: 100%;
text-align: center;
background-color: #FFFFFF;
}
canvas {
max-width: 100%;
border: 2px dotted #ccc;
}
.opinion {
width: 100%;
height: 235px;
font-size: 16px;
border: 1px solid #000;
}
.opinion::-webkit-input-placeholder {
line-height: 235px;
text-align: center;
}
/* 使用webkit内核的浏览器 */
.opinion:-moz-placeholder {
line-height: 235px;
text-align: center;
}
/* Firefox版本4-18 */
.opinion::-moz-placeholder {
line-height: 235px;
text-align: center;
}
/* Firefox版本19+ */
.opinion:-ms-input-placeholder {
line-height: 235px;
text-align: center;
}
/*elmeentui文本 textarea字体*/
.is-disabled .el-input__inner {
font-weight: bold !important;
font-size: 14px !important;
color: #4A5560 !important;
}
.is-disabled .el-textarea__inner {
font-weight: bold !important;
font-size: 14px !important;
color: #4A5560 !important;
}
.el-form-item__label {
color: black !important;
font-weight: bold !important;
}
</style>
</head>
<body>
<script src="__CDN__/assets/js/jquery-3.4.1.min.js"></script>
<script src="/assets/js/index.js"></script>
<script src="/assets/ele/vue.js"></script>
<body style="margin: 0;">
<div class="popverBox">
<div class="titleBox">项目审核</div>
<div id="signSure" class="signSure">
<input type="hidden" name="id" id="id" value="{$id}">
<div class="topBtnBox">
<div class="topTitle">电子签名</div>
<canvas class="whiteBord" id="whiteBord">
您的浏览器不支持canvas技术,请升级浏览器!
</canvas>
<link rel="stylesheet" href="__CDN__/assets/ele/element/element.css">
<script src="__CDN__/assets/ele/element/element.js"></script>
<script src="__CDN__/assets/ele/Sortable.min.js"></script>
<script src="__CDN__/assets/ele/vuedraggable.js"></script>
<script src="__CDN__/assets/ele/moment.js"></script>
<div id="app">
<input type="hidden" name="id" id="id" value="{$id}">
<div v-if="step==1" style="padding:0 15px;margin-top: 25px;">
<el-form size="mini">
<div>
<el-form-item label="审核状态">
<div>
<el-radio v-model="v_status" label="1" border>通过</el-radio>
<el-radio v-model="v_status" label="2" border>退回</el-radio>
</div>
</el-form-item>
</div>
<div>
<div class="topTitle">审核意见</div>
<textarea class="opinion" placeholder="输入审核意见,不超过200个字" name="opinion" id="opinion"></textarea>
<el-form-item label="审核意见">
<el-input type="textarea" rows="8" v-model="option"></el-input>
</el-form-item>
</div>
<div class="bottomBtnBox">
<button class="primaryBtn" id="againWrite">重写</button>
<button class="primaryBtn activeBtn" id="sureWrite">通过</button>
<button class="primaryBtn backBtn" id="back">退回</button>
</el-form>
<button @click="draw" class="ui-btn-lg ui-btn-primary">确认</button>
</div>
<div v-if="step==3" class="buttons" style="position: absolute;left:15px;bottom:100px;">
<button type="button" style="width:40px;height:130px;background-color:#C2C7CC;" @click="clear" class="ui-btn clear">重签</button>
<button type="button" @click="toDetail" style="width:40px;height:130px;margin-top:8px" class="ui-btn ui-btn-primary ouput back">项目详情</button>
<button type="button" @click="pass" style="width:40px;height:130px;margin-top:10px" class="ui-btn ui-btn-primary ouput pass">确认签名</button>
</div>
</div>
</body>
<script>
function sureWriteCallback(imageBase64,type){
new Vue({
el: '#app',
data: {
step: 1,
sign : null,
id : "{$id}",
option:'',
v_status:'1',
},
mounted(){
var _this = this;
},
methods:{
clear:function(){
this.sign.clear();
},
draw :function(){
this.step = 3;
//初始化
this.sign = sign = new Draw({
lineWidth: 10, // 线条宽度
width: 400, // canvas 宽
height: window.screen.height, //canvas 高
strokeStyle: '#333333' // 线条颜色
});
},
toDetail(){
var _this = this;
_this.sign.destroyed();
$('canvas').remove();
window.location.href = '/teacher/container/container_detail/detail_view?id=' + _this.id;
},
pass:function(){
var img = new Image();
img.style.width = '200px';
img.src = this.sign.ouput();
this.sureWriteCallback(this.sign.ouput(), 1);
},
sureWriteCallback:function(imageBase64, type) {
// 签名完成后的的逻辑代码
if(this.sign.state.undopath.length <= 0){
alert("还没有签名");
return false;
}
var _this = this;
$.ajax({
type : "POST", //提交方式
url : "canvas",//路径
data : {
"imgbase64" : imageBase64,
'type' : type,
'id' : $('#id').val(),
'opinion' : $('#opinion').val()
},//数据,这里使用的是Json格式进行传输
success:function (data) {
console.log('成功');
type: "POST", //提交方式
url: "canvas", //路径
data: {
"imgbase64": imageBase64,
'type': _this.v_status,
'id': _this.id,
'opinion': _this.option,
'status':_this.v_status
}, //数据,这里使用的是Json格式进行传输
success: function(data) {
alert(data.msg)
// window.location.href = '/teacher/container/container_detail/detail_view?id=' + _this.id;
},
error:function (data) {
console.log('失败')
error: function(data) {
alert(data.msg)
}
})
}
let params = {
whiteBord:'whiteBord',//canvas标签的id名称
againWrite:'againWrite',//重写按钮id名
sureWrite:'sureWrite',//确认按钮id名
back:'back',//退回按钮id名
whiteBordPtions:{},//白板的配置项(空对象时取默认值)
sureWriteCallback,// 签名完成后的回调函数
}
signature(params) // signature.js里封装好的函数,把参数传进去,调用一下即可
</script>
<style>
.popverBox{
background: #f2f2f2;
position: relative;
font-size: 30px;
display: flex;
align-items: center;
flex-direction: column;
height: 100vh;
}
.signSure{
width: 90%;
border-radius: 16px;
padding: 20px 12px 28px 12px;
}
.titleBox{
color: #fff;
background-color: #4285dc;
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 7rem;
font-size: 2.5rem;
}
.topTitle{
margin: 20px 0 12px 12px;
font-size: 2.3rem;
}
.whiteBord{
width: 100%;
height: 95%;
border: 1px solid #000;
background: #fff;
margin: 0 auto;
border-radius: 4px;
margin-bottom: 12px;
}
.bottomBtnBox{
padding: 60px 7px;
display: flex;
justify-content: space-between;
}
.primaryBtn{
width: 25%;
height: 80px;
color: #666;
border: 1px solid #ccc;
border-radius: 4px;
background: #fff;
font-size: 30px;
}
.activeBtn{
/*background: #315294;*/
background: rgb(38,198,218);
color: #fff;
border: none;
}
.backBtn{
/*background: #315294;*/
background: rgb(252,75,108);
color: #fff;
border: none;
}
.opinion{
width: 100%;
height: 235px;
font-size: 30px;
border: 1px solid #000;
}
})
.opinion::-webkit-input-placeholder{
line-height: 235px;text-align: center;
}/* 使用webkit内核的浏览器 */
.opinion:-moz-placeholder{
line-height: 235px;text-align: center;
}/* Firefox版本4-18 */
.opinion::-moz-placeholder{
line-height: 235px;text-align: center;
}/* Firefox版本19+ */
.opinion:-ms-input-placeholder{
line-height: 235px;text-align: center;
}
</script>
</body>
</style>
</html>
... ...
var main = new Vue({
el:"#main",
data:function(){
return{
// 公共数据
allData:__data,
// 左侧tab栏active
leftKey:'course',
// 右侧部分需要的数据
nowData: {},
}
},
// 计算属性
computed: {
videoList: function () {
return this.nowData.videoList || []
}
},
// 钩子函数
mounted() {
this.nowData = __data[this.leftKey]
console.log("右侧数据",this.nowData)
},
// 监控属性
watch: {
// 监听导航按钮下标改变,使用导航对应的平台数据
leftKey: function (newVal, oldVal) {
this.nowData = __data[newVal]
},
},
methods: {
changeTabIndex: function (key) {
console.log(this.leftKey)
console.log(Key)
this.leftKey = key;
}
},
})
\ No newline at end of file
( function ( global, factory ) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define( factory ) :
( global = global || self, global.Draw = factory() );
}( this, ( function () {
'use strict';
var classCallCheck = function ( instance, Constructor ) {
if ( !( instance instanceof Constructor ) ) {
throw new TypeError( "Cannot call a class as a function" );
}
};
var createClass = function () {
function defineProperties ( target, props ) {
for ( var i = 0; i < props.length; i++ ) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ( "value" in descriptor ) descriptor.writable = true;
Object.defineProperty( target, descriptor.key, descriptor );
}
}
return function ( Constructor, protoProps, staticProps ) {
if ( protoProps ) defineProperties( Constructor.prototype, protoProps );
if ( staticProps ) defineProperties( Constructor, staticProps );
return Constructor;
};
}();
/**
* @github https://github.com/929467350/draw
* @description 手写签字版
*/
var Draw = function () {
function Draw () {
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
classCallCheck( this, Draw );
this.el = params.el || document.createElement( 'canvas' );
this.state = {
undopath: [],
index: -1,
old: void 0,
isStart: false,
width: params.width || 400,
height: params.height || 400,
lineWidth: params.lineWidth || 1,
isTouch: 'ontouchstart' in window,
strokeStyle: params.strokeStyle || '#333333'
};
var _state = this.state,
width = _state.width,
height = _state.height,
lineWidth = _state.lineWidth;
this.el.width = width * 2;
this.el.height = height * 2;
document.body.appendChild( this.el );
this.ctx = this.el.getContext( '2d' );
this.ctx.scale( 2, 2 );
this.ctx.lineWidth = lineWidth;
this.ctx.lineJoin = 'round';
this.ctx.lineCap = 'round';
this.init();
}
createClass( Draw, [{
key: 'onStart',
value: function onStart () {
++this.state.index;
this.state.isStart = true;
}
}, {
key: 'onMove',
value: function onMove ( e ) {
e.preventDefault();
if ( !this.state.isStart ) return;
var pos = this.pos( e );
var index = this.state.index;
this.ctx.strokeStyle = this.state.strokeStyle;
if ( this.state.old ) {
this.ctx.beginPath();
this.ctx.moveTo( this.state.old.x, this.state.old.y );
this.ctx.lineTo( pos.x, pos.y );
this.ctx.stroke();
}
this.state.old = pos;
if ( this.state.undopath[index] ) {
this.state.undopath[index].push( { x: this.state.old.x, y: this.state.old.y } );
} else {
this.state.undopath[index] = [{
x: this.state.old.x,
y: this.state.old.y,
strokeStyle: this.ctx.strokeStyle,
lineWidth: this.ctx.lineWidth
}];
}
}
}, {
key: 'onEnd',
value: function onEnd () {
this.state.old = void 0;
this.state.isStart = false;
}
}, {
key: 'pos',
value: function pos ( e ) {
var x = 0,
y = 0;
if ( e.touches ) {
x = e.touches[0].pageX;
y = e.touches[0].pageY;
} else {
x = e.offsetX / 2;
y = e.offsetY / 2;
}
return { x: x, y: y };
}
}, {
key: 'ouput',
value: function ouput () {
// 输出图片
return this.el.toDataURL();
}
}, {
key: 'init',
value: function init () {
// 绑定事件
var isTouch = this.state.isTouch;
this.el.addEventListener( isTouch ? 'touchstart' : 'mousedown', this.onStart.bind( this ), false );
this.el.addEventListener( isTouch ? 'touchmove' : 'mousemove', this.onMove.bind( this ), false );
this.el.addEventListener( isTouch ? 'touchend' : 'mouseup', this.onEnd.bind( this ), false );
this.el.addEventListener( isTouch ? 'touchcancel' : 'mouseout', this.onEnd.bind( this ), false );
}
}, {
key: 'destroyed',
value: function destroyed () {
if ( this.el ) {
var isTouch = this.state.isTouch;
this.el.removeEventListener( isTouch ? 'touchstart' : 'mousedown', this.onStart.bind( this ) );
this.el.removeEventListener( isTouch ? 'touchmove' : 'mousemove', this.onMove.bind( this ) );
this.el.removeEventListener( isTouch ? 'touchend' : 'mouseup', this.onEnd.bind( this ) );
this.el.removeEventListener( isTouch ? 'touchcancel' : 'mouseout', this.onEnd.bind( this ) );
}
}
}, {
key: 'clear',
value: function clear () {
// 清除画布
this.state.index = -1;
this.state.undopath = [];
this.ctx.clearRect( 0, 0, this.el.width, this.el.height );
}
}, {
key: 'undo',
value: function undo () {
// 撤销
this.state.index >= 0 && --this.state.index;
var undopath = this.state.undopath;
this.state.undopath.pop();
this.ctx.clearRect( 0, 0, this.el.width, this.el.height );
if ( undopath ) {
this.ctx.beginPath();
for ( var z = 0; z < undopath.length; ++z ) {
this.ctx.moveTo( undopath[z][0].x, undopath[z][0].y );
this.ctx.lineWidth = undopath[z][0].lineWidth;
this.ctx.strokeStyle = undopath[z][0].strokeStyle;
for ( var i = 0; i < undopath[z].length; ++i ) {
this.ctx.lineTo( undopath[z][i].x, undopath[z][i].y );
}
}
this.ctx.stroke();
this.ctx.closePath();
} else {
this.state.undopath = [];
}
}
}] );
return Draw;
}();
return Draw;
} ) ) );
... ...