You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
138 lines
2.9 KiB
138 lines
2.9 KiB
6 months ago
|
const app = getApp<IAppOption>();
|
||
|
|
||
|
Page({
|
||
|
data: {
|
||
|
prev: "",
|
||
|
|
||
|
showArea: false,
|
||
|
fieldNames: { text: "label", value: "value", children: "children" },
|
||
|
|
||
|
hospitalClassification: {},
|
||
|
hospitalLevel: {},
|
||
|
|
||
|
search: "",
|
||
|
ProvinceId: "",
|
||
|
CityId: "",
|
||
|
CountyId: "",
|
||
|
ProvinceName: "",
|
||
|
CityName: "",
|
||
|
CountyName: "",
|
||
|
pagination: {
|
||
|
page: 1,
|
||
|
pages: 1,
|
||
|
count: 1,
|
||
|
},
|
||
|
list: [],
|
||
|
|
||
|
area: [],
|
||
|
},
|
||
|
onLoad(options) {
|
||
|
if (options.prev) {
|
||
|
this.setData({
|
||
|
prev: decodeURIComponent(options.prev),
|
||
|
});
|
||
|
}
|
||
|
app.waitLogin(true).then(() => {
|
||
|
this.getHostipalDict();
|
||
|
this.getList();
|
||
|
this.getArea();
|
||
|
});
|
||
|
},
|
||
|
getHostipalDict() {
|
||
|
wx.ajax({
|
||
|
method: "GET",
|
||
|
url: "?r=takeda/reg/hospital-dict",
|
||
|
data: {},
|
||
|
}).then((res) => {
|
||
|
this.setData({
|
||
|
hospitalClassification: res.hospitalClassification,
|
||
|
hospitalLevel: res.hospitalLevel,
|
||
|
});
|
||
|
});
|
||
|
},
|
||
|
handleSearch() {
|
||
|
this.setData({
|
||
|
list: [],
|
||
|
});
|
||
|
this.getList();
|
||
|
},
|
||
|
getList(newPage = 1) {
|
||
|
wx.ajax({
|
||
|
method: "GET",
|
||
|
url: "?r=takeda/reg/hospitals",
|
||
|
data: {
|
||
|
page: newPage,
|
||
|
ProvinceId: this.data.ProvinceId,
|
||
|
CityId: this.data.CityId,
|
||
|
CountyId: this.data.CountyId,
|
||
|
Search: this.data.search,
|
||
|
},
|
||
|
}).then((res) => {
|
||
|
const list = res.page === 1 ? res.list : [...this.data.list, ...res.list];
|
||
|
this.setData({
|
||
|
list,
|
||
|
pagination: {
|
||
|
page: res.page,
|
||
|
pages: res.pages,
|
||
|
count: res.count,
|
||
|
},
|
||
|
});
|
||
|
});
|
||
|
},
|
||
|
onReachBottom() {
|
||
|
const { page, pages } = this.data.pagination;
|
||
|
if (pages > page) {
|
||
|
this.getList(page + 1);
|
||
|
}
|
||
|
},
|
||
|
getArea() {
|
||
|
wx.ajax({
|
||
|
method: "GET",
|
||
|
url: "/js/area.json",
|
||
|
isJSON: true,
|
||
|
}).then((res) => {
|
||
|
this.setData({
|
||
|
area: res,
|
||
|
});
|
||
|
});
|
||
|
},
|
||
|
handleArea() {
|
||
|
this.setData({
|
||
|
showArea: true,
|
||
|
});
|
||
|
},
|
||
|
onClose() {
|
||
|
this.setData({
|
||
|
showArea: false,
|
||
|
});
|
||
|
},
|
||
|
onFinish(e: any) {
|
||
|
this.setData({
|
||
|
ProvinceId: e.detail.selectedOptions[0].value,
|
||
|
ProvinceName: e.detail.selectedOptions[0].label,
|
||
|
CityId: e.detail.selectedOptions[1].value,
|
||
|
CityName: e.detail.selectedOptions[1].label,
|
||
|
CountyId: e.detail.selectedOptions[2].value,
|
||
|
CountyName: e.detail.selectedOptions[2].label,
|
||
|
showArea: false,
|
||
|
});
|
||
|
this.handleSearch();
|
||
|
},
|
||
|
|
||
|
handleSelect(e: any) {
|
||
|
const { index } = e.currentTarget.dataset;
|
||
|
const item: any = this.data.list[index];
|
||
|
const isParams = this.data.prev.includes("?");
|
||
|
wx.redirectTo({
|
||
|
url: `${this.data.prev}${isParams ? "&" : "?"}hid=${item.HospitalId}&hname=${item.ShortName || item.Name}`,
|
||
|
});
|
||
|
},
|
||
|
handlePushDoctor() {
|
||
|
wx.navigateTo({
|
||
|
url: "/module1/pages/cHostipal/index",
|
||
|
});
|
||
|
},
|
||
|
});
|
||
|
|
||
|
export {};
|