diff --git a/components/claim-patient-modal/claim-patient-modal.vue b/components/claim-patient-modal/claim-patient-modal.vue index 077e97f..bd287be 100644 --- a/components/claim-patient-modal/claim-patient-modal.vue +++ b/components/claim-patient-modal/claim-patient-modal.vue @@ -112,8 +112,9 @@ export default { method: 'post', data: { register_id: registerId }, }) - if (res.data && (res.data.errcode == 0 || res.data.errcode === '0')) { - const data = res.data.data || {} + // registePay 为 xk-api:按 code/result/message 取值 + if (res.data && (res.data.code == 0 || res.data.code === '0')) { + const data = res.data.result || {} if (data.is_paid == 1 || data.is_pay == 1) { uni.showToast({ title: '认领成功', icon: 'success' }) return @@ -134,7 +135,7 @@ export default { }) } else { uni.showToast({ - title: (res.data && (res.data.message || res.data.msg)) || '获取支付参数失败', + title: (res.data && res.data.message) || '获取支付参数失败', icon: 'none', }) } diff --git a/pages/home/home.vue b/pages/home/home.vue index df655a4..a9dec25 100644 --- a/pages/home/home.vue +++ b/pages/home/home.vue @@ -54,7 +54,15 @@ - + - + - 您有 {{ unpaidRegisterCount }} 个待支付挂号订单,点击前往查看 - + + + {{ item.title }} + {{ item.count }} + + + - - - 您有 {{ unpaidProductOrderCount }} 个待支付商品订单,点击前往查看 - + + + + {{ item.count }} + + {{ item.title }} + @@ -324,12 +367,18 @@ import { storeChange, storeInfo, storeList, - fetchUnpaidProductOrderListApi, } from '../../request/api/api' import { getPlatformQualificationsApi } from '../../request/api/platform' -import { getStoreDrugListBySalespersonApi, getHomeTopProductsApi, getHomeZonesApi, checkOnlineConsultationConfigApi } from "@/request/api/product"; +import { + getStoreDrugListBySalespersonApi, + getHomeTopProductsApi, + getHomeZonesApi, + getHomeDisplayConfigApi, + getHomeOrderRemindApi, + checkOnlineConsultationConfigApi, +} from "@/request/api/product"; import { getSpecialPrescriptionHomeApi } from '@/request/api/specialPrescription'; -import { fetchUnpaidRegisterListApi } from '@/request/api/register'; +import { unwrapXkApi } from '@/utils/api-response.js'; import request from "@/request/api/request"; import MessageNotification from "@/components/MessageNotification/MessageNotification.vue"; import ClaimPatientModal from "@/components/claim-patient-modal/claim-patient-modal.vue"; @@ -375,13 +424,11 @@ export default { statusBarHeight: 20, isSticky: false, - // 控制金刚区布局模式: 'scroll' (滑动) 或 'wrap' (换行) + // 金刚区布局:scroll 横滑 / wrap 一行五个 / wrap2 一行两个(后台可配) zoneLayoutMode: 'scroll', - - unpaidRegisterCount: 0, - unpaidRegisterList: [], - unpaidProductOrderCount: 0, - unpaidProductOrderList: [], + // 订单提醒:grid 一行两列 / zone 金刚区(后台可配) + orderRemindStyle: 'grid', + orderRemindItems: [], // 特色药方(API) specialPrescription: { @@ -402,7 +449,11 @@ export default { // 判断是否为guest模式(用于模板) isGuestMode() { return isGuestMode; - } + }, + // 只展示有数量的订单提醒,避免空宫格占位 + visibleOrderReminds() { + return (this.orderRemindItems || []).filter((item) => item && item.count > 0); + }, }, onLoad() { @@ -458,53 +509,85 @@ export default { } }, methods: { - async fetchUnpaidCounts() { + /** + * 拉取首页展示样式(游客/登录都要,金刚区布局跟配置走) + */ + async fetchHomeDisplayConfig() { + try { + const res = await getHomeDisplayConfigApi(); + const { ok, payload } = unwrapXkApi(res); + if (!ok || !payload) { + return; + } + if (payload.zone_layout === 'scroll' || payload.zone_layout === 'wrap' || payload.zone_layout === 'wrap2') { + this.zoneLayoutMode = payload.zone_layout; + } + if (payload.order_remind_style === 'grid' || payload.order_remind_style === 'zone') { + this.orderRemindStyle = payload.order_remind_style; + } + } catch (e) { + console.error('fetchHomeDisplayConfig', e); + } + }, + /** + * 首页订单提醒:待支付挂号/商品、已发货、已到货待确认 + * 未登录不请求,避免游客打到需登录接口 + */ + async fetchOrderReminds() { if (!isLoggedIn()) { - this.unpaidRegisterCount = 0; - this.unpaidRegisterList = []; - this.unpaidProductOrderCount = 0; - this.unpaidProductOrderList = []; + this.orderRemindItems = []; return; } try { - const [registerList, productList] = await Promise.all([ - fetchUnpaidRegisterListApi(), - fetchUnpaidProductOrderListApi(), - ]); - this.unpaidRegisterList = registerList; - this.unpaidRegisterCount = registerList.length; - this.unpaidProductOrderList = productList; - this.unpaidProductOrderCount = productList.length; + const res = await getHomeOrderRemindApi(); + const { ok, payload } = unwrapXkApi(res); + if (!ok || !payload) { + this.orderRemindItems = []; + return; + } + if (payload.zone_layout === 'scroll' || payload.zone_layout === 'wrap' || payload.zone_layout === 'wrap2') { + this.zoneLayoutMode = payload.zone_layout; + } + if (payload.order_remind_style === 'grid' || payload.order_remind_style === 'zone') { + this.orderRemindStyle = payload.order_remind_style; + } + this.orderRemindItems = payload.items || []; } catch (e) { - console.error('fetchUnpaidCounts', e); - this.unpaidRegisterCount = 0; - this.unpaidRegisterList = []; - this.unpaidProductOrderCount = 0; - this.unpaidProductOrderList = []; + console.error('fetchOrderReminds', e); + this.orderRemindItems = []; } }, - onUnpaidRegisterBannerClick() { - if (this.unpaidRegisterCount === 1 && this.unpaidRegisterList[0]) { - const id = this.unpaidRegisterList[0].id; + /** + * 订单提醒点击:1 条进详情,多条进对应列表 + * 已发货/待确认都落在商品订单「待收货」tab + */ + onOrderRemindTap(item) { + if (!item) { + return; + } + const count = Number(item.count) || 0; + const firstId = Number(item.first_id) || 0; + if (item.key === 'unpaid_register') { + if (count === 1 && firstId > 0) { + uni.navigateTo({ + url: `/subPackages/doctor/doctor-userinfo?step=2®ister_id=${firstId}`, + }); + return; + } uni.navigateTo({ - url: `/subPackages/doctor/doctor-userinfo?step=2®ister_id=${id}`, + url: '/subPackages/my/myappiont', }); return; } - uni.navigateTo({ - url: '/subPackages/my/myappiont', - }); - }, - onUnpaidProductOrderBannerClick() { - if (this.unpaidProductOrderCount === 1 && this.unpaidProductOrderList[0]) { - const id = this.unpaidProductOrderList[0].id; + if (count === 1 && firstId > 0) { uni.navigateTo({ - url: `/subPackages/my/my-drug/drug-info?id=${id}`, + url: `/subPackages/my/my-drug/drug-info?id=${firstId}`, }); return; } + const tabIndex = item.key === 'unpaid_product' ? 1 : 3; uni.navigateTo({ - url: '/subPackages/my/my-drug/drug-list?index=1', + url: `/subPackages/my/my-drug/drug-list?index=${tabIndex}`, }); }, // 处理购物车按钮点击 @@ -834,6 +917,8 @@ export default { this._productFetchDone = 0; return Promise.all([ this.getHomeZones(), + this.fetchHomeDisplayConfig(), + this.fetchOrderReminds(), this.getList(), this.getProductList(), this.getHomeTopProducts(), @@ -963,7 +1048,8 @@ export default { this.getHomeZones(); this.getPlatformQualifications(); // 已补回 this.getDefaultDoctorId(); - this.fetchUnpaidCounts(); + this.fetchHomeDisplayConfig(); + this.fetchOrderReminds(); this.fetchSpecialPrescriptionHome(); this.openClaimPatientModal(); this.openProxyPayConfirmModal(); @@ -1050,13 +1136,20 @@ $card-shadow: 0 8rpx 20rpx rgba(0, 0, 0, 0.04); .zone-item { width: 140rpx; margin-right: 10rpx; } } - /* 模式2: 换行 */ + /* 模式2: 换行(一行五个) */ &.zone-wrap-mode { flex-wrap: wrap; justify-content: flex-start; .zone-item { width: 20%; margin-bottom: 24rpx; } } + /* 模式3: 一行两个 */ + &.zone-wrap2-mode { + flex-wrap: wrap; + justify-content: flex-start; + .zone-item { width: 50%; margin-bottom: 24rpx; } + } + .zone-item { flex-shrink: 0; text-align: center; display: flex; flex-direction: column; align-items: center; &:active { transform: scale(0.95); } @@ -1089,44 +1182,77 @@ $card-shadow: 0 8rpx 20rpx rgba(0, 0, 0, 0.04); } } - .unpaid-banner { + .order-remind-grid { + display: flex; + flex-wrap: wrap; + padding: 0 32rpx 8rpx; + box-sizing: border-box; + } + .order-remind-card { + width: calc(50% - 10rpx); + margin: 0 20rpx 16rpx 0; + padding: 22rpx 20rpx; + border-radius: 16rpx; + box-sizing: border-box; display: flex; align-items: center; justify-content: space-between; - margin: 16rpx 32rpx 0; - padding: 24rpx 28rpx; - border-radius: 16rpx; - + &:nth-child(2n) { margin-right: 0; } + &:active { transform: scale(0.98); } &--register { - background: linear-gradient(90deg, rgba(65, 117, 238, 0.08) 0%, rgba(65, 117, 238, 0.04) 100%); - border: 1rpx solid rgba(65, 117, 238, 0.2); - - .unpaid-banner-text, - .unpaid-banner-arrow { - color: #4175EE; - } + border: 1rpx solid rgba(65, 117, 238, 0.3); + box-shadow: 0 0 12rpx rgba(65, 117, 238, 0.18); + background: rgba(65, 117, 238, 0.06); + .order-remind-card-title, .order-remind-card-count, .order-remind-card-arrow { color: #4175EE; } } - &--product { - background: linear-gradient(90deg, rgba(0, 181, 120, 0.08) 0%, rgba(0, 181, 120, 0.04) 100%); - border: 1rpx solid rgba(0, 181, 120, 0.25); - - .unpaid-banner-text, - .unpaid-banner-arrow { - color: #00B578; + border: 1rpx solid rgba(0, 181, 120, 0.3); + box-shadow: 0 0 12rpx rgba(0, 181, 120, 0.18); + background: rgba(0, 181, 120, 0.06); + .order-remind-card-title, .order-remind-card-count, .order-remind-card-arrow { color: #00B578; } + } + &--shipped { + border: 1rpx solid rgba(255, 140, 0, 0.3); + box-shadow: 0 0 12rpx rgba(255, 140, 0, 0.18); + background: rgba(255, 140, 0, 0.06); + .order-remind-card-title, .order-remind-card-count, .order-remind-card-arrow { color: #E67E00; } + } + &--arrived { + border: 1rpx solid rgba(139, 92, 246, 0.3); + box-shadow: 0 0 12rpx rgba(139, 92, 246, 0.18); + background: rgba(139, 92, 246, 0.06); + .order-remind-card-title, .order-remind-card-count, .order-remind-card-arrow { color: #7C3AED; } + } + .order-remind-card-main { flex: 1; min-width: 0; } + .order-remind-card-title { display: block; font-size: 24rpx; font-weight: 500; } + .order-remind-card-count { display: block; margin-top: 6rpx; font-size: 36rpx; font-weight: 800; line-height: 1.1; } + .order-remind-card-arrow { font-size: 22rpx; margin-left: 8rpx; } + } + .order-remind-zone { + padding-top: 8rpx; + .order-remind-zone-icon { + position: relative; + &--register { color: #4175EE; } + &--product { color: #00B578; } + &--shipped { color: #E67E00; } + &--arrived { color: #7C3AED; } + .iconfont { font-size: 48rpx; } + .order-remind-badge { + position: absolute; + top: -8rpx; + right: -8rpx; + min-width: 28rpx; + height: 28rpx; + padding: 0 8rpx; + border-radius: 14rpx; + background: #FF4D4F; + color: #fff; + font-size: 18rpx; + line-height: 28rpx; + text-align: center; + box-sizing: border-box; } } - - .unpaid-banner-text { - flex: 1; - font-size: 26rpx; - line-height: 1.5; - } - - .unpaid-banner-arrow { - font-size: 24rpx; - margin-left: 12rpx; - } } .section-header { diff --git a/pages/index/index.vue b/pages/index/index.vue index 723f4d0..a7a4a01 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -12,107 +12,43 @@ - - - + @@ -183,6 +119,9 @@