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.8 KiB
138 lines
2.8 KiB
const app = getApp<IAppOption>(); |
|
|
|
Page({ |
|
data: { |
|
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: [], |
|
|
|
reg: true, |
|
}, |
|
onLoad(options) { |
|
this.setData({ |
|
reg: options.reg === "1", |
|
}); |
|
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.code[0], |
|
ProvinceName: e.detail.value[0], |
|
CityId: e.detail.code[1], |
|
CityName: e.detail.value[1], |
|
CountyId: e.detail.code[2], |
|
CountyName: e.detail.value[2], |
|
showArea: false, |
|
}); |
|
this.handleSearch(); |
|
}, |
|
|
|
handleSelect(e: any) { |
|
const { index } = e.currentTarget.dataset; |
|
const { list } = this.data; |
|
const item: any = list[index]; |
|
const eventChannel = this.getOpenerEventChannel(); |
|
eventChannel.emit("acceptDataFromOpenedPage", { |
|
hid: item.HospitalId, |
|
hname: item.ShortName || item.Name, |
|
}); |
|
wx.navigateBack(); |
|
}, |
|
handlePushDoctor() { |
|
wx.navigateTo({ |
|
url: "/module1/pages/cHostipal/index", |
|
}); |
|
}, |
|
}); |
|
|
|
export {};
|
|
|