作者 曹东东
@@ -295,4 +295,17 @@ return [ @@ -295,4 +295,17 @@ return [
295 //API接口地址 295 //API接口地址
296 'api_url' => 'https://api.fastadmin.net', 296 'api_url' => 'https://api.fastadmin.net',
297 ], 297 ],
  298 + //公众号
  299 + 'officialAccount'=>[
  300 + 'app_id' => 'wx401d047673f1c578',
  301 + 'secret' => '2f99955f1964d30d6e962c345c268274',
  302 + 'token' => 'wlzj3',
  303 + 'response_type' => 'array',
  304 + 'aes_key' => 'fT6nItu6itza0uIvFngi1AocwITGqOEe6GUCoqgTFDz'
  305 + ],
  306 + //公众号 模板消息 模板id
  307 + 'templateMessage'=>[
  308 + //审核通知
  309 + 'currency' => 'QUWHawyGohboStMgzZ4B4vQbqeFGWEnd-6MPh7jM8QQ',
  310 + ],
298 ]; 311 ];
@@ -7,11 +7,14 @@ use app\common\controller\TeacherBase; @@ -7,11 +7,14 @@ use app\common\controller\TeacherBase;
7 use app\school\model\basic\Clazz; 7 use app\school\model\basic\Clazz;
8 use app\school\model\basic\College; 8 use app\school\model\basic\College;
9 use app\school\model\basic\Specialty; 9 use app\school\model\basic\Specialty;
  10 +use EasyWeChat\Factory;
10 use fast\Random; 11 use fast\Random;
  12 +use Overtrue\Socialite\AuthorizeFailedException;
11 use think\addons\Service; 13 use think\addons\Service;
12 use think\Cache; 14 use think\Cache;
13 use think\Config; 15 use think\Config;
14 use think\Db; 16 use think\Db;
  17 +use think\Exception;
15 use think\Lang; 18 use think\Lang;
16 use Upyun\Upyun; 19 use Upyun\Upyun;
17 20
@@ -22,7 +25,8 @@ use Upyun\Upyun; @@ -22,7 +25,8 @@ use Upyun\Upyun;
22 class Ajax extends TeacherBase 25 class Ajax extends TeacherBase
23 { 26 {
24 27
25 - protected $noNeedLogin = ['lang','canvas','upyun_upload']; 28 + protected $noNeedLogin = ['lang'];
  29 + //'canvas','upyun_upload'
26 protected $noNeedRight = ['*']; 30 protected $noNeedRight = ['*'];
27 protected $layout = ''; 31 protected $layout = '';
28 32
@@ -310,20 +314,22 @@ class Ajax extends TeacherBase @@ -310,20 +314,22 @@ class Ajax extends TeacherBase
310 public function canvas(){ 314 public function canvas(){
311 $id = input('id'); 315 $id = input('id');
312 if ($this->request->isPost()){ 316 if ($this->request->isPost()){
313 - if (!$id) $this->error('用户数据异常'); 317 + if (!$id) $this->error('用户项目数据异常');
  318 + if (!$this->auth) $this->error('当前登录用户数据异常');
  319 + $teacher_name = $this->auth['username'];
314 $teacher_id = $this->auth['id']; 320 $teacher_id = $this->auth['id'];
315 - $detail = Db::table('fa_project_register')->where(['review_stage' => 0,'project_approval_status' => 0,'item_id' => $id])->find(); 321 + $detail = Db::table('fa_project_register')->where(['id' => $id])->find();
  322 + if ($detail['review_stage'] != 0) $this->error('用户项目数据已审核过');
  323 + if ($detail['project_approval_status'] != 0) $this->error('用户项目数据已审核过');
  324 + if ($detail['project_status'] == 2) $this->error('用户项目数据已被退回');
316 if (!$detail) $this->error('项目数据异常'); 325 if (!$detail) $this->error('项目数据异常');
317 //判断是否是审核成员 326 //判断是否是审核成员
318 $member_ids = Db::table('fa_members') 327 $member_ids = Db::table('fa_members')
319 - ->alias('m')  
320 -// ->field('m.container_id,m.member_id')  
321 -// ->join('fa_project_register p','m.container_id = p.container_id and m.item_id = p.id','LEFT')  
322 - ->where(['m.member_type' => 2 ,'m.member_source' => 2,'m.item_id' => $id]) 328 + ->where(['member_type' => 2 ,'member_source' => 2,'item_id' => $id])
323 ->column('member_id'); 329 ->column('member_id');
324 if (!in_array($teacher_id,$member_ids)) $this->error('当前用户不是该项目审核人员'); 330 if (!in_array($teacher_id,$member_ids)) $this->error('当前用户不是该项目审核人员');
325 $opinion = input('opinion');//意见 331 $opinion = input('opinion');//意见
326 - $type = input('type');//审核 1:通过 2:退回 332 + $project_type = input('type');//审核 1:通过 2:退回
327 $imgbase64 = input('imgbase64'); 333 $imgbase64 = input('imgbase64');
328 $file_url = ''; 334 $file_url = '';
329 //图片上传 335 //图片上传
@@ -345,10 +351,9 @@ class Ajax extends TeacherBase @@ -345,10 +351,9 @@ class Ajax extends TeacherBase
345 } 351 }
346 } 352 }
347 //通过:project_approval_status => 1 退回:project_status => 2 353 //通过:project_approval_status => 1 退回:project_status => 2
348 -  
349 $data['signature_url'] = $file_url; 354 $data['signature_url'] = $file_url;
350 $data['updatetime'] = time(); 355 $data['updatetime'] = time();
351 - if ($type == 2){ 356 + if ($project_type == 2){
352 $data['project_status'] = 2; 357 $data['project_status'] = 2;
353 $msg = '退回'; 358 $msg = '退回';
354 }else{ 359 }else{
@@ -356,6 +361,8 @@ class Ajax extends TeacherBase @@ -356,6 +361,8 @@ class Ajax extends TeacherBase
356 $msg = '通过'; 361 $msg = '通过';
357 } 362 }
358 Db::table("fa_project_register")->where('id',$id)->update($data); 363 Db::table("fa_project_register")->where('id',$id)->update($data);
  364 + //项目类型
  365 + $project_type_name = Db::table('fa_project_type')->where('id',$detail['project_type'])->value('name');
359 //fa_register_log project_type_name => fa_project_register.project_type--fa_project_type 366 //fa_register_log project_type_name => fa_project_register.project_type--fa_project_type
360 $log['register_id'] = $id; 367 $log['register_id'] = $id;
361 $log['container_id'] = $detail['container_id']; 368 $log['container_id'] = $detail['container_id'];
@@ -366,13 +373,32 @@ class Ajax extends TeacherBase @@ -366,13 +373,32 @@ class Ajax extends TeacherBase
366 $log['verify_stage'] = 0; 373 $log['verify_stage'] = 0;
367 $log['project_name'] = $detail['project_name']; 374 $log['project_name'] = $detail['project_name'];
368 $log['project_type'] = $detail['project_type']; 375 $log['project_type'] = $detail['project_type'];
369 - $log['project_type_name'] = Db::table('fa_project_type')->where('id',$detail['project_type'])->value('name'); 376 + $log['project_type_name'] = $project_type_name;
370 $log['created_time'] = datetime('Y-m-d H:i:s',time()); 377 $log['created_time'] = datetime('Y-m-d H:i:s',time());
371 - $log['teacher_name'] = $this->auth['teacher_name']; 378 + $log['teacher_name'] = $teacher_name;
372 $log['job_num'] = $this->auth['job_num']; 379 $log['job_num'] = $this->auth['job_num'];
373 $log['operation'] = '项目审核' . $msg; 380 $log['operation'] = '项目审核' . $msg;
374 - $log['memo'] = '项目审核'; 381 + $log['memo'] = $opinion;
375 Db::table("fa_register_log")->insert($log); 382 Db::table("fa_register_log")->insert($log);
  383 + $open_id = Db::table('fa_user')->where('id',$detail['user_id'])->value('open_id');
  384 + if ($open_id){
  385 + $config = Config::get('officialAccount');
  386 + $app = Factory::officialAccount($config);
  387 + $app->template_message->send([
  388 + 'touser' => $open_id,
  389 + 'template_id' => 'QUWHawyGohboStMgzZ4B4vQbqeFGWEnd-6MPh7jM8QQ',
  390 + 'data' => array(
  391 + 'first' => array('value' => "项目审核结果通知", 'color' => ''),
  392 + 'keyword1' => array('value' => $project_type_name, 'color' => ''),
  393 + 'keyword2' => array('value' => $detail['project_name'], 'color' => ''),
  394 + 'keyword3' => array('value' => $msg, 'color' => ''),
  395 + 'keyword4' => array('value' => $teacher_name, 'color' => ''),
  396 + 'keyword5' => array('value' => $opinion, 'color' => ''),
  397 + 'remark' => array('value' => '【您报名参加的' . $detail['project_name'] . '】被' . $msg, 'color' => ''),
  398 + ),
  399 + ]);
  400 + }
  401 +
376 $this->success('操作成功',$file_url); 402 $this->success('操作成功',$file_url);
377 } 403 }
378 $this->view->assign('id',$id); 404 $this->view->assign('id',$id);
@@ -8,8 +8,9 @@ @@ -8,8 +8,9 @@
8 <script src="__CDN__/assets/js/jquery-3.4.1.min.js"></script> 8 <script src="__CDN__/assets/js/jquery-3.4.1.min.js"></script>
9 </head> 9 </head>
10 10
11 -<body> 11 +<body style="margin: 0;">
12 <div class="popverBox"> 12 <div class="popverBox">
  13 + <div class="titleBox">项目审核</div>
13 <div id="signSure" class="signSure"> 14 <div id="signSure" class="signSure">
14 <input type="hidden" name="id" id="id" value="{$id}"> 15 <input type="hidden" name="id" id="id" value="{$id}">
15 <div class="topBtnBox"> 16 <div class="topBtnBox">
@@ -33,26 +34,33 @@ @@ -33,26 +34,33 @@
33 </body> 34 </body>
34 35
35 <script> 36 <script>
36 - function sureWriteCallback(imageBase64){  
37 - // 签名完成后的的逻辑代码... 37 + function sureWriteCallback(imageBase64,type){
  38 + // 签名完成后的的逻辑代码
38 $.ajax({ 39 $.ajax({
39 type : "POST", //提交方式 40 type : "POST", //提交方式
40 url : "canvas",//路径 41 url : "canvas",//路径
41 data : { 42 data : {
42 "imgbase64" : imageBase64, 43 "imgbase64" : imageBase64,
43 - 'type' : 1, 44 + 'type' : type,
44 'id' : $('#id').val(), 45 'id' : $('#id').val(),
45 'opinion' : $('#opinion').val() 46 'opinion' : $('#opinion').val()
46 },//数据,这里使用的是Json格式进行传输 47 },//数据,这里使用的是Json格式进行传输
47 success:function (data) { 48 success:function (data) {
48 - layer.msg('签名成功'); 49 + console.log('成功');
  50 + alert(data.msg)
  51 + },
  52 + error:function (data) {
  53 + console.log('失败')
  54 + alert(data.msg)
49 } 55 }
50 }) 56 })
51 } 57 }
  58 +
52 let params = { 59 let params = {
53 whiteBord:'whiteBord',//canvas标签的id名称 60 whiteBord:'whiteBord',//canvas标签的id名称
54 againWrite:'againWrite',//重写按钮id名 61 againWrite:'againWrite',//重写按钮id名
55 sureWrite:'sureWrite',//确认按钮id名 62 sureWrite:'sureWrite',//确认按钮id名
  63 + back:'back',//退回按钮id名
56 whiteBordPtions:{},//白板的配置项(空对象时取默认值) 64 whiteBordPtions:{},//白板的配置项(空对象时取默认值)
57 sureWriteCallback,// 签名完成后的回调函数 65 sureWriteCallback,// 签名完成后的回调函数
58 } 66 }
@@ -61,30 +69,38 @@ @@ -61,30 +69,38 @@
61 69
62 <style> 70 <style>
63 .popverBox{ 71 .popverBox{
64 - background: #666;; 72 + background: #f2f2f2;
65 position: relative; 73 position: relative;
66 font-size: 30px; 74 font-size: 30px;
67 - /*height: 900px;*/ 75 + display: flex;
  76 + align-items: center;
  77 + flex-direction: column;
  78 + height: 100vh;
68 } 79 }
69 .signSure{ 80 .signSure{
70 - position: absolute;  
71 - left: 9%;  
72 - top: 4%;  
73 - /*transform: translate(-50%, -50%);*/  
74 - width: 80%;  
75 - background: #fff; 81 + width: 90%;
76 border-radius: 16px; 82 border-radius: 16px;
77 padding: 20px 12px 28px 12px; 83 padding: 20px 12px 28px 12px;
78 } 84 }
  85 + .titleBox{
  86 + color: #fff;
  87 + background-color: #4285dc;
  88 + display: flex;
  89 + align-items: center;
  90 + justify-content: center;
  91 + width: 100%;
  92 + height: 7rem;
  93 + font-size: 2.5rem;
  94 + }
79 .topTitle{ 95 .topTitle{
80 margin: 20px 0 12px 12px; 96 margin: 20px 0 12px 12px;
81 - font-size: 30px; 97 + font-size: 2.3rem;
82 } 98 }
83 .whiteBord{ 99 .whiteBord{
84 width: 100%; 100 width: 100%;
85 height: 400px; 101 height: 400px;
86 - border: 1px solid #eee;  
87 - background: #f6f6f6; 102 + border: 1px solid #000;
  103 + background: #fff;
88 margin: 0 auto; 104 margin: 0 auto;
89 border-radius: 4px; 105 border-radius: 4px;
90 margin-bottom: 12px; 106 margin-bottom: 12px;
@@ -117,22 +133,22 @@ @@ -117,22 +133,22 @@
117 } 133 }
118 .opinion{ 134 .opinion{
119 width: 100%; 135 width: 100%;
120 - height: 179px; 136 + height: 235px;
121 font-size: 30px; 137 font-size: 30px;
122 - color: white; 138 + border: 1px solid #000;
123 } 139 }
124 140
125 .opinion::-webkit-input-placeholder{ 141 .opinion::-webkit-input-placeholder{
126 - height: 179px;line-height: 179px 142 + line-height: 235px;text-align: center;
127 }/* 使用webkit内核的浏览器 */ 143 }/* 使用webkit内核的浏览器 */
128 .opinion:-moz-placeholder{ 144 .opinion:-moz-placeholder{
129 - height: 179px;line-height: 179px 145 + line-height: 235px;text-align: center;
130 }/* Firefox版本4-18 */ 146 }/* Firefox版本4-18 */
131 .opinion::-moz-placeholder{ 147 .opinion::-moz-placeholder{
132 - height: 179px;line-height: 179px 148 + line-height: 235px;text-align: center;
133 }/* Firefox版本19+ */ 149 }/* Firefox版本19+ */
134 .opinion:-ms-input-placeholder{ 150 .opinion:-ms-input-placeholder{
135 - height: 179px;line-height: 179px 151 + line-height: 235px;text-align: center;
136 } 152 }
137 153
138 </style> 154 </style>
@@ -10,10 +10,11 @@ @@ -10,10 +10,11 @@
10 * @returns 签名的图片:格式base64 10 * @returns 签名的图片:格式base64
11 */ 11 */
12 function signature(params) { 12 function signature(params) {
13 - let {whiteBord,againWrite,sureWrite,whiteBordPtions,sureWriteCallback} = params 13 + let {whiteBord,againWrite,sureWrite,back,whiteBordPtions,sureWriteCallback} = params
14 let whiteBoardDom = document.getElementById(whiteBord); 14 let whiteBoardDom = document.getElementById(whiteBord);
15 let againWriteBtn = document.getElementById(againWrite) 15 let againWriteBtn = document.getElementById(againWrite)
16 let sureWriteBtn = document.getElementById(sureWrite) 16 let sureWriteBtn = document.getElementById(sureWrite)
  17 + let backBtn = document.getElementById(back)
17 18
18 let writeCanvas; 19 let writeCanvas;
19 let imageBase64='' 20 let imageBase64=''
@@ -21,7 +22,10 @@ function signature(params) { @@ -21,7 +22,10 @@ function signature(params) {
21 drawClear() 22 drawClear()
22 }) 23 })
23 sureWriteBtn.addEventListener('click', function () { 24 sureWriteBtn.addEventListener('click', function () {
24 - savePict() 25 + savePict(1)
  26 + })
  27 + backBtn.addEventListener('click', function () {
  28 + savePict(2)
25 }) 29 })
26 function WriteFont(options) { 30 function WriteFont(options) {
27 let obj = { 31 let obj = {
@@ -156,10 +160,10 @@ function signature(params) { @@ -156,10 +160,10 @@ function signature(params) {
156 */ 160 */
157 writeCanvas = new WriteFont('whiteBord', whiteBordPtions); 161 writeCanvas = new WriteFont('whiteBord', whiteBordPtions);
158 162
159 - function savePict() { 163 + function savePict(type) {
160 imageBase64 = whiteBoardDom.toDataURL("image/png"); //base64 164 imageBase64 = whiteBoardDom.toDataURL("image/png"); //base64
161 writeCanvas.option.control.clearCanvas(); 165 writeCanvas.option.control.clearCanvas();
162 - sureWriteCallback(imageBase64) 166 + sureWriteCallback(imageBase64,type)
163 } 167 }
164 function drawClear() { 168 function drawClear() {
165 writeCanvas.option.control.clearCanvas(); 169 writeCanvas.option.control.clearCanvas();