Просмотр исходного кода

style: [AE-会员端] 修改订单详情取货UI

bill 2 недель назад
Родитель
Сommit
188a057195

+ 95 - 8
src/ui-refactor/views/guest-shop/GuestOrderDetails.vue

@@ -84,8 +84,8 @@ export default {
     paymentMethod() {
       return this.order.PAY_TYPE === 'pay_stack' ? 'Paystack' : this.order.PAY_TYPE || '—'
     },
-    address() {
-      return String(this.order.EXPRESS_TYPE) === '1' ? 'Self Pick-up' : 'Delivery'
+    isPickup() {
+      return String(this.order.EXPRESS_TYPE) === '1'
     }
   },
   methods: {
@@ -171,11 +171,33 @@ export default {
           </dl>
           <p v-if="!currency">Currency information is unavailable.</p>
         </ui-section-card>
-        <ui-section-card :title="address">
-          <strong>{{ order.CONSIGNEE || '—' }}</strong>
-          <p class="ng-guest-order-address">
-            {{ order.MOBILE || '—' }}<br>{{ order.FULL_ADDRESS }}<br>{{ order.COUNTRY || '—' }}
-          </p>
+        <ui-section-card class="ng-guest-order-fulfillment">
+          <div class="ng-guest-order-fulfillment-heading">
+            <h2 class="ng-guest-order-fulfillment-title">{{ isPickup ? 'Pickup' : 'Delivery' }}</h2>
+            <el-tag
+              :type="isPickup ? 'success' : ''"
+              size="small"
+              class="ng-guest-order-fulfillment-tag"
+            >{{ isPickup ? 'Self-pickup' : 'Door delivery' }}</el-tag>
+          </div>
+          <div class="ng-guest-order-fulfillment-fields">
+            <div class="ng-guest-order-fulfillment-row ng-guest-order-recipient">
+              <i class="el-icon-user" aria-hidden="true" />
+              <div class="ng-guest-order-fulfillment-content">
+                <span class="ng-guest-order-fulfillment-label">Recipient</span>
+                <strong>{{ order.CONSIGNEE || '—' }}</strong>
+                <p class="ng-guest-order-fulfillment-detail">{{ order.MOBILE || 'No phone on file' }}</p>
+              </div>
+            </div>
+            <div v-if="!isPickup" class="ng-guest-order-fulfillment-row ng-guest-order-address">
+              <i class="el-icon-location-outline" aria-hidden="true" />
+              <div class="ng-guest-order-fulfillment-content">
+                <span class="ng-guest-order-fulfillment-label">Delivery address</span>
+                <strong>{{ order.FULL_ADDRESS || '—' }}</strong>
+                <p class="ng-guest-order-fulfillment-detail">{{ order.COUNTRY || '—' }}</p>
+              </div>
+            </div>
+          </div>
         </ui-section-card>
         <ui-section-card title="Payment">
           <div class="ng-guest-order-payment">
@@ -309,9 +331,74 @@ export default {
 .ng-guest-order-total dt {
   color: inherit;
 }
-.ng-guest-order-address {
+.ng-guest-order-fulfillment-heading {
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+  flex-wrap: wrap;
+  gap: 12px;
+  margin-bottom: 16px;
+}
+.ng-guest-order-fulfillment-title {
+  margin: 0;
+  color: #202259;
+  font-size: 16px;
+  line-height: 1.5;
+}
+.ng-guest-order-fulfillment-tag {
+  flex-shrink: 0;
+  border: 0;
+  border-radius: 999px;
+  color: #00749a;
+  background: #e8f4f8;
+  font-weight: 600;
+}
+.ng-guest-order-fulfillment-tag.el-tag--success {
+  color: #08794f;
+  background: #e9f6ef;
+}
+.ng-guest-order-fulfillment-fields {
+  display: grid;
+  gap: 8px;
+  margin-bottom: 20px;
+}
+.ng-guest-order-fulfillment-row {
+  display: flex;
+  align-items: flex-start;
+  gap: 12px;
+  padding: 14px;
+  border-radius: 8px;
+  background: #f7f8fa;
+}
+.ng-guest-order-fulfillment-row > i {
+  flex-shrink: 0;
+  margin-top: 2px;
+  color: #606266;
+  line-height: 1.5;
+}
+.ng-guest-order-fulfillment-content {
+  min-width: 0;
+  overflow-wrap: anywhere;
+}
+.ng-guest-order-fulfillment-label {
+  display: block;
+  color: #606266;
+  font-size: 12px;
+  line-height: 1.5;
+  letter-spacing: 0.04em;
+  text-transform: uppercase;
+}
+.ng-guest-order-fulfillment-content strong {
+  display: block;
+  margin-top: 4px;
+  color: #303133;
+  line-height: 1.5;
   white-space: pre-line;
 }
+.ng-guest-order-details .ng-guest-order-fulfillment-detail {
+  margin: 4px 0 0;
+  font-size: 13px;
+}
 .ng-guest-order-member-fields {
   margin: 0 0 20px;
 }

+ 4 - 2
src/ui-refactor/views/guest-shop/README.md

@@ -35,9 +35,11 @@
 
 `/guest-order?order=<SN>` 在进入、刷新和订单参数变化时调用匿名详情接口,传 `orderSn`,响应为 `{ order, goods }`。订单号必须与请求一致;加载中清除旧明细,失败可重试,离开页面或更换订单后忽略旧响应。`GuestOrderPage` 管理请求、下载与复制,`GuestOrderDetails` 负责展示;卡片复用 `UiSectionCard`,图片、按钮和状态使用 Element UI。
 
-详情以 `order.CURRENCY / PAY_AMOUNT / ORDER_AMOUNT / PAY_FREIGHT / FREIGHT / STATUS / CREATED_AT / PAY_TYPE / CONSIGNEE / MOBILE / FULL_ADDRESS / COUNTRY` 展示,配送地址缺失时使用已有 `ADDRESS / LGA_NAME / CITY_NAME`,不把 `PROVINCE` 地区 ID 当名称。`goods` 沿用会员订单商品的 `GOODS_TITLE / SKU_CODE / COVER / REAL_PRICE / BUY_NUMS / TAX_RATE`。商品为空显示暂无明细;缺失金额和地址显示 `—`,不会补成零。税额按原含税算法展示,不再次加到接口金额;总额直接取 `PAY_AMOUNT`,缺失时取 `ORDER_AMOUNT`,两者均为已含税金额。支付状态只取详情接口,数字状态不推断为 Paid,前端支付回调和 URL 参数均不能改变状态。
+详情以 `order.CURRENCY / PAY_AMOUNT / ORDER_AMOUNT / PAY_FREIGHT / FREIGHT / STATUS / CREATED_AT / PAY_TYPE / CONSIGNEE / MOBILE / FULL_ADDRESS / COUNTRY` 展示,配送地址直接使用 `FULL_ADDRESS`,不把 `PROVINCE` 地区 ID 当名称。`goods` 沿用会员订单商品的 `GOODS_TITLE / SKU_CODE / COVER / REAL_PRICE / BUY_NUMS / TAX_RATE`。商品为空显示暂无明细;缺失金额和地址显示 `—`,不会补成零。税额按原含税算法展示,不再次加到接口金额;总额直接取 `PAY_AMOUNT`,缺失时取 `ORDER_AMOUNT`,两者均为已含税金额。支付状态只取详情接口,数字状态不推断为 Paid,前端支付回调和 URL 参数均不能改变状态。
 
-2026-10-27 按用户最新确认,订单详情读取现有 `usersInfo.accessToken()`:没有 token 时隐藏全部 BV,有 token 时显示商品 `REAL_PV` 和订单 BV(优先 `PAY_PV`,缺失时 `PV`),不再依赖接口 `SHOW_BV`。展示标识在详情请求完成时读取,重试或切换订单时重新判断;不改认证或 token 存储。Payment 下方始终显示 Member 卡片,包含 Member ID、Name、Placed、Paid、Currency;有 token 时读取 `USER_NAME / REAL_NAME`,否则两个身份字段固定显示 `-`,不把推荐人信息当成游客的会员身份。时间读取 `CREATED_AT / PAY_AT`,未付款且无有效付款时间显示 `Not yet paid`;缺失 BV 显示 `—`,真实零值保留为 `0`。配送卡片标题按 `EXPRESS_TYPE` 判断,数值/字符串 `0` 显示 `Delivery`,`1` 显示 `Self Pick-up`,不再按地址文字推测。
+2026-10-27 按用户最新确认,订单详情读取现有 `usersInfo.accessToken()`:没有 token 时隐藏全部 BV,有 token 时显示商品 `REAL_PV` 和订单 BV(优先 `PAY_PV`,缺失时 `PV`),不再依赖接口 `SHOW_BV`。展示标识在详情请求完成时读取,重试或切换订单时重新判断;不改认证或 token 存储。Payment 下方始终显示 Member 卡片,包含 Member ID、Name、Placed、Paid、Currency;有 token 时读取 `USER_NAME / REAL_NAME`,否则两个身份字段固定显示 `-`,不把推荐人信息当成游客的会员身份。时间读取 `CREATED_AT / PAY_AT`,未付款且无有效付款时间显示 `Not yet paid`;缺失 BV 显示 `—`,真实零值保留为 `0`。
+
+2026-10-28 取货信息按 `EXPRESS_TYPE` 区分,兼容数字与字符串:`0` 显示 `Delivery` 和蓝色 `Door delivery` 标记,收件人、电话和配送地址分组展示;`1` 显示 `Pickup` 和绿色 `Self-pickup` 标记,只显示收件人及电话,不显示地址和国家。不根据地址文字推测取货方式。收件人、电话、地址和国家分别读取 `CONSIGNEE / MOBILE / FULL_ADDRESS / COUNTRY`,缺失电话显示 `No phone on file`,其他缺失信息显示 `—`;不修改接口或订单业务。
 
 复制链接使用当前访问地址和 Vue Router 解析后的路径,自动适配测试/生产域名、部署目录与 Hash 路由;复用既有 clipboard 工具。下载根据现有登录状态选择接口:游客使用 `GET /v1/shop/no-login-order-export/{orderSn}`,已登录使用原 `downloadOrder` 与 `/v1/shop/order-export/{orderSn}`;两者沿用 `fileUrl / targetName` 返回字段。游客调用中的 HTTP 401 留给页面处理,避免会员请求拦截器清缓存并跳回登录;不修改全局拦截器或会员导出方法。下载支持失败重试、阻止重复请求并忽略离开后的响应。不缓存本地订单,不提供邮件发送、物流查询或前端生成收据。
 

+ 1 - 1
src/ui-refactor/views/guest-shop/__tests__/verifyBrowser.cjs

@@ -230,7 +230,7 @@ async function main() {
     assert(!(await page.locator('.ng-guest-order-member').textContent()).includes('Sample member'))
     assert.equal(await page.locator('.ng-guest-order-item-bv').count(), 0)
     assert.equal(await page.locator('.ng-guest-order-bv-total').count(), 0)
-    assert(await page.getByRole('heading', { name: 'Self Pick-up', exact: true }).isVisible())
+    assert(await page.getByRole('heading', { name: 'Pickup', exact: true }).isVisible())
     assert.equal((await page.locator('.ng-guest-order-grand-total strong').textContent()).trim(), 'NGN 130.00')
     await layouts('anonymous-order-with-bv-flag')
     detailMode = 'empty'

+ 31 - 6
tests/unit/ui-refactor/guestShopOrder.spec.js

@@ -411,13 +411,38 @@ it('hides BV after the token is removed and order details are reloaded', async()
 })
 
 it.each([
-  [0, 'Self Pick-up', 'Delivery'], ['0', 'Self Pick-up', 'Delivery'],
-  [1, 'Sample street, Lagos', 'Self Pick-up'], ['1', 'Sample street, Lagos', 'Self Pick-up']
-])('uses EXPRESS_TYPE %s for the delivery title instead of address text', async(type, address, title) => {
+  [0, 'Self Pick-up', false], ['0', 'Self Pick-up', false],
+  [1, 'Sample street, Lagos', true], ['1', 'Sample street, Lagos', true]
+])('uses EXPRESS_TYPE %s for the fulfillment card instead of address text', async(type, address, pickup) => {
   fetchGuestOrderDetail.mockResolvedValue(response({ ...sample, EXPRESS_TYPE: type, FULL_ADDRESS: address }))
   const vm = mount()
   await settle()
-  const titles = Array.from(vm.$el.querySelectorAll('h2'), heading => heading.textContent)
-  expect(titles).toContain(title)
-  expect(titles).not.toContain(title === 'Delivery' ? 'Self Pick-up' : 'Delivery')
+  const card = vm.$el.querySelector('.ng-guest-order-fulfillment')
+  expect(card.querySelector('h2').textContent).toBe(pickup ? 'Pickup' : 'Delivery')
+  const badge = card.querySelector('.el-tag')
+  expect(badge.textContent).toBe(pickup ? 'Self-pickup' : 'Door delivery')
+  expect(badge.classList.contains('el-tag--success')).toBe(pickup)
+  const recipient = card.querySelector('.ng-guest-order-recipient')
+  expect(recipient.textContent).toContain('Recipient')
+  expect(recipient.textContent).toContain(sample.CONSIGNEE)
+  expect(recipient.textContent).toContain(sample.MOBILE)
+  const delivery = card.querySelector('.ng-guest-order-address')
+  if (pickup) {
+    expect(delivery).toBeNull()
+    expect(card.textContent).not.toContain(address)
+    expect(card.textContent).not.toContain(sample.COUNTRY)
+  } else {
+    expect(delivery.textContent).toContain('Delivery address')
+    expect(delivery.textContent).toContain(address)
+    expect(delivery.textContent).toContain(sample.COUNTRY)
+  }
+})
+
+it('shows the no-phone placeholder for pickup without rendering the self-pickup address', async() => {
+  fetchGuestOrderDetail.mockResolvedValue(response({ ...sample, EXPRESS_TYPE: '1', MOBILE: '', FULL_ADDRESS: 'Self Pick-up' }))
+  const vm = mount()
+  await settle()
+  const card = vm.$el.querySelector('.ng-guest-order-fulfillment')
+  expect(card.querySelector('.ng-guest-order-recipient').textContent).toContain('No phone on file')
+  expect(card.querySelector('.ng-guest-order-address')).toBeNull()
 })