Commit 424962a8 authored by Lily Wang's avatar Lily Wang

updateupdate

parent 6dac75af
...@@ -4,4 +4,6 @@ VITE_STREAMS_TYPE=ticket ...@@ -4,4 +4,6 @@ VITE_STREAMS_TYPE=ticket
VITE_STREAMS_TICKET=cydz5uLSWULm1gu5ACUWEXor1mrrBzr0 VITE_STREAMS_TICKET=cydz5uLSWULm1gu5ACUWEXor1mrrBzr0
VITE_MIDDLE_QUERY_DEVIATION_PATH=/client/salesforce/call/DeviationAgreementService VITE_MIDDLE_QUERY_DEVIATION_PATH=/client/salesforce/call/DeviationAgreementService
VITE_MIDDLE_CREATE_DEVIATION_PATH=/client/salesforce/call/DeviationAgreementService VITE_MIDDLE_CREATE_DEVIATION_PATH=/client/salesforce/call/DeviationAgreementService
VITE_MIDDLE_TERMS_PATH=/record/query
VITE_MIDDLE_TERMS_PAGE_SIZE=20
VITE_USE_MOCK=false VITE_USE_MOCK=false
...@@ -5,4 +5,6 @@ VITE_STREAMS_TYPE=ticket ...@@ -5,4 +5,6 @@ VITE_STREAMS_TYPE=ticket
VITE_STREAMS_TICKET=ODJuvaIno8PUnnHhCCZSuFpJVD7ZJCJh VITE_STREAMS_TICKET=ODJuvaIno8PUnnHhCCZSuFpJVD7ZJCJh
VITE_MIDDLE_QUERY_DEVIATION_PATH=/client/salesforce/call/DeviationAgreementService VITE_MIDDLE_QUERY_DEVIATION_PATH=/client/salesforce/call/DeviationAgreementService
VITE_MIDDLE_CREATE_DEVIATION_PATH=/client/salesforce/call/DeviationAgreementService VITE_MIDDLE_CREATE_DEVIATION_PATH=/client/salesforce/call/DeviationAgreementService
VITE_MIDDLE_TERMS_PATH=/record/query
VITE_MIDDLE_TERMS_PAGE_SIZE=20
VITE_USE_MOCK=false VITE_USE_MOCK=false
...@@ -5,4 +5,6 @@ VITE_STREAMS_TYPE=ticket ...@@ -5,4 +5,6 @@ VITE_STREAMS_TYPE=ticket
VITE_STREAMS_TICKET=ODJuvaIno8PUnnHhCCZSuFpJVD7ZJCJh VITE_STREAMS_TICKET=ODJuvaIno8PUnnHhCCZSuFpJVD7ZJCJh
VITE_MIDDLE_QUERY_DEVIATION_PATH=/client/salesforce/call/DeviationAgreementService VITE_MIDDLE_QUERY_DEVIATION_PATH=/client/salesforce/call/DeviationAgreementService
VITE_MIDDLE_CREATE_DEVIATION_PATH=/client/salesforce/call/DeviationAgreementService VITE_MIDDLE_CREATE_DEVIATION_PATH=/client/salesforce/call/DeviationAgreementService
VITE_MIDDLE_TERMS_PATH=/record/query
VITE_MIDDLE_TERMS_PAGE_SIZE=20
VITE_USE_MOCK=false VITE_USE_MOCK=false
...@@ -5,4 +5,6 @@ VITE_STREAMS_TYPE=ticket ...@@ -5,4 +5,6 @@ VITE_STREAMS_TYPE=ticket
VITE_STREAMS_TICKET=cydz5uLSWULm1gu5ACUWEXor1mrrBzr0 VITE_STREAMS_TICKET=cydz5uLSWULm1gu5ACUWEXor1mrrBzr0
VITE_MIDDLE_QUERY_DEVIATION_PATH=/client/salesforce/call/DeviationAgreementService VITE_MIDDLE_QUERY_DEVIATION_PATH=/client/salesforce/call/DeviationAgreementService
VITE_MIDDLE_CREATE_DEVIATION_PATH=/client/salesforce/call/DeviationAgreementService VITE_MIDDLE_CREATE_DEVIATION_PATH=/client/salesforce/call/DeviationAgreementService
VITE_MIDDLE_TERMS_PATH=/record/query
VITE_MIDDLE_TERMS_PAGE_SIZE=20
VITE_USE_MOCK=false VITE_USE_MOCK=false
...@@ -32,6 +32,23 @@ npm run dev:production ...@@ -32,6 +32,23 @@ npm run dev:production
- `GET /client/salesforce/call/DeviationAgreementService?PassengerID=xxx` - `GET /client/salesforce/call/DeviationAgreementService?PassengerID=xxx`
- `POST /client/salesforce/call/DeviationAgreementService` - `POST /client/salesforce/call/DeviationAgreementService`
补偿条款接口:
- `POST /record/query`
请求体:
```json
{
"subject": "deviation",
"page": 0,
"page_size": 20,
"filter": {},
"full": false,
"select": null
}
```
本地开发时 Vite 会把 `/api2` 代理到测试中台;生产环境默认使用 `https://streams.vikingcruises.cn/api/`。 本地开发时 Vite 会把 `/api2` 代理到测试中台;生产环境默认使用 `https://streams.vikingcruises.cn/api/`。
## 打包部署 ## 打包部署
......
{ {
"scripts": { "scripts": {
"dev": "vite --host 0.0.0.0 --port 5173 --strictPort", "dev": "vite --host 0.0.0.0 --port 5173",
"dev:development": "vite --mode development --host 0.0.0.0 --port 5173 --strictPort", "dev:development": "vite --mode development --host 0.0.0.0 --port 5173",
"dev:staging": "vite --mode staging --host 0.0.0.0 --port 5173 --strictPort", "dev:staging": "vite --mode staging --host 0.0.0.0 --port 5173",
"dev:production": "vite --mode production --host 0.0.0.0 --port 5173 --strictPort", "dev:production": "vite --mode production --host 0.0.0.0 --port 5173",
"build": "vite build", "build": "vite build",
"build:staging": "vite build --mode staging", "build:staging": "vite build --mode staging",
"build:production": "vite build --mode production", "build:production": "vite build --mode production",
......
...@@ -2,6 +2,7 @@ import { useEffect, useMemo, useState } from 'react'; ...@@ -2,6 +2,7 @@ import { useEffect, useMemo, useState } from 'react';
import { import {
createDeviationService, createDeviationService,
fetchDeviationPageData, fetchDeviationPageData,
fetchDeviationTerms,
sendSmsCode, sendSmsCode,
useMock, useMock,
verifySmsCode, verifySmsCode,
...@@ -126,9 +127,16 @@ export default function App() { ...@@ -126,9 +127,16 @@ export default function App() {
} }
const passengerId = getPassengerId(); const passengerId = getPassengerId();
const { order: nextOrder, terms: nextTerms } = passengerId if (!passengerId) {
? await fetchDeviationPageData(passengerId) setOrder(null);
: { order: null, terms: [] }; setTerms([]);
return;
}
const [{ order: nextOrder }, nextTerms] = await Promise.all([
fetchDeviationPageData(passengerId),
fetchDeviationTerms(),
]);
if (!active) { if (!active) {
return; return;
......
...@@ -2,6 +2,7 @@ import { get as middleGet, post as middlePost } from './streamsRequest.js'; ...@@ -2,6 +2,7 @@ import { get as middleGet, post as middlePost } from './streamsRequest.js';
const messageBaseUrl = import.meta.env.VITE_MESSAGE_BASE_URL || 'https://api.cmviking.com/message'; const messageBaseUrl = import.meta.env.VITE_MESSAGE_BASE_URL || 'https://api.cmviking.com/message';
const middleDeviationPath = '/client/salesforce/call/DeviationAgreementService'; const middleDeviationPath = '/client/salesforce/call/DeviationAgreementService';
const middleTermsPath = import.meta.env.VITE_MIDDLE_TERMS_PATH || '/record/query';
const middleQueryDeviationPath = const middleQueryDeviationPath =
import.meta.env.VITE_MIDDLE_QUERY_DEVIATION_PATH || middleDeviationPath; import.meta.env.VITE_MIDDLE_QUERY_DEVIATION_PATH || middleDeviationPath;
const middleCreateDeviationPath = const middleCreateDeviationPath =
...@@ -26,25 +27,82 @@ async function parseJson(response) { ...@@ -26,25 +27,82 @@ async function parseJson(response) {
function normalizeDeviationPayload(payload) { function normalizeDeviationPayload(payload) {
const data = payload?.data || payload || {}; const data = payload?.data || payload || {};
const order = data.itinerary || data.order || data; const order = data.itinerary || data.order || data;
const terms =
data.terms ||
data.deviation_terms ||
data.deviationTerms ||
payload?.terms ||
payload?.deviation_terms ||
[];
return { return {
order, order,
terms: Array.isArray(terms) ? terms : [], terms: normalizeDeviationTerms(payload),
};
}
function parseRecordData(record) {
const rawData = record?.data || record?.fields || record?.value || {};
if (typeof rawData === 'string') {
try {
return JSON.parse(rawData);
} catch (error) {
return {};
}
}
return rawData && typeof rawData === 'object' ? rawData : {};
}
function normalizeTermRecord(record) {
const data = parseRecordData(record);
return {
code: record?.code || data.code || record?.slug || data.slug || '',
desc: record?.desc || data.desc || record?.description || data.description || '',
content:
record?.content ||
data.content ||
record?.post_content ||
data.post_content ||
record?.html ||
data.html ||
'',
}; };
} }
function normalizeDeviationTerms(payload) {
const data = payload?.data || payload || {};
const records =
data.records ||
data.list ||
data.items ||
data.rows ||
data.data ||
payload?.records ||
payload?.terms ||
payload?.deviation_terms ||
[];
if (!Array.isArray(records)) {
return [];
}
return records.map(normalizeTermRecord).filter((item) => item.code);
}
export async function fetchDeviationPageData(passengerId) { export async function fetchDeviationPageData(passengerId) {
const payload = await middleGet(middleQueryDeviationPath, { PassengerID: passengerId }); const payload = await middleGet(middleQueryDeviationPath, { PassengerID: passengerId });
return normalizeDeviationPayload(payload); return normalizeDeviationPayload(payload);
} }
export async function fetchDeviationTerms() {
const payload = await middlePost(middleTermsPath, {
subject: 'deviation',
page: 0,
page_size: Number(import.meta.env.VITE_MIDDLE_TERMS_PAGE_SIZE || 20),
filter: {},
full: false,
select: null,
});
return normalizeDeviationTerms(payload);
}
export async function sendSmsCode(mobile) { export async function sendSmsCode(mobile) {
const response = await fetch(`${messageBaseUrl}/send-sms-code`, { const response = await fetch(`${messageBaseUrl}/send-sms-code`, {
method: 'POST', method: 'POST',
......
...@@ -32,3 +32,6 @@ ...@@ -32,3 +32,6 @@
11:42:55 [vite] (client) page reload index.html 11:42:55 [vite] (client) page reload index.html
11:42:59 [vite] .env.development changed, restarting server... 11:42:59 [vite] .env.development changed, restarting server...
11:42:59 [vite] server restarted. 11:42:59 [vite] server restarted.
12:09:27 [vite] .env.development changed, restarting server...
12:09:27 [vite] (client) Re-optimizing dependencies because vite config has changed
12:09:27 [vite] server restarted.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment