393 lines
7.8 KiB
JavaScript
393 lines
7.8 KiB
JavaScript
// pages/expertConsult/expertConsult.js
|
|
const app = getApp()
|
|
import {doctorList,getProvince,getCity,getCountry} from "../../../api/consultExpert"
|
|
import {sickType} from "../../../api/common"
|
|
let provinceArr=[{area_id:'', area_name: "全国"}];
|
|
let cityArr=[];
|
|
import {throttle} from "../../../utils/util"
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
page:1,
|
|
pageNumber:10,
|
|
isTriggered:false,
|
|
show:false,
|
|
expertise_id:'',
|
|
province_id:'',
|
|
city_id:'',
|
|
keyword:'',
|
|
lock:false,
|
|
is_online:0,
|
|
sort_order:1,
|
|
inquiry_type:'1,3',
|
|
inquiry_mode:'1,2',
|
|
navName:"专家问诊",
|
|
scrollHeight:300,
|
|
sickList:[],
|
|
img_host:'https://oss.prod.applets.igandanyiyuan.com/applet/patient/static',
|
|
option: [
|
|
{ text: '综合', value: 1 },
|
|
{ text: '响应时间快', value: 2 },
|
|
{ text: '价格从低到高', value: 3 },
|
|
{ text: '价格从高到低', value: 4 },
|
|
{ text: '服务数从多到少', value: 5},
|
|
],
|
|
overlay:true,
|
|
selectkind:false,
|
|
selectkarea:false,
|
|
position:"全国",
|
|
doctorList: [],
|
|
triggered: false,
|
|
scrollTop: 0,
|
|
offsetTop: 0,
|
|
columns: [
|
|
{
|
|
values:[],
|
|
className: 'column1',
|
|
},
|
|
{
|
|
values: [],
|
|
className: 'column2',
|
|
defaultIndex: 1,
|
|
}
|
|
],
|
|
isLoding:false,
|
|
tabId:-1
|
|
},
|
|
goBack(){
|
|
wx.navigateBack({
|
|
delta: 1,
|
|
})
|
|
},
|
|
toggleOnline(){
|
|
this.setData({
|
|
is_online:this.data.is_online==0?1:0
|
|
})
|
|
this.onfresh();
|
|
},
|
|
onScroll(event) {
|
|
wx.createSelectorQuery().select('#scroller')
|
|
.boundingClientRect((res) => {
|
|
// console.log(event.detail.scrollTop)
|
|
let H=0;
|
|
if(event.detail.scrollTop>350){
|
|
H=0;
|
|
}else{
|
|
H=300
|
|
}
|
|
this.setData({
|
|
//scrollTop: event.detail.scrollTop,
|
|
// offsetTop: res.top,
|
|
scrollHeight:H
|
|
});
|
|
}).exec();
|
|
},
|
|
transforpage(arr) {
|
|
const pages = [];
|
|
let L= Math.ceil(arr.length / 2);
|
|
arr.forEach((item, index) => {
|
|
const page = Math.floor(index / L)
|
|
if (!pages[page]) {
|
|
pages[page] = []
|
|
}
|
|
pages[page].push(item)
|
|
});
|
|
return pages
|
|
},
|
|
goSearch:throttle(function(){
|
|
wx.hideKeyboard();
|
|
app.method.navigateTo({
|
|
url: '/patient/pages/search/search',
|
|
})
|
|
}),
|
|
switchTab(event){
|
|
this.setData({
|
|
tabId:event.target.dataset.id,
|
|
expertise_id:event.target.dataset.id
|
|
})
|
|
this.onfresh();
|
|
},
|
|
changeSorder({ detail }){
|
|
this.setData({
|
|
sort_order: detail,
|
|
selectkind:true
|
|
});
|
|
this.onfresh();
|
|
},
|
|
getIptvalue(event){
|
|
this.setData({
|
|
keyword:event.detail.value
|
|
})
|
|
this.onfresh();
|
|
},
|
|
goExpertDetail:throttle(function(event){
|
|
app.method.navigateTo({
|
|
url: '/patient/pages/expertDetail/expertDetail?doctor_id='+event.currentTarget.dataset.doctorid
|
|
})
|
|
}),
|
|
openCity(){
|
|
this.setData({
|
|
show:true,
|
|
overlay:false
|
|
})
|
|
},
|
|
closeCity(){
|
|
this.setData({
|
|
show:false,
|
|
overlay:true
|
|
})
|
|
},
|
|
onChange(event) {
|
|
const { picker, value, index } = event.detail;
|
|
if(index===0){
|
|
let currentIndex=picker.getIndexes()[0];
|
|
if(provinceArr[currentIndex].area_id){
|
|
this.cityList(provinceArr[currentIndex].area_id);
|
|
}else{
|
|
this.setData({
|
|
'columns[1].values':[]
|
|
})
|
|
}
|
|
|
|
}
|
|
},
|
|
|
|
onConfirm(event) {
|
|
const { picker, value, index } = event.detail;
|
|
let currentPosition=''
|
|
for (let index = 0; index < value.length; index++) {
|
|
if(!value[0].area_id){
|
|
currentPosition="全国";
|
|
this.setData({
|
|
province_id:'',
|
|
city_id:''
|
|
})
|
|
}else{
|
|
currentPosition+=value[index].area_name;
|
|
if(index===0){
|
|
this.setData({
|
|
province_id:value[index].area_id
|
|
})
|
|
}else if(index==1){
|
|
this.setData({
|
|
city_id:value[index].area_id
|
|
})
|
|
}
|
|
}
|
|
}
|
|
this.setData({
|
|
show:false,
|
|
selectarea:true,
|
|
position:currentPosition
|
|
})
|
|
this.selectComponent('#item').toggle();
|
|
this.onfresh();
|
|
},
|
|
|
|
onCancel() {
|
|
this.setData({
|
|
show:false
|
|
})
|
|
this.selectComponent('#item').toggle(false);
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
getSickType(){
|
|
sickType().then((res)=>{
|
|
this.setData({
|
|
sickList:this.transforpage(res)
|
|
})
|
|
})
|
|
},
|
|
handleRefresher(){
|
|
|
|
this.setData({
|
|
lock:false,
|
|
page:1,
|
|
scrollHeight:300,
|
|
doctorList:[]
|
|
});
|
|
this.getDoctorList()
|
|
},
|
|
getDoctorList(){
|
|
let {expertise_id,province_id, city_id,sort_order,keyword,page,pageNumber,is_online,inquiry_type,inquiry_mode}=this.data;
|
|
doctorList({
|
|
expertise_id:expertise_id,
|
|
province_id:province_id,
|
|
city_id:city_id,
|
|
sort_order: sort_order,
|
|
is_first_online:is_online,
|
|
keyword:keyword,
|
|
inquiry_type,
|
|
inquiry_mode,
|
|
page:page,
|
|
per_page:pageNumber
|
|
}).then((res)=>{
|
|
let {doctorList}=this.data;
|
|
if(res.data.length==0){
|
|
this.setData({
|
|
lock:true,
|
|
isTriggered:false
|
|
});
|
|
return false;
|
|
}else{
|
|
this.setData({
|
|
isTriggered:false,
|
|
doctorList:doctorList.concat(res.data)
|
|
})
|
|
}
|
|
|
|
|
|
})
|
|
},
|
|
provinceList(){
|
|
getProvince().then((res)=>{
|
|
provinceArr= provinceArr.concat(res);
|
|
let province=[{area_id:'', area_name: "全国"}];//
|
|
for (let i = 0; i < res.length; i++) {
|
|
province.push(res[i]);
|
|
};
|
|
this.setData({
|
|
'columns[0].values':province
|
|
})
|
|
//this.cityList(province[0].area_id);
|
|
|
|
})
|
|
},
|
|
cityList(area_id){
|
|
getCity({
|
|
area_id:area_id
|
|
}).then((res)=>{
|
|
|
|
cityArr=res;
|
|
let city=[];
|
|
for (let i = 0; i < res.length; i++) {
|
|
city.push(res[i]);
|
|
};
|
|
this.setData({
|
|
'columns[1].values':city,
|
|
|
|
})
|
|
//this.countryList(res[0].area_id);
|
|
})
|
|
},
|
|
countryList(area_id){
|
|
getCountry({
|
|
area_id:area_id
|
|
}).then((res)=>{
|
|
let area=[];
|
|
for (let i = 0; i < res.length; i++) {
|
|
area.push(res[i]);
|
|
};
|
|
this.setData({
|
|
'columns[2].values':area,
|
|
isLoding:false
|
|
})
|
|
})
|
|
},
|
|
onfresh(){
|
|
this.setData({
|
|
page:1,
|
|
doctorList:[],
|
|
lock:false
|
|
})
|
|
this.getDoctorList();
|
|
},
|
|
lower(e) {
|
|
let {lock}=this.data;
|
|
let addPage=this.data.page+1;
|
|
if(!lock){
|
|
this.setData({
|
|
page:addPage
|
|
});
|
|
this.getDoctorList();
|
|
}
|
|
},
|
|
onLoad(options) {
|
|
if(options.type=="free"){
|
|
wx.setNavigationBarTitle({
|
|
title: "公益问诊"
|
|
});
|
|
this.setData({
|
|
navName:"公益问诊",
|
|
inquiry_type:3,
|
|
inquiry_mode:1
|
|
})
|
|
}
|
|
this.getSickType();
|
|
this.getDoctorList();
|
|
this.provinceList();
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {
|
|
|
|
},
|
|
|
|
|
|
onRefresh() {
|
|
if (this._freshing) return
|
|
this._freshing = true
|
|
setTimeout(() => {
|
|
this.setData({
|
|
triggered: false,
|
|
})
|
|
this._freshing = false
|
|
}, 3000)
|
|
},
|
|
onRestore(e) {
|
|
console.log('onRestore:', e)
|
|
},
|
|
|
|
onAbort(e) {
|
|
console.log('onAbort', e)
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {
|
|
this.setData({
|
|
img_host:app.hostConfig().imghost
|
|
});
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
|
|
}) |