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.
 
 
 

154 lines
3.9 KiB

import { formatArea } from '@/utils/util'
const app = getApp<IAppOption>()
Page({
data: {
id: '',
detail: {} as any,
LNG: '' as number | string,
LAT: '' as number | string,
pagination: {
page: 1,
pages: 1,
count: 1,
},
},
onLoad(options) {
const SystemInfo = app.globalSystemInfo
if (SystemInfo) {
const { top, bottom } = SystemInfo.capsulePosition
this.setData({
top,
bottom,
})
}
app.waitLogin().then((_res) => {
this.setData({
id: options.id,
})
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.getFuzzyLocation()
} else if (res.confirm) {
//确定授权,通过wx.openSetting发起授权请求
wx.openSetting({
success(res) {
if (res.authSetting['scope.userFuzzyLocation'] == true) {
that.getFuzzyLocation()
} else {
that.getFuzzyLocation()
}
},
})
}
},
})
}
},
})
} else {
that.setData({
LNG: '',
LAT: '',
})
this.getDetail()
}
},
getFuzzyLocation() {
const that = this
wx.getFuzzyLocation({
success(res) {
that.setData({
LNG: res.longitude,
LAT: res.latitude,
})
that.getDetail()
},
fail(_err) {
that.getDetail()
},
})
},
getDetail() {
wx.ajax({
method: 'GET',
url: '?r=igg4/doctor/detail',
data: {
Id: this.data.id,
lng: this.data.LNG,
lat: this.data.LAT,
},
}).then((res) => {
let weekName: any = ''
if (res.ClinicType == 2) {
weekName = res.Clinic
} else {
weekName = (res.Clinic ? res.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],
}
},
)
}
this.setData({
detail: {
...res,
weekName,
},
})
})
},
handlePhone() {
const { detail } = this.data
wx.makePhoneCall({
phoneNumber: detail.Telephone,
})
},
handleOpenMap() {
const {
detail: { hospital },
} = this.data
wx.openLocation({
latitude: hospital.LAT,
longitude: hospital.LNG,
name: hospital.Name,
address: `${formatArea(hospital.ProvinceName, hospital.CityName)}${hospital.AreaName}${hospital.Address}`,
})
},
handleBack() {
wx.navigateBack()
},
onPageScroll() {},
})