武田基因病B开发环境
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.
 
 
 

93 lines
2.4 KiB

import { parseScene } from '@/utils/util'
const app = getApp<IAppOption>()
Page({
data: {
popupShow: false,
// popupType: 'selectIdentity', // 选择您的身份
// popupType: 'bindDoctorReject', // 绑定失败
// popupType: 'bindDoctor', // 绑定成功
// popupType: 'bindDoctorQuestion', // 为什么绑定医生
// popupType: 'conformBindDoctorQuestion', // 确认绑定曾经扫码医生
popupType: 'conformBindDoctorConform', // 注册后绑定医生码
popupParams: {},
},
onLoad() {},
handleBindDoctor() {
wx.scanCode({
scanType: ['wxCode'],
success: (res) => {
const path = res.path
if (res.errMsg !== 'scanCode:ok' || !path || !path.includes('?scene=doctorId')) {
wx.showToast({
icon: 'none',
title: '扫码失败,请重试',
})
return
}
const scene = path.split('?scene=')[1]
const { doctorId } = parseScene(scene) as { doctorId: string }
this.bindDoctor(doctorId)
},
})
},
bindDoctor(id) {
wx.ajax({
method: 'POST',
url: '?r=wtx/account/bind-doctor',
data: {
doctorId: id,
},
showMsg: false,
})
.then(() => {
app.getDoctorInfo(id).then((res) => {
this.setData({
popupShow: true,
popupType: 'bindDoctor',
popupParams: {
name: res.doctorName,
avatar: res.doctorAvatar,
hostipal: res.hospitalName,
className: res.hospitalClassificationName,
levelName: res.hospitalLevelName,
},
})
})
})
.catch((err) => {
if ([101, 102].includes(err.data.code)) {
this.setData({
popupShow: true,
popupType: 'bindDoctorReject',
popupParams: {
msg: err.data.msg || '请检查网络后重试',
},
})
} else {
wx.showToast({
icon: 'none',
title: err.data.msg || '请检查网络后重试',
})
}
})
},
handlePopupOk() {
const { popupType } = this.data
if (popupType === 'bindDoctor') {
wx.navigateBack()
}
this.handlePopupCancel()
},
handlePopupCancel() {
this.setData({
popupShow: false,
popupType: '',
})
},
handleBack() {
wx.navigateBack()
},
})
export {}