360 lines
8.4 KiB
JavaScript
360 lines
8.4 KiB
JavaScript
// pages/expertDetail/expertDetail.js
|
|
const app = getApp()
|
|
import {
|
|
doctorDetail,
|
|
isReceivepatient,
|
|
commentList,
|
|
fllowDoctor,
|
|
notfllowDoctor
|
|
} from "../../api/consultExpert"
|
|
import {throttle} from "../../utils/util"
|
|
Page({
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
img_host:'https://oss.prod.applets.igandanyiyuan.com/applet/patient/static',
|
|
showDialog:false,
|
|
avatar: '',
|
|
user_name: '',
|
|
doctor_title: '',
|
|
doctor_id: '',
|
|
doctor_title_name:'',
|
|
user_id:'',
|
|
is_online:'0',
|
|
avg_response_time: 0,
|
|
be_good_at: '',
|
|
department_custom_name: '',
|
|
served_patients_num: 0,
|
|
number_of_fans: 0,
|
|
hospital: null,
|
|
brief_introduction:'',
|
|
multi_point_status: 0,
|
|
multi_point_enable:0,
|
|
iden_auth_status:0,
|
|
is_img_expert_reception: 0,
|
|
is_img_welfare_reception: 0,
|
|
days: 0,
|
|
praise_rate: 0,
|
|
doctor_inquiry_config: [],
|
|
doctor_expertise: [],
|
|
value: 3,
|
|
show: false,
|
|
isHide: false,
|
|
current_inquiry_config: null,
|
|
follow: false,
|
|
id:'',
|
|
recieveStatus:0,
|
|
commentList: [],
|
|
totalComment:0,
|
|
isFinished:false,
|
|
isReceivePatient:false //是否可接诊
|
|
},
|
|
handleThrottle:throttle(function(){
|
|
this.goSelectPatient()
|
|
}),
|
|
goSelectPatient() {
|
|
|
|
//判断是否能接诊
|
|
this.handleIsReceivepatient();
|
|
},
|
|
showPop() {
|
|
this.setData({
|
|
show: true
|
|
})
|
|
},
|
|
goBack(){
|
|
wx.navigateBack({
|
|
delta: 1,
|
|
})
|
|
},
|
|
toggleFllow(){
|
|
if(this.data.follow){
|
|
this.handenotfllowDoctor()
|
|
}else{
|
|
this.handelfllowDoctor()
|
|
}
|
|
},
|
|
notAsk(){
|
|
wx.showToast({
|
|
title: '该医生暂不就诊',
|
|
icon:"none"
|
|
})
|
|
},
|
|
confirm(event) {
|
|
let {id}=this.data;
|
|
if (event.detail) {
|
|
app.method.navigateTo({
|
|
url: '/pages/orderDetail/orderDetail?order_inquiry_id=' + id,
|
|
})
|
|
}
|
|
},
|
|
handleIsReceivepatient() {
|
|
let {doctor_id}=this.data;
|
|
isReceivepatient({
|
|
inquiry_type: this.data.current_inquiry_config.inquiry_type,
|
|
inquiry_mode: 1,
|
|
doctor_id: doctor_id
|
|
}).then(data => {
|
|
let recieveStatus=data.status;
|
|
if (recieveStatus == 1) {
|
|
app.method.navigateTo({
|
|
url: '/pages/selectPatient/selectPatient?chat_id='+ this.data.user_id+"&doctor_id="+this.data.doctor_id+"&inquiry_type="+ this.data.current_inquiry_config.inquiry_type
|
|
})
|
|
} else if (recieveStatus == 2) {
|
|
this.setData({
|
|
showDialog: true,
|
|
id: data.data.order_inquiry_id
|
|
})
|
|
|
|
} else if (recieveStatus == 3) {
|
|
wx.showToast({
|
|
title: '当前不可问诊',
|
|
icon: "none"
|
|
})
|
|
}
|
|
|
|
})
|
|
},
|
|
handelfllowDoctor(){
|
|
let id=this.data.doctor_id
|
|
fllowDoctor(id).then(data=>{
|
|
this.setData({
|
|
follow:true
|
|
})
|
|
wx.showToast({
|
|
title: '关注成功',
|
|
icon:"none"
|
|
})
|
|
})
|
|
},
|
|
handenotfllowDoctor(){
|
|
let id=this.data.doctor_id;
|
|
notfllowDoctor(id).then(data=>{
|
|
this.setData({
|
|
follow:false
|
|
})
|
|
wx.showToast({
|
|
title: '已取消关注',
|
|
icon:"none"
|
|
})
|
|
})
|
|
},
|
|
goComment() {
|
|
app.method.navigateTo({
|
|
url: '/pages/comment/comment?doctor_id=' + this.data.doctor_id,
|
|
})
|
|
},
|
|
onClose() {
|
|
this.setData({
|
|
show: false
|
|
})
|
|
},
|
|
getEvaluationList() {
|
|
let {doctor_id}=this.data;
|
|
commentList({
|
|
doctor_id,
|
|
evaluation_type:1,
|
|
page: 1,
|
|
per_page: 3
|
|
}).then((res) => {
|
|
this.setData({
|
|
commentList: res.data,
|
|
totalComment:res.total_quantity
|
|
})
|
|
})
|
|
},
|
|
loopArr(arr,type){
|
|
let inquiry_mode='';
|
|
let inquiry_price='';
|
|
let recieveStatus='';
|
|
let duration='';
|
|
let work_num_day=0;
|
|
let times_number=0;
|
|
let order_inquiry_count=0;
|
|
let order_type=type;
|
|
for (let i = 0; i < arr.length; i++) {
|
|
if(arr[i].inquiry_type==type){
|
|
recieveStatus=arr[i].work_num_day-arr[i].order_inquiry_count;
|
|
inquiry_mode=arr[i].inquiry_mode;
|
|
inquiry_price=arr[i].inquiry_price;
|
|
duration=arr[i].duration;
|
|
work_num_day=arr[i].work_num_day;
|
|
times_number=arr[i].times_number;
|
|
order_inquiry_count=arr[i].order_inquiry_count;
|
|
}
|
|
}
|
|
//如果公益问诊 次数为0 则去看是否有专家问诊
|
|
if(type==3 && recieveStatus==0){
|
|
for (let i = 0; i < arr.length; i++) {
|
|
if(arr[i].inquiry_type==1){
|
|
order_type=1;
|
|
recieveStatus=arr[i].work_num_day-arr[i].order_inquiry_count;
|
|
inquiry_mode=arr[i].inquiry_mode;
|
|
inquiry_price=arr[i].inquiry_price;
|
|
duration=arr[i].duration;
|
|
work_num_day=arr[i].work_num_day;
|
|
times_number=arr[i].times_number;
|
|
order_inquiry_count=arr[i].order_inquiry_count;
|
|
}
|
|
}
|
|
}
|
|
console.log('2222222222')
|
|
console.log(recieveStatus)
|
|
this.setData({
|
|
current_inquiry_config: {
|
|
inquiry_type:order_type,
|
|
inquiry_mode:inquiry_mode,
|
|
inquiry_price:inquiry_price,
|
|
recieveStatus:recieveStatus,
|
|
duration,
|
|
work_num_day,
|
|
times_number,
|
|
order_inquiry_count
|
|
}
|
|
})
|
|
},
|
|
formatInquiryStatus(arr){
|
|
var a='3';
|
|
if(arr){
|
|
for (var i = 0; i < arr.length; ++i) {
|
|
if(arr[i].is_enable==1 && arr[i].inquiry_type==1){
|
|
a='2'
|
|
};
|
|
if(arr[i].is_enable==1 && arr[i].inquiry_type==3){
|
|
return '1'
|
|
};
|
|
}
|
|
|
|
}
|
|
return a
|
|
},
|
|
getDeatil(id) {
|
|
doctorDetail(id).then((res) => {
|
|
for (const key in this.data) {
|
|
if (res[key]) {
|
|
this.setData({
|
|
[key]: res[key]
|
|
})
|
|
}
|
|
};
|
|
let doctor_inquiry_config = this.data.doctor_inquiry_config;
|
|
let inquiryType=this.formatInquiryStatus(doctor_inquiry_config);
|
|
console.log("inquiryType:"+inquiryType)
|
|
if(inquiryType==1){
|
|
this.loopArr(doctor_inquiry_config,3);
|
|
}else if(inquiryType==2){
|
|
this.loopArr(doctor_inquiry_config,1);
|
|
}else{
|
|
this.setData({
|
|
current_inquiry_config:null
|
|
})
|
|
}
|
|
this.setData({
|
|
isFinished:true
|
|
})
|
|
// if(res.is_img_expert_reception==1 && res.is_img_welfare_reception==1){
|
|
// this.loopArr(doctor_inquiry_config,3);
|
|
// // 1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药
|
|
// this.setData({
|
|
// isHide:true
|
|
// })
|
|
// }else if(res.is_img_expert_reception==1 && res.is_img_welfare_reception==0){
|
|
// this.loopArr(doctor_inquiry_config,1);
|
|
|
|
// }else if(res.is_img_welfare_reception== 1 && res.is_img_expert_reception==0){
|
|
// this.loopArr(doctor_inquiry_config,3);
|
|
// }else{
|
|
// this.setData({
|
|
// current_inquiry_config:null
|
|
// })
|
|
// }
|
|
// this.setData({
|
|
// isFinished:true
|
|
// })
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
const scene = options.scene?decodeURIComponent(options.scene):'';
|
|
let doctor_id='';
|
|
if(scene){
|
|
doctor_id=scene.split('=')[1]
|
|
}else{
|
|
doctor_id=options.doctor_id
|
|
};
|
|
console.log(options)
|
|
this.setData({
|
|
doctor_id:doctor_id
|
|
})
|
|
this.getDeatil(doctor_id);
|
|
this.getEvaluationList()
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {
|
|
this.setData({
|
|
img_host:app.hostConfig().imghost
|
|
});
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom() {
|
|
|
|
},
|
|
// onShareTimeline(){
|
|
// const {user_name,doctor_title_name,hospital,avatar,img_host,doctor_id}=this.data;
|
|
// return {
|
|
// title: '【'+ user_name +'】 '+ doctor_title_name+' '+hospital.hospital_name,
|
|
// imageUrl:avatar?avatar:img_host+'/doctor_avatar.png',
|
|
// query:'doctor_id='+doctor_id
|
|
// }
|
|
// },
|
|
onShareAppMessage() {
|
|
const {user_name,doctor_title_name,hospital}=this.data;
|
|
return {
|
|
title: '【'+ user_name +'】 '+ doctor_title_name+' '+hospital.hospital_name
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
|
|
}) |