haomingming 3f40c4c237 优化
2023-04-08 09:51:45 +08:00

91 lines
2.4 KiB
JavaScript

import { API } from './../../../utils/network/api'
const api = new API()
const app = getApp()
Page({
data: {
navbarData: {
showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示
title: '患者评价', //导航栏 中间的标题
},
height: app.globalData.height,
stickyProps: {
offsetTop: app.globalData.height*2 + 20,
zIndex: 99
},
doctor_id: "",
evaluation_type: 1,
appraise_list_1: [],
appraise_list_2: [],
appraise_list_3: [],
current_page: 0,
total: 0,
per_page: 0,
last_page: 0,
total_quantity: 0,
good_quantity: 0,
bad_quantity: 0,
},
onPullDownRefresh(){
console.log('===下拉动作===');
this.setData({
current_page: 0,
})
this.getDoctorEvaluationList();
},
onReachBottom() {
console.log('===触底了!!===');
if(this.data.current_page < this.data.last_page){//最后一页时停止分页
this.getDoctorEvaluationList()
}
},
onLoad(option){
console.log(option.doctor_id);
this.setData({
doctor_id: option.doctor_id
})
},
onShow(){
console.log("onShow");
this.getDoctorEvaluationList();
},
onTabsChange(e){
console.log(e);
let list_name = "appraise_list_" + e.detail.name;
this.setData({
evaluation_type: e.detail.name,
current_page: 0,
last_page: 0,
[list_name]: []
})
this.getDoctorEvaluationList()
},
getDoctorEvaluationList(){
//获取评价列表
let params = {};
params.page = this.data.current_page + 1;
params.doctor_id = this.data.doctor_id;
params.evaluation_type = this.data.evaluation_type;
api.getDoctorEvaluation(params).then(response => {
console.log(response);
if(response.data.total > 0){
let list_name = "appraise_list_" + this.data.evaluation_type;
console.log(list_name);
let apprise_list = this.data[list_name];
this.setData({
[list_name]: apprise_list.concat(response.data.data),
current_page: response.data.current_page,
total: response.data.total,
per_page: response.data.per_page,
last_page: response.data.last_page,
total_quantity: response.data.total_quantity,
good_quantity: response.data.good_quantity,
bad_quantity: response.data.bad_quantity,
})
}
}).catch(errors => {
console.error(errors);
})
}
})