作者 魏强
1 个管道 的构建 通过 耗费 1 秒

转诊待答操作

... ... @@ -14,6 +14,8 @@ use app\user\model\TransferModel;
use app\user\model\UserModel;
use cmf\controller\WeChatBaseController;
use EasyWeChat\Foundation\Application;
use Qiniu\Auth;
use Qiniu\Storage\UploadManager;
use think\Db;
class ExpertController extends WeChatBaseController
... ... @@ -153,4 +155,187 @@ class ExpertController extends WeChatBaseController
return $this->fetch();
}
/**
* 转诊疑问
*/
public function replyTransfer(){
$data=$this->request->param();
$update['reply']=$this->getSaveContent($data,'reply');
$update['id']=$data['id'];
$model=new TransferModel();
$model->adminEdit($update);
//todo 生成卡片
$this->success('提交成功','',$model->getLastSql());
}
/**
* 同意转诊
*/
public function agreeTransfer(){
$data=$this->request->param();
$update['reply_again']=$this->getSaveContent($data,'reply_again');
$update['id']=$data['id'];
$update['receive_hospital']=$data['receive_hospital'];
$update['receive_expert']=$data['receive_expert'];
$update['receive_address']=$data['receive_address'];
$update['receive_time']=strtotime($data['receive_time']);
$update['status']=1;
$model=new TransferModel();
$model->adminEdit($update);
//todo 生成卡片
$this->success('');
}
/**
* 驳回转诊
*/
public function refuseTransfer(){
$id=$this->request->param('id');
$model=new TransferModel();
$row=$model->where(['id'=>$id])->setField('status',2);
if($row){
$this->success('驳回成功');
}else{
$this->error('驳回失败');
}
}
/**
* 内容处理
* @param $input
* @param $name
* @return mixed
*/
protected function getSaveContent($input,$name){
$return['type']=$input[$name.'_type'];
if ($return['type']==1){
$return['content']=explode(',',$input[$name]);
$dir=[];
foreach ($return['content'] as $k=>$v) {
$dir[$k]=$this->saveWxVoice($v);
}
$return['dir']=$dir;
}else{
$return['content']=$input[$name];
}
return $return;
}
/**
* 获取微信语音到本地
* @param $audioID
*/
protected function saveWxVoice($mediaId){
$config=config('wechat_config');
$Wechat=new Application($config);
$temporary = $Wechat->material_temporary;
$dir=ROOT_PATH.'public/'.'upload/inquery'.'/';
$name=date('YmdHis',time()).rand(1000,9999);
$file=$name.'.amr';
$data=$temporary->download($mediaId,"$dir", "$file");
$filePath=$dir.$file;
$result=$this->upChange($filePath,$name);
if($result['err']==0){
return $result['data'];
}else{
$this->error($result['msg']);
}
}
/**
* 录音文件amr转mp3
* @param $filePath 文件绝对路径
* @param $name 文件名不含后缀
* @return mixed
*/
protected function upChange($filePath,$name){
//转码时使用的队列名称
$pipeline = 'jyht_list';
//要进行转码的转码操作
$fops = "avthumb/mp3/ab/320k/ar/44100/acodec/libmp3lame";
//可以对转码后的文件进行使用saveas参数自定义命名,当然也可以不指定文件会默认命名并保存在当间
$savekey = \Qiniu\base64_urlSafeEncode("jyht_list:$name.mp3");
$fops = $fops.'|saveas/'.$savekey;
$policy = array(
'persistentOps' => $fops,
'persistentPipeline' => $pipeline
);
$key = "$name.mp3";
$ret=$this->uploadToQiniu($filePath,$key,$policy);
return $ret;
}
/**
* @return mixed
* @throws \EasyWeChat\Core\Exceptions\InvalidArgumentException
*/
public function upload_wx_pic_mul($mediaId)
{
$config=config('wechat_config');
$Wechat=new Application($config);
$temporary = $Wechat->material_temporary;
$dir=ROOT_PATH.'public/'.'upload/friend'.'/';
$name=date('YmdHis',time()).rand(1000,9999).'.jpg';
$data=$temporary->download($mediaId,"$dir", "$name");
$filePath=$dir.$name;
$result=$this->uploadToQiniu($filePath,$name);
if($result['err']===0){
return $result['data'];
}else{
$this->error($result['msg']);
}
return $data;
}
/**
* @param $filePath
* @param $save_name
* @param $policy
* @return array
*/
protected function uploadToQiniu($filePath,$save_name,$policy=null){
$plugin=Db::name('plugin')->field('config')->where(['name'=>'Qiniu'])->find();
$config=json_decode($plugin['config'],true);
// 上传到七牛后保存的文件名
$key =$save_name;
require_once VENDOR_PATH . 'qiniu/php-sdk/autoload.php';
// 需要填写你的 Access Key 和 Secret Key
$accessKey = $config['accessKey'];
$secretKey = $config['secretKey'];
// 构建鉴权对象
$auth = new Auth($accessKey,$secretKey);
// 要上传的空间
$bucket = $config['bucket'];
$token = $auth->uploadToken($bucket, null, 3600, $policy);
// 初始化 UploadManager 对象并进行文件的上传
$uploadMgr = new UploadManager();
// 调用 UploadManager 的 putFile 方法进行文件的上传
list($ret, $err) = $uploadMgr->putFile($token, $key, $filePath);
if ($err !== null) {
return ["err"=>1,"msg"=>$err,"data"=>""];
} else {
unlink($filePath);
return ["err"=>0,"msg"=>"上传完成","data"=>cmf_get_asset_url($ret['key'])];
}
}
}
\ No newline at end of file
... ...
... ... @@ -21,7 +21,10 @@ class TransferModel extends Model
'inspected' => 'array',
'diagnose' => 'array',
'used_drugs' => 'array',
'problem' => 'array'
'problem' => 'array',
'reply' => 'array',
'problem_again' => 'array',
'reply_again' => 'array',
];
/**
... ...
... ... @@ -128,14 +128,14 @@
<div class="tab_content_box info_item question_yes">
<div class="tab_info inquiry_content title">
<text>提问</text>
<text class="iconfont icon-huatong voice_btn"></text>
<text class="iconfont icon-huatong voice_btn voice_btn1"></text>
<text class="iconfont icon-tianxie"></text>
</div>
<div class="textarea_content">
<textarea class="area" type="text" placeholder="请输入" maxlength="1000"></textarea>
<textarea class="area textarea1" type="text" placeholder="请输入" maxlength="1000"></textarea>
<p class="text_num num_box"><span class="text-count">0</span>/1000</p>
</div>
<div class="voice_module agree_box" video-id="1">
<div id="voice_module1" class="voice_module agree_box" video-id="1">
<div class="voice_list" voiceitemid="1">
<div class="voice_box voice_third">
<div class="voice_item">
... ... @@ -160,6 +160,59 @@
</div>
</div>
<notempty name="info.reply">
<!--专家提问显示内容-->
<div class="tab_content_box">
<div class="tab_info">
<text>专家提问</text>
</div>
<div class="user_info_box">
<eq name="info.reply.type" value="1">
<div class="voice_box" >
<foreach name="info.reply.dir" item="item">
<div class="voice_item">
<text class="iconfont icon-luyin voice_icon voice_play" data-url="{$item}"></text>
<text class="iconfont icon-luying_ongoing voice_icon voice_puse"></text>
<text class="voice_font">点击图标开始播放</text>
</div>
</foreach>
</div>
<else/>
<div class="tab_textarea">
<textarea readonly>{$info.reply.content}</textarea>
</div>
</eq>
</div>
</div>
<!--回复专家的内容-->
<div class="tab_content_box">
<div class="tab_info">
<text>回答</text>
</div>
<div class="user_info_box">
<notempty name="info.problem_again">
<eq name="info.problem_again.type" value="1">
<div class="voice_box" >
<foreach name="info.problem_again.dir" item="item">
<div class="voice_item">
<text class="iconfont icon-luyin voice_icon voice_play" data-url="{$item}"></text>
<text class="iconfont icon-luying_ongoing voice_icon voice_puse"></text>
<text class="voice_font">点击图标开始播放</text>
</div>
</foreach>
</div>
<else/>
<div class="tab_textarea">
<textarea readonly>{$info.problem_again.content}</textarea>
</div>
</eq>
<else/>
尚未回答
</notempty>
</div>
</div>
</notempty>
<!--转诊意见内容部分-->
<div class="tab_content_box info_item question_no">
<div class="tab_info inquiry_content title">
... ... @@ -195,29 +248,7 @@
</div>
</div>
</div>
<notempty name="info.reply">
<!--专家提问显示内容-->
<div class="tab_content_box">
<div class="tab_info">
<text>专家提问</text>
</div>
<div class="user_info_box">
{$info.reply}
</div>
</div>
<!--回复专家的内容-->
<div class="tab_content_box">
<div class="tab_info">
<text>回答</text>
</div>
<div class="user_info_box">
{$info.problem_again|default='尚未回答'}
</div>
</div>
</notempty>
<!--同意转诊须填表单-->
<div class="tab_content_box question_no">
<div class="tab_content">
... ... @@ -226,19 +257,19 @@
<div class="info_box">
<div class="info_item">
<div class="title">接诊医院</div>
<div class="info_input"><input type="text" placeholder="请填写接诊医院"></div>
<div class="info_input"><input type="text" id="receive_hospital" placeholder="请填写接诊医院"></div>
</div>
<div class="info_item">
<div class="title">转诊专家</div>
<div class="info_input"><input type="text" placeholder="请填写接诊医院"></div>
<div class="info_input"><input type="text" id="receive_expert" placeholder="请填写转诊专家"></div>
</div>
<div class="info_item">
<div class="title">接诊地点</div>
<div class="info_input"><input type="text" placeholder="请填写接诊医院"></div>
<div class="info_input"><input type="text" id="receive_address" placeholder="请填写接诊地点"></div>
</div>
<div class="info_item" id="showDatePicker">
<div class="title">就诊时间</div>
<div class="info_input"><input class="time_value" type="text" placeholder="请填写接诊医院">
<div class="info_input"><input class="time_value" id="receive_time" type="text" placeholder="请选择就诊时间">
<text class="iconfont icon-xiala"></text>
</div>
</div>
... ... @@ -246,26 +277,33 @@
</div>
</div>
</div>
<!--确认回复按钮-->
<div class="agree_btn submit question_yes1">确认回复</div>
<!---->
<div class="bottom_box question_no">
<div class="agree_btn">同意</div>
<div class="bottom_btn">驳回</div>
</div>
<eq name="info.status" value="0">
<!--确认回复按钮-->
<div class="agree_btn submit question_yes1" id="submit_reply">确认回复</div>
<!---->
<div class="bottom_box question_no">
<div class="agree_btn" id="agree_transfer">同意</div>
<div class="bottom_btn">驳回</div>
</div>
</eq>
</div>
<div class="mask_box" hidden>
<div class="mask_box refuse_box" hidden>
<div class="referral_popup_box">
<div>确认驳回</div>
<div class="referral_info">确定驳回转诊吗?</div>
<div class="referral_btn_box">
<div class="btn cancel_btn">取消</div>
<div class="btn confirm_btn">确认</div>
<div class="btn confirm_btn" id="refuse_transfer">确认</div>
</div>
</div>
</div>
<!--表单判断弹窗-->
<div class="form_popup_box" hidden>
<text></text>
</div>
<!--录音弹窗-->
<div class="mask_box first" hidden>
<div class="popup_box">
... ... @@ -339,6 +377,14 @@
<script src="http://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
<!--<script src="__TMPL__/public/assets/js/referral.js"></script>-->
<script>
$('.bottom_btn').click(function () {
$('.refuse_box').show();
});
$('.cancel_btn').click(function () {
$('.refuse_box').hide();
});
wx.config({$sdk});
//文本框显示字数
$(".area").on("input propertychange", function () {
... ... @@ -486,7 +532,7 @@
})
//显示弹窗
var videoid=''
var videoid='';
//生命全局唯一 音频
var voiceBox;
$(document).on("click", ".mike", function () {
... ... @@ -496,34 +542,15 @@
$('.stopping').hide()
$('.stop').hide()
$('.next_step').hide();
// videoid=$(this).parents(".voice_module").attr("video-id")
// $(this).parents(".voice_first").hide();
// $(this).parents(".voice_first").siblings(".voice_third").show()
//
// // vioceid=$(this).parents(".voice_first").attr("voiceid");
//
voiceBox = $(this).parents('.voice_list');
// console.log(voiceBox)
// $('.submit_voice').attr('videoid')
//
// var videolist = $(".voice_module");
// console.log(videolist)
// for (var i = 0; i < videolist.length; i++) {
// if (videoid == title_id) {
// $(videolist[i]).children(".voice_list").children(".voice_list").hide();
// $(videolist[i]).children(".voice_list").children(".voice_third").show();
// }
// }
});
//删除语音
$(".voice_module").on("click",".cancle_voice",function(){
$(this).parents(".voice_box").remove();
})
});
//开始录音
var localId;
... ... @@ -536,7 +563,7 @@
$('.next_step').hide()
/*微信开始录音*/
wx.startRecord();
})
});
//暂停
$('.pause').click(function () {
... ... @@ -544,7 +571,7 @@
$('.start').show()
$('.stopping').hide()
})
});
//停止录音
$('.stopping').click(function () {
... ... @@ -557,14 +584,14 @@
}
});
})
});
//下一步
$('.next_step').click(function () {
$('.first').hide()
$('.second').show()
$('.first').hide();
$('.second').show();
})
});
//点击试听
$('.audition').click(function () {
... ... @@ -719,8 +746,157 @@
$('.question_no').show();
$(this).attr('data-id',1);
}
})
});
//回复
$('#submit_reply').click(function () {
/*获取病人主诉*/
var display=$('.voice_btn1').css('display');
//console.log(display1);
if (display=='none'){
var reply='';
/*判断发送类型*/
var reply_type='1';
$('#voice_module1 .voice_third').each(function () {
/*拼接信息*/
var voiceId1=$(this).attr('data-serverid');
if (voiceId1!=undefined){
if (reply==''){
reply=voiceId1;
}else{
reply+=','+voiceId1;
}
}
})
}else{
var reply=$('.textarea1').val();
var reply_type='2';
if (!reply){
$('.form_popup_box').show();
$('.form_popup_box').text('回复内容不能为空');
$('.form_popup_box').delay(1000).hide(0);
return;
}
}
alert(JSON.stringify({
reply:reply,
reply_type:reply_type
}))
/*提交后台*/
$.ajax({
url:"{:url('replyTransfer',array('id'=>$info['id']))}",
type:'POST',
data:{
reply:reply,
reply_type:reply_type
},
success:function (res) {
console.log(res);
alert(JSON.stringify(res));
$('.box').show().delay(2000).hide(2)
},
error:function (res) {
alert(res);
}
})
});
//同意
$('#agree_transfer').click(function () {
/*获取病人主诉*/
var display2=$('.voice_btn2').css('display');
//console.log(display1);
if (display2=='none'){
var reply_again='';
/*判断发送类型*/
var ireply_again_type='1';
$('#voice_module2 .voice_third').each(function () {
/*拼接信息*/
var voiceId1=$(this).attr('data-serverid');
if (voiceId1!=undefined){
if (reply_again==''){
reply_again=voiceId1;
}else{
reply_again+=','+voiceId1;
}
}
})
}else{
var reply_again=$('.textarea2').val();
var reply_again_type='2';
if (!reply_again){
$('.form_popup_box').show();
$('.form_popup_box').text('转诊意见');
$('.form_popup_box').delay(1000).hide(0);
return;
}
}
var receive_hospital = $('#receive_hospital').val();
var receive_expert = $('#receive_expert').val();
var receive_address = $('#receive_address').val();
var receive_time = $('#receive_time').val();
if (receive_hospital == '') {
$('.form_popup_box').show();
$('.form_popup_box').text('请填写接诊医院');
$('.form_popup_box').delay(1000).hide(0);
return false;
} else if (receive_expert == '') {
$('.form_popup_box').show();
$('.form_popup_box').text('请填写接诊专家');
$('.form_popup_box').delay(1000).hide(0);
return false;
} else if (receive_address == '') {
$('.form_popup_box').show();
$('.form_popup_box').text('请填写接诊地点');
$('.form_popup_box').delay(1000).hide(0);
return false;
} else if (receive_time == '') {
$('.form_popup_box').show();
$('.form_popup_box').text('请填写就诊时间');
$('.form_popup_box').delay(1000).hide(0);
return false;
}
/*提交后台*/
$.ajax({
url:"{:url('agreeTransfer',array('id'=>$info['id']))}",
type:'POST',
data:{
receive_hospital:receive_hospital,
receive_expert:receive_expert,
receive_address:receive_address,
receive_time:receive_time,
reply_again:reply_again,
reply_again_type:reply_again_type
},
success:function (res) {
console.log(res);
alert(JSON.stringify(res));
$('.box').show().delay(2000).hide(2)
},
error:function (res) {
alert(res);
}
})
});
//驳回
$('#refuse_transfer').click(function () {
$.ajax({
url:"{:url('refuseTransfer',array('id'=>$info['id']))}",
type:'POST',
success:function (res) {
console.log(res);
alert(JSON.stringify(res));
$('.box').show().delay(2000).hide(2)
},
error:function (res) {
alert(res);
}
})
});
</script>
</body>
</html>
\ No newline at end of file
... ...
... ... @@ -950,7 +950,7 @@
}
})
}else{
var inspected=$('.textarea1').val();
var inspected=$('.textarea2').val();
var inspected_type='2';
if (!inspected){
$('.form_popup_box').show();
... ... @@ -1004,7 +1004,7 @@
}
})
}else{
var used_drugs=$('.textarea3').val();
var used_drugs=$('.textarea4').val();
var used_drugs_type='2';
if (!used_drugs){
$('.form_popup_box').show();
... ...