2024-04-28 09:49:38 +08:00

224 lines
4.3 KiB
JavaScript

// healthyService/pages/healthyIntro/healthyIntro.js
import {throttle} from "../../../utils/util"
import {doctorList} from "../../../api/consultExpert"
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
blockHeight:"150rpx",
type:'',
doctorList:[],
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',
inquiry_mode:'8',
},
handleRefresher(){
this.setData({
lock:false,
page:1,
doctorList:[]
});
this.getDoctorList()
},
goExpertDetail:throttle(function(e){
let {doctorid,price}=e.currentTarget.dataset;
if(price){
app.method.navigateTo({
url:'/healthyService/pages/healthyDetail/healthyDetail?doctor_id='+doctorid
})
}
else{
app.method.navigateTo({
url:'/healthyService/pages/healthyDetail/healthyDetail?doctor_id='+doctorid+"&price="+price
})
wx.showToast({
title: '未设置健康包价格',
icon:'none'
})
}
}),
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)
})
}
})
},
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();
}
},
goAgree(){
this.setData({
showRight:false
})
},
lookGood:throttle(function(){
this.setData({
showRight:true
})
}),
// 显示遮罩层
showModal() {
this.setData({
hideModal: true,
blockHeight:"1130rpx"
})
},
// 隐藏遮罩层
hideModal() {
this.setData({
hideModal: false,
blockHeight:"150rpx"
})
},
touchstart(e) {
this.setData({
startX: e.changedTouches[0].clientX,
startY: e.changedTouches[0].clientY
})
},
angle(start, end) {
var _X = end.X - start.X,
_Y = end.Y - start.Y;
//返回角度 Math.atan()返回数字的反正切值
return 360 * Math.atan(_Y / _X) / (2 * Math.PI);
},
touchend(e) {
let {startX,startY} = this.data;
let slidingRange = 45; //
let touchMoveX = e.changedTouches[0].clientX;
let touchMoveY = e.changedTouches[0].clientY;
let angle = this.angle({
X: startX,
Y: startY
}, {
X: touchMoveX,
Y: touchMoveY
});
//为了方便计算取绝对值判断
if (Math.abs(angle) > slidingRange && touchMoveY < startY) {
this.showModal()
// 向上滑动
};
if (Math.abs(angle) > slidingRange && touchMoveY > startY ) {
this.hideModal()
// 向下滑动
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
if(options.type){
this.setData({
type:'visit'
})
}
this.getDoctorList();
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})