diff --git a/package.json b/package.json index 3909b32..c422e57 100644 --- a/package.json +++ b/package.json @@ -62,6 +62,7 @@ "pinia": "2.0.33", "pinia-plugin-persistedstate": "^3.2.1", "postcss-pxtorem": "^6.0.0", + "underscore": "^1.13.6", "unplugin-auto-import": "^0.17.3", "uview-plus": "^3.1.41", "vue": "^3.2.45", @@ -74,6 +75,7 @@ "@dcloudio/uni-stacktracey": "3.0.0-3081220230817001", "@dcloudio/vite-plugin-uni": "3.0.0-3081220230817001", "@types/node": "^20.11.22", + "@types/underscore": "^1.11.15", "@types/wechat-miniprogram": "^3.4.7", "@uni-helper/uni-app-types": "^0.5.12", "@uni-helper/uni-ui-types": "^0.5.11", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 54f5a11..6c12d38 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -74,6 +74,9 @@ dependencies: postcss-pxtorem: specifier: ^6.0.0 version: 6.1.0(postcss@8.4.35) + underscore: + specifier: ^1.13.6 + version: 1.13.6 unplugin-auto-import: specifier: ^0.17.3 version: 0.17.5 @@ -106,6 +109,9 @@ devDependencies: '@types/node': specifier: ^20.11.22 version: 20.11.22 + '@types/underscore': + specifier: ^1.11.15 + version: 1.11.15 '@types/wechat-miniprogram': specifier: ^3.4.7 version: 3.4.7 @@ -3095,6 +3101,10 @@ packages: resolution: {integrity: sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==} dev: true + /@types/underscore@1.11.15: + resolution: {integrity: sha512-HP38xE+GuWGlbSRq9WrZkousaQ7dragtZCruBVMi0oX1migFZavZ3OROKHSkNp/9ouq82zrWtZpg18jFnVN96g==} + dev: true + /@types/wechat-miniprogram@3.4.7: resolution: {integrity: sha512-X6SVOOaTPQN24lYBSV5jLuWyIedx8DGJnT0VUBnoNzJruhxotCL28ecGb7AO5JfXOXtHqSS5+CnJ70NxFxmisA==} dev: true @@ -6784,6 +6794,10 @@ packages: resolution: {integrity: sha512-Hhy+BhRBleFjpJ2vchUNN40qgkh0366FWJGqVLYBHev0vpHTrXSA0ryT+74UiW6KWsldNurQMKGqCm1M2zBciQ==} dev: false + /underscore@1.13.6: + resolution: {integrity: sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A==} + dev: false + /undici-types@5.26.5: resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..02ed328 --- /dev/null +++ b/readme.md @@ -0,0 +1,7 @@ +## 获取接口字段 +``` +let c = a.data[22].requestBody.jsonSchema.properties +for (let i = 0; i < Object.keys(c).length; i++) { + console.log(Object.keys(c)[i], + ':',c[Object.keys(c)[i]].type + '; //' + c[Object.keys(c)[i]].description ) +} +``` \ No newline at end of file diff --git a/src/components/Modal/smallModal.vue b/src/components/Modal/smallModal.vue index b92b8d4..38789ef 100644 --- a/src/components/Modal/smallModal.vue +++ b/src/components/Modal/smallModal.vue @@ -8,8 +8,8 @@ @@ -30,9 +30,13 @@ const props = withDefaults( show: false } ); -const emit = defineEmits(["handleModal"]); -const handleClose = () => { +const emit = defineEmits(["handleModal", "handleOk"]); +const handleClose = (v: string) => { emit("handleModal", false); + if (v === 'ok') { + // 走确认操作 + emit("handleOk"); + } }; diff --git a/src/pages/index/shipmenting.vue b/src/pages/index/shipmenting.vue deleted file mode 100644 index eb1d7b5..0000000 --- a/src/pages/index/shipmenting.vue +++ /dev/null @@ -1,99 +0,0 @@ - - - diff --git a/src/pages/index/tareing.vue b/src/pages/index/tareing.vue deleted file mode 100644 index 66394c9..0000000 --- a/src/pages/index/tareing.vue +++ /dev/null @@ -1,100 +0,0 @@ - - - diff --git a/src/pages/login/index copy.vue b/src/pages/login/index copy.vue deleted file mode 100644 index b7134ec..0000000 --- a/src/pages/login/index copy.vue +++ /dev/null @@ -1,95 +0,0 @@ - - - - - diff --git a/src/pages/login/index.vue b/src/pages/login/index.vue index 5a9b357..5cec5cc 100644 --- a/src/pages/login/index.vue +++ b/src/pages/login/index.vue @@ -163,9 +163,6 @@ const submit = () => { }); } }); - uni.navigateTo({ - url: "/pages/index/index", // 要跳转到的页面路径 - }); }; const handleForgetPwd = () => { uni.navigateTo({ diff --git a/src/pages/review/index.vue b/src/pages/review/index.vue deleted file mode 100644 index 60ba966..0000000 --- a/src/pages/review/index.vue +++ /dev/null @@ -1,257 +0,0 @@ - - - diff --git a/src/pages/scenePhoto/index.vue b/src/pages/scenePhoto/index.vue deleted file mode 100644 index 9a15b74..0000000 --- a/src/pages/scenePhoto/index.vue +++ /dev/null @@ -1,62 +0,0 @@ - - - diff --git a/src/pages/statistics/customer/detail.vue b/src/pages/statistics/customer/detail.vue index 2ebfa57..7c7d26b 100644 --- a/src/pages/statistics/customer/detail.vue +++ b/src/pages/statistics/customer/detail.vue @@ -140,7 +140,7 @@ const gridList2 = reactive([ ]); const handleScenePhoto = () => { uni.navigateTo({ - url: "/pages/scenePhoto/index", // 要跳转到的页面路径 + url: "/pagesScenePhoto/index", // 要跳转到的页面路径 }); }; diff --git a/src/pages/statistics/supplier/detail.vue b/src/pages/statistics/supplier/detail.vue index 9f847a7..e50aaff 100644 --- a/src/pages/statistics/supplier/detail.vue +++ b/src/pages/statistics/supplier/detail.vue @@ -96,7 +96,7 @@ const gridList1 = reactive([ ]); const handleScenePhoto = () => { uni.navigateTo({ - url: "/pages/scenePhoto/index", // 要跳转到的页面路径 + url: "/pagesScenePhoto/index", // 要跳转到的页面路径 }); }; diff --git a/src/pagesReceive/form/pricingForm.vue b/src/pagesReceive/form/pricingForm.vue new file mode 100644 index 0000000..e102006 --- /dev/null +++ b/src/pagesReceive/form/pricingForm.vue @@ -0,0 +1,422 @@ + + + diff --git a/src/pages/index/payReview.vue b/src/pagesReceive/payReview.vue similarity index 60% rename from src/pages/index/payReview.vue rename to src/pagesReceive/payReview.vue index 5eeb27a..3d125e8 100644 --- a/src/pages/index/payReview.vue +++ b/src/pagesReceive/payReview.vue @@ -21,90 +21,147 @@ {{ item.name }} - + - 收货单号:SHD20230901132333 + 收货单号:{{ item.receiptNumber }} - 陡其成 + {{ item.userName }} - 过磅总净重:1870.00KG + 过磅总净重:{{ item.netWeight || 0 }}KG - 贷款金额:2510.00元 + 货款金额:{{ item.totalPrice || 0 }}元 - 去审核 - 去支付 - 查看 + 去支付 + 查看 - - + - + - + diff --git a/src/pagesReceive/review/index.vue b/src/pagesReceive/review/index.vue new file mode 100644 index 0000000..9fb6dd4 --- /dev/null +++ b/src/pagesReceive/review/index.vue @@ -0,0 +1,452 @@ + + + + diff --git a/src/pagesReceive/tareing.vue b/src/pagesReceive/tareing.vue new file mode 100644 index 0000000..7b1678d --- /dev/null +++ b/src/pagesReceive/tareing.vue @@ -0,0 +1,166 @@ + + + diff --git a/src/pagesScenePhoto/index.vue b/src/pagesScenePhoto/index.vue new file mode 100644 index 0000000..f71a462 --- /dev/null +++ b/src/pagesScenePhoto/index.vue @@ -0,0 +1,92 @@ + + + +@/types/status diff --git a/src/pagesShipment/form/shipmentForm.vue b/src/pagesShipment/form/shipmentForm.vue new file mode 100644 index 0000000..e61e9d8 --- /dev/null +++ b/src/pagesShipment/form/shipmentForm.vue @@ -0,0 +1,318 @@ + + + diff --git a/src/pagesShipment/shipmenting.vue b/src/pagesShipment/shipmenting.vue new file mode 100644 index 0000000..1937c48 --- /dev/null +++ b/src/pagesShipment/shipmenting.vue @@ -0,0 +1,166 @@ + + + diff --git a/src/services/demo copy.ts b/src/services/demo copy.ts new file mode 100644 index 0000000..dc63488 --- /dev/null +++ b/src/services/demo copy.ts @@ -0,0 +1,48 @@ +// 存放路径: src/services/home.ts + +import { http } from '@/utils/http' + +/** + * 首页-广告区域-小程序 + * @param distributionSite 广告区域展示位置(投放位置 投放位置,1为首页,2为分类商品页) 默认是1 + */ +export const getHomeBannerAPI = (distributionSite = 1) => { + return http({ + method: 'GET', + url: '/home/banner', + data: { + distributionSite, + }, + }) +} +// services/home.ts +/** + * 首页-前台分类-小程序 + */ +export const getHomeCategoryAPI = () => { + return http({ + method: 'GET', + url: '/home/category/mutli', + }) +} +// services/home.ts +/** + * 首页-热门推荐-小程序 + */ +export const getHomeHotAPI = () => { + return http({ + method: 'GET', + url: '/home/hot/mutli', + }) +} +// src/services/home.ts +/** + * 猜你喜欢-小程序 + */ +export const getHomeGoodsGuessLikeAPI = (data: any) => { + return http({ + method: 'GET', + url: '/home/goods/guessLike', + data, + }) +} diff --git a/src/services/index.ts b/src/services/index.ts index 75eae6d..edda03c 100644 --- a/src/services/index.ts +++ b/src/services/index.ts @@ -1,3 +1,5 @@ export * as ProfileApi from './profile' export * as ReceiveApi from './receive' -export * as ShipmentApi from './shipment' \ No newline at end of file +export * as ShipmentApi from './shipment' +export * as PictureApi from './picture' +export * as ReceiveProductApi from './receiveProduct' \ No newline at end of file diff --git a/src/services/picture.ts b/src/services/picture.ts new file mode 100644 index 0000000..6049520 --- /dev/null +++ b/src/services/picture.ts @@ -0,0 +1,51 @@ +import type { ImagesType } from "@/utils/enum"; +import { http } from "@/utils/http"; + +// 资源存储接口 +export const addAnnex = (data: any) => { + return http({ + method: "POST", + url: "/api/annex/addAnnex", + data, + }); +}; + +// 获取图片资源 +export const getAnnex = (data: {businessId: number, orderType: number, imagesType: ImagesType | any}) => { + return http({ + method: "GET", + url: "/api/annex/getAnnex", + data + }); +}; +// 批量存储资源 +export const addListAnnex = (data: any) => { + return http({ + method: "POST", + url: "/api/annex/addListAnnex", + data, + }); +}; +// 多个上传 +export const uploadList = (data: any) => { + return http({ + method: "POST", + header: {type: 'UPLOAD'}, + url: "/api/file/uploadList", + data, + }); +}; +// 单个上传 +export const upload = (data: any) => { + return http({ + method: "POST", + header: {type: 'UPLOAD'}, + url: "/api/file/upload", + data, + }); +}; + + + + + diff --git a/src/services/profile.ts b/src/services/profile.ts index 69b92d7..2fdf5f4 100644 --- a/src/services/profile.ts +++ b/src/services/profile.ts @@ -94,3 +94,16 @@ export const addMenusRole = (data: { data, }); }; + + +// 查询用户列表 +export const getUserList = (data: { + name?: string; + userType?: number; // 1= 工作人员 2=采购商 +}) => { + return http({ + method: "GET", + url: "/api/user/getUserList", + data, + }); +}; diff --git a/src/services/receive.ts b/src/services/receive.ts index eb33557..59e65de 100644 --- a/src/services/receive.ts +++ b/src/services/receive.ts @@ -3,55 +3,9 @@ import type { Result } from '@/types/global' import { http } from "@/utils/http"; -type PageParams = { - pageNumber: number, - pageSize: number, - pricingUserId?: string, // 定价人 - userId?: string, // 供应商id - productId?: string, // 产品id - repairFlag?: boolean, // 是否为补单,true 是未补单,false是补单 - scaleStatus?: number, // 磅单状态:0:待定价1:待过皮2:待审核3:已审核待支付4:已支付 -} - -interface ReceiveOrderPage { - total: number, - list: T, - pageNum: number, - pageSize: number -} -type ReceiveOrder = { - id: number, - deviceId: number, // 设备id - deviceName: string, // 设备名称 - userId: number, // 用户id - cardId: number, //库存卡id - cardNumber: number, // 库存卡号 - userName: string, // 用户名称:关联用户表得到 - productId: number, // 品类id - productName: string, // 品类名称:关联品类表得到 - imagesId: string, - imageUrls: string, - carNumber: string, // 车牌号 - receiptNumber: string, // 收货单号 - grossWeight: number, // 毛重 - tare: number, // 皮重 - grossTime: string, // 过毛日期 - tareTime: string, // 过皮日期 - netWeight: string, // 净重(净重=净重*(1-扣点)-扣杂) - buttonType: string, // 扣杂状态:0扣杂1扣点 - points: string, // 扣点 - buckleMiscellaneous: string, //扣杂 - price: string, // 单价 - balanceTotalPrice: string, //结算总价 - totalPrice: string, //实际总价 - weighingMethod: string, //称重方式:0:有皮重 1:零皮重 - multiCategory: string, // 多品类:0:单品类 1:多品类 - -} - // 收库单分页查询 export const getOrderPage = (data: PageParams) => { - return http>({ + return http>({ method: "GET", url: "/api/orderIn/getOrderPage", data, @@ -68,7 +22,7 @@ export const getList = () => { //根据id获取收货单详情 export const getDetailById = (data: {id: number}) => { - return http({ + return http({ method: "GET", url: "/api/orderIn/getOne", data @@ -110,14 +64,7 @@ export const deleteOrder = (data: any) => { }; // 统计首页的本月总收获以及总支出 // 收货类型 -type ReceiveSummary = { - totalReceipt: number, // 本月总出货 - totalExpenditure: number, // 本月总收入 - toBePriced: number, // 待收货 - toBeTare: number, // 待过皮重 - audit: number, // 付款审核 - toBePaid: number, // 待支付 -} + export const countOrderByMonth = () => { return http({ method: "GET", @@ -125,4 +72,15 @@ export const countOrderByMonth = () => { }); }; +// 更新定价详情 +export const updateOne = (data: any) => { + return http({ + method: "POST", + url: "/api/orderIn/updateOne", + data, + }); +}; + + + diff --git a/src/services/receiveProduct.ts b/src/services/receiveProduct.ts new file mode 100644 index 0000000..ddd866d --- /dev/null +++ b/src/services/receiveProduct.ts @@ -0,0 +1,20 @@ +import { http } from "@/utils/http"; + +// 收货产品分页列表 +export const getReceiveProduct = () => { + return http({ + method: "GET", + url: "/api/reproducts/getPage" + }); +}; + +// 查询收货产品列表All +export const getAllReProducts = () => { + return http({ + method: "GET", + url: "/api/reproducts/allReProducts" + }); +}; + + + diff --git a/src/services/shipment.ts b/src/services/shipment.ts index ada2b96..9b1622c 100644 --- a/src/services/shipment.ts +++ b/src/services/shipment.ts @@ -9,6 +9,42 @@ type ShipmentSummary = { shipmentReview: number, // 出货结算 toBeSettled: number, // 待结算 } +// 根据id查询出货单 +export const getDetailById = (data: {id: number}) => { + return http({ + method: "GET", + url: "/api/orderOut/getOne", + data + }); +}; +// 根据条件查询出库单下拉列表 +export const getList = () => { + return http({ + method: "GET", + url: "/api/orderOut/getList" + }); +}; +type PageParams = { + userId?: number; // 供应商id + productId?: string; // 产品id + cardId?: number; + deviceId?:number; + scaleStatus?: number; // 磅单状态:0:待出货1:待过毛2:待审核3:已审未付4:已审已付 + flag?: boolean; // true 皮重 false 毛重 + pageNumber: number; + pageSize: number; + startTime?: string; // 开始时间 + endTime?: string; // 结束时间 + +}; +// 根据条件获取出库单,并且进行分页 +export const getOrderPage = (data: PageParams) => { + return http>({ + method: "GET", + url: "/api/orderOut/getOrderPage", + data + }); +}; // 统计首页的本月收入以及待出库 export const countOrderByMonth = () => { return http({ @@ -16,3 +52,46 @@ export const countOrderByMonth = () => { url: "/api/orderOut/countOrderByMonth" }); }; +// 出库分类统计 + +export const getOrderInReceipt = () => { + return http({ + method: "GET", + url: "/api/orderOut/OrderInReceipt" + }); +}; +// 出货单排行榜 +export const getOrderInRanking = () => { + return http({ + method: "GET", + url: "/api/orderOut/OrderInRanking" + }); +}; +// 单个或则批量作废 +export const deleteOrder = (data: any) => { + return http({ + method: "POST", + url: "/api/orderOut/delete", + data, + }); +}; +// 新增出货单 +export const addOrderOut = (data: any) => { + return http({ + method: "POST", + url: "/api/orderOut/addOrderOut", + data, + }); +}; +// 批量修改出货单 +export const updateOrderIn = (data: any) => { + return http({ + method: "POST", + url: "/api/orderOut/updateOrderIn", + data, + }); +}; + + + + diff --git a/src/store/modules/member.ts b/src/store/modules/member.ts index 812c657..40bceba 100644 --- a/src/store/modules/member.ts +++ b/src/store/modules/member.ts @@ -7,9 +7,11 @@ export const useMemberStore = defineStore( () => { // 会员信息 const profile = ref({ + token: '', userInfo: { userName: "", factory_name: "", + }, }); diff --git a/src/types/global.d.ts b/src/types/global.d.ts index 6e7f7ca..e923252 100644 --- a/src/types/global.d.ts +++ b/src/types/global.d.ts @@ -1,4 +1,6 @@ declare var wx: any; +declare var $_: any; + export type PageResult = { items: T[], counts: number, @@ -17,4 +19,6 @@ export type Result = { data: T, message: string, time: string -} \ No newline at end of file +} + +export type ComType = {[attrName: string]: any } \ No newline at end of file diff --git a/src/types/order.d.ts b/src/types/order.d.ts new file mode 100644 index 0000000..e7b8a73 --- /dev/null +++ b/src/types/order.d.ts @@ -0,0 +1,112 @@ +interface Order { + id?: number; + deviceId?: number; //设备id + deviceName?: string; // 设备名称 + userId?: number | string; //供应商id + cardId?: number; //库存卡id + cardNumber?: string; //undefined + userName?: string; //undefined + productId?: number | string; //产品id + productName?: string; //undefined + imagesId?: number | undefined; //弃用 + imageUrls?: string; //弃用 + carNumber?: string; //车牌号 + receiptNumber?: string; //收货单号 + grossWeight?: number; //毛重 + tare?: string; //皮重 + grossTime?: string; //过毛日期 + tareTime?: string; //过皮日期 + netWeight?: string; //净重 + buttonType?: number; //扣杂状态:0扣杂1扣点 + points?: number; //扣点 + buckleMiscellaneous?: number; //扣杂 + price?: string; //单价 + balanceTotalPrice?: string; //结算总价 货款金额 + totalPrice?: string; //实际总价 预估价格 + weighingMethod?: number; //称重方式:0:有皮重 1:零皮重 + multiCategory?: number; //多品类:0:单品类 1:多品类 + notes?: string; //备注 + scaleStatus?: number; // 磅单状态:0:待定价1:待过皮2:待审核3:已审核待支付4:已支付 + paymentMethod?: string; //支付方式:0:未支付,1:现金支付,2:银行卡支付,3:线上支付(微信)4:支付宝 + updateTime?: string; //修改时间 + repairTime?: string; //补单时间 + createTime?: string; //创建时间 + updateUserId?: number; //修改人 + createUserId?: number; //创建人 + reviewerUserId?: string; //审核人 + reviewerUserName?: string; // 审核人名称 + pricingUserId?: string; //定价人 + pricingUserName?: string; //定价人名称 + fileList?: array; + subtractNum?: number; // input 扣杂扣点参数 + isChecked?: boolean; + [attrName: string]: any; +} +interface Shipment { + id?: string; + userId?: number; //供应商id + productId?: number; //产品id + cardId?: number; //库存卡id + imagesId?: number; //图片表id + deviceId?: number; //设备id + carNumber?: string; //车牌号 + scaleStatus?: number; //出库单状态 + orderNumber?: string; //订单编号 + grossWeight?: number; //毛重 + grossTime?: string; //过毛时间 + tare?: number; //皮重 + tareTime?: string; //过皮时间 + netWeight?: string; //净重 + number?: number; //数量 + notes?: string; //备注 + settlementNotes?: string; //结算备注 + deliveryMethod?: string; //提货方式:0:送货1:自提 + phone?: string; //手机号 + box?: string; //箱号 + title?: string; //封号 + freight?: string; //运费 + incidentals?: string; //杂费 + pricingPerson?: string; //定价人 + reviewerId?: string; //审核人 + buttonType?: string; //扣点状态:默认0:扣杂1扣点 + points?: string; //扣点 + buckleMiscellaneous?: string; //扣杂 + unitPrice?: string; //结算单价 + estimatePrice?: string; //预估金额 + totalPrice?: string; //结算金额 + realIncome?: string; //实际收入 + errorPrice?: string; //误差金额 + repairTime?: string; //补单时间 + createTime?: string; //undefined + createUserId?: string; //undefined + updateUserId?: string; //undefined + updateTime?: string; //undefined + isDeleted?: string; //删除标识true删除,false未删除 + [attrName: string]: any; +} +// 分页结构 +interface OrderPage { + total: number; + list: T; + pageNum: number; + pageSize: number; +} + +interface ReceiveSummary { + totalReceipt: number; // 本月总出货 + totalExpenditure: number; // 本月总收入 + toBePriced: number; // 待收货 + toBeTare: number; // 待过皮重 + audit: number; // 付款审核 + toBePaid: number; // 待支付 +} + +type PageParams = { + pageNumber: number; + pageSize: number; + pricingUserId?: string; // 定价人 + userId?: string; // 供应商id + productId?: string; // 产品id + repairFlag?: boolean; // 是否为补单,true 是未补单,false是补单 + scaleStatus?: number; // 磅单状态:0:待定价1:待过皮2:待审核3:已审核待支付4:已支付 +}; diff --git a/src/types/resouce.d.ts b/src/types/resouce.d.ts new file mode 100644 index 0000000..7eb149b --- /dev/null +++ b/src/types/resouce.d.ts @@ -0,0 +1,8 @@ +interface Resource { + businessId: number, + orderType: number, // 1:入库单 2:出库单 + imagesType: number, // 0:普通资源1:皮重 2毛重 + url: string, + urlName: string, + urlSuffix: string, // 附件后缀 +} \ No newline at end of file diff --git a/src/types/user.d.ts b/src/types/user.d.ts new file mode 100644 index 0000000..5914000 --- /dev/null +++ b/src/types/user.d.ts @@ -0,0 +1,2 @@ +interface User { +} diff --git a/src/utils/enum.ts b/src/utils/enum.ts new file mode 100644 index 0000000..1853f4b --- /dev/null +++ b/src/utils/enum.ts @@ -0,0 +1,55 @@ + +// 1收货2出货 +export enum OrderType { + Receive = 1, + Shipment = 2, +} +// 扣杂状态:0扣杂1扣点 +export enum ButtonType { + BuckleMiscellaneous = 0, + Points = 1, +} +// 称重方式:0:有皮重 1:零皮重 +export enum WeighingMethod { + Yes = 0, + No = 1, +} +// 多品类:0:单品类 1:多品类 +export enum MultiCategory { + Single = 0, + Multiple = 1, +} + +// 0:普通资源1:皮重 2毛重 +export enum ImagesType { + NORMARL = 0, + Tare = 1, + GROSSWEIGHT = 2, +} +//磅单状态:0:待定价1:待过皮2:待审核3:已审核待支付4:已支付 +// 磅单状态:0:待出货1:待过毛2:待审核3:已审未付4:已审已付 +export enum ScaleStatus { + ToBePriced = 0, + ToBeTare = 1, + ToBeReview = 2, + ToBePay = 2, + Paid = 4, + ToBeShipment = 0, + ToBeGrossWeight = 1, + ToBeShipmentReview = 2, + ToBeShipmentPay = 3, + ShipmentPaid = 4 +} +// 支付方式:0:未支付,1:现金支付,2:银行卡支付,3:线上支付(微信)4:支付宝 +export enum PaymentMethod { + NoPay = 0, + Cash = 1, + BankCard = 2, + WeChat = 2, + Alipay = 4 +} +//用户类型0:刷脸1:刷卡 +export enum UserType { + Face = 0, + Card = 1, +} \ No newline at end of file diff --git a/src/utils/http.ts b/src/utils/http.ts index d075ccb..6b5a85d 100644 --- a/src/utils/http.ts +++ b/src/utils/http.ts @@ -1,17 +1,15 @@ import { useMemberStore } from "@/store/modules/member"; import ENV_CONFIG from "../config/env"; - // 基础地址 let baseUrl = ""; // #ifdef H5 -(process.env as any).config= ENV_CONFIG +(process.env as any).config = ENV_CONFIG; // #endif baseUrl = (process.env as any).config[(process.env as any).NODE_ENV] .VITE_APP_BASE_URL; - const store = useMemberStore(); const obj = { @@ -54,40 +52,84 @@ interface Data { */ export const http = (options: UniApp.RequestOptions) => { return new Promise>((resolve, reject) => { - uni.request({ - ...options, - success(res) { - if (res.statusCode >= 200 && res.statusCode < 300) { - if ( - (res.data as any).code === 1001 || - (res.data as any).code === 1002 - ) { + console.log(options); + if ((options as any).header?.type === "UPLOAD") { + uni.uploadFile({ + header: { + "x-userToken": store.profile?.token, + // #ifdef H5 + "Content-Type": "multipart/form-data", + // #endif + }, + url: baseUrl + options.url, //仅为示例,非真实的接口地址 + fileType: "image", + // #ifdef H5 + files: (options as any).data.files, + // #endif + // #ifdef MP-WEIXIN + filePath: (options as any).data.path, + // #endif + name: "file", + formData: { + file: (options as any).data.files, + }, // HTTP 请求中其他额外的 form data + success: (res) => { + resolve(JSON.parse(res.data) as Data); + }, + fail(err) { + console.log(err); + }, + }); + } else { + uni.request({ + ...options, + dataType:'string', //1.先将dataType设置为string + success(res) { + var json=(res.data as any).replace(/:s*([0-9]{15,})s*(,?)/g, ': "$1" $2') + //2.根据后端返回的数据调用一次或者两次replace替换 + var json1=json.replace(/:s*([0-9]{15,})s*(,?)/g, ': "$1" $2') + //3.手动转换回json数据即可 + let res1 = JSON.parse(json1); + console.log(res1) + if (res.statusCode >= 200 && res.statusCode < 300) { + if ( + (res1 as any).code === 1001 || + (res1 as any).code === 1002 + ) { + uni.showToast({ + icon: "none", + title: (res1 as Data).message || "请求失败", + }); + store.clearProfile(); + uni.navigateTo({ + url: "/pages/login/index", + }); + return; + } + if ((res1 as any).code === 10001) { + uni.showToast({ + icon: "none", + title: (res1 as Data).message || "请求失败", + }); + return + } + resolve(res1 as Data); + } else { uni.showToast({ icon: "none", - title: (res.data as Data).message || "请求失败", + title: (res1 as any).msg || "请求失败", }); - store.clearProfile(); - // uni.navigateTo({ - // url: "/pages/login/index", - // }); - return; + reject(res1); } - resolve(res.data as Data); - } else { + }, + fail(err) { uni.showToast({ icon: "none", - title: (res.data as Data).msg || "请求失败", + title: "网络错误,请检查网络", }); - reject(res); - } - }, - fail(err) { - uni.showToast({ - icon: "none", - title: "网络错误,请检查网络", - }); - reject(err); - }, - }); + reject(err); + }, + }); + } }); };