77 lines
1.5 KiB
JavaScript
77 lines
1.5 KiB
JavaScript
import request from "@/utils/request"
|
||
|
||
const app = getApp()
|
||
Page({
|
||
data: {
|
||
list: [
|
||
{
|
||
s: "李",
|
||
name: "李医生",
|
||
title: "主任医师 · 骨科专家",
|
||
desc: "20年临床经验"
|
||
},
|
||
{
|
||
s: "王",
|
||
name: "王医生",
|
||
title: "副主任医师 · 康复医学",
|
||
desc: "15年临床经验"
|
||
},
|
||
{
|
||
s: "张",
|
||
name: "张护士长",
|
||
title: "主管护师 · 伤口护理",
|
||
desc: "18年护理经验"
|
||
}
|
||
],
|
||
count: 0
|
||
},
|
||
onShow() {
|
||
let userInfo = app.globalData.userInfo
|
||
this.setData({
|
||
count: userInfo.consult_remains
|
||
})
|
||
this.getTabBar((tabBar) => {
|
||
tabBar.setData({
|
||
selected: '专家服务',
|
||
})
|
||
})
|
||
},
|
||
|
||
async onPlay() {
|
||
if (this.data.count <= 0) {
|
||
wx.showToast({
|
||
title: '免费次数已用完',
|
||
icon: 'none'
|
||
});
|
||
return;
|
||
}
|
||
// 2. 弹窗确认
|
||
wx.showModal({
|
||
title: '拨打专家热线',
|
||
content: '确认拨打专家咨询电话吗?本次咨询将使用1次免费机会',
|
||
success: async (res) => {
|
||
if (res.confirm) {
|
||
try {
|
||
wx.showLoading({ title: '正在呼叫...', mask: true });
|
||
const info = await request.get("/expert/phone");
|
||
this.setData({
|
||
count: this.data.count - 1
|
||
});
|
||
wx.hideLoading();
|
||
|
||
// 5. 吊起拨号盘
|
||
if (info && info.expert_phone) {
|
||
wx.makePhoneCall({
|
||
phoneNumber: info.expert_phone,
|
||
});
|
||
} else {
|
||
wx.showToast({ title: '暂无专家电话', icon: 'none' });
|
||
}
|
||
} catch (error) {
|
||
wx.hideLoading();
|
||
}
|
||
}
|
||
}
|
||
});
|
||
}
|
||
}) |