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.
446 lines
11 KiB
446 lines
11 KiB
const app = getApp<IAppOption>(); |
|
import dayjs from "dayjs"; |
|
|
|
Page({ |
|
data: { |
|
NrdlOnePicSwitch: 0, |
|
NrdlCityListSwitch: 0, |
|
NrdlQASwitch: 0, |
|
NrdlOnePicAJMDSwitch: 0, |
|
showProgress: false, |
|
video1Height: null as null | string, |
|
video2Height: null as null | string, |
|
|
|
nrdlDetail: {}, |
|
|
|
cascaderShow: false, |
|
options: [], |
|
areaValue: [], |
|
cascaderName: "", |
|
cascaderValue: "", |
|
fieldNames: { text: "label", value: "value", children: "children" }, |
|
|
|
hosList: [] as { HospitalName: string; HospitalId: string }[], |
|
hosName: "", |
|
hosIndex: "", |
|
hosValue: "", |
|
|
|
OtherHospitalName: "", |
|
|
|
toastShow: false, |
|
toastType: "popupNdrlFollow", |
|
toastParams: {} as any, |
|
|
|
LAT: "", |
|
LNG: "", |
|
|
|
follow: false, |
|
|
|
asideOut: false, |
|
asideType: "11", |
|
|
|
score: [], |
|
|
|
medicalInsurancePolicy: null, |
|
|
|
timeToastType: "19", |
|
}, |
|
onLoad() { |
|
const SystemInfo = app.globalSystemInfo; |
|
if (SystemInfo) { |
|
const { bottom } = SystemInfo.capsulePosition; |
|
this.setData({ |
|
bottom: bottom, |
|
}); |
|
} |
|
app.zdWaitLogin().then((_res) => { |
|
app.zdMpBehavior({ PageName: 'PG_PATIENTNRDL' }) |
|
this.addOpenRecord(); |
|
this.getConfig(); |
|
this.getCode(); |
|
this.getArea(); |
|
this.getNrdlDetail(); |
|
this.getAdlScore(); |
|
}); |
|
}, |
|
getAdlScore() { |
|
wx.ajax({ |
|
method: "GET", |
|
url: "?r=zd/nrdl/get-score", |
|
data: {}, |
|
}).then((res) => { |
|
this.setData({ |
|
score: res, |
|
}); |
|
}); |
|
}, |
|
getConfig() { |
|
wx.ajax({ |
|
method: "GET", |
|
url: "?r=zd/common/get-config", |
|
data: {}, |
|
}).then((res) => { |
|
this.setData({ |
|
NrdlOnePicSwitch: res.NrdlOnePicSwitch, |
|
NrdlCityListSwitch: res.NrdlCityListSwitch, |
|
NrdlQASwitch: res.NrdlQASwitch, |
|
NrdlOnePicAJMDSwitch: res.NrdlOnePicAJMDSwitch, |
|
}); |
|
}); |
|
}, |
|
addOpenRecord() { |
|
wx.ajax({ |
|
method: "POST", |
|
url: "?r=zd/nrdl/add-open-record&OpenType=1", |
|
data: {}, |
|
}).then((res) => { |
|
if (res.CanGetScore) { |
|
this.setData({ |
|
asideOut: true, |
|
}); |
|
} |
|
}); |
|
}, |
|
handleDetail(e) { |
|
const { id } = e.currentTarget.dataset; |
|
if (id == 3) { |
|
wx.navigateTo({ |
|
url: "/patient/pages/nrdlTable/index", |
|
}); |
|
return; |
|
} |
|
wx.navigateTo({ |
|
url: `/patient/pages/nrdlDetail/index?id=${id}`, |
|
}); |
|
}, |
|
getCode() { |
|
wx.ajax({ |
|
method: "GET", |
|
url: "?r=zd/common/get-channel-wx-code", |
|
data: { ChannelType: 12 }, |
|
}).then((res) => { |
|
this.setData({ |
|
["toastParams.code"]: res, |
|
}); |
|
}); |
|
}, |
|
getNrdlDetail() { |
|
wx.ajax({ |
|
method: "GET", |
|
url: "?r=zd/nrdl-hospital/detail", |
|
data: {}, |
|
}).then((res) => { |
|
res.last10Records = res.last10Records.map((item) => { |
|
return { |
|
...item, |
|
telephone: item.Telephone.replace(/(\d{3})\d{4}(\d{4})/, "$1****$2"), |
|
timeNow: dayjs(item.CreateTime).fromNow().replace(" ", ""), |
|
}; |
|
}); |
|
this.setData({ |
|
nrdlDetail: res, |
|
["toastParams.follow"]: res.isFollow, |
|
}); |
|
const newRecord = res.newRecord; |
|
if (!Array.isArray(newRecord) && newRecord) { |
|
this.setData({ |
|
areaValue: [newRecord.ProvinceId, newRecord.CityId], |
|
cascaderName: `${newRecord.ProvinceName}/${newRecord.CityName}`, |
|
cascaderValue: newRecord.CityId, |
|
hosName: |
|
{ |
|
"0": "暂无选定医院", |
|
"-1": "其它医院", |
|
}[newRecord.HospitalId] || newRecord.HospitalName, |
|
hosValue: newRecord.HospitalId, |
|
OtherHospitalName: newRecord.OtherHospitalName, |
|
follow: true, |
|
}); |
|
this.getHospitalList(); |
|
} |
|
const medicalInsurancePolicy = res.medicalInsurancePolicy; |
|
this.setData({ |
|
medicalInsurancePolicy, |
|
}); |
|
}); |
|
}, |
|
handlePlay(e) { |
|
const { id, width, height } = e.currentTarget.dataset; |
|
let query = wx.createSelectorQuery(); |
|
query |
|
.select(`#${id}`) |
|
.boundingClientRect((rect) => { |
|
let videoWidth = rect.width; |
|
let videoHeight = videoWidth * (height / width); |
|
if (id === "video1") { |
|
this.setData({ |
|
video1Height: videoHeight + "px", |
|
}); |
|
} |
|
if (id === "video2") { |
|
this.setData({ |
|
video2Height: videoHeight + "px", |
|
}); |
|
} |
|
}) |
|
.exec(); |
|
}, |
|
getArea() { |
|
wx.ajax({ |
|
method: "GET", |
|
url: "/js/area.json", |
|
isJSON: true, |
|
}).then((res) => { |
|
this.setData({ |
|
options: res.map((item) => { |
|
return { |
|
...item, |
|
children: item.children.map((item2) => { |
|
return { |
|
label: item2.label, |
|
value: item2.value, |
|
}; |
|
}), |
|
}; |
|
}), |
|
}); |
|
}); |
|
}, |
|
handleGetSite() { |
|
const that = this; |
|
wx.getSetting({ |
|
success(res) { |
|
if ( |
|
res.authSetting["scope.userFuzzyLocation"] != undefined && |
|
res.authSetting["scope.userFuzzyLocation"] == true |
|
) { |
|
//获取当前位置 |
|
that.getFuzzyLocation(); |
|
} else if (res.authSetting["scope.userFuzzyLocation"] == undefined) { |
|
//获取当前位置 |
|
that.getFuzzyLocation(); |
|
} else { |
|
wx.showModal({ |
|
title: "请求授权当前位置", |
|
content: "需要获取您的地理位置,请确认授权", |
|
confirmColor: "#cf5375", |
|
success: function (res) { |
|
if (res.cancel) { |
|
//取消授权 |
|
wx.showToast({ |
|
title: "拒绝授权", |
|
icon: "none", |
|
duration: 1000, |
|
}); |
|
} else if (res.confirm) { |
|
//确定授权,通过wx.openSetting发起授权请求 |
|
wx.openSetting({ |
|
success: function (res) { |
|
if (res.authSetting["scope.userFuzzyLocation"] == true) { |
|
//再次授权,调用wx.getLocation的API |
|
that.getFuzzyLocation(); |
|
} else { |
|
wx.showToast({ |
|
title: "授权失败", |
|
icon: "none", |
|
duration: 1000, |
|
}); |
|
} |
|
}, |
|
}); |
|
} |
|
}, |
|
}); |
|
} |
|
}, |
|
}); |
|
}, |
|
getFuzzyLocation() { |
|
const that = this; |
|
wx.getFuzzyLocation({ |
|
success(res) { |
|
that.setData({ |
|
LNG: res.longitude, |
|
LAT: res.latitude, |
|
}); |
|
that.getLocationInfo(); |
|
}, |
|
fail(err) { |
|
console.log(err); |
|
}, |
|
}); |
|
}, |
|
handleCascader() { |
|
this.setData({ |
|
cascaderShow: true, |
|
}); |
|
}, |
|
onFinish(e) { |
|
console.log(e); |
|
const selectedOptions = e.detail.selectedOptions; |
|
this.setData({ |
|
cascaderName: `${selectedOptions[0].label}/${selectedOptions[1].label}`, |
|
cascaderValue: e.detail.value, |
|
areaValue: [selectedOptions[0].value, selectedOptions[1].value], |
|
hosName: "", |
|
hosIndex: "", |
|
hosValue: "", |
|
follow: false, |
|
}); |
|
this.getHospitalList(); |
|
this.onClose(); |
|
}, |
|
onClose() { |
|
this.setData({ |
|
cascaderShow: false, |
|
}); |
|
}, |
|
handleToggleSite() { |
|
const that = this; |
|
if (!this.data.LNG) { |
|
} else { |
|
that.setData({ |
|
LNG: "", |
|
LAT: "", |
|
}); |
|
this.getLocationInfo(); |
|
} |
|
}, |
|
getLocationInfo() { |
|
wx.ajax({ |
|
method: "GET", |
|
url: "?r=zd/nrdl-hospital/location-info", |
|
data: { |
|
lat: this.data.LAT, |
|
lng: this.data.LNG, |
|
}, |
|
loading: true, |
|
}).then((res) => { |
|
this.setData({ |
|
cascaderName: `${res.ProvinceName}/${res.CityName}`, |
|
cascaderValue: res.CityId, |
|
areaValue: [res.ProvinceId, res.CityId], |
|
hosIndex: "", |
|
hosValue: "", |
|
hosName: "", |
|
follow: false, |
|
}); |
|
this.getHospitalList(); |
|
}); |
|
}, |
|
getHospitalList() { |
|
const areaValue = this.data.areaValue; |
|
wx.ajax({ |
|
method: "GET", |
|
url: "?r=zd/nrdl-hospital/list", |
|
data: { |
|
ProvinceId: areaValue[0], |
|
CityId: areaValue[1], |
|
}, |
|
}).then((res) => { |
|
this.setData({ |
|
hosList: [ |
|
{ |
|
HospitalName: "暂无选定医院", |
|
HospitalId: "0", |
|
}, |
|
...res, |
|
{ |
|
HospitalName: "其它医院", |
|
HospitalId: "-1", |
|
}, |
|
], |
|
}); |
|
}); |
|
}, |
|
handleChangeHos(e) { |
|
const index = e.detail.value; |
|
const hos = this.data.hosList[index]; |
|
this.setData({ |
|
hosIndex: index, |
|
hosName: hos.HospitalName, |
|
hosValue: hos.HospitalId, |
|
follow: false, |
|
}); |
|
if (hos.HospitalId !== "-1") { |
|
this.setData({ |
|
OtherHospitalName: "", |
|
}); |
|
} |
|
}, |
|
handleToastCancel() { |
|
this.setData({ |
|
toastShow: false, |
|
}); |
|
}, |
|
handleSubmit() { |
|
const { areaValue, cascaderName, hosName, hosValue, OtherHospitalName } = this.data; |
|
let title = ""; |
|
if (!areaValue.length) { |
|
title = "请选择地区"; |
|
} |
|
if (!hosName) { |
|
title = "请选择医院"; |
|
} |
|
if (title) { |
|
wx.showToast({ |
|
title, |
|
icon: "none", |
|
}); |
|
return; |
|
} |
|
wx.ajax({ |
|
method: "POST", |
|
url: "?r=zd/nrdl-hospital/add", |
|
data: { |
|
ProvinceId: areaValue[0], //省Id |
|
ProvinceName: cascaderName.split("/")[0], //省份名 |
|
CityId: areaValue[1], //城市Id |
|
CityName: cascaderName.split("/")[1], //城市名 |
|
HospitalId: hosValue || undefined, //医院id 为空时填0 |
|
HospitalName: hosName || undefined, //医院名 为空时,空字符串 |
|
OtherHospitalName: OtherHospitalName, |
|
}, |
|
}).then((res) => { |
|
this.setData({ |
|
follow: true, |
|
}); |
|
if (res.rewardScore > 0) { |
|
this.setData({ |
|
timeToast: true, |
|
timeToastParams: { |
|
rewardScore: res.rewardScore, |
|
}, |
|
}); |
|
setTimeout(() => { |
|
this.setData({ |
|
timeToast: false, |
|
}); |
|
}, 3000); |
|
} |
|
this.getAdlScore(); |
|
this.getNrdlDetail(); |
|
}); |
|
}, |
|
handleHos() { |
|
wx.navigateTo({ |
|
url: "/patient/pages/doctor/index", |
|
}); |
|
this.handleDtpRecord(); |
|
}, |
|
handleDtpRecord() { |
|
wx.ajax({ |
|
method: "POST", |
|
url: "?r=zd/nrdl/add-dtp-pharmacy-click-record", |
|
data: {}, |
|
}).then((res) => { |
|
console.log("res: ", res); |
|
}); |
|
}, |
|
handleBack() { |
|
wx.navigateBack(); |
|
}, |
|
catchtouchmove() { |
|
return false; |
|
}, |
|
});
|
|
|