修改了页面样式。
This commit is contained in:
+35
-43
@@ -2,8 +2,8 @@ const API = require('../../utils/api.js')
|
||||
const { parseDate } = require('../../utils/date.js')
|
||||
|
||||
// 首页未完成预约预览:服务端按预约日期倒序,这里取一页后在本地正序,
|
||||
// 让最近的一场排在最前。20 条覆盖常见未完成量;更多时卡头仍显示总数,
|
||||
// 由「查看全部」承接完整列表
|
||||
// 让最近的一场排在最前。20 条覆盖常见未完成量;首页只展示最近三条,
|
||||
// 更多由「常用功能 · 预约记录」承接
|
||||
const PENDING_PREVIEW_LIMIT = 3
|
||||
const PENDING_FETCH_SIZE = 20
|
||||
|
||||
@@ -33,8 +33,7 @@ const SERVICE_ORDER = [1, 2, 7, 3, 4, 5, 8, 6]
|
||||
Page({
|
||||
data: {
|
||||
escortServices: [], // 陪诊服务(来自后端,按 SERVICE_ORDER 展示)
|
||||
pendingCount: 0, // 未完成预约数,用于预览卡头徽标
|
||||
pendingRecords: [], // 按预约时间正序的最近几条未完成预约,最多 3 条
|
||||
pendingRecords: [], // 按预约时间正序的最近几条未完成预约,每条渲染成一张卡,最多 3 条
|
||||
quickEntries: [{
|
||||
id: 'records',
|
||||
name: '预约记录',
|
||||
@@ -65,6 +64,12 @@ Page({
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
// 先用上次成功拉取的列表渲染宫格,避免首屏出现一块空白;
|
||||
// 紧接着请求最新数据,回来后覆盖
|
||||
const cached = getApp().getCachedServices()
|
||||
if (cached) {
|
||||
this.setData({ escortServices: this.buildEscortServices(cached) })
|
||||
}
|
||||
this.loadServices()
|
||||
},
|
||||
|
||||
@@ -84,42 +89,42 @@ Page({
|
||||
app.loadServices()
|
||||
.then((services) => {
|
||||
if (!services) {
|
||||
this.setData({ escortServices: [] })
|
||||
// 失败时保留缓存渲染结果,避免宫格从有到无闪一下
|
||||
console.error('首页服务列表加载失败')
|
||||
return
|
||||
}
|
||||
|
||||
const serviceMap = {}
|
||||
services.forEach((service) => {
|
||||
serviceMap[service.id] = service
|
||||
})
|
||||
|
||||
// 按展示顺序拼装。首页宫格不取 price / subtitle——
|
||||
// 定价与服务介绍分别留到指南页、详情页展示
|
||||
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
|
||||
escortServices: this.buildEscortServices(services)
|
||||
})
|
||||
})
|
||||
.catch((err) => {
|
||||
this.setData({ escortServices: [] })
|
||||
console.error('首页服务列表加载失败', err)
|
||||
})
|
||||
},
|
||||
|
||||
// 未完成预约预览:等待鉴权完成,登录后由后端按状态汇总并取一页用于逐条展示
|
||||
// 按展示顺序把后端服务拼成宫格数据。
|
||||
// 首页宫格不取 price / subtitle——定价与服务介绍分别留到指南页、详情页展示
|
||||
buildEscortServices(services) {
|
||||
const serviceMap = {}
|
||||
services.forEach((service) => {
|
||||
serviceMap[service.id] = service
|
||||
})
|
||||
|
||||
return 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
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 未完成预约预览:等待鉴权完成,登录后由后端按「未完成」状态筛选并取一页用于逐条展示
|
||||
refreshPendingPreview() {
|
||||
if (this.pendingRequest) return this.pendingRequest
|
||||
|
||||
@@ -128,7 +133,7 @@ Page({
|
||||
.then(() => {
|
||||
const user = app.globalData.user
|
||||
if (!user || !user._id) {
|
||||
this.setData({ pendingCount: 0, pendingRecords: [] })
|
||||
this.setData({ pendingRecords: [] })
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -144,14 +149,7 @@ Page({
|
||||
if (!res || res.code !== 0) return
|
||||
|
||||
const data = res.data || {}
|
||||
const counts = data.counts || {}
|
||||
const pendingCount = Number(
|
||||
counts.ongoing === undefined || counts.ongoing === null
|
||||
? (data.total || 0)
|
||||
: counts.ongoing
|
||||
) || 0
|
||||
this.setData({
|
||||
pendingCount,
|
||||
pendingRecords: this.buildPendingPreview(data.records || [])
|
||||
})
|
||||
})
|
||||
@@ -241,12 +239,6 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
goToRecords() {
|
||||
wx.navigateTo({
|
||||
url: '/pages/escort/recordlist'
|
||||
})
|
||||
},
|
||||
|
||||
// 未完成预约预览:点单条直达详情
|
||||
goToRecordDetail(e) {
|
||||
const id = e.currentTarget.dataset.id
|
||||
|
||||
Reference in New Issue
Block a user