521
This commit is contained in:
parent
b7b9bd8d42
commit
bbad73400b
168
info/basicinfo.txt
Normal file
168
info/basicinfo.txt
Normal file
@ -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
|
||||
}
|
||||
@ -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",
|
||||
|
||||
52
src/api/index.ts
Normal file
52
src/api/index.ts
Normal file
@ -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<string, unknown> = {},
|
||||
options?: RequestOptions
|
||||
) {
|
||||
return request<ApiBody>('user.getLoginWechatCode', data, {
|
||||
skipAuth: true,
|
||||
...options,
|
||||
})
|
||||
}
|
||||
|
||||
/** 工牌 / 条码码登录 */
|
||||
export function loginByCode(code: string) {
|
||||
return request<ApiBody>('user.loginByCode', { code }, { skipAuth: true })
|
||||
}
|
||||
|
||||
/** 账号密码登录 */
|
||||
export function loginByAccount(username: string, password: string) {
|
||||
return request<ApiBody>(
|
||||
'user.login',
|
||||
{ username, password },
|
||||
{ skipAuth: true }
|
||||
)
|
||||
}
|
||||
|
||||
/** 当前登录用户信息 */
|
||||
export function fetchUserInfo() {
|
||||
return request<ApiBody>('user.info', { ...workerPayload })
|
||||
}
|
||||
|
||||
/** 切换角色 / 门店身份 */
|
||||
export function changeUserRole(roleId: string | number) {
|
||||
return request<ApiBody>('user.changeRole', {
|
||||
roleId,
|
||||
...workerPayload,
|
||||
})
|
||||
}
|
||||
|
||||
/** 退出登录 */
|
||||
export function logout() {
|
||||
return request<ApiBody>('user.logout', {})
|
||||
}
|
||||
31
src/api/order.ts
Normal file
31
src/api/order.ts
Normal file
@ -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<ApiBody>(
|
||||
'order.review.search',
|
||||
{
|
||||
...workerPayload,
|
||||
...params,
|
||||
},
|
||||
options
|
||||
)
|
||||
}
|
||||
|
||||
/** 当前波次待处理订单列表(method 占位) */
|
||||
export function fetchCurrentWavePendingOrders(options?: RequestOptions) {
|
||||
return request<ApiBody>('order.review.currentWave', { ...workerPayload }, options)
|
||||
}
|
||||
87
src/api/request.ts
Normal file
87
src/api/request.ts
Normal file
@ -0,0 +1,87 @@
|
||||
import { API_URL } from '@/config/api'
|
||||
|
||||
/** 与后端约定的通用响应结构(字段名因接口可能略有差异) */
|
||||
export type ApiBody<T = unknown> = {
|
||||
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<string, string>
|
||||
}
|
||||
|
||||
const DEFAULT_HEADERS: Record<string, string> = {
|
||||
accept: 'application/json, text/plain, */*',
|
||||
'content-type': 'application/json',
|
||||
platform: 'workerstation',
|
||||
project: 'warehouse',
|
||||
}
|
||||
|
||||
function getAuthHeader(): Record<string, string> {
|
||||
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<T = ApiBody>(
|
||||
method: string,
|
||||
data?: Record<string, unknown>,
|
||||
options?: RequestOptions
|
||||
): Promise<T> {
|
||||
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)
|
||||
})
|
||||
}
|
||||
3
src/config/api.ts
Normal file
3
src/config/api.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import { API_URL, BASE_URL, IMG_URL } from '../../env.js'
|
||||
|
||||
export { BASE_URL, API_URL, IMG_URL }
|
||||
@ -1,10 +1,10 @@
|
||||
<template>
|
||||
<view class="page" @click="closeMinePopup">
|
||||
<view class="layout-page" @click="closeMinePopup">
|
||||
<view class="top-nav" @click.stop>
|
||||
<image class="top-nav-logo" src="http://192.168.11.56:5174/public/logo/1.png" mode="heightFix"></image>
|
||||
<view class="top-nav-menu-wrap" v-if="getTopMenus().length">
|
||||
<view class="top-nav-menu-wrap" v-if="topMenus.length">
|
||||
<view
|
||||
v-for="menu in getTopMenus()"
|
||||
v-for="menu in topMenus"
|
||||
:key="menu.path || menu.name"
|
||||
:class="['top-nav-menu-item', isMenuActive(menu) ? 'top-nav-menu-item--active' : '']"
|
||||
@click="handleMenuClick(menu)"
|
||||
@ -37,23 +37,26 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="content-wrap">
|
||||
<order-review-one v-if="activeMenuPath === '/order'" compact-top />
|
||||
<view class="layout-main">
|
||||
<component
|
||||
v-if="activeViewComponent"
|
||||
:is="activeViewComponent"
|
||||
:key="activeMenuPath"
|
||||
compact-top
|
||||
/>
|
||||
<view v-else class="module-placeholder">
|
||||
<text class="module-placeholder-title">{{ getActiveMenuTitle() || '请选择功能菜单' }}</text>
|
||||
<text v-if="activeMenuPath" class="module-placeholder-desc">该菜单页面尚未配置({{ activeMenuPath }})</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import OrderReviewOne from '@/components/order-review-one/index.vue'
|
||||
import { changeUserRole, fetchUserInfo, logout } from '@/api/index'
|
||||
import { hasMenuView, normalizeMenuPath, resolveMenuView } from '@/router/menuRoutes'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
OrderReviewOne,
|
||||
},
|
||||
onLoad(options) {
|
||||
const token = uni.getStorageSync('token')
|
||||
if (!token) {
|
||||
@ -63,9 +66,8 @@ export default {
|
||||
return
|
||||
}
|
||||
|
||||
this.activeMenuPath = this.normalizeRawPath(options?.menu)
|
||||
|
||||
this.loadCurrentUserInfo(token)
|
||||
this.activeMenuPath = normalizeMenuPath(options?.menu)
|
||||
this.loadCurrentUserInfo()
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@ -74,64 +76,74 @@ export default {
|
||||
activeMenuPath: '',
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getTopMenus() {
|
||||
computed: {
|
||||
topMenus() {
|
||||
const menus = this.currentUser?.menus
|
||||
if (!Array.isArray(menus)) {
|
||||
return []
|
||||
}
|
||||
|
||||
return menus.filter((menu) => !menu?.hidden)
|
||||
},
|
||||
activeViewComponent() {
|
||||
return resolveMenuView(this.activeMenuPath)
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
getMenuTitle(menu) {
|
||||
return menu?.meta?.title || menu?.name || '未命名菜单'
|
||||
},
|
||||
normalizeMenuPath(menu) {
|
||||
const rawPath = (menu?.path || '').trim()
|
||||
if (!rawPath) {
|
||||
return ''
|
||||
}
|
||||
|
||||
return rawPath.startsWith('/') ? rawPath : `/${rawPath}`
|
||||
},
|
||||
normalizeRawPath(rawPath) {
|
||||
const raw = String(rawPath || '').trim()
|
||||
if (!raw) {
|
||||
return ''
|
||||
}
|
||||
|
||||
return raw.startsWith('/') ? raw : `/${raw}`
|
||||
},
|
||||
isMenuActive(menu) {
|
||||
const path = this.normalizeMenuPath(menu)
|
||||
const path = normalizeMenuPath(menu?.path)
|
||||
return !!path && this.activeMenuPath === path
|
||||
},
|
||||
getActiveMenuTitle() {
|
||||
const activeMenu = this.getTopMenus().find((menu) => this.normalizeMenuPath(menu) === this.activeMenuPath)
|
||||
return this.getMenuTitle(activeMenu)
|
||||
getActiveMenu() {
|
||||
return this.topMenus.find((menu) => normalizeMenuPath(menu?.path) === this.activeMenuPath)
|
||||
},
|
||||
updateUrlByActiveMenu(menuPath) {
|
||||
const normalizedPath = this.normalizeRawPath(menuPath)
|
||||
const pages = getCurrentPages()
|
||||
const currentPage = pages[pages.length - 1]
|
||||
const currentMenu = this.normalizeRawPath(currentPage?.options?.menu)
|
||||
getActiveMenuTitle() {
|
||||
return this.getMenuTitle(this.getActiveMenu())
|
||||
},
|
||||
syncMenuToUrl(menuPath) {
|
||||
const normalizedPath = normalizeMenuPath(menuPath)
|
||||
|
||||
if (currentPage?.route !== 'pages/index/index' || currentMenu !== normalizedPath) {
|
||||
// #ifdef H5
|
||||
if (typeof window !== 'undefined' && window.history?.replaceState) {
|
||||
const query = normalizedPath ? `?menu=${encodeURIComponent(normalizedPath)}` : ''
|
||||
uni.redirectTo({
|
||||
url: `/pages/index/index${query}`,
|
||||
fail: () => {
|
||||
uni.showToast({
|
||||
title: '页面切换失败',
|
||||
icon: 'none',
|
||||
})
|
||||
},
|
||||
})
|
||||
const base = window.location.pathname || '/'
|
||||
window.history.replaceState(null, '', `${base}${query}`)
|
||||
}
|
||||
// #endif
|
||||
},
|
||||
setActiveMenu(menuPath, options = {}) {
|
||||
const { syncUrl = true } = options
|
||||
const normalizedPath = normalizeMenuPath(menuPath)
|
||||
if (!normalizedPath) {
|
||||
return
|
||||
}
|
||||
|
||||
this.activeMenuPath = normalizedPath
|
||||
if (syncUrl) {
|
||||
this.syncMenuToUrl(normalizedPath)
|
||||
}
|
||||
},
|
||||
ensureActiveMenuValid() {
|
||||
const menus = this.topMenus
|
||||
if (!menus.length) {
|
||||
this.activeMenuPath = ''
|
||||
return
|
||||
}
|
||||
|
||||
const matched = menus.find((menu) => normalizeMenuPath(menu?.path) === this.activeMenuPath)
|
||||
if (matched) {
|
||||
return
|
||||
}
|
||||
|
||||
const firstPath = normalizeMenuPath(menus[0]?.path)
|
||||
if (firstPath) {
|
||||
this.setActiveMenu(firstPath)
|
||||
}
|
||||
},
|
||||
handleMenuClick(menu) {
|
||||
const rawPath = (menu?.path || '').trim()
|
||||
|
||||
if (!rawPath) {
|
||||
uni.showToast({
|
||||
title: '菜单路径为空',
|
||||
@ -140,20 +152,21 @@ export default {
|
||||
return
|
||||
}
|
||||
|
||||
const normalizedPath = this.normalizeMenuPath(menu)
|
||||
if (!normalizedPath) {
|
||||
return
|
||||
}
|
||||
const normalizedPath = normalizeMenuPath(rawPath)
|
||||
this.setActiveMenu(normalizedPath)
|
||||
|
||||
this.activeMenuPath = normalizedPath
|
||||
this.updateUrlByActiveMenu(normalizedPath)
|
||||
if (!hasMenuView(normalizedPath)) {
|
||||
uni.showToast({
|
||||
title: '该功能页面暂未开放',
|
||||
icon: 'none',
|
||||
})
|
||||
}
|
||||
},
|
||||
getTopNavRealName() {
|
||||
const employees = this.currentUser?.employees || []
|
||||
if (employees.length && employees[0]?.real_name) {
|
||||
return employees[0].real_name
|
||||
}
|
||||
|
||||
return this.currentUser?.real_name || '未命名用户'
|
||||
},
|
||||
isCurrentRole(employee) {
|
||||
@ -162,31 +175,13 @@ export default {
|
||||
handleChangeRole(employee) {
|
||||
const employeeId = employee?.id
|
||||
const token = uni.getStorageSync('token')
|
||||
|
||||
if (!employeeId || !token) {
|
||||
return
|
||||
}
|
||||
|
||||
uni.request({
|
||||
url: `http://192.168.11.56:6060/system?method=user.changeRole&v=1.0×tamp=${Date.now()}`,
|
||||
method: 'POST',
|
||||
header: {
|
||||
accept: 'application/json, text/plain, */*',
|
||||
'content-type': 'application/json',
|
||||
platform: 'workerstation',
|
||||
project: 'warehouse',
|
||||
token,
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
data: {
|
||||
roleId: employeeId,
|
||||
device: 'workerstation',
|
||||
project: 'warehouse',
|
||||
},
|
||||
success: (res) => {
|
||||
const body = res?.data || {}
|
||||
changeUserRole(employeeId)
|
||||
.then((body) => {
|
||||
const isSuccess = body?.code === 0 || body?.success === true || body?.status === 1
|
||||
|
||||
if (!isSuccess && (body?.msg || body?.message)) {
|
||||
uni.showToast({
|
||||
title: body?.msg || body?.message,
|
||||
@ -195,19 +190,18 @@ export default {
|
||||
return
|
||||
}
|
||||
|
||||
this.loadCurrentUserInfo(token)
|
||||
this.loadCurrentUserInfo()
|
||||
uni.showToast({
|
||||
title: '角色切换成功',
|
||||
icon: 'success',
|
||||
})
|
||||
},
|
||||
fail: () => {
|
||||
})
|
||||
.catch(() => {
|
||||
uni.showToast({
|
||||
title: '角色切换失败',
|
||||
icon: 'none',
|
||||
})
|
||||
},
|
||||
})
|
||||
})
|
||||
},
|
||||
openMinePopup() {
|
||||
this.showMinePopup = true
|
||||
@ -215,34 +209,22 @@ export default {
|
||||
closeMinePopup() {
|
||||
this.showMinePopup = false
|
||||
},
|
||||
loadCurrentUserInfo(token) {
|
||||
uni.request({
|
||||
url: `http://192.168.11.56:6060/system?method=user.info&v=1.0×tamp=${Date.now()}`,
|
||||
method: 'POST',
|
||||
header: {
|
||||
accept: 'application/json, text/plain, */*',
|
||||
platform: 'workerstation',
|
||||
project: 'warehouse',
|
||||
token,
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
data: {
|
||||
device: 'workerstation',
|
||||
project: 'warehouse',
|
||||
},
|
||||
success: (res) => {
|
||||
const body = res?.data || {}
|
||||
loadCurrentUserInfo() {
|
||||
fetchUserInfo()
|
||||
.then((body) => {
|
||||
this.currentUser = body?.data || body?.result || body || null
|
||||
this.ensureActiveMenuValid()
|
||||
|
||||
if (!this.activeMenuPath) {
|
||||
const firstMenuPath = this.normalizeMenuPath(this.getTopMenus()[0])
|
||||
this.activeMenuPath = firstMenuPath
|
||||
if (firstMenuPath) {
|
||||
this.updateUrlByActiveMenu(firstMenuPath)
|
||||
if (!this.activeMenuPath && this.topMenus.length) {
|
||||
const firstPath = normalizeMenuPath(this.topMenus[0]?.path)
|
||||
if (firstPath) {
|
||||
this.setActiveMenu(firstPath)
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
})
|
||||
.catch(() => {
|
||||
/* 静默失败,避免打断主导航 */
|
||||
})
|
||||
},
|
||||
finishLogout() {
|
||||
uni.removeStorageSync('token')
|
||||
@ -258,26 +240,13 @@ export default {
|
||||
},
|
||||
handleLogout() {
|
||||
const token = uni.getStorageSync('token')
|
||||
|
||||
if (!token) {
|
||||
this.finishLogout()
|
||||
return
|
||||
}
|
||||
|
||||
uni.request({
|
||||
url: `http://192.168.11.56:6060/system?method=user.logout&v=1.0×tamp=${Date.now()}`,
|
||||
method: 'POST',
|
||||
header: {
|
||||
accept: 'application/json, text/plain, */*',
|
||||
platform: 'workerstation',
|
||||
project: 'warehouse',
|
||||
token,
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
data: {},
|
||||
complete: () => {
|
||||
this.finishLogout()
|
||||
},
|
||||
logout().finally(() => {
|
||||
this.finishLogout()
|
||||
})
|
||||
},
|
||||
},
|
||||
@ -285,7 +254,7 @@ export default {
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.page {
|
||||
.layout-page {
|
||||
min-height: 100vh;
|
||||
min-width: 960px;
|
||||
box-sizing: border-box;
|
||||
@ -294,11 +263,12 @@ export default {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
justify-content: flex-start;
|
||||
background-color: #f8f8f8;
|
||||
}
|
||||
|
||||
.top-nav {
|
||||
width: 100%;
|
||||
align-self: stretch;
|
||||
flex-shrink: 0;
|
||||
margin: 0 0 24rpx;
|
||||
padding: 18rpx 28rpx;
|
||||
box-sizing: border-box;
|
||||
@ -328,6 +298,7 @@ export default {
|
||||
|
||||
.top-nav-menu-item {
|
||||
padding: 10rpx 18rpx;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.top-nav-menu-item--active {
|
||||
@ -344,6 +315,7 @@ export default {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10rpx;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.top-nav-mine-icon {
|
||||
@ -376,12 +348,6 @@ export default {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.top-nav-mine-icon,
|
||||
.top-nav-mine-icon-head,
|
||||
.top-nav-mine-icon-body {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.top-nav-mine-name {
|
||||
font-size: 32rpx;
|
||||
line-height: 1;
|
||||
@ -454,64 +420,11 @@ export default {
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.content-wrap {
|
||||
padding: 0 28rpx 24rpx;
|
||||
}
|
||||
|
||||
.order-module {
|
||||
background-color: #fff;
|
||||
border-radius: 16rpx;
|
||||
padding: 24rpx;
|
||||
}
|
||||
|
||||
.order-search-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
margin-bottom: 18rpx;
|
||||
}
|
||||
|
||||
.order-search-input {
|
||||
.layout-main {
|
||||
flex: 1;
|
||||
height: 72rpx;
|
||||
border: 1rpx solid #e5e5e5;
|
||||
border-radius: 10rpx;
|
||||
padding: 0 18rpx;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.order-search-btn {
|
||||
width: 150rpx;
|
||||
height: 72rpx;
|
||||
line-height: 72rpx;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.order-result-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12rpx;
|
||||
}
|
||||
|
||||
.order-item {
|
||||
background-color: #fafbfe;
|
||||
border: 1rpx solid #edf0f5;
|
||||
border-radius: 10rpx;
|
||||
padding: 16rpx;
|
||||
}
|
||||
|
||||
.order-item-text {
|
||||
display: block;
|
||||
font-size: 26rpx;
|
||||
color: #333;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.order-empty {
|
||||
text-align: center;
|
||||
color: #999;
|
||||
font-size: 26rpx;
|
||||
padding: 20rpx 0;
|
||||
min-height: 0;
|
||||
padding: 0 28rpx 24rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.module-placeholder {
|
||||
@ -526,10 +439,16 @@ export default {
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.module-placeholder-desc {
|
||||
display: block;
|
||||
margin-top: 10rpx;
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 1024px) {
|
||||
.page {
|
||||
.layout-page {
|
||||
min-width: 760px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.top-nav {
|
||||
@ -567,7 +486,7 @@ export default {
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.content-wrap {
|
||||
.layout-main {
|
||||
padding: 0 20rpx 18rpx;
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,6 +79,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getLoginWechatCode, loginByCode, loginByAccount } from '@/api/index'
|
||||
|
||||
const qrBaseUrl = 'https://ye4s.wms.gztbyc.com/grcode/build?text='
|
||||
const qrFallbackBaseUrl = 'https://api.qrserver.com/v1/create-qr-code/?size=280x280&data='
|
||||
const loginLinkTemplate = 'https://ye4s.wms.gztbyc.com/mini/?spm=0.4.${code}.1.4'
|
||||
@ -284,22 +286,10 @@ export default {
|
||||
this.scanStatus = '正在获取二维码...'
|
||||
}
|
||||
|
||||
const query = [`method=user.getLoginWechatCode`, `v=1.0`, `timestamp=${Date.now()}`]
|
||||
const requestData = this.scanClientCode ? { clientCode: this.scanClientCode } : {}
|
||||
|
||||
uni.request({
|
||||
url: `http://192.168.11.56:6060/system?${query.join('&')}`,
|
||||
method: 'POST',
|
||||
timeout: this.scanRequestTimeout,
|
||||
header: {
|
||||
accept: 'application/json, text/plain, */*',
|
||||
'content-type': 'application/json',
|
||||
platform: 'workerstation',
|
||||
project: 'warehouse',
|
||||
},
|
||||
data: requestData,
|
||||
success: (res) => {
|
||||
const body = res?.data || {}
|
||||
getLoginWechatCode(requestData, { timeout: this.scanRequestTimeout })
|
||||
.then((body) => {
|
||||
const payload = body?.data || body?.result || body
|
||||
|
||||
const clientCode =
|
||||
@ -327,8 +317,8 @@ export default {
|
||||
} else {
|
||||
this.scanStatus = body?.message || body?.msg || '二维码获取失败'
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
})
|
||||
.catch((err) => {
|
||||
const errMsg = err?.errMsg || ''
|
||||
if (errMsg.includes('timeout') || errMsg.includes('abort') || errMsg.includes('cancel')) {
|
||||
this.scanStatus = '请求超时,正在继续轮询...'
|
||||
@ -336,14 +326,13 @@ export default {
|
||||
}
|
||||
|
||||
this.scanStatus = '网络异常,请稍后重试'
|
||||
},
|
||||
complete: () => {
|
||||
})
|
||||
.finally(() => {
|
||||
this.scanLoading = false
|
||||
if (this.loginMode === 'scan' && this.scanClientCode) {
|
||||
this.startScanLongPolling()
|
||||
}
|
||||
},
|
||||
})
|
||||
})
|
||||
},
|
||||
handleScanBadgeLogin(codeParam = '') {
|
||||
const code = (codeParam || '').trim()
|
||||
@ -363,20 +352,8 @@ export default {
|
||||
this.scanBadgeLastSubmittedCode = code
|
||||
this.scanBadgeLastSubmittedAt = now
|
||||
|
||||
uni.request({
|
||||
url: `http://192.168.11.56:6060/system?method=user.loginByCode&v=1.0×tamp=${Date.now()}`,
|
||||
method: 'POST',
|
||||
header: {
|
||||
accept: 'application/json, text/plain, */*',
|
||||
'content-type': 'application/json',
|
||||
platform: 'workerstation',
|
||||
project: 'warehouse',
|
||||
},
|
||||
data: {
|
||||
code,
|
||||
},
|
||||
success: (res) => {
|
||||
const body = res?.data || {}
|
||||
loginByCode(code)
|
||||
.then((body) => {
|
||||
const token = body?.token || body?.data?.token || body?.result?.token
|
||||
|
||||
if (token) {
|
||||
@ -398,18 +375,17 @@ export default {
|
||||
title: body?.msg || body?.message || '工牌登录失败',
|
||||
icon: 'none',
|
||||
})
|
||||
},
|
||||
fail: () => {
|
||||
})
|
||||
.catch(() => {
|
||||
this.focusScanInput()
|
||||
uni.showToast({
|
||||
title: '网络异常,请稍后重试',
|
||||
icon: 'none',
|
||||
})
|
||||
},
|
||||
complete: () => {
|
||||
})
|
||||
.finally(() => {
|
||||
this.scanBadgeSubmitting = false
|
||||
},
|
||||
})
|
||||
})
|
||||
},
|
||||
handleAccountLogin() {
|
||||
if (!this.form.username || !this.form.password) {
|
||||
@ -420,20 +396,8 @@ export default {
|
||||
return
|
||||
}
|
||||
|
||||
uni.request({
|
||||
url: `http://192.168.11.56:6060/system?method=user.login&v=1.0×tamp=${Date.now()}`,
|
||||
method: 'POST',
|
||||
header: {
|
||||
accept: 'application/json, text/plain, */*',
|
||||
platform: 'workerstation',
|
||||
project: 'warehouse'
|
||||
},
|
||||
data: {
|
||||
username: this.form.username,
|
||||
password: this.form.password,
|
||||
},
|
||||
success: (res) => {
|
||||
const body = res?.data || {}
|
||||
loginByAccount(this.form.username, this.form.password)
|
||||
.then((body) => {
|
||||
const token = body?.token || body?.data?.token || body?.result?.token
|
||||
|
||||
if (token) {
|
||||
@ -454,14 +418,13 @@ export default {
|
||||
title: body?.msg || body?.message || '登录失败',
|
||||
icon: 'none',
|
||||
})
|
||||
},
|
||||
fail: () => {
|
||||
})
|
||||
.catch(() => {
|
||||
uni.showToast({
|
||||
title: '网络异常,请稍后重试',
|
||||
icon: 'none',
|
||||
})
|
||||
},
|
||||
})
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@ -6,7 +6,10 @@
|
||||
|
||||
<script>
|
||||
import OrderReviewOne from '@/components/order-review-one/index.vue'
|
||||
|
||||
/**
|
||||
* 订单相关 HTTP 请使用 `@/api/order`(如 searchOrdersForReview、fetchCurrentWavePendingOrders),
|
||||
* 将 method 与入参与后端对齐后再在组件中调用。
|
||||
*/
|
||||
export default {
|
||||
name: 'OrderReviewOnePage',
|
||||
components: {
|
||||
|
||||
36
src/router/menuRoutes.js
Normal file
36
src/router/menuRoutes.js
Normal file
@ -0,0 +1,36 @@
|
||||
import OrderView from '@/views/order/index.vue'
|
||||
import CatchWeightView from '@/views/catch-weight/index.vue'
|
||||
import ReturnsView from '@/views/returns/index.vue'
|
||||
|
||||
/** 将 user.info 中 menus[].path 规范为以 / 开头的路径 */
|
||||
export function normalizeMenuPath(path) {
|
||||
const raw = String(path || '').trim()
|
||||
if (!raw) {
|
||||
return ''
|
||||
}
|
||||
return raw.startsWith('/') ? raw : `/${raw}`
|
||||
}
|
||||
|
||||
/**
|
||||
* 后端动态菜单 path -> 本地页面组件
|
||||
* 新增菜单时在此注册对应 views 组件
|
||||
*/
|
||||
const menuRouteMap = {
|
||||
'/order': OrderView,
|
||||
'/catchWeight': CatchWeightView,
|
||||
'/returns': ReturnsView,
|
||||
}
|
||||
|
||||
/** 根据菜单 path 解析要渲染的页面组件 */
|
||||
export function resolveMenuView(path) {
|
||||
const normalized = normalizeMenuPath(path)
|
||||
if (!normalized) {
|
||||
return null
|
||||
}
|
||||
return menuRouteMap[normalized] || null
|
||||
}
|
||||
|
||||
/** 是否已在本地注册该动态路由页面 */
|
||||
export function hasMenuView(path) {
|
||||
return !!resolveMenuView(path)
|
||||
}
|
||||
16
src/shime-uni.d.ts
vendored
16
src/shime-uni.d.ts
vendored
@ -1,6 +1,14 @@
|
||||
export {};
|
||||
/// <reference types="@dcloudio/types" />
|
||||
|
||||
declare module "vue" {
|
||||
type Hooks = App.AppInstance & Page.PageInstance;
|
||||
export {}
|
||||
|
||||
declare module 'vue' {
|
||||
type Hooks = App.AppInstance & Page.PageInstance
|
||||
interface ComponentCustomOptions extends Hooks {}
|
||||
}
|
||||
}
|
||||
|
||||
declare module '../../env.js' {
|
||||
export const BASE_URL: string
|
||||
export const API_URL: string
|
||||
export const IMG_URL: string
|
||||
}
|
||||
|
||||
48
src/views/catch-weight/index.vue
Normal file
48
src/views/catch-weight/index.vue
Normal file
@ -0,0 +1,48 @@
|
||||
<template>
|
||||
<view class="dynamic-view dynamic-view--catch-weight">
|
||||
<view class="module-card">
|
||||
<text class="module-card-title">称重</text>
|
||||
<text class="module-card-desc">称重模块页面(待对接业务接口)</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'CatchWeightMenuView',
|
||||
props: {
|
||||
compactTop: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.dynamic-view--catch-weight {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.module-card {
|
||||
background-color: #fff;
|
||||
border-radius: 16rpx;
|
||||
padding: 32rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.module-card-title {
|
||||
display: block;
|
||||
font-size: 32rpx;
|
||||
color: #333;
|
||||
font-weight: 600;
|
||||
margin-bottom: 12rpx;
|
||||
}
|
||||
|
||||
.module-card-desc {
|
||||
display: block;
|
||||
font-size: 26rpx;
|
||||
color: #888;
|
||||
line-height: 1.5;
|
||||
}
|
||||
</style>
|
||||
28
src/views/order/index.vue
Normal file
28
src/views/order/index.vue
Normal file
@ -0,0 +1,28 @@
|
||||
<template>
|
||||
<view class="dynamic-view dynamic-view--order">
|
||||
<order-review-one :compact-top="compactTop" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import OrderReviewOne from '@/components/order-review-one/index.vue'
|
||||
|
||||
export default {
|
||||
name: 'OrderMenuView',
|
||||
components: {
|
||||
OrderReviewOne,
|
||||
},
|
||||
props: {
|
||||
compactTop: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.dynamic-view--order {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
48
src/views/returns/index.vue
Normal file
48
src/views/returns/index.vue
Normal file
@ -0,0 +1,48 @@
|
||||
<template>
|
||||
<view class="dynamic-view dynamic-view--returns">
|
||||
<view class="module-card">
|
||||
<text class="module-card-title">退件</text>
|
||||
<text class="module-card-desc">退件模块页面(待对接业务接口)</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'ReturnsMenuView',
|
||||
props: {
|
||||
compactTop: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.dynamic-view--returns {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.module-card {
|
||||
background-color: #fff;
|
||||
border-radius: 16rpx;
|
||||
padding: 32rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.module-card-title {
|
||||
display: block;
|
||||
font-size: 32rpx;
|
||||
color: #333;
|
||||
font-weight: 600;
|
||||
margin-bottom: 12rpx;
|
||||
}
|
||||
|
||||
.module-card-desc {
|
||||
display: block;
|
||||
font-size: 26rpx;
|
||||
color: #888;
|
||||
line-height: 1.5;
|
||||
}
|
||||
</style>
|
||||
19
tsconfig.json
Normal file
19
tsconfig.json
Normal file
@ -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"]
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user