|
|
@ -98,10 +98,6 @@ |
|
|
|
<!-- #ifdef MP-WEIXIN --> |
|
|
|
<doctorImport v-if="user_type == '1' || user_type == '2'"></doctorImport> |
|
|
|
<!-- #endif --> |
|
|
|
<!-- #ifdef MP-WEIXIN --> |
|
|
|
<button id="getPhoneBtn" open-type="getPhoneNumber" bindgetphonenumber="onGetPhoneNumber" |
|
|
|
style="display: none;"></button> |
|
|
|
<!-- #endif --> |
|
|
|
<uni-popup ref="nameWrap" :safe-area="false"> |
|
|
|
<view class="popup-container"> |
|
|
|
<view class="header"> |
|
|
@ -117,7 +113,7 @@ |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</uni-popup> |
|
|
|
|
|
|
|
<button class="getphone-box" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber" v-if="!doctorInfo.aid"></button> |
|
|
|
</view> |
|
|
|
</template> |
|
|
|
|
|
|
@ -164,12 +160,6 @@ export default { |
|
|
|
this.state = option.state |
|
|
|
} |
|
|
|
}, |
|
|
|
onReady() { // 使用 onReady 替代 onLoad |
|
|
|
// #ifdef MP-WEIXIN |
|
|
|
// this.triggerGetPhone(); |
|
|
|
// #endif |
|
|
|
|
|
|
|
}, |
|
|
|
async onShow() { |
|
|
|
this.doctor_id = getApp().globalData.doctorId |
|
|
|
if (!this.doctor_id) return |
|
|
@ -200,55 +190,18 @@ export default { |
|
|
|
this.$refs.nameWrap.close() |
|
|
|
}); |
|
|
|
}, |
|
|
|
// 主动触发获取手机号 |
|
|
|
triggerGetPhone() { |
|
|
|
// 确保组件作用域和延迟 |
|
|
|
setTimeout(() => { |
|
|
|
const query = uni.createSelectorQuery().in(this); |
|
|
|
query.select('#getPhoneBtn') |
|
|
|
.node() |
|
|
|
.exec((res) => { |
|
|
|
const node = res[0]?.node; |
|
|
|
if (node) { |
|
|
|
node.dispatchEvent(new CustomEvent('tap')); |
|
|
|
} else { |
|
|
|
console.error('节点未找到,请检查:', res); |
|
|
|
// 备用方案:引导用户手动点击 |
|
|
|
wx.showModal({ |
|
|
|
title: '提示', |
|
|
|
content: '请手动点击授权按钮', |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, 800); |
|
|
|
}, |
|
|
|
// 手机号授权回调 |
|
|
|
onGetPhoneNumber(e) { |
|
|
|
if (e.detail.errMsg === "getPhoneNumber:ok") { |
|
|
|
const { code } = e.detail; |
|
|
|
// 发送 code 到后端解密手机号 |
|
|
|
wx.login({ |
|
|
|
success: (loginRes) => { |
|
|
|
wx.request({ |
|
|
|
url: '/api/user/bind_phone', |
|
|
|
data: { wxCode: loginRes.code, phoneCode: code }, |
|
|
|
success: (res) => { |
|
|
|
const phone = res.data.phone; |
|
|
|
this.setData({ phone }); |
|
|
|
// 手机号获取成功后,弹出姓名填写 |
|
|
|
this.setData({ showNameDialog: true }); |
|
|
|
}, |
|
|
|
}); |
|
|
|
}, |
|
|
|
getPhoneNumber(e) { |
|
|
|
console.log(e) |
|
|
|
if (e.detail.errMsg === 'getPhoneNumber:ok') { |
|
|
|
this.$http.req('api/user/bind_phone', {phonecode:e.detail.code}, 'POST').then(data=>{ |
|
|
|
if(data == -1) return |
|
|
|
this.getDoctorInfo() |
|
|
|
}); |
|
|
|
} else { |
|
|
|
// 用户拒绝,记录状态 |
|
|
|
this.setData({ hasRejectedPhone: true }); |
|
|
|
wx.showToast({ title: "需要手机号才能继续", icon: "none" }); |
|
|
|
|
|
|
|
} |
|
|
|
}, |
|
|
|
toLocation(hospital) { |
|
|
|
|
|
|
|
// #ifdef MP-WEIXIN |
|
|
|
var lngLat = hospital.hospital_pos.toString().split(',') |
|
|
|
var lng = Number(lngLat[1]) |
|
|
@ -332,15 +285,17 @@ export default { |
|
|
|
|
|
|
|
this.pageShow = true; |
|
|
|
|
|
|
|
this.$nextTick(() => { |
|
|
|
console.log(this.$refs, 'this.$refs.nameWrap'); |
|
|
|
this.$refs.nameWrap.open('bottom') |
|
|
|
}) |
|
|
|
|
|
|
|
let visitFlag = true; |
|
|
|
this.doctorInfo = data; |
|
|
|
this.user_type = this.doctorInfo.user_type; |
|
|
|
|
|
|
|
if(!data.realname && data.aid) { |
|
|
|
this.$nextTick(() => { |
|
|
|
this.$refs.nameWrap.open('bottom') |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
var title = this.doctorInfo.doctor_info.doctor_name + '主页' |
|
|
|
uni.setNavigationBarTitle({ |
|
|
|
title: title |
|
|
@ -748,7 +703,15 @@ export default { |
|
|
|
margin: 0 auto; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.getphone-box{ |
|
|
|
position: fixed; |
|
|
|
left: 0; |
|
|
|
top: 0; |
|
|
|
width: 100vw; |
|
|
|
height: 100vh; |
|
|
|
z-index: 8999999999; |
|
|
|
opacity: 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.popup-container { |
|
|
@ -831,6 +794,5 @@ export default { |
|
|
|
font-size: 26rpx; |
|
|
|
font-family: PingFang SC; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
</style> |
|
|
|