diff --git a/packages/app-client/config/dev.ts b/packages/app-client/config/dev.ts index 86edac3..1179e15 100644 --- a/packages/app-client/config/dev.ts +++ b/packages/app-client/config/dev.ts @@ -14,6 +14,10 @@ export default { process.env.TARO_ENV === "h5" ? '"/api"' : '"https://api.erp.qilincloud168.com"', + "process.env.TARO_POSTER_DOMAIN": + process.env.TARO_ENV === "h5" + ? '""' + : '"https://poster.qilincloud168.com"', }, mini: { miniCssExtractPluginOption: { @@ -23,6 +27,11 @@ export default { h5: { devServer: { proxy: { + "/api/v1": { + target: JSON.parse('"https://poster.qilincloud168.com"'), + pathRewrite: { "^/api": "/api" }, + changeOrigin: true, + }, "/api/": { target: JSON.parse('"https://api.erp.qilincloud168.com"'), pathRewrite: { "^/api": "/" }, diff --git a/packages/app-client/src/components/purchase/button/PurchaseOrderWithdrawReview.tsx b/packages/app-client/src/components/purchase/button/PurchaseOrderWithdrawReview.tsx index 6c88ba3..f5bf2a8 100644 --- a/packages/app-client/src/components/purchase/button/PurchaseOrderWithdrawReview.tsx +++ b/packages/app-client/src/components/purchase/button/PurchaseOrderWithdrawReview.tsx @@ -7,7 +7,9 @@ interface IPurchaseOrderWithdrawReviewProps { onFinish?: () => void; } -export default function PurchaseOrderWithdrawReview(props: IPurchaseOrderWithdrawReviewProps) { +export default function PurchaseOrderWithdrawReview( + props: IPurchaseOrderWithdrawReviewProps, +) { const { purchaseOrderVO, size = "normal", onFinish } = props; const onWithdraw = async () => { @@ -24,9 +26,10 @@ export default function PurchaseOrderWithdrawReview(props: IPurchaseOrderWithdra let errMessage = ""; try { if (purchaseOrderVO.orderId) { - const { data } = await business.purchaseOrder.withdrawReviewPurchaseOrder({ - orderId: purchaseOrderVO.orderId, - }); + const { data } = + await business.purchaseOrder.withdrawReviewPurchaseOrder({ + orderId: purchaseOrderVO.orderId, + }); if (data.success) { success = data.success; @@ -65,7 +68,6 @@ export default function PurchaseOrderWithdrawReview(props: IPurchaseOrderWithdra block type={"danger"} size={size} - className="btn-large bg-gray-200 ml-2 flex-1 text-gray-700" onClick={async (e) => { Dialog.open("dialog", { title: "撤回提审提醒", diff --git a/packages/app-client/src/components/purchase/module/OrderPackage.tsx b/packages/app-client/src/components/purchase/module/OrderPackage.tsx index 8dc7667..dc5d5e5 100644 --- a/packages/app-client/src/components/purchase/module/OrderPackage.tsx +++ b/packages/app-client/src/components/purchase/module/OrderPackage.tsx @@ -41,8 +41,6 @@ export default forwardRef( const orderPackageList = value.orderPackageList || []; setOrderPackageList(orderPackageList); - console.log("orderPackageList.length", orderPackageList.length, value) - if (orderPackageList.length > 0) { // 根据当前供应商确定需要检查的纸箱类型 let requiredTypes: string[] = []; @@ -56,8 +54,6 @@ export default forwardRef( requiredTypes = ["OWN", "EXTRA_USED"]; } - console.log("requiredTypes", requiredTypes) - requiredTypes.map((type) => { setPackageTypeEnabled((prev) => { return { @@ -225,6 +221,7 @@ export default forwardRef( boxBrandId: boxBrand.brandId, boxBrandName: boxBrand.name, boxBrandImage: boxBrand.image, + boxBrandType: boxBrand.type, boxCategoryList: boxCategoryList .map((boxCategory) => { @@ -797,34 +794,49 @@ export default forwardRef( 选择品牌 - {boxBrandList?.map((boxBrand) => ( - handleBatchBrandSelect(boxBrand)} - > + {boxBrandList + ?.filter((item) => { + console.log("item: ", item); + console.log("boxType: ", boxType); + if (boxType === "OWN") { + return item.boxBrandType === "FARMER_BOX"; + } else { + return ( + item.boxBrandType === "THIRD_PARTY_BOX" || + item.boxBrandType === "OUR_BOX" + ); + } + }) + ?.map((boxBrand) => ( handleBatchBrandSelect(boxBrand)} > - {boxBrand.boxBrandImage} + + {boxBrand.boxBrandImage} + + + {boxBrand.boxBrandName} + - - {boxBrand.boxBrandName} - - - ))} + ))} diff --git a/packages/app-client/src/components/purchase/module/OrderVehicle.tsx b/packages/app-client/src/components/purchase/module/OrderVehicle.tsx index f9583af..d0a20e7 100644 --- a/packages/app-client/src/components/purchase/module/OrderVehicle.tsx +++ b/packages/app-client/src/components/purchase/module/OrderVehicle.tsx @@ -15,12 +15,16 @@ import dayjs from "dayjs"; import Taro from "@tarojs/taro"; import { business } from "@/services"; import { validatePrice as validatePrice1 } from "@/utils/format"; +import { generateShortId } from "@/utils/generateShortId"; +import { CostItem } from "@/types/typings"; interface IOrderVehicleProps { orderVehicle: BusinessAPI.OrderVehicle; setOrderVehicle: (orderVehicle: BusinessAPI.OrderVehicle) => void; orderDealer: BusinessAPI.OrderDealer; setOrderDealer: (orderDealer: BusinessAPI.OrderDealer) => void; + orderCostList: CostItem[]; + setOrderCostList: (orderCostList: CostItem[]) => void; } export interface OrderVehicleRef { @@ -29,8 +33,14 @@ export interface OrderVehicleRef { export default forwardRef( function OrderVehicle(props, ref) { - const { orderVehicle, setOrderVehicle, setOrderDealer, orderDealer } = - props; + const { + orderVehicle, + setOrderVehicle, + setOrderDealer, + orderDealer, + orderCostList, + setOrderCostList, + } = props; const [dealerVO, setDealerVO] = useState(); const [openStrawCurtain, setOpenStrawCurtain] = useState(false); @@ -56,6 +66,28 @@ export default forwardRef( const startDate = new Date(currentYear, 0, 1); // 当年第一天 const endDate = new Date(); // 今天 + // 费用项目列表 + const [costItems, setCostItems] = useState([]); + + // 获取费用项目列表 + useEffect(() => { + const fetchCostItems = async () => { + try { + const { data } = await business.costItem.listCostItem({ + costItemListQry: { + status: true, + showInEntry: true, + }, + }); + setCostItems(data.data || []); + } catch (error) { + console.error("获取费用项目列表失败:", error); + } + }; + + fetchCostItems(); + }, []); + // 当desc改变时更新车辆信息中的时间 useEffect(() => { if (desc) { @@ -394,6 +426,17 @@ export default forwardRef( } }; + const getCostItemByName = (name: string): BusinessAPI.CostItemVO => { + return costItems?.find( + (item) => item.name === name && item.costType === "PRODUCTION_ADVANCE", + )!; + }; + const getOrderCostByName = (name: string): CostItem => { + return orderCostList?.find( + (item) => item.name === name && item.costType === "PRODUCTION_ADVANCE", + )!; + }; + const handleStrawCurtainPriceChange = (value: string) => { const numValue = validatePrice1(value); if (numValue !== undefined) { @@ -402,6 +445,38 @@ export default forwardRef( strawCurtainPrice: numValue as any, }); + const strawCurtainCostItem = getOrderCostByName("草帘"); + + if (!strawCurtainCostItem) { + Toast.show("toast", { + icon: "fail", + content: "请联系管理员,先添加草帘费用项", + }); + + return; + } + + // 创建草帘费用项 + setOrderCostList([ + ...(orderCostList.filter( + (item) => + !(item.name === "草帘" && item.costType === "PRODUCTION_ADVANCE"), + ) || []), + { + orderCostId: generateShortId(), + itemId: strawCurtainCostItem?.itemId, + name: strawCurtainCostItem?.name, + price: numValue as number, + unit: strawCurtainCostItem?.unit, + count: 1, + costType: "PRODUCTION_ADVANCE", + payerType: "US", + requireQuantityAndPrice: + strawCurtainCostItem?.requireQuantityAndPrice || false, + selected: true, + }, + ]); + // 校验草帘费用并更新错误状态 const isValid = validatePrice(value); setStrawCurtainPriceError(!isValid && value !== ""); @@ -744,8 +819,56 @@ export default forwardRef( { + if (checked) { + // 从费用项目列表中查找草帘费用项 + const strawCurtainCostItem = getCostItemByName("草帘"); + + if (!strawCurtainCostItem) { + Toast.show("toast", { + icon: "fail", + content: "请联系管理员,先添加草帘费用项", + duration: 3000, + }); + + return; + } + + // 创建草帘费用项 + setOrderCostList([ + ...(orderCostList || []), + { + orderCostId: generateShortId(), + itemId: strawCurtainCostItem?.itemId, + name: strawCurtainCostItem?.name, + price: 0, + unit: strawCurtainCostItem?.unit, + count: 1, + costType: "PRODUCTION_ADVANCE", + payerType: "US", + requireQuantityAndPrice: + strawCurtainCostItem?.requireQuantityAndPrice || + false, + selected: true, + }, + ]); + } else { + // 如果关闭了草帘选项,则移除草帘费用项 + setOrderCostList( + orderCostList?.filter( + (item) => + item.costType === "PRODUCTION_ADVANCE" && + item.name === "草帘", + ), + ); + } + setOpenStrawCurtain(checked); + setOrderVehicle({ + ...orderVehicle, + openStrawCurtain: checked, + }); }} > diff --git a/packages/app-client/src/components/purchase/module/Weigh.tsx b/packages/app-client/src/components/purchase/module/Weigh.tsx index b429372..5948e2c 100644 --- a/packages/app-client/src/components/purchase/module/Weigh.tsx +++ b/packages/app-client/src/components/purchase/module/Weigh.tsx @@ -1,11 +1,13 @@ import { View } from "@tarojs/components"; import { + Button, Input, + Popup, Radio, + SafeArea, Toast, Uploader, UploaderFileItem, - Popup, } from "@nutui/nutui-react-taro"; import { Icon } from "@/components"; import { SupplierVO } from "@/types/typings"; @@ -324,15 +326,13 @@ export default forwardRef(function Weigh(props, ref) { visible={productPopupVisible} position="bottom" title="请选择具体品种" + description={"请选择具体品种,选择其他时请注明"} onClose={() => setProductPopupVisible(false)} round closeable > - - - - 请选择具体品种 - + + {productList.map((product) => ( (function Weigh(props, ref) { ))} {selectedProduct === "其他(请注明)" && ( - - - { - setCustomProduct(value); - }} - /> - + + { + setCustomProduct(value); + }} + /> )} - - + + + + + {isFirst && ( diff --git a/packages/app-client/src/components/purchase/section/PackagingCostSection.tsx b/packages/app-client/src/components/purchase/section/PackagingCostSection.tsx index 0c25192..b645c6f 100644 --- a/packages/app-client/src/components/purchase/section/PackagingCostSection.tsx +++ b/packages/app-client/src/components/purchase/section/PackagingCostSection.tsx @@ -135,6 +135,7 @@ export default function PackagingCostSection(props: { count: 1, unit: "项", payerType: "US", + requireQuantityAndPrice: false, }; // 更新purchaseOrderVO,添加默认计提费 diff --git a/packages/app-client/src/pages/delivery/document/delivery.tsx b/packages/app-client/src/pages/delivery/document/delivery.tsx index e55a8a3..158ff68 100644 --- a/packages/app-client/src/pages/delivery/document/delivery.tsx +++ b/packages/app-client/src/pages/delivery/document/delivery.tsx @@ -16,10 +16,59 @@ import { import shipOrder from "@/constant/shipOrder"; import Taro from "@tarojs/taro"; import classNames from "classnames"; -import { business } from "@/services"; +import { business, poster } from "@/services"; import dayjs from "dayjs"; import buildUrl from "@/utils/buildUrl"; +// 特殊处理:其他费用要实时获取费用项目 +const updateOtherFeesModule = async ( + module: any, + shipOrderVO: BusinessAPI.ShipOrderVO, +) => { + const { + data: { data }, + } = await business.costItem.listCostItem({ + costItemListQry: { + status: true, + }, + }); + const costItems = + data?.filter((item) => item.costType !== "HUMAN_COST") || []; + + console.log("module", module); + + return { + ...module, + config: { + ...module.config, + feeItems: shipOrderVO.orderCostList?.filter( + (item) => item.costType !== "HUMAN_COST", + ), + feeLabels: costItems.reduce((acc: any, item: any) => { + acc[item.itemId] = item.name; + return acc; + }, {}), + }, + schemas: [ + { + title: "显示配置", + valueType: "group", + columns: [ + { + dataIndex: "feeItems", + title: "显示费用项目", + valueType: "checkbox", + valueEnum: costItems.reduce((acc: any, item: any) => { + acc[item.itemId] = item.name; + return acc; + }, {}), + }, + ], + }, + ], + }; +}; + export default hocAuth(function Page(props: CommonComponent) { const { router, setLoading } = props; const shipOrderId = router.params @@ -93,7 +142,8 @@ export default hocAuth(function Page(props: CommonComponent) { }, }); - setDeliveryTemplate(data.data?.deliveryTemplate!); + const deliveryTemplate = data.data?.deliveryTemplate!; + setDeliveryTemplate(deliveryTemplate); } setLoading(false); }; @@ -104,13 +154,25 @@ export default hocAuth(function Page(props: CommonComponent) { } }, [shipOrderId]); + const refresh = async ( + deliveryTemplate: string, + shipOrderVO: BusinessAPI.ShipOrderVO, + ) => { + const template = JSON.parse(deliveryTemplate); + // 将 shipOrderVO 转换为 examples 的数据格式,然后再替换 moduleList 里面的 config 数据 + const convertedData = convertShipOrderVOToExamplesFormat(shipOrderVO); + const updatedTemplate = await updateTemplateConfig( + template, + convertedData, + shipOrderVO, + ); + console.log("updatedTemplate", updatedTemplate); + setModuleList(updatedTemplate); + }; + useEffect(() => { if (deliveryTemplate && shipOrderVO) { - const template = JSON.parse(deliveryTemplate); - // 将 shipOrderVO 转换为 examples 的数据格式,然后再替换 moduleList 里面的 config 数据 - const convertedData = convertShipOrderVOToExamplesFormat(shipOrderVO); - const updatedTemplate = updateTemplateConfig(template, convertedData); - setModuleList(updatedTemplate); + refresh(deliveryTemplate, shipOrderVO).then(); } }, [shipOrderVO, deliveryTemplate]); @@ -170,36 +232,46 @@ export default hocAuth(function Page(props: CommonComponent) { strawMatDebt: shipOrderVO.strawMatDebt?.toString() || "", remarks: shipOrderVO.remark || "", }, - otherFees: { - trademark: shipOrderVO.trademarkFee?.toString() || "", - labor: shipOrderVO.laborFee?.toString() || "", - paperBox: shipOrderVO.cartonFee?.toString() || "", - fee: shipOrderVO.provisionFee?.toString() || "", - codingFee: shipOrderVO.codingFee?.toString() || "", - }, + otherFees: {}, totalAmount: { amount: shipOrderVO.totalAmount?.toString() || "", farmer: shipOrderVO.farmerInfo || "", }, otherInfo: { - origin: "", - supplier: "", - departureTime: "", - arrivalTime: "", - productName: "", + data: shipOrderVO.shipOrderItemList, + driverPhone: shipOrderVO?.driverPhone || "", + licensePlate: shipOrderVO.licensePlate || "", + accountCompany: shipOrderVO.companyName || "", + vehicleNumber: `第 ${shipOrderVO.vehicleNo || ""} 车`, + destination: shipOrderVO.receivingAddress || "", + shippingFrom: shipOrderVO.shippingAddress || "", + estimatedArrivalTime: shipOrderVO.estimatedArrivalDate + ? dayjs(shipOrderVO?.estimatedArrivalDate).format("YYYY年MM月DD日") + : "1", }, }; }; // 更新模板配置 - const updateTemplateConfig = (template: any[], data: any) => { - return template.map((module: any) => { - const newModule = { ...module }; + const updateTemplateConfig = async ( + template: any[], + data: any, + shipOrderVO: BusinessAPI.ShipOrderVO, + ) => { + let templateList: any[] = []; + template.map(async (module: any) => { + let newModule = { ...module }; if (data[module.type]) { newModule.config = { ...module.config, ...data[module.type] }; } - return newModule; + // 特殊处理: otherFees 要更新为最新的数据 + if (module.type === "otherFees") { + newModule = await updateOtherFeesModule(module, shipOrderVO); + } + templateList.push(newModule); }); + + return templateList; }; // 渲染内容配置表单字段 @@ -759,7 +831,7 @@ export default hocAuth(function Page(props: CommonComponent) { // 将预览内容转换为HTML字符串的函数 const generateHtmlString = () => { let htmlString = ` - +
`; @@ -1229,28 +1301,141 @@ export default hocAuth(function Page(props: CommonComponent) { if (module.type === "otherInfo") { htmlString += ` -
-
产地:
-
- ${config.origin || ""} +
+
+
车次:
+
+ ${config.vehicleNumber} +
-
供应商:
-
- ${config.supplier || ""} +
+
+ 收货地: +
+
+ ${config.destination} +
-
发车时间:
-
- ${config.departureTime || ""} + `; + + if (config.showShippingFrom) { + htmlString += ` +
+
+ 产地: +
+
+ ${config.shippingFrom} +
-
到达时间:
-
- ${config.arrivalTime || ""} + `; + } + + htmlString += `
+
+ 供应商: +
+
+ ${config.accountCompany} +
+
+
+
+ 发车时间: +
+
+ ${config.date} +
+
+ `; + + if (config.showEstimatedArrivalTime) { + htmlString += `
+
+ 到达时间:
-
产品名称:
-
- ${config.productName || ""} +
+ ${config.estimatedArrivalTime}
+ `; + } + + if (config.data) { + config.data?.forEach((item: any) => { + if (config.showGrade) { + htmlString += ` +
+
+ 品名: +
+
+ ${item.watermelonGrade} +
+
+ `; + } + + htmlString += ` +
+
+ 发货重量: +
+
+ 以公司入库重量为准。 +
+
+
+
+ 净瓜单价: +
+
+ ${item.unitPrice} + ${config.unitPriceUnit === "1" ? "元/斤" : "元/公斤"} +
+
+ `; + }); + } + + htmlString += ` +
+
+ 大约重量: +
+
+ ${config.data?.reduce( + (acc: any, cur: any) => acc + cur.grossWeight, + 0, + )} +
+
+
+
+
箱数
+
+ ${config.data?.reduce( + (acc: any, cur: any) => acc + cur.boxCount, + 0, + )} +
+
+
+
+
车号:
+
+ ${config.licensePlate} +
+
+
+
+ 手机号: +
+
+ ${config.driverPhone} +
+
+
`; } }); @@ -1262,23 +1447,16 @@ export default hocAuth(function Page(props: CommonComponent) { // 截图预览内容 const capturePreview = async () => { // 请求 poster.qilincloud168.com/api/v1/pdfs 接口 请求参数是 html 内容 的json 格式响应结果为 - // 调用API生成PDF - const { data } = await Taro.request({ - url: "https://poster.qilincloud168.com/api/v1/pdf", - method: "POST", - header: { - "content-type": "application/json", - }, - data: { - html: generateHtmlString(), - }, + console.log("generateHtmlString", generateHtmlString()); + const { data } = await poster.pdf.postApiV1Pdf({ + html: generateHtmlString(), }); // 存储 至 shipOrder previewUrl if (shipOrderVO) { let formData: BusinessAPI.ShipOrderGenerateDocumentCmd = { shipOrderId: shipOrderVO?.shipOrderId, - shipDocument: data.path, + shipDocument: data?.data?.path, }; // 检查各模块中的必填字段是否已填写 for (const module of moduleList) { @@ -1320,8 +1498,8 @@ export default hocAuth(function Page(props: CommonComponent) { business.shipOrder.generateDocumentShipOrder(formData).then(); } - if (data && data.path) { - setShipDocument(data.path); + if (data && data?.data?.path) { + setShipDocument(data?.data?.path); } }; @@ -2153,10 +2331,10 @@ export default hocAuth(function Page(props: CommonComponent) { {config.feeItems?.map((feeType: any) => ( <> - {config.feeLabels[feeType]}: + {config.feeLabels[feeType.itemId]}: - {config[feeType]}元 + {feeType.count * feeType.price}元 ))} @@ -2201,41 +2379,128 @@ export default hocAuth(function Page(props: CommonComponent) { if (module.type === "otherInfo") { return ( - - - 产地: + + + 车次: + + {config.vehicleNumber} + - - {config.origin} + + + 收货地: + + + {config.destination} + - - 供应商: + {config.showShippingFrom && ( + + + 产地: + + + {config.shippingFrom} + + + )} + + + 供应商: + + + {config.accountCompany} + - - {config.supplier} + + + 发车时间: + + + {config.date} + - - 发车时间: + {config.showEstimatedArrivalTime && ( + + + 到达时间: + + + {config.estimatedArrivalTime} + + + )} + {config.data?.map((item: any) => { + return ( + <> + {config.showGrade && ( + + + 品名: + + + {item.watermelonGrade} + + + )} + + + 发货重量: + + + 以公司入库重量为准。 + + + + + 净瓜单价: + + + {item.unitPrice} + {config.unitPriceUnit === "1" + ? "元/斤" + : "元/公斤"} + + + + ); + })} + + + + 大约重量: + + + {config.data?.reduce( + (acc: any, cur: any) => acc + cur.grossWeight, + 0, + )} + + - - {config.departureTime} + + 箱数 + + {config.data?.reduce( + (acc: any, cur: any) => acc + cur.boxCount, + 0, + )} + + - - 到达时间: + + 车号: + + {config.licensePlate} + - - {config.arrivalTime} - - - 产品名称: - - - {config.productName} + + + 手机号: + + + {config.driverPhone} + ); diff --git a/packages/app-client/src/pages/purchase/purchaser/create.tsx b/packages/app-client/src/pages/purchase/purchaser/create.tsx index 5765b41..db6d52d 100644 --- a/packages/app-client/src/pages/purchase/purchaser/create.tsx +++ b/packages/app-client/src/pages/purchase/purchaser/create.tsx @@ -278,6 +278,7 @@ export default hocAuth(function Page(props: CommonComponent) { active: active, orderVehicle: purchaseOrder.orderVehicle, orderDealer: purchaseOrder.orderDealer, + orderCostList: purchaseOrder.orderCostList, }); if (data.success) { @@ -295,6 +296,7 @@ export default hocAuth(function Page(props: CommonComponent) { active: active, orderVehicle: purchaseOrder.orderVehicle, orderDealer: purchaseOrder.orderDealer, + orderCostList: purchaseOrder.orderCostList, }); if (data.success) { @@ -547,6 +549,10 @@ export default hocAuth(function Page(props: CommonComponent) { setOrderVehicle={setOrderVehicle} orderDealer={orderDealer!} setOrderDealer={setOrderDealer} + orderCostList={orderCostList} + setOrderCostList={(costItemList: CostItem[]) => { + setOrderCostList(costItemList); + }} /> )} diff --git a/packages/app-client/src/services/business/typings.d.ts b/packages/app-client/src/services/business/typings.d.ts index 9f69c0c..6a5a70a 100644 --- a/packages/app-client/src/services/business/typings.d.ts +++ b/packages/app-client/src/services/business/typings.d.ts @@ -3315,6 +3315,8 @@ declare namespace BusinessAPI { orderVehicle: OrderVehicle; /** 经销商信息 */ orderDealer: OrderDealer; + /** 采购订单费用信息 */ + orderCostList: OrderCost[]; }; type PurchaseOrderStep2Cmd = { @@ -3724,6 +3726,8 @@ declare namespace BusinessAPI { grossWeight?: number; /** 箱重(斤) */ boxWeight?: number; + /** 箱数 */ + boxCount?: number; /** 净重(斤) */ netWeight?: number; /** 单价(元) */ @@ -3917,6 +3921,8 @@ declare namespace BusinessAPI { shipOrderItemList?: ShipOrderItem[]; /** 发货单子项表 */ shipOrderPackageList?: ShipOrderPackage[]; + /** 发货单费用项 */ + orderCostList?: OrderCost[]; }; type showAgreementParams = { diff --git a/packages/app-client/src/services/index.ts b/packages/app-client/src/services/index.ts index 85f08d0..a52962c 100644 --- a/packages/app-client/src/services/index.ts +++ b/packages/app-client/src/services/index.ts @@ -1,2 +1,3 @@ export { default as auth } from "./auth"; export { default as business } from "./business"; +export { default as poster } from "./poster"; diff --git a/packages/app-client/src/services/poster-request.ts b/packages/app-client/src/services/poster-request.ts index 6a51a89..56cb2a3 100644 --- a/packages/app-client/src/services/poster-request.ts +++ b/packages/app-client/src/services/poster-request.ts @@ -1,25 +1,13 @@ import axios from "axios"; -import Taro from "@tarojs/taro"; -import { Toast } from "@nutui/nutui-react-taro"; const request = axios.create({ - baseURL: process.env.TARO_API_DOMAIN, + baseURL: process.env.TARO_POSTER_DOMAIN, }); // 创建全局的axios实例,并安装请求拦截器 request.interceptors.request.use( (config) => { - // 在发送请求之前做些什么 - const saToken = Taro.getStorageSync("saToken"); - if (saToken) { - config.headers.saToken = saToken; - } - - const slug = Taro.getStorageSync("userRoleVO")?.slug; - if (slug) { - config.headers["Xh-Role-Slug"] = slug; - } - + config.headers["Authorization"] = "Bearer abc123"; return config; }, (error) => { @@ -28,80 +16,4 @@ request.interceptors.request.use( }, ); -// 在获取到响应后,安装响应拦截器 -request.interceptors.response.use( - async (response) => { - console.log("response", response); - const { - data: { success, data }, - } = response; - // 处理响应成功的情况 - if (success) { - const saToken = data?.meta?.accessToken; - if (saToken) { - Taro.setStorageSync("saToken", saToken); - Taro.setStorageSync("user", data.userVO); - Taro.setStorageSync("userRoleVO", data.userRoleVOList?.[0]); - } - } else { - // 异常处理 - if (response.data.errCode === "403") { - Toast.show("toast", { - icon: "fail", - title: "暂无权限", - content: response.data.errMessage, - }); - } - - // 如果是401则重新登录,然后重新发起请求 - if (response.data.errCode === "401") { - // 移除缓存 - Taro.removeStorageSync("saToken"); - Taro.removeStorageSync("user"); - Taro.removeStorageSync("userRoleVO"); - // const { code } = await Taro.login(); - // const data = await wxMaLogin(code); - // if (data) { - // response.config.headers.saToken = `${Taro.getStorageSync("saToken")}`; - // return request(response.config); - // } - // 跳转到登录页面 - Taro.navigateTo({ - url: "/pages/public/login/index", - }); - return response; - } - - console.log("response.data.errCode", response.data.errCode); - if (response.data.errCode === "400") { - Toast.show("toast", { - icon: "fail", - title: "请求失败", - content: response.data.errMessage, - }); - } - - if (response.data.errCode === "500") { - Toast.show("toast", { - icon: "fail", - title: "服务器错误", - content: response.data.errMessage, - }); - } else { - Toast.show("toast", { - icon: "fail", - title: "请求失败", - content: response.data.errMessage, - }); - } - } - - return response; - }, - (error) => { - // 处理响应错误的情况 - return Promise.reject(error); - }, -); - export default request; diff --git a/packages/app-client/src/types/typings.ts b/packages/app-client/src/types/typings.ts index 0b077a1..d22dbb8 100644 --- a/packages/app-client/src/types/typings.ts +++ b/packages/app-client/src/types/typings.ts @@ -33,6 +33,7 @@ export interface BoxBrand { boxBrandId: string; boxBrandName: string; boxBrandImage: string; + boxBrandType: "OUR_BOX" | "FARMER_BOX" | "THIRD_PARTY_BOX"; boxType: "USED" | "EXTRA" | "EXTRA_USED" | "REMAIN" | "OWN" | "DEFAULT"; boxCategoryList: BoxCategory[]; }