75 lines
2.2 KiB
JavaScript
75 lines
2.2 KiB
JavaScript
const API = require('../../utils/api.js')
|
|
|
|
// 陪诊师公示列表:数据来自后端公开接口 /health/attendant
|
|
// 该接口已做脱敏(不含手机号 / 身份证号 / 证书编号原文),
|
|
// 前端不再做二次裁剪,只把后端字段整形为展示所需结构
|
|
Page({
|
|
data: {
|
|
loading: true,
|
|
attendants: []
|
|
},
|
|
|
|
onLoad() {
|
|
this.loadAttendants()
|
|
},
|
|
|
|
loadAttendants() {
|
|
API.escort.getAttendants()
|
|
.then((res) => {
|
|
if (res.code !== 0) {
|
|
this.setData({ loading: false })
|
|
return
|
|
}
|
|
|
|
const list = (res.data && res.data.attendants) || []
|
|
this.setData({
|
|
loading: false,
|
|
attendants: list.map((item) => {
|
|
const specialties = item.specialties || []
|
|
const serviceAreas = item.serviceAreas || []
|
|
const languages = item.languages || []
|
|
|
|
return {
|
|
id: item.id,
|
|
name: item.name,
|
|
avatar: item.avatar,
|
|
// 头像兜底用的首字:姓名已脱敏为「姓 + 陪诊师」,取第一个字即可
|
|
initial: (item.name || '').slice(0, 1),
|
|
workYears: item.workYears || 0,
|
|
orderCount: item.orderCount || 0,
|
|
qualificationVerified: !!item.qualificationVerified,
|
|
// 擅长场景最多展示 3 个,避免长尾把卡片撑高;完整列表在详情页
|
|
specialtyTags: specialties.slice(0, 3),
|
|
// 数组在 WXML 里不能直接拼展示,这里先转成文本
|
|
areaText: serviceAreas.join(' / '),
|
|
langText: languages.join(' / ')
|
|
}
|
|
})
|
|
})
|
|
})
|
|
.catch((err) => {
|
|
console.log('获取陪诊师列表失败', err)
|
|
this.setData({ loading: false })
|
|
})
|
|
},
|
|
|
|
// 整卡可点进详情。卡片右侧补 chevron 做点击暗示——
|
|
// 项目约束不允许"无暗示的整卡可点"
|
|
goToDetail(e) {
|
|
const id = e.currentTarget.dataset.id
|
|
if (!id) {
|
|
return
|
|
}
|
|
wx.navigateTo({
|
|
url: `/pages/attendant/attendantdetail?id=${id}`
|
|
})
|
|
},
|
|
|
|
onShareAppMessage() {
|
|
return {
|
|
title: '暖橙陪诊 · 陪诊师团队',
|
|
path: '/pages/attendant/attendantlist'
|
|
}
|
|
}
|
|
})
|