修改界面中,临时提交
This commit is contained in:
+168
-146
@@ -1,92 +1,180 @@
|
||||
const API = require('../../utils/api.js')
|
||||
|
||||
// 陪诊服务的展示配置:价格等以后端返回为准,这里只覆盖展示名。
|
||||
// 图标不走数据,而是按 id 映射到 index.wxss 里内嵌的细线 SVG(.assist-icon-1 ~ .assist-icon-8)
|
||||
// key 为后端 services 的 id,顺序即首页宫格的展示顺序
|
||||
const SERVICE_UI = {
|
||||
1: { name: '全天陪诊' },
|
||||
2: { name: '半天陪诊' },
|
||||
3: { name: '代问诊' },
|
||||
4: { name: '检查预约' },
|
||||
5: { name: '出入院代办' },
|
||||
6: { name: '跑腿服务' },
|
||||
7: { name: '陪诊套餐' },
|
||||
8: { name: '买药套餐' }
|
||||
}
|
||||
|
||||
// 陪诊服务的展示顺序(两行共 8 项)
|
||||
const SERVICE_ORDER = [1, 2, 3, 4, 5, 6, 7, 8]
|
||||
|
||||
// 计入"待服务订单"的订单状态:待确认 / 已确认 / 进行中
|
||||
const PENDING_ORDER_STATUS = ['pending', 'confirmed', 'in_progress']
|
||||
|
||||
// 人工客服电话
|
||||
const SERVICE_PHONE = '18618162956'
|
||||
|
||||
Page({
|
||||
data: {
|
||||
escortServices: [{
|
||||
id: 1,
|
||||
name: '陪诊',
|
||||
icon: 'heart',
|
||||
iconColor: '#E11D48',
|
||||
bgColor: '#FFF1F2'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '代问诊',
|
||||
icon: 'chat-heart',
|
||||
iconColor: '#EA580C',
|
||||
bgColor: '#FFF7ED'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: '代办理',
|
||||
icon: 'fact-check',
|
||||
iconColor: '#059669',
|
||||
bgColor: '#ECFDF5'
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
name: '其他助诊',
|
||||
icon: 'app',
|
||||
iconColor: '#2563EB',
|
||||
bgColor: '#EFF6FF'
|
||||
}
|
||||
],
|
||||
otherServices: [{
|
||||
id: 1,
|
||||
name: '代探望',
|
||||
icon: 'apple',
|
||||
url: '',
|
||||
type: '',
|
||||
iconColor: '#7C3AED',
|
||||
bgColor: '#F5F3FF'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '企业陪诊',
|
||||
icon: 'city-8',
|
||||
url: '',
|
||||
type: '',
|
||||
iconColor: '#D97706',
|
||||
bgColor: '#FFFBEB'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: '陪诊师入驻',
|
||||
icon: 'usergroup',
|
||||
url: '',
|
||||
type: '',
|
||||
iconColor: '#4F46E5',
|
||||
bgColor: '#EEF2FF'
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: '商务合作',
|
||||
icon: 'command',
|
||||
url: '',
|
||||
type: '',
|
||||
iconColor: '#0D9488',
|
||||
bgColor: '#F0FDFA'
|
||||
},
|
||||
],
|
||||
tools: [{
|
||||
id: 1,
|
||||
escortServices: [], // 陪诊服务(来自后端,最多 8 项)
|
||||
pendingCount: 0, // 待服务订单数,大于 0 时首页顶部展示状态条
|
||||
quickEntries: [{
|
||||
id: 'records',
|
||||
name: '预约记录',
|
||||
icon: 'assignment',
|
||||
url: 'pages/escort/recordlist',
|
||||
type: 'page',
|
||||
iconColor: '#0891B2',
|
||||
bgColor: '#ECFEFF'
|
||||
desc: '查看预约进度与历史',
|
||||
// 日历:与「健康档案」的人形图标形成明显形态差异(原先两个都是"文档+勾",缩小后难分辨)
|
||||
icon: 'calendar-1',
|
||||
url: '/pages/escort/recordlist'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
id: 'health',
|
||||
name: '健康档案',
|
||||
icon: 'attach',
|
||||
url: '',
|
||||
type: '',
|
||||
iconColor: '#DB2777',
|
||||
bgColor: '#FDF2F8'
|
||||
desc: '管理家人就诊信息',
|
||||
icon: 'user-checked',
|
||||
url: '/pages/health/profilelist'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.loadServices()
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.refreshPendingCount()
|
||||
// 同步自定义 tabBar 选中态(首页为第 0 项)
|
||||
if (typeof this.getTabBar === 'function' && this.getTabBar()) {
|
||||
this.getTabBar().setData({
|
||||
selected: 0
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
// 读取后端服务列表,拼装成首页宫格所需的展示数据
|
||||
loadServices() {
|
||||
const app = getApp()
|
||||
// servicesReady 由 app.onLaunch 创建,兜底避免极端情况下取不到
|
||||
const ready = app.globalData.servicesReady || Promise.resolve(app.globalData.services || [])
|
||||
|
||||
ready.then((services) => {
|
||||
const serviceMap = {}
|
||||
;(services || []).forEach((service) => {
|
||||
serviceMap[service.id] = service
|
||||
})
|
||||
|
||||
const escortServices = SERVICE_ORDER
|
||||
.filter((id) => serviceMap[id])
|
||||
.map((id) => {
|
||||
const service = serviceMap[id]
|
||||
const ui = SERVICE_UI[id] || {}
|
||||
return {
|
||||
id,
|
||||
name: ui.name || service.title,
|
||||
// 图标类名:与 index.wxss 中 .assist-icon-{id} 对应
|
||||
iconClass: 'assist-icon-' + id
|
||||
}
|
||||
})
|
||||
|
||||
this.setData({
|
||||
escortServices
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
// 统计待服务订单:仅在登录信息就绪后请求,未就绪时稍后重试一次
|
||||
refreshPendingCount(retry) {
|
||||
const app = getApp()
|
||||
const user = app.globalData.user
|
||||
|
||||
if (!user || !user._id) {
|
||||
// 首次进入时 App 的登录请求可能还没返回,延迟重试一次即可
|
||||
if (!retry) {
|
||||
setTimeout(() => this.refreshPendingCount(1), 1500)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
API.escort.getMyRecords({
|
||||
userId: user._id,
|
||||
page: 1,
|
||||
pageSize: 50
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.code !== 0) {
|
||||
return
|
||||
}
|
||||
const records = (res.data && res.data.records) || []
|
||||
const pendingCount = records.filter((record) => PENDING_ORDER_STATUS.indexOf(record.status) > -1).length
|
||||
this.setData({
|
||||
pendingCount
|
||||
})
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log('获取待服务订单失败', err)
|
||||
})
|
||||
},
|
||||
|
||||
goToAiChat() {
|
||||
wx.switchTab({
|
||||
url: '/pages/ai/aichat'
|
||||
});
|
||||
},
|
||||
|
||||
// 页脚 B 端合作入口仍直接转服务电话
|
||||
goToContact() {
|
||||
wx.makePhoneCall({
|
||||
phoneNumber: SERVICE_PHONE
|
||||
});
|
||||
},
|
||||
|
||||
// 「联系我们」卡片:进入独立联系页,页内再提供拨号/复制/工作时间
|
||||
goToContactPage() {
|
||||
wx.navigateTo({
|
||||
url: '/pages/mine/contact'
|
||||
});
|
||||
},
|
||||
|
||||
// Hero 主按钮:先引导新用户了解服务,服务列表入口在指南页底部
|
||||
goToGuide() {
|
||||
wx.navigateTo({
|
||||
url: '/pages/escort/guide'
|
||||
});
|
||||
},
|
||||
|
||||
// 点击陪诊服务,直达服务详情下单
|
||||
goToServiceDetail(e) {
|
||||
const id = e.currentTarget.dataset.id
|
||||
wx.navigateTo({
|
||||
url: `/pages/escort/itemdetail?id=${id}`
|
||||
})
|
||||
},
|
||||
|
||||
// 常用功能:预约记录、健康档案
|
||||
onQuickEntryTap(e) {
|
||||
const entry = e.currentTarget.dataset.item
|
||||
if (!entry || !entry.url) {
|
||||
return
|
||||
}
|
||||
wx.navigateTo({
|
||||
url: entry.url
|
||||
})
|
||||
},
|
||||
|
||||
goToRecords() {
|
||||
wx.navigateTo({
|
||||
url: '/pages/escort/recordlist'
|
||||
})
|
||||
},
|
||||
|
||||
onShareAppMessage() {
|
||||
return {
|
||||
title: '暖橙陪诊', // 转发标题
|
||||
@@ -98,71 +186,5 @@ Page({
|
||||
return {
|
||||
title: '暖橙陪诊',
|
||||
}
|
||||
},
|
||||
|
||||
async onLoad() {},
|
||||
|
||||
goToAiChat() {
|
||||
wx.switchTab({
|
||||
url: '/pages/ai/aichat'
|
||||
});
|
||||
},
|
||||
|
||||
goToContact() {
|
||||
wx.makePhoneCall({
|
||||
phoneNumber: '18618162956'
|
||||
});
|
||||
},
|
||||
|
||||
goToServiceList() {
|
||||
wx.navigateTo({
|
||||
url: '/pages/escort/itemlist'
|
||||
});
|
||||
},
|
||||
|
||||
goToAssistDetail(e) {
|
||||
const id = e.currentTarget.dataset.id;
|
||||
wx.navigateTo({
|
||||
url: `/pages/escort/itemlist?assistId=${id}`
|
||||
});
|
||||
},
|
||||
|
||||
goToOtherServicesDetail(e) {
|
||||
const item = e.currentTarget.dataset.item;
|
||||
if (!item || !item.type || !item.url) {
|
||||
wx.showToast({
|
||||
title: '建设中...',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
switch (item.type) {
|
||||
case 'page':
|
||||
wx.navigateTo({
|
||||
url: '/' + item.url
|
||||
});
|
||||
break;
|
||||
case 'tab':
|
||||
wx.switchTab({
|
||||
url: '/' + item.url
|
||||
});
|
||||
break;
|
||||
case 'website':
|
||||
wx.navigateTo({
|
||||
url: '/pages/home/webview?url=' + encodeURIComponent(item.url)
|
||||
});
|
||||
break;
|
||||
case 'wxapp':
|
||||
wx.navigateToMiniProgram({
|
||||
shortLink: item.url,
|
||||
env: 'release'
|
||||
})
|
||||
break;
|
||||
default:
|
||||
wx.showToast({
|
||||
title: '建设中...',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user