123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560 |
- var d = dialog({contentType:'load', skin:'bk-popup'});
- var dd = dialog({contentType:'load', skin:'bk-popup', content:'发送中...'});
- var Request = new Object();
- Request = GetRequest();
- var userAgent = window.localStorage.getItem(agentName);
- var toUser = Request["toUser"];
- var toName = decodeURIComponent(Request["toName"]);
- var openid = Request["openid"];
- var represented = Request["represented"];
- var consult = Request["consult"];
- var pagetype = 0;
- $(function() {
- if(!userAgent) {
- window.localStorage.setItem(pageName, JSON.stringify({pageurl: location.href}))
- window.location.href = server + "wx/html/home/html/login.html?type=" + pagetype + "&openid=" + openid;
- return false;
- }
- var newUaObj = JSON.parse(window.localStorage.getItem(agentName))
- //判断关系
- function hasFamilyRelation(a,b){
- return new Promise(function(resolve, reject) {
- var data={
- patient:a,
- familyMember:b
- }
- sendPost("patient/family/is_authorize", data, "json", "get", function(res){
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请求家庭成员关系失败'}).show();
- }, function(res){
- if(res.status == 200) {
- window.localStorage.setItem('nowPatientName',res.data.name);
- resolve(res)
- }else if(res.status == 100) {
- dialog({
- content:'对不起,'+res.data.name+'未授权给您,如需查看,请切换'+res.data.name+'账号登录',
- okValue:'切换账号',
- ok: function() {
- window.localStorage.setItem(pageName, JSON.stringify({pageurl: location.href}))
- window.location.href = "../../grzx/html/change-login.html?type=0&openid="+ Request["openid"];
- },
- cancelValue: '我不看了',
- cancel: function () {
- wx.closeWindow();
- }
- }).showModal();
- }else{
- relogin();
- }
-
- })
- })
- }
- //重新登录操作
- function relogin(){
- dialog({
- content:'对不起,该消息是发给'+toName+',如需查看,请切换'+toName+'账号登录',
- okValue:'切换账号',
- ok: function() {
- window.localStorage.setItem(pageName, JSON.stringify({pageurl: location.href}))
- window.location.href = "../../grzx/html/change-login.html?type=0&openid="+ Request["openid"];
- },
- cancelValue: '我不看了',
- cancel: function () {
- wx.closeWindow();
- }
- }).showModal();
- }
- //保存信息
- function saveUserInfo(a,b){
- Promise.all([hasFamilyRelation(a,b)]).then(function () {
- newUaObj.represented = represented;
- window.localStorage.setItem(agentName,JSON.stringify(newUaObj));
- })
- }
-
- function initFamilyData () {
- //从微信模板消息进入
- if(represented && userAgent && toUser){
- if(toUser == represented){
- saveUserInfo(represented,newUaObj.uid)
- }else if(toUser != represented && represented == newUaObj.uid){
- //本人代理
- saveUserInfo(represented,newUaObj.uid)
- }else if(toUser != represented && toUser == newUaObj.uid){
- //需要判定关系 200有授权 100家人 1无关系
- saveUserInfo(represented,newUaObj.uid)
- }else{
- //重新登录
- relogin();
- }
- }
- }
- initFamilyData();
-
- var doctorPar,//参与咨询医生信息
- $starListGroup = $('#manValueList'),
- reqUrl = '',
- evaluateKind = 1,//实名类型
- finish = 1;//提交后标志
-
- //参与者
- var data = {};
- data.consult = consult;
- data.page = 1;
- data.pagesize = 1;
- sendPost('patient/consult/loglist', data, 'json', 'GET', function(){
- dialog({contentType:'tipsbox', skin:'bk-popup' ,bottom:true, content:'请求数据失败'}).show();
- }, function(res){
- if (res.status == 200) {
- res = res.list;
- var arr = [];//储存参与咨询的医生
- for(var k in res.users){
- if(res.users[k].is_patient == 0){
- arr.push(res.users[k])
- }
- }
- doctorPar=arr;
- nextWork();
- }else{
- dialog({contentType:'tipsbox', skin:'bk-popup' ,bottom:true, content:'加载数据失败'}).show();
- }
- })
-
-
- function nextWork(){
- if(doctorPar){
- for(var k in doctorPar){
- if(doctorPar[k].level == 1){
- doctorPar[k].levelName = '专科医生'
- }
- if(doctorPar[k].level == 2){
- doctorPar[k].levelName = '全科医生'
- }
- if(doctorPar[k].level == 3){
- doctorPar[k].levelName = '健康管理师'
- }
- }
- }
- queryOldData();
- bindEvents();
- }
-
- function bindEvents(){
- //文本框
- $starListGroup.on('keyup',"textarea",function(){
- var $this = $(this);
- var count = $this.val().length;
- $this.parent('.text-input').find('.text_count').text(count);
- });
- //匿名
- $('.j-niming').on('click',function(){
- if(finish == 1){
- var $this = $(this).parent();
- if($this.hasClass('active')){
- $this.removeClass('active');
- evaluateKind = 1;
- }else{
- $this.addClass('active');
- evaluateKind = 2;
- }
- }
- })
- //贴标签展开和关闭
- $starListGroup.on('click','.small-title',function(){
- if(finish == 1){
- var $this = $(this);
- if($this.hasClass('active')){
- $this.removeClass('active');
- $this.siblings('.j-tag-detail').animate({height:'hide'},300)
- }else{
- $this.addClass('active');
- $this.siblings('.j-tag-detail').animate({height:'show'},300)
- }
- }
- })
- //点击显示星星
- $starListGroup.on('click','.star-lists .one-star',function(){
- var $this = $(this);
- var $parent = $this.parent();
- if(finish == 1){
- $parent.find('.one-star').removeClass('active')
- for(var i=0;i<=$this.index();i++){
- $parent.find('.one-star').eq(i).addClass('active');
- }
- }
- })
- //贴上功能
- $starListGroup.on('click','.j-submit',function(){
- if(finish == 1){
- var $this = $(this);
- var $input = $this.siblings('.input').find('input');
- var val = $input.val().trim();
- if($this.parent().siblings('ul.tag-list').find('li.active').length > 3){
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'最多只能选择4个标签'}).show();
- }else{
- if(val){
- if(val.length>8){
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'自定义标签最多8个字'}).show();
- $input.blur();
- return;
- }else{
- var html = '<li class="active">'+val+'</li>';
- $this.parent().siblings('ul.tag-list').append(html);
- $input.val('');
- $input.blur();
- }
- }
- }
- }
- })
- //点击标签选取
- $starListGroup.on('click','ul.tag-list li',function(){
- if(finish == 1){
- var $this = $(this);
- if($this.hasClass('active')){
- $this.removeClass('active');
- }else{
- if($this.closest('ul.tag-list').find('li.active').length > 3){
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'最多只能选择4个标签'}).show();
- }else{
- $this.addClass('active');
- }
- }
- }
- })
-
- $('#commit').click(function(){
- var data = {},
- label = [],
- evaluate = [],
- evaluateScore = [],
- $one = $starListGroup.find('.j-section');
-
- for(var i=0;i< $one.length;i++){
- var $ul = $one.eq(i).find('.star-lists').find('ul.list li.active').length;//该医生是否评价完整
- var remarkValue = $one.eq(i).find('.text-input textarea').val().trim();
- if($ul >0){
- for(var j=0;j<3;j++){
- var val = $one.eq(i).find('.star-lists').eq(j).find('ul.list li.active').length;
- if(!val){
- dialog({contentType:'tipsbox', skin:'bk-popup' ,bottom:true, content:'请完善医生评分'}).show();
- return ;
- }
- if(val <= 3){
- var isNimimg = $('.ni-select').hasClass('active');
- if(isNimimg){
- dialog({
- content:'为了帮助医生及时发现服务中存在的问题并作出改正,当您给出三星及以下评价时,需要实名评价哦~',
- okValue:'确定',
- ok: function() {
- // wx.closeWindow();
- }
- }).showModal();
- return ;
- }
- }
- if(val <= 4){
- if(!remarkValue){
- dialog({
- content:'为帮助医生及时发现服务存在的问题,当您给出四星及以下评价时,需要说明对医生服务的意见哦~',
- okValue:'确定',
- ok: function() {
- // wx.closeWindow();
- }
- }).showModal();
- return ;
- }
- }
- }
- }else{
- dialog({contentType:'tipsbox', skin:'bk-popup' ,bottom:true, content:'请完善医生评分'}).show();
- return ;
- }
- }
-
- dd.showModal();
- for(var i=0;i< $one.length;i++){
- for(var j=0;j<3;j++){
- var obj = {};
- obj['doctor'] = $one.eq(i).find('.down-sec').data('code');
- obj['score'] = $one.eq(i).find('.star-lists').eq(j).find('ul.list li.active').length*20;
- obj['type'] = evaluateKind;
- obj['evaluateType'] = j+1;//匿名评价类型
- evaluate.push(obj);
- }
-
- var that = $one.eq(i).find('.j-nosel .tag-list li.active');
- if(that.length >0){
- for(var z=0;z<that.length;z++){
- var obj = {};
- obj['doctor'] = $one.eq(i).find('.down-sec').data('code');
- obj['content'] = that.eq(z).text().trim();
- label.push(obj);
- }
- }
-
- var $text = $one.eq(i).find('.text-input textarea');
- var obj = {};
- obj['doctor'] = $one.eq(i).find('.down-sec').data('code');
- obj['remark'] = $text.val().trim();
- evaluateScore.push(obj);
- }
- data['consult'] = consult;
- data['label'] = label;
- data['evaluateScore'] = evaluateScore;
- data['evaluate'] = evaluate;
- var params = {evaluate:JSON.stringify(data)};
- sendPost(reqUrl, params, 'json', 'post', submitFailed, submitSuccess);
-
- })
- }
-
- //点击修改按钮
- $('#revise').on('click',function(){
- revising()
- reqUrl = 'patient/consult/evaluate/update';
- })
-
- //点击修改评价的样式
- function revising(){
- $('#again_header').show();
- $('#yes_header').hide();
- $('#no_header').hide();
- $('#commit').show();//按钮
- $('#revise').hide();
- finish = 1;
- showTag2();
- showTextarea2();
- $('body').scrollTop(0);
- }
- //点击修改显示标签
- function showTag2(){
- var $one = $starListGroup.find('.j-section');
- for(var i=0;i<$one.length;i++){
- var $ul = $one.eq(i).find('.j-hassel .tag-list');
- var $li = $ul.find('li.active');
- var num = $li.length;
- var $ul2 = $one.eq(i).find('.j-nosel .tag-list');
- var $li2 = $ul2.find('li');
- if(num>0){
- for(var j=0;j<num;j++){
- var yes = 0;
- var name = $li.eq(j).text();
- for(var z=0;z<$li2.length;z++){
- if($li2.eq(z).text() == name){
- $li2.eq(z).addClass('active');
- yes = 1;
- }
- }
- if(yes == 0){
- var html = '<li class="active">'+name+'</li>';
- $ul2.append(html);
- }
- }
- }
- }
- $('.j-nosel').show();
- $('.j-hassel').hide();
- }
- //点击修改显示文本
- function showTextarea2(){
- var $one = $starListGroup.find('.j-section');
- for(var i=0;i<$one.length;i++){
- var $ul = $one.eq(i).find('.text-input textarea'),
- $ul2 = $one.eq(i).find('.show-word'),
- $val = $ul2.html();
- if($val){
- $ul.val($val);
- $ul.parent('.text-input').find('.text_count').text($ul.val().length);
- }
- }
- $('.text-input').show();
- $('.show-word').hide();
- }
-
- //正要评价的样式
- function evaluating(){
- finish = 1;
- $('#show_text').show();
- $('#no_header').show();
- }
- //已经评价过的样式
- function evaluated(){
- finish = 0;
- $('#show_text').show();
- $('#yes_header').show();
- $('.j-nosel').hide();
- $('.text-input').hide();
- $('.show-word').show();
- hasName();
- $('#revise').show();
- $('#commit').hide();
- $('.small-title').removeClass('active');
- $('.j-tag-detail').hide();
- }
- //提交评价后的样式
- function committed(){
- finish = 0;
- localStorage.setItem("evaluate",1);
- $('#commit').hide();//按钮
- $('#revise').show();
- $('#yes_header').show();
- $('#again_header').hide();
- $('#no_header').hide();
- $('.small-title').removeClass('active');
- $('.j-tag-detail').hide();
- showTag();
- showTextarea();
- $('body').scrollTop(0);
- }
-
- //实匿名样式切换
- function hasName(){
- if(evaluateKind == 2){
- $('.ni-select').addClass('active');
- }else{
- $('.ni-select').removeClass('active');
- }
- }
-
- function submitFailed(res) {
- dd.close();
- if (res && res.msg) {
- dialog({contentType:'tipsbox', skin:'bk-popup' ,bottom:true, content:res.msg}).show();
- } else {
- dialog({contentType:'tipsbox', skin:'bk-popup' , bottom:true,content:'提交失败'}).show();
- }
- }
- function submitSuccess(res) {
- dd.close();
- if(res.status==200){
- dialog({contentType:'tipsbox', skin:'bk-popup' , bottom:true,content:'提交成功'}).show();
- committed();
- }else{
- if (res && res.msg) {
- dialog({contentType:'tipsbox', skin:'bk-popup' ,bottom:true, content:res.msg}).show();
- }
- }
- }
- //提交后显示标签
- function showTag(){
- var $one = $starListGroup.find('.j-section');
- for(var i=0;i<$one.length;i++){
- var $ul = $one.eq(i).find('.j-nosel .tag-list');
- var $li = $ul.find('li.active');
- var num = $li.length;
- var $ul2 = $one.eq(i).find('.j-hassel .tag-list');
- if(num>0){
- var html='';
- for(var j=0;j<num;j++){
- html +='<li class="active">'+$li.eq(j).text()+'</li>'
- }
- $ul2.html(html);
- $one.eq(i).find('.j-hassel').show();
- }
- }
- $('.j-nosel').hide();
- }
- //提交后显示文本
- function showTextarea(){
- var $one = $starListGroup.find('.j-section');
- for(var i=0;i<$one.length;i++){
- var $ul = $one.eq(i).find('.text-input'),
- $val = $ul.find('textarea').val().trim(),
- $ul2 = $one.eq(i).find('.show-word');
- if($val){
- $ul2.html($val);
- $one.eq(i).find('.show-word').show();
- }
- }
- $('.text-input').hide();
- }
-
- //请求数据看是否评价
- function queryOldData(){
- var params= {};
- params.consult = consult;
- sendPost('patient/consult/evaluate/list', params, 'json', 'get', queryFailed, querySuccess);
-
- function queryFailed(res) {
- if (res && res.msg) {
- dialog({contentType:'tipsbox', skin:'bk-popup' ,bottom:true, content:res.msg}).show();
- } else {
- dialog({contentType:'tipsbox', skin:'bk-popup' , bottom:true,content:'请求数据失败'}).show();
- }
- }
- function querySuccess(res) {
- if(res.status==200){
- //显示内容
- var html = template("star_list_temp", {data: doctorPar});
- $starListGroup.append(html);
-
- var list = res.data['evaluate'];
- var labelTag = res.data['label'];
- var content = res.data['evaluateScore'];
- if(list && list.length>0){
- for(var i=0;i<$('.j-section').length;i++){
- for(var j=0;j<list.length;j++){
- if($('.down-sec').eq(i).data('code') == list[j].doctor){
- //1专业能力,2服务态度,3回复速度
- if(list[j].evaluateType == 1){
- //临时判断实匿名
- evaluateKind = list[j].type;
-
- var num = Math.floor(list[j].score/20);
- for(var q=0;q<num;q++){
- $('.j-section').eq(i).find('.star-lists').eq(0).find('.one-star').eq(q).addClass('active');
- }
- }
- if(list[j].evaluateType == 2){
- var num = Math.floor(list[j].score/20);
- for(var q=0;q<num;q++){
- $('.j-section').eq(i).find('.star-lists').eq(1).find('.one-star').eq(q).addClass('active');
- }
- }
- if(list[j].evaluateType == 3){
- var num = Math.floor(list[j].score/20);
- for(var q=0;q<num;q++){
- $('.j-section').eq(i).find('.star-lists').eq(2).find('.one-star').eq(q).addClass('active');
- }
- }
- }
- }
- //显示标签
- if(labelTag && labelTag.length>0){
- var that = $('.j-hassel').eq(i).find('.tag-list');
- for(var z=0;z<labelTag.length;z++){
- if($('.down-sec').eq(i).data('code') == labelTag[z].doctor){
- var html = '<li class="active">'+labelTag[z].content+'</li>';
- that.append(html);
- }
- }
- $('.j-section').eq(i).find('.j-hassel').show();
- }
- //显示意见内容
- if(content && content.length>0){
- var that = $('.j-section').eq(i).find('.show-word');
- for(var z=0;z<content.length;z++){
- if($('.down-sec').eq(i).data('code') == content[z].doctor){
- that.html(content[z].remark);
- }
- }
- }
- }
- evaluated();
- reqUrl = 'patient/consult/evaluate/update';
- }else{//未评价
- evaluating();
- reqUrl = 'patient/consult/evaluate/save';
- }
- }else{
- queryFailed(res);
- }
- }
- }
- })
- template.helper('getPhoto', function(str){
- return getImgUrl(str);
- })
|