diff --git a/info/basicinfo.txt b/info/basicinfo.txt new file mode 100644 index 0000000..4a371e6 --- /dev/null +++ b/info/basicinfo.txt @@ -0,0 +1,168 @@ +user.info接口返回数据: +{ + "flag": "success", + "code": 200, + "message": "获取成功{\"device\":\"workerstation\",\"project\":\"warehouse\"}", + "success": true, + "data": { + "id": 3, + "status": 1, + "employees": [ + { + "id": 34, + "store_id": 1000028, + "store_name": "天豹云仓", + "is_primary": 1, + "real_name": "殷建铭", + "auth_end": "2099-12-26", + "role_type": "warehouse" + }, + { + "id": 31, + "store_id": 100000, + "store_name": "测试仓", + "is_primary": 0, + "real_name": "殷建铭", + "auth_end": "2099-11-08", + "role_type": "warehouse" + } + ], + "auth_end": "2099-12-26", + "employees_id": 34, + "employees_name": "殷建铭", + "loginIp": "58.63.152.206", + "store_id": 1000028, + "store_name": "天豹云仓", + "store_type": "warehouse", + "menus": [ + { + "path": "/order", + "component": "", + "name": "Workorder", + "redirect": "", + "meta": { + "title": "订单复核1", + "icon": "" + }, + "hidden": false, + "alwaysShow": false, + "children": [] + }, + { + "path": "/catchWeight", + "component": "", + "name": "CatchWeight", + "redirect": null, + "meta": { + "title": "称重", + "icon": "" + }, + "hidden": false, + "alwaysShow": false, + "children": [] + }, + { + "path": "/returns", + "component": "", + "name": "Returns", + "redirect": null, + "meta": { + "title": "退件", + "icon": "" + }, + "hidden": false, + "alwaysShow": false, + "children": [] + } + ], + "permissions": [ + "dashboard.hotOrderRank", + "dashboard.orderTrend", + "dashboard.platformDist", + "dashboard.expressRatio", + "dashboard.storeBaseData", + "dashboard.auth", + "store.getStoreRoles", + "store.auditApply", + "warehouse.getWarehouseZones", + "warehouse.create", + "warehouse.getWarehouseTree", + "warehouse.detail", + "warehouse.update", + "warehouse.delete", + "warehouse.updateSpaceInfo", + "stock.saveWarehouseStock", + "stock.saveWarehouseStockBarcode", + "stock.bindItem", + "stock.unbindItem", + "index.ReferenceFile", + "warehouseExport", + "warehouseRecycle", + "stock.createWarehouseStock", + "stock.handleBatchDelete", + "stock.handleBatchChange", + "storage.receiving.create", + "storage.receiving.getReceivingDetail", + "storage.receiving.batchCancelReceiving", + "index.getCOSUploadConfig", + "index.getExpressList", + "index.tryAutoTranslateNewKeys", + "index.uploadSuccessNotify", + "order.getOrderModels", + "stock.warehouse.bindItem", + "stock.warehouse.createProhibited", + "stock.warehouse.createUnit", + "stock.warehouse.createWarehouseStock", + "stock.warehouse.deleteProhibited", + "stock.warehouse.deleteUnit", + "stock.warehouse.handleBatchChange", + "stock.warehouse.handleBatchDelete", + "stock.warehouse.saveWarehouseStock", + "stock.warehouse.saveWarehouseStockBarcode", + "stock.warehouse.unbindItem", + "storage.receiving.addItem", + "storage.receiving.removeItem", + "storage.receiving.saveReceiving", + "warehouse.createRack", + "warehouse.createRackWithSpaces", + "warehouse.recalculatePickPath", + "warehouse.updateNeighbors", + "warehouse.updateRackPosition", + "stock.getInfo", + "printer.bind", + "setting.permission.add", + "setting.permission.delete", + "setting.permission.update", + "order.base.getOrderModels", + "warehouse.getAreaRacks", + "storeWarehouse.store.adjustPrintQuantity", + "storage.inventory.quickPutaway", + "storage.inventory.transferLocation", + "storage.inventory.transferByProduct", + "order.reviewOrder.detail", + "order.pendingOrder.detail", + "order.outboundOrder.detail", + "order.expectionOrder.detail", + "order.entrustOrder.detail", + "order.deliveryOrder.detail", + "order.deliveryExpectionOrder.detail", + "order.archiveOrder.detail", + "warehouse.batchUpdateSpaceInfo", + "warehouse.exportRackSpaces", + "warehouse.getChildren", + "warehouse.toggleActive", + "warehouse.getPath", + "warehouse.getPickPath", + "storage.receiving.save", + "order.wave.waveStrategyUpdate", + "order.wave.waveStrategyCreate", + "\r\norder.wave.wavePickTaskCancel", + "\r\nstock.warehouse.import", + "storeWarehouse.store.queryPrintQuantityLogs" + ], + "userRole": "customer", + "platform_code": "workerstation", + "avatar": "" + }, + "timestamp": 1779333004 +} \ No newline at end of file diff --git a/package.json b/package.json index f6439a5..7912186 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "uni-preset-vue", "version": "0.0.0", "scripts": { + "dev": "uni", "dev:custom": "uni -p", "dev:h5": "uni", "dev:h5:electron": "uni --mode electron", diff --git a/src/api/index.ts b/src/api/index.ts new file mode 100644 index 0000000..32ed56b --- /dev/null +++ b/src/api/index.ts @@ -0,0 +1,52 @@ +import { request, type ApiBody, type RequestOptions } from './request' + +export { request, type ApiBody, type RequestOptions } from './request' +// export * from './order' + +const workerPayload = { + device: 'workerstation', + project: 'warehouse', +} + +/** 微信扫码登录:获取客户端码 / 二维码信息 */ +export function getLoginWechatCode( + data: Record = {}, + options?: RequestOptions +) { + return request('user.getLoginWechatCode', data, { + skipAuth: true, + ...options, + }) +} + +/** 工牌 / 条码码登录 */ +export function loginByCode(code: string) { + return request('user.loginByCode', { code }, { skipAuth: true }) +} + +/** 账号密码登录 */ +export function loginByAccount(username: string, password: string) { + return request( + 'user.login', + { username, password }, + { skipAuth: true } + ) +} + +/** 当前登录用户信息 */ +export function fetchUserInfo() { + return request('user.info', { ...workerPayload }) +} + +/** 切换角色 / 门店身份 */ +export function changeUserRole(roleId: string | number) { + return request('user.changeRole', { + roleId, + ...workerPayload, + }) +} + +/** 退出登录 */ +export function logout() { + return request('user.logout', {}) +} diff --git a/src/api/order.ts b/src/api/order.ts new file mode 100644 index 0000000..d2c8cf2 --- /dev/null +++ b/src/api/order.ts @@ -0,0 +1,31 @@ +import { request, type ApiBody, type RequestOptions } from './request' + +const workerPayload = { + device: 'workerstation', + project: 'warehouse', +} + +/** + * 订单相关接口集中在此文件,按页面/功能拆分方法。 + * method 名请与后端约定一致后修改下列字符串。 + */ + +/** 复核台等:订单关键词搜索(method 占位,对接后端时改名) */ +export function searchOrdersForReview( + params: { keyword?: string } = {}, + options?: RequestOptions +) { + return request( + 'order.review.search', + { + ...workerPayload, + ...params, + }, + options + ) +} + +/** 当前波次待处理订单列表(method 占位) */ +export function fetchCurrentWavePendingOrders(options?: RequestOptions) { + return request('order.review.currentWave', { ...workerPayload }, options) +} diff --git a/src/api/request.ts b/src/api/request.ts new file mode 100644 index 0000000..2533fb9 --- /dev/null +++ b/src/api/request.ts @@ -0,0 +1,87 @@ +import { API_URL } from '@/config/api' + +/** 与后端约定的通用响应结构(字段名因接口可能略有差异) */ +export type ApiBody = { + code?: number + success?: boolean + status?: number + msg?: string + message?: string + data?: T + result?: T + token?: string + [key: string]: unknown +} + +export type RequestOptions = { + /** 传给 uni.request */ + timeout?: number + /** 不携带本地 token(登录、取码等未鉴权接口) */ + skipAuth?: boolean + /** 额外或覆盖请求头 */ + header?: Record +} + +const DEFAULT_HEADERS: Record = { + accept: 'application/json, text/plain, */*', + 'content-type': 'application/json', + platform: 'workerstation', + project: 'warehouse', +} + +function getAuthHeader(): Record { + const token = uni.getStorageSync('token') + if (!token) { + return {} + } + return { + token: String(token), + Authorization: `Bearer ${token}`, + } +} + +function buildRequestUrl(method: string): string { + const params = new URLSearchParams({ + method, + v: '1.0', + timestamp: String(Date.now()), + }) + return `${API_URL}?${params.toString()}` +} + +/** + * 统一走 `/system?method=xxx` 的 POST 请求 + */ +export function request( + method: string, + data?: Record, + options?: RequestOptions +): Promise { + const url = buildRequestUrl(method) + const authHeader = options?.skipAuth ? {} : getAuthHeader() + + return new Promise((resolve, reject) => { + const requestOptions: UniApp.RequestOptions = { + url, + method: 'POST', + header: { + ...DEFAULT_HEADERS, + ...authHeader, + ...options?.header, + }, + data: data ?? {}, + success: (res) => { + resolve(res.data as T) + }, + fail: (err) => { + reject(err) + }, + } + + if (options?.timeout != null) { + requestOptions.timeout = options.timeout + } + + uni.request(requestOptions) + }) +} diff --git a/src/config/api.ts b/src/config/api.ts new file mode 100644 index 0000000..a80e620 --- /dev/null +++ b/src/config/api.ts @@ -0,0 +1,3 @@ +import { API_URL, BASE_URL, IMG_URL } from '../../env.js' + +export { BASE_URL, API_URL, IMG_URL } diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 0cd1632..d46eaa1 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -1,10 +1,10 @@ diff --git a/src/views/order/index.vue b/src/views/order/index.vue new file mode 100644 index 0000000..c4d6523 --- /dev/null +++ b/src/views/order/index.vue @@ -0,0 +1,28 @@ + + + + + diff --git a/src/views/returns/index.vue b/src/views/returns/index.vue new file mode 100644 index 0000000..a88acf2 --- /dev/null +++ b/src/views/returns/index.vue @@ -0,0 +1,48 @@ + + + + + diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..d1c3818 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "target": "ESNext", + "module": "ESNext", + "moduleResolution": "bundler", + "strict": false, + "jsx": "preserve", + "resolveJsonModule": true, + "allowJs": true, + "noEmit": true, + "skipLibCheck": true, + "types": ["@dcloudio/types"], + "baseUrl": ".", + "paths": { + "@/*": ["src/*"] + } + }, + "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.vue", "env.js"] +}