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.
436 lines
11 KiB
436 lines
11 KiB
1 month ago
|
const app = getApp<IAppOption>()
|
||
|
|
||
|
Page({
|
||
|
data: {
|
||
|
tabActive: 0,
|
||
|
LNG: '' as number | string,
|
||
|
LAT: '' as number | string,
|
||
|
HosList: [],
|
||
|
DoctortList: [],
|
||
|
dtpList: [],
|
||
|
pagination: {
|
||
|
page: 1,
|
||
|
pages: 1,
|
||
|
count: 0,
|
||
|
},
|
||
|
ProvinceName: '',
|
||
|
ProvinceId: '',
|
||
|
CityName: '',
|
||
|
CityId: '',
|
||
|
Name: '',
|
||
|
|
||
|
bottom: 0,
|
||
|
|
||
|
asideOut: false,
|
||
|
timeToast: false,
|
||
|
timeToastType: '17',
|
||
|
timeToastParams: {
|
||
|
rewardScore: 0,
|
||
|
},
|
||
|
areaShow: false,
|
||
|
|
||
|
toastShow: false,
|
||
|
// toastType: 'dtpDrug',// TODO:已销毁
|
||
|
toastType: 'siteConform',
|
||
|
toastParams: {} as any,
|
||
|
|
||
|
es: '',
|
||
|
|
||
|
locationName: '重新定位',
|
||
|
},
|
||
|
onLoad(options) {
|
||
|
const SystemInfo = app.globalSystemInfo
|
||
|
if (SystemInfo) {
|
||
|
const { bottom } = SystemInfo.capsulePosition
|
||
|
this.setData({
|
||
|
bottom,
|
||
|
})
|
||
|
}
|
||
|
app.waitLogin().then((_res) => {
|
||
|
if (options.es === '201504') {
|
||
|
app.globalData.IsAliQiWei = 1
|
||
|
app.zdMpBehavior({ PageName: 'PG_PATIENTVISITMAP_PAGE' })
|
||
|
this.setData({
|
||
|
es: options.es,
|
||
|
})
|
||
|
}
|
||
|
|
||
|
if (options.active && ['1', '2'].includes(options.active)) {
|
||
|
this.setData({
|
||
|
tabActive: Number(options.active),
|
||
|
})
|
||
|
} else {
|
||
|
app.zdMpBehavior({ PageName: 'PG_PATIENTVISITMAPLIST' })
|
||
|
}
|
||
|
if (options.pid) {
|
||
|
this.setData({
|
||
|
ProvinceName: options.pn || '',
|
||
|
ProvinceId: options.pid || '',
|
||
|
CityName: options.cn || '',
|
||
|
CityId: options.cid || '',
|
||
|
})
|
||
|
this.getList()
|
||
|
} else {
|
||
|
this.handleToggleSite()
|
||
|
}
|
||
|
})
|
||
|
},
|
||
|
handleToggleSite() {
|
||
|
const that = this
|
||
|
if (!this.data.LNG) {
|
||
|
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(res) {
|
||
|
if (res.cancel) {
|
||
|
//取消授权
|
||
|
wx.showToast({
|
||
|
title: '拒绝授权',
|
||
|
icon: 'none',
|
||
|
duration: 1000,
|
||
|
})
|
||
|
that.getList()
|
||
|
} else if (res.confirm) {
|
||
|
//确定授权,通过wx.openSetting发起授权请求
|
||
|
wx.openSetting({
|
||
|
success(res) {
|
||
|
if (res.authSetting['scope.userFuzzyLocation'] == true) {
|
||
|
wx.showToast({
|
||
|
title: '授权成功',
|
||
|
icon: 'success',
|
||
|
duration: 1000,
|
||
|
})
|
||
|
//再次授权,调用wx.getLocation的API
|
||
|
that.getFuzzyLocation()
|
||
|
} else {
|
||
|
wx.showToast({
|
||
|
title: '授权失败',
|
||
|
icon: 'none',
|
||
|
duration: 1000,
|
||
|
})
|
||
|
that.getList()
|
||
|
}
|
||
|
},
|
||
|
})
|
||
|
}
|
||
|
},
|
||
|
})
|
||
|
}
|
||
|
},
|
||
|
})
|
||
|
} else {
|
||
|
that.setData({
|
||
|
LNG: '',
|
||
|
LAT: '',
|
||
|
})
|
||
|
this.getLocationInfo()
|
||
|
}
|
||
|
},
|
||
|
getFuzzyLocation() {
|
||
|
const that = this
|
||
|
wx.getFuzzyLocation({
|
||
|
success(res) {
|
||
|
that.setData({
|
||
|
LNG: res.longitude,
|
||
|
LAT: res.latitude,
|
||
|
})
|
||
|
that.getLocationInfo()
|
||
|
},
|
||
|
fail() {
|
||
|
that.getList()
|
||
|
},
|
||
|
})
|
||
|
},
|
||
|
handleTapSite() {
|
||
|
app.zdMpBehavior({ PageName: 'BTN_PATIENTVISITMAPCHANGEAREA' })
|
||
|
},
|
||
|
handleChangeSite(e: WechatMiniprogram.CustomEvent) {
|
||
|
const detail = e.detail
|
||
|
this.setData({
|
||
|
ProvinceId: detail.ProvinceId,
|
||
|
ProvinceName: detail.ProvinceName,
|
||
|
CityId: detail.CityId,
|
||
|
CityName: detail.CityName,
|
||
|
})
|
||
|
this.getList()
|
||
|
},
|
||
|
onChange(e: WechatMiniprogram.CustomEvent) {
|
||
|
const index = e.detail.index
|
||
|
if (index == 0) {
|
||
|
app.zdMpBehavior({ PageName: 'PG_PATIENTVISITMAPLIST' })
|
||
|
} else if (index == 1) {
|
||
|
app.zdMpBehavior({ PageName: 'PG_PATIENTVISITMAPDUALCHANNELPHARMACY' })
|
||
|
} else if (index == 2) {
|
||
|
app.zdMpBehavior({ PageName: 'PG_PATIENTVISITMAPDOCTORS' })
|
||
|
}
|
||
|
this.setData({
|
||
|
tabActive: index,
|
||
|
})
|
||
|
wx.pageScrollTo({
|
||
|
scrollTop: 0,
|
||
|
})
|
||
|
this.getList()
|
||
|
},
|
||
|
handleBlur() {
|
||
|
this.getList()
|
||
|
},
|
||
|
getLocationInfo() {
|
||
|
wx.ajax({
|
||
|
method: 'GET',
|
||
|
url: '?r=xd/hospital/location-info',
|
||
|
data: {
|
||
|
lng: this.data.LNG,
|
||
|
lat: this.data.LAT,
|
||
|
},
|
||
|
}).then((res) => {
|
||
|
this.setData({
|
||
|
ProvinceId: res.ProvinceId,
|
||
|
ProvinceName: res.ProvinceName,
|
||
|
CityId: res.CityId,
|
||
|
CityName: res.CityName,
|
||
|
})
|
||
|
this.getList()
|
||
|
})
|
||
|
},
|
||
|
getList() {
|
||
|
const { tabActive, toastShow, toastType } = this.data
|
||
|
if (tabActive != 1 && toastShow && toastType == 'dtpDrug') {
|
||
|
this.hideDtpAlert()
|
||
|
}
|
||
|
if (tabActive == 0) {
|
||
|
this.getHosList()
|
||
|
} else if (tabActive == 1) {
|
||
|
this.getDtpList()
|
||
|
} else if (tabActive == 2) {
|
||
|
this.getDoctorList()
|
||
|
}
|
||
|
},
|
||
|
getHosList() {
|
||
|
const { Name, LNG, LAT, ProvinceId, CityId } = this.data
|
||
|
wx.ajax({
|
||
|
method: 'GET',
|
||
|
url: '?r=xd/hospital/list',
|
||
|
data: {
|
||
|
lng: LNG,
|
||
|
lat: LAT,
|
||
|
ProvinceId: Name ? '' : ProvinceId,
|
||
|
CityId: Name ? '' : CityId,
|
||
|
Name,
|
||
|
},
|
||
|
}).then((res) => {
|
||
|
if (res.CanGetScore) {
|
||
|
this.handleTimeOut()
|
||
|
}
|
||
|
this.setData({
|
||
|
HosList: Array.isArray(res) ? res : res.list,
|
||
|
locationName: '重新定位',
|
||
|
})
|
||
|
})
|
||
|
},
|
||
|
getDoctorList() {
|
||
|
const { Name, LNG, LAT, ProvinceId, CityId } = this.data
|
||
|
wx.ajax({
|
||
|
method: 'GET',
|
||
|
url: '?r=xd/doctor/list',
|
||
|
data: {
|
||
|
lng: LNG,
|
||
|
lat: LAT,
|
||
|
ProvinceId: Name ? '' : ProvinceId,
|
||
|
CityId: Name ? '' : CityId,
|
||
|
Name,
|
||
|
},
|
||
|
}).then((res) => {
|
||
|
this.setData({
|
||
|
locationName: '重新定位',
|
||
|
DoctortList: res.map((item: { Clinic: string }) => {
|
||
|
let weekName = ''
|
||
|
if (item.ClinicType == 2) {
|
||
|
weekName = item.Clinic
|
||
|
} else {
|
||
|
weekName = (JSON.parse(item.Clinic) ? JSON.parse(item.Clinic) : []).map(
|
||
|
(subItem: { weekday: string | number; timeType: string | number }) => {
|
||
|
const week = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
|
||
|
const timeDay = { 1: '上午', 2: '下午' }
|
||
|
return { week: week[Number(subItem.weekday) - 1], timeDay: timeDay[subItem.timeType] }
|
||
|
},
|
||
|
)
|
||
|
}
|
||
|
return {
|
||
|
weekName,
|
||
|
...item,
|
||
|
}
|
||
|
}),
|
||
|
})
|
||
|
})
|
||
|
},
|
||
|
getDtpList() {
|
||
|
const { Name, LNG, LAT, ProvinceId, CityId } = this.data
|
||
|
wx.ajax({
|
||
|
method: 'GET',
|
||
|
url: '?r=xd/dtp-pharmacy/list',
|
||
|
data: {
|
||
|
lng: LNG,
|
||
|
lat: LAT,
|
||
|
ProvinceId: Name ? '' : ProvinceId,
|
||
|
CityId: Name ? '' : CityId,
|
||
|
Name,
|
||
|
},
|
||
|
}).then((res) => {
|
||
|
this.setData({
|
||
|
dtpList: res.list,
|
||
|
locationName: '重新定位',
|
||
|
})
|
||
|
})
|
||
|
},
|
||
|
// getDtpAlert() {
|
||
|
// wx.ajax({
|
||
|
// method: 'GET',
|
||
|
// url: '?r=xd/popup/info',
|
||
|
// data: { Type: 3 },
|
||
|
// }).then((res) => {
|
||
|
// if (res.showAlert) {
|
||
|
// this.setData({
|
||
|
// toastShow: true,
|
||
|
// toastType: 'dtpDrug',
|
||
|
// })
|
||
|
// }
|
||
|
// })
|
||
|
// },
|
||
|
hideDtpAlert() {
|
||
|
wx.ajax({
|
||
|
method: 'POST',
|
||
|
url: '?r=xd/popup/close-popup',
|
||
|
data: { Type: 3 },
|
||
|
}).then((_res) => {})
|
||
|
},
|
||
|
handleDetail(e: WechatMiniprogram.CustomEvent) {
|
||
|
const { url } = e.currentTarget.dataset
|
||
|
const { tabActive } = this.data
|
||
|
if (tabActive == 0) {
|
||
|
app.zdMpBehavior({ PageName: 'BTN_PATIENTVISITMAPLIST' })
|
||
|
} else if (tabActive == 1) {
|
||
|
app.zdMpBehavior({ PageName: 'BTN_PATIENTVISITMAPDUALCHANNELPHARMACY' })
|
||
|
} else if (tabActive == 2) {
|
||
|
app.zdMpBehavior({ PageName: 'BTN_PATIENTVISITMAPDOCTORS' })
|
||
|
}
|
||
|
wx.navigateTo({
|
||
|
url,
|
||
|
})
|
||
|
},
|
||
|
handleOpenMap(e: WechatMiniprogram.CustomEvent) {
|
||
|
const { lat, lng, name, address } = e.currentTarget.dataset
|
||
|
wx.openLocation({
|
||
|
latitude: lat * 1,
|
||
|
longitude: lng * 1,
|
||
|
name,
|
||
|
address,
|
||
|
})
|
||
|
},
|
||
|
handleBack() {
|
||
|
wx.navigateBack()
|
||
|
},
|
||
|
onPageScroll() {},
|
||
|
handleToastOk() {
|
||
|
this.handleToastCancel()
|
||
|
},
|
||
|
handleToastCancel() {
|
||
|
this.hideDtpAlert()
|
||
|
this.setData({
|
||
|
toastShow: false,
|
||
|
})
|
||
|
},
|
||
|
handleDtpPhone(e: any) {
|
||
|
const { tel } = e.currentTarget.dataset
|
||
|
if (!tel) {
|
||
|
wx.showToast({
|
||
|
icon: 'none',
|
||
|
title: '电话暂未开通',
|
||
|
})
|
||
|
return
|
||
|
}
|
||
|
wx.makePhoneCall({
|
||
|
phoneNumber: tel,
|
||
|
})
|
||
|
},
|
||
|
|
||
|
handleTimeOut() {
|
||
|
this.setData({
|
||
|
asideOut: false,
|
||
|
})
|
||
|
wx.ajax({
|
||
|
method: 'POST',
|
||
|
url: '?r=xd/score/send-score',
|
||
|
data: {
|
||
|
Type: this.data.timeToastType,
|
||
|
Id: 0,
|
||
|
},
|
||
|
}).then((res) => {
|
||
|
if (!Array.isArray(res)) {
|
||
|
this.setData({
|
||
|
timeToast: true,
|
||
|
timeToastParams: {
|
||
|
rewardScore: res.rewardScore,
|
||
|
},
|
||
|
})
|
||
|
setTimeout(() => {
|
||
|
this.setData({
|
||
|
timeToast: false,
|
||
|
})
|
||
|
}, 3000)
|
||
|
}
|
||
|
})
|
||
|
},
|
||
|
handleSiteShare(e) {
|
||
|
this.setData({
|
||
|
toastShow: true,
|
||
|
toastType: 'siteConform',
|
||
|
toastParams: e.detail,
|
||
|
})
|
||
|
},
|
||
|
handleDefultLocation() {
|
||
|
if (this.data.locationName === '定位中') return
|
||
|
this.setData({
|
||
|
locationName: '定位中',
|
||
|
})
|
||
|
this.handleToggleSite()
|
||
|
},
|
||
|
handleSiteShareShow(e) {
|
||
|
this.setData({
|
||
|
areaShow: e.detail,
|
||
|
})
|
||
|
},
|
||
|
onShareAppMessage(e: any) {
|
||
|
let path = `/pages/doctor/index?active=${this.data.tabActive}&es=${this.data.es}`
|
||
|
const { toastType, toastParams } = this.data
|
||
|
if (toastType === 'siteConform' && e.from === 'button') {
|
||
|
path = `${path}&pid=${toastParams.ProvinceId}&cid=${toastParams.CityId}&pn=${toastParams.ProvinceName}&cn=${toastParams.CityName}`
|
||
|
this.setData({
|
||
|
ProvinceId: toastParams.ProvinceId,
|
||
|
ProvinceName: toastParams.ProvinceName,
|
||
|
CityId: toastParams.CityId,
|
||
|
CityName: toastParams.CityName,
|
||
|
})
|
||
|
this.getList()
|
||
|
}
|
||
|
|
||
|
return {
|
||
|
title: '【就诊地图】帮您快速找到医生和医院',
|
||
|
imageUrl: `${app.globalData.imageUrl}5/share1.png?t=${app.globalData.Timestamp}`,
|
||
|
path,
|
||
|
}
|
||
|
},
|
||
|
})
|