作者 杨育虎

转诊待答语音调试

... ... @@ -13,6 +13,7 @@ use app\user\model\InquiryModel;
use app\user\model\TransferModel;
use app\user\model\UserModel;
use cmf\controller\WeChatBaseController;
use EasyWeChat\Foundation\Application;
use think\Db;
class ExpertController extends WeChatBaseController
... ... @@ -97,6 +98,26 @@ class ExpertController extends WeChatBaseController
public function inquiryDetail(){
$config=config('wechat_config');
$Wechat=new Application($config);
$js = $Wechat->js;
$api[]='startRecord';
$api[]='stopRecord';
$api[]='onVoiceRecordEnd';
$api[]='playVoice';
$api[]='pauseVoice';
$api[]='stopVoice';
$api[]='onVoicePlayEnd';
$api[]='uploadVoice';
$api[]='downloadVoice';
$api[]='chooseImage';
$api[]='previewImage';
$api[]='uploadImage';
$api[]='downloadImage';
$api[]='translateVoice';
$sdk=$js->config($api, true);
$this->assign('sdk',$sdk);
$id=$this->request->param('id',0,'intval');
$model=new InquiryModel();
$info=$model->getInfo($id);
... ... @@ -105,6 +126,26 @@ class ExpertController extends WeChatBaseController
}
public function transferDetail(){
$config=config('wechat_config');
$Wechat=new Application($config);
$js = $Wechat->js;
$api[]='startRecord';
$api[]='stopRecord';
$api[]='onVoiceRecordEnd';
$api[]='playVoice';
$api[]='pauseVoice';
$api[]='stopVoice';
$api[]='onVoicePlayEnd';
$api[]='uploadVoice';
$api[]='downloadVoice';
$api[]='chooseImage';
$api[]='previewImage';
$api[]='uploadImage';
$api[]='downloadImage';
$api[]='translateVoice';
$sdk=$js->config($api, true);
$this->assign('sdk',$sdk);
$id=$this->request->param('id',0,'intval');
$model=new TransferModel();
$info=$model->getInfo($id);
... ...
... ... @@ -115,12 +115,14 @@
</div>
</div>
</div>
<div class="tab_content_box">
<div class="tab_info title_info" id="is_have_question" data-id="1">
<text class="tab_title">若您对转诊信息不明确,请点击发起提问</text>
<text class="iconfont icon-icon02 add_problem"></text>
<empty name="info.reply">
<div class="tab_content_box">
<div class="tab_info title_info" id="is_have_question" data-id="1">
<text class="tab_title">若您对转诊信息不明确,请点击发起提问</text>
<text class="iconfont icon-icon02 add_problem"></text>
</div>
</div>
</div>
</empty>
<!--提问内容部分-->
<div class="tab_content_box info_item question_yes">
... ... @@ -138,7 +140,7 @@
<div class="voice_box voice_third">
<div class="voice_item">
<text class="iconfont icon-luyin voice_icon"></text>
<text class="voice_font luyin">点击图标可播放 时长:10</text>
<text class="voice_font luyin">点击图标可播放 时长:<span class="timeLength">0</span></text>
</div>
<div class="voice_btn_box">
<text class="iconfont icon-quxiao cancle_voice"></text>
... ... @@ -162,26 +164,26 @@
<div class="tab_content_box info_item question_no">
<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_btn2"></text>
<text class="iconfont icon-tianxie"></text>
</div>
<div class="textarea_content">
<textarea class="area" type="text" placeholder="请输入" maxlength="1000"></textarea>
<textarea class="area textarea2" 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 class="voice_list" voiceitemid="1">
<div id="voice_module2" class="voice_module agree_box" video-id="2">
<div class="voice_list" voiceitemid="2">
<div class="voice_box voice_third">
<div class="voice_item">
<text class="iconfont icon-luyin voice_icon"></text>
<text class="voice_font luyin">点击图标可播放 时长:10</text>
<text class="voice_font luyin">点击图标可播放 时长:<span class="timeLength">0</span></text>
</div>
<div class="voice_btn_box">
<text class="iconfont icon-quxiao cancle_voice"></text>
<text class="iconfont icon-tianjia add_voice"></text>
</div>
</div>
<div class="voice_box voice_first" voiceid="1">
<div class="voice_box voice_first" voiceid="2">
<div class="voice_item">
<text class="iconfont icon-huatong mike voice_icon"></text>
<text class="voice_font huatong">点击图标开始语音语音最长60秒</text>
... ... @@ -334,9 +336,10 @@
<script src="__TMPL__/public/assets/js/jquery-2.1.0.js"></script>
<script src="__TMPL__/public/assets/js/weui.js"></script>
<script src="__TMPL__/public/assets/js/myweui.js"></script>
<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>
wx.config({$sdk});
//文本框显示字数
$(".area").on("input propertychange", function () {
... ... @@ -350,99 +353,11 @@
$(this).siblings(".text_num").children('.text-count').text(count);
});
// 疾病分类下拉
$('.inquiry_type').click(function () {
weui.picker([
{label: '一类', value: 0},
{label: '二类', value: 1}
], {
onChange: function (res) {
console.log(res)
},
onConfirm: function (res) {
$('.inquiry_value').val(res[0].label)
}
}
)
})
// 疾病分类下拉
$('.expert').click(function () {
weui.picker([
{label: '王医生', value: 0},
{label: '刘易斯', value: 1}
], {
onChange: function (res) {
console.log(res)
},
onConfirm: function (res) {
$('.expert_value').val(res[0].label)
}
}
)
})
// 性别分类
$('.sex_type').click(function () {
weui.picker([
{label: '男', value: 0},
{label: '女', value: 1}
], {
onChange: function (res) {
console.log(res)
},
onConfirm: function (res) {
$('.sex_value').val(res[0].label)
}
}
)
})
// 性别分类
$('.unit_type').click(function () {
weui.picker([
{label: '国企', value: 0},
{label: '私企', value: 1}
], {
onChange: function (res) {
console.log(res)
},
onConfirm: function (res) {
$('.unit_value').val(res[0].label)
}
}
)
})
//就诊时间
$('#showDatePicker').on('click', function () {
weui.datePicker({
start: 2019,
end: new Date().getFullYear(),
onChange: function (result) {
console.log(result);
},
onConfirm: function (result) {
console.log(result[0].label+' - '+result[1].label+' - '+result[2].label)
$('.time_value').val(result[0].value+' - '+result[1].value+' - '+result[2].value)
}
});
});
//语音模块
// $('.icon-tianxie').hide()
// $('.voice_first').hide()
// $('.voice_second').hide()
$('.voice_third').hide()
$('.icon_cancle').hide()
// $('.voice_module').hide()
var title_id = ''
//点击
$('.info_item').on('click','.title',function () {
$(this).parent().toggleClass('voice')
})
//点击正在播放按钮
$('.icon-luying_ongoing').click(function () {
var videolist = $(".voice_module");
... ... @@ -456,10 +371,10 @@
}
})
var times = "";//倒计时总秒数量
var time = "";
//倒计时
var times = "60";//倒计时总秒数量
var time="";
var timeLength=0;
function countDown(times) {
var timer = null;
timer = setInterval(function () {
... ... @@ -481,9 +396,10 @@
$('#hour_show').html('<text id="h"></text>' + hour + ':');
$('#minute_show').html('<text></text>' + minute + ':');
$('#second_show').html('<text></text>' + second + '');
$('#second_test').html('<text></text>' + second + '');
//
console.log(day + "天:" + hour + "小时:" + minute + "分钟:" + second + "秒");
// console.log(day + "天:" + hour + "小时:" + minute + "分钟:" + second + "秒");
times--;
}, 1000);
... ... @@ -494,31 +410,32 @@
$('.pause').click(function () {
// timer(intDiff);
clearInterval(timer);
localStorage.setItem("times", times)
localStorage.setItem("times",times)
})
$('.stop').click(function () {
clearInterval(timer);
times = 0;
times=0;
})
$('.stopping').click(function () {
clearInterval(timer);
timeLength=60-times;
console.log('录音时长:'+timeLength);
localStorage.clear()
})
}
$('.start').click(function () {
time = localStorage.getItem("times")
if (time == null) {
time=localStorage.getItem("times")
if(time==null){
times = parseInt(60)
} else {
times = time;
}else{
times=time;
}
console.log(time)
// myTimer(intDiff);
countDown(times);
localStorage.setItem("times", times)
localStorage.setItem("times",times)
})
//添加一条新语音
var num = 1;
$('.voice_module').on('click', '.add_voice', function () {
... ... @@ -561,6 +478,9 @@
' </div>\n' +
' </div>\n' +
'</div>'
// parent.append($('.voice_list').html());
parent.append(html)
})
... ... @@ -606,12 +526,16 @@
})
//开始录音
var localId;
$('.start').click(function () {
$('.start').hide()
$('.stop').hide()
$('.play').hide()
$('.pause').show()
$('.stopping').show()
$('.next_step').hide()
/*微信开始录音*/
wx.startRecord();
})
//暂停
... ... @@ -619,60 +543,134 @@
$('.pause').hide()
$('.start').show()
$('.stopping').hide()
})
//播放语音
$('.voice_puse').hide()
$('.voice_play').click(function () {
var url=$(this).data('url');
var mySound = new Audio(url);
mySound.play();
$(this).hide()
$(this).siblings('.voice_puse').show();
$('.voice_puse').click(function () {
mySound.pause();
$(this).hide()
$(this).siblings('.voice_play').show()
})
})
//停止录音
$('.stopping').click(function () {
$('.next_step').show()
$('.stop').show()
$('.pause').hide()
wx.stopRecord({
success: function (res) {
localId = res.localId;
}
});
})
//下一步
$('.next_step').click(function () {
$('.first').hide()
$('.second').show()
})
//点击试听
$('.audition').click(function () {
wx.onVoicePlayEnd({
success: function (res) {
var localId = res.localId; // 返回音频的本地ID
}
});
wx.playVoice({
localId:localId //需要播放的音频的本地ID,由stopRecord接口获得
});
var videolist = $(".voice_module");
for (var i = 0; i < videolist.length; i++) {
var videoid = $(videolist[i]).attr("video-id");
if (videoid == title_id) {
$('.second').hide()
$(videolist[i]).show();
$(videolist[i]).children('.voice_list').hide()
$(videolist[i]).children('.voice_third').show();
}
}
})
// 列表中点击试听
$('.voice_third').click(
function () {
var tryId=$(this).attr('try-id');
wx.playVoice({
localId:tryId
});
}
)
//就诊时间
$('#showDatePicker').on('click', function () {
weui.datePicker({
start: 2019,
end: new Date().getFullYear(),
onChange: function (result) {
console.log(result);
},
onConfirm: function (result) {
console.log(result[0].label+' - '+result[1].label+' - '+result[2].label)
$('.time_value').val(result[0].value+' - '+result[1].value+' - '+result[2].value)
}
});
});
//语音模块
$('.voice_third').hide()
$('.icon_cancle').hide()
var title_id = ''
//我要发送
$('.submit_voice').click(function () {
voiceBox.find('.voice_first').hide().siblings('.voice_third').show()
wx.uploadVoice({localId: localId, // 需要上传的音频的本地ID,由stopRecord接口获得
isShowProgressTips: 1, // 默认为1,显示进度提示
success: function (res) {
voiceBox.find('.voice_first').hide().siblings('.voice_third').attr('data-serverid',res.serverId);
}
});
voiceBox.find('.voice_first').hide().siblings('.voice_third').attr('data-try',localId);
voiceBox.find('.voice_first').hide().siblings('.voice_third').attr('data-time',timeLength);
voiceBox.find('.timeLength').html(timeLength);
$('.second').hide()
})
//确认音频
$('.upload').click(function () {
var videolist = $(".voice_module");
for (var i = 0; i < videolist.length; i++) {
var videoid = $(videolist[i]).attr("video-id");
if (videoid == title_id) {
$('.second').hide()
$(videolist[i]).show();
$(videolist[i]).children('.voice_list').hide()
$(videolist[i]).children('.voice_third').show();
/*上面放上 音频id和本地地址*/
$(videolist[i]).children('.voice_third').attr('try-id',localId);
$(videolist[i]).children('.voice_third').data('data-try',localId);
$(videolist[i]).children('.voice_third').attr('id','audio'+videoid);
wx.uploadVoice({
localId: localId, // 需要上传的音频的本地ID,由stopRecord接口获得
isShowProgressTips: 1, // 默认为1,显示进度提示
success: function (res) {
var serverId = res.serverId; // 返回音频的服务器端ID
$(videolist[i]).children('.voice_third').attr('server-id',serverId);
$(videolist[i]).children('.voice_third').data('data-server',serverId);
localId='';
}
});
}
}
})
//重新录制
$('.rerecord').click(function () {
$('#second_test').html(60);
$('.first').show()
$('.second').hide()
$('.stop').hide()
$('.stopping').hide()
$('.start').show()
$('.start').show()
})
//上传图片
... ...
... ... @@ -654,8 +654,6 @@
$(this).parents(".voice_box").remove();
})
//开始录音
var localId;
$('.start').click(function () {
... ... @@ -720,7 +718,6 @@
}
})
// 列表中点击试听
$('.voice_third').click(
function () {
... ...