From 178bd0d1e91e2ff3dc553f29f1abd2b4da037a7a Mon Sep 17 00:00:00 2001 From: Sun_sun <469361609@qq.com> Date: Mon, 15 Sep 2025 21:03:25 +0800 Subject: [PATCH] 2025-09-15 --- api/auth.js | 20 + api/captcha.js | 16 + api/common.js | 9 + api/payment.js | 24 + api/transfer.js | 65 +++ api/user.js | 27 + main.js | 5 +- package-lock.json | 240 ++++++++- pages.json | 8 + pages/login/login.vue | 66 ++- pages/register/register.vue | 490 ++++++++++++++++++ static/{login => icon}/Chevron right.png | Bin static/icon/Credit card.png | Bin 0 -> 352 bytes static/{login => icon}/Globe.png | Bin static/{login => icon}/Lock.png | Bin static/icon/Mail.png | Bin 0 -> 684 bytes static/icon/Map pin.png | Bin 0 -> 1081 bytes static/icon/Phone.png | Bin 0 -> 895 bytes static/{login => icon}/Repeat.png | Bin static/{login => icon}/user.png | Bin .../components/u-select/u-select.vue | 2 +- uni_modules/vk-uview-ui/package-lock.json | 264 ++++++++++ uni_modules/vk-uview-ui/package.json | 7 +- util/api.js | 368 +++++++++++++ util/common.js | 5 + vite.config.js | 15 + 26 files changed, 1606 insertions(+), 25 deletions(-) create mode 100644 api/auth.js create mode 100644 api/captcha.js create mode 100644 api/common.js create mode 100644 api/payment.js create mode 100644 api/transfer.js create mode 100644 api/user.js create mode 100644 pages/register/register.vue rename static/{login => icon}/Chevron right.png (100%) create mode 100644 static/icon/Credit card.png rename static/{login => icon}/Globe.png (100%) rename static/{login => icon}/Lock.png (100%) create mode 100644 static/icon/Mail.png create mode 100644 static/icon/Map pin.png create mode 100644 static/icon/Phone.png rename static/{login => icon}/Repeat.png (100%) rename static/{login => icon}/user.png (100%) create mode 100644 uni_modules/vk-uview-ui/package-lock.json create mode 100644 util/api.js create mode 100644 util/common.js create mode 100644 vite.config.js diff --git a/api/auth.js b/api/auth.js new file mode 100644 index 0000000..18761d8 --- /dev/null +++ b/api/auth.js @@ -0,0 +1,20 @@ +import { http } from "../util/api" + +// 认证相关API +export const authAPI = { + // 登录 + login: (data) => http.post('/auth/login', data), + + // 注册 + register: (data) => http.post('/auth/register', data), + + // 获取当前用户信息 + me: () => http.get('/auth/me'), + + // 修改密码 + changePassword: (data) => http.put('/auth/change-password', data) +} + +export default { + authAPI +} \ No newline at end of file diff --git a/api/captcha.js b/api/captcha.js new file mode 100644 index 0000000..903ab1f --- /dev/null +++ b/api/captcha.js @@ -0,0 +1,16 @@ +import { + http +} from "../util/api" + +// 验证码相关API +export const captchaAPI = { + // 生成验证码 + generate: () => http.get('/captcha/generate'), + + // 验证验证码 + verify: (data) => http.post('/captcha/verify', data) +} + +export default { + captchaAPI +} \ No newline at end of file diff --git a/api/common.js b/api/common.js new file mode 100644 index 0000000..9954c3d --- /dev/null +++ b/api/common.js @@ -0,0 +1,9 @@ +import { http } from "../util/api"; + +export const commonAPI = { + getRegion: () => http.get('/regions/provinces'), +} + +export default { + commonAPI +} \ No newline at end of file diff --git a/api/payment.js b/api/payment.js new file mode 100644 index 0000000..5c9fea3 --- /dev/null +++ b/api/payment.js @@ -0,0 +1,24 @@ +import { http } from "../util/api" + +// 支付相关API +export const paymentAPI = { + // 获取支付方式 + getMethods: () => http.get('/payment/methods'), + + // 创建支付订单 + createOrder: (data) => http.post('/payment/create-order', data), + + // 查询支付状态 + queryStatus: (outTradeNo) => http.get(`/payment/query-status/${outTradeNo}`), + + getOrder: () => http.get('/payment/check-status'), + + // 获取支付记录 + getOrders: (params = {}) => http.get('/payment/orders', { + params + }) +} + +export default { + paymentAPI +} \ No newline at end of file diff --git a/api/transfer.js b/api/transfer.js new file mode 100644 index 0000000..83ecfc9 --- /dev/null +++ b/api/transfer.js @@ -0,0 +1,65 @@ +import { + http +} from "../util/api"; + + +// 转账相关API +export const transferAPI = { + // 获取公户信息 + getPublicAccount: () => http.get('/transfers/public-account'), + + // 创建转账记录 + create: (data) => { + const formData = new FormData() + Object.keys(data).forEach(key => { + formData.append(key, data[key]) + }) + return http.post('/transfers', data) + }, + + // 确认转账 + confirm: (id) => http.put(`/transfers/${id}/confirm`), + + // 拒绝转账 + reject: (id) => http.put(`/transfers/${id}/reject`), + + // 确认收款 + confirmReceived: (id) => http.post('/transfers/confirm-received', { + transfer_id: id + }), + + // 确认未收到款 + confirmNotReceived: (id) => http.post('/transfers/confirm-not-received', { + transfer_id: id + }), + + // 获取用户转账记录 + getUserTransfers: (params = {}) => http.get('/transfers/user', { + params + }), + + // 获取指定用户的转账记录 + getUserTransfersByUserId: (userId, params = {}) => http.get(`/transfers/user/${userId}`, { + params + }), + + // 获取待确认转账 + getPendingTransfers: (params = {}) => http.get('/transfers/pending', { + params + }), + + // 获取用户账户信息 + getUserAccount: () => http.get('/transfers/account'), + + // 获取转账列表(管理员) + getList: (params = {}) => http.get('/transfers', { + params + }), + + // 获取转账统计 + getStats: () => http.get('/transfers/stats') +} + +export default { + transferAPI +} \ No newline at end of file diff --git a/api/user.js b/api/user.js new file mode 100644 index 0000000..e735f3a --- /dev/null +++ b/api/user.js @@ -0,0 +1,27 @@ +import { + http +} from "../util/api" + +// 用户相关API +export const userAPI = { + // 获取用户列表 + getList: (params = {}) => http.get('/users', { + params + }), + + // 获取用户详情 + getDetail: (id) => http.get(`/users/${id}`), + + // 更新用户信息 + update: (id, data) => http.put(`/users/${id}`, data), + + // 删除用户 + delete: (id) => http.delete(`/users/${id}`), + + // 获取用户统计 + getStats: () => http.get('/users/stats/overview') +} + +export default { + userAPI +} \ No newline at end of file diff --git a/main.js b/main.js index 7766e79..a3597aa 100644 --- a/main.js +++ b/main.js @@ -2,7 +2,6 @@ import App from './App' // 引入 uView UI import uView from './uni_modules/vk-uview-ui'; - // 引入Tabbar import TabbarVue from './components/Tabbar/Tabbar.vue'; @@ -23,10 +22,8 @@ import { } from 'vue' export function createApp() { const app = createSSRApp(App) - app.use(uView) - - app.use("Tabbar", TabbarVue) + app.component("Tabbar", TabbarVue) return { app diff --git a/package-lock.json b/package-lock.json index f0949f9..814118d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,13 +5,61 @@ "packages": { "": { "dependencies": { - "vk-uview-ui": "^1.5.2" + "vk-uview-ui": "^1.5.2", + "vue": "^3.5.21" }, "devDependencies": { "sass": "^1.92.1", "sass-loader": "^16.0.5" } }, + "node_modules/@babel/helper-string-parser": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz", + "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.27.1.tgz", + "integrity": "sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.28.4", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.28.4.tgz", + "integrity": "sha512-yZbBqeM6TkpP9du/I2pUZnJsRMGGvOuIrhjzC1AwHwW+6he4mni6Bp/m8ijn0iOuZuPI2BfkCoSRunpyjnrQKg==", + "dependencies": { + "@babel/types": "^7.28.4" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/types": { + "version": "7.28.4", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.28.4.tgz", + "integrity": "sha512-bkFqkLhh3pMBUQQkpVgWDWq/lqzc2678eUyDlTBhRqhCHFguYYGM0Efga7tYk4TogG/3x0EEl66/OQ+WGbWB/Q==", + "dependencies": { + "@babel/helper-string-parser": "^7.27.1", + "@babel/helper-validator-identifier": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", + "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==" + }, "node_modules/@parcel/watcher": { "version": "2.5.1", "resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.5.1.tgz", @@ -308,6 +356,97 @@ "url": "https://opencollective.com/parcel" } }, + "node_modules/@vue/compiler-core": { + "version": "3.5.21", + "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.21.tgz", + "integrity": "sha512-8i+LZ0vf6ZgII5Z9XmUvrCyEzocvWT+TeR2VBUVlzIH6Tyv57E20mPZ1bCS+tbejgUgmjrEh7q/0F0bibskAmw==", + "dependencies": { + "@babel/parser": "^7.28.3", + "@vue/shared": "3.5.21", + "entities": "^4.5.0", + "estree-walker": "^2.0.2", + "source-map-js": "^1.2.1" + } + }, + "node_modules/@vue/compiler-dom": { + "version": "3.5.21", + "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.5.21.tgz", + "integrity": "sha512-jNtbu/u97wiyEBJlJ9kmdw7tAr5Vy0Aj5CgQmo+6pxWNQhXZDPsRr1UWPN4v3Zf82s2H3kF51IbzZ4jMWAgPlQ==", + "dependencies": { + "@vue/compiler-core": "3.5.21", + "@vue/shared": "3.5.21" + } + }, + "node_modules/@vue/compiler-sfc": { + "version": "3.5.21", + "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.5.21.tgz", + "integrity": "sha512-SXlyk6I5eUGBd2v8Ie7tF6ADHE9kCR6mBEuPyH1nUZ0h6Xx6nZI29i12sJKQmzbDyr2tUHMhhTt51Z6blbkTTQ==", + "dependencies": { + "@babel/parser": "^7.28.3", + "@vue/compiler-core": "3.5.21", + "@vue/compiler-dom": "3.5.21", + "@vue/compiler-ssr": "3.5.21", + "@vue/shared": "3.5.21", + "estree-walker": "^2.0.2", + "magic-string": "^0.30.18", + "postcss": "^8.5.6", + "source-map-js": "^1.2.1" + } + }, + "node_modules/@vue/compiler-ssr": { + "version": "3.5.21", + "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.5.21.tgz", + "integrity": "sha512-vKQ5olH5edFZdf5ZrlEgSO1j1DMA4u23TVK5XR1uMhvwnYvVdDF0nHXJUblL/GvzlShQbjhZZ2uvYmDlAbgo9w==", + "dependencies": { + "@vue/compiler-dom": "3.5.21", + "@vue/shared": "3.5.21" + } + }, + "node_modules/@vue/reactivity": { + "version": "3.5.21", + "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.5.21.tgz", + "integrity": "sha512-3ah7sa+Cwr9iiYEERt9JfZKPw4A2UlbY8RbbnH2mGCE8NwHkhmlZt2VsH0oDA3P08X3jJd29ohBDtX+TbD9AsA==", + "dependencies": { + "@vue/shared": "3.5.21" + } + }, + "node_modules/@vue/runtime-core": { + "version": "3.5.21", + "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.5.21.tgz", + "integrity": "sha512-+DplQlRS4MXfIf9gfD1BOJpk5RSyGgGXD/R+cumhe8jdjUcq/qlxDawQlSI8hCKupBlvM+3eS1se5xW+SuNAwA==", + "dependencies": { + "@vue/reactivity": "3.5.21", + "@vue/shared": "3.5.21" + } + }, + "node_modules/@vue/runtime-dom": { + "version": "3.5.21", + "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.5.21.tgz", + "integrity": "sha512-3M2DZsOFwM5qI15wrMmNF5RJe1+ARijt2HM3TbzBbPSuBHOQpoidE+Pa+XEaVN+czbHf81ETRoG1ltztP2em8w==", + "dependencies": { + "@vue/reactivity": "3.5.21", + "@vue/runtime-core": "3.5.21", + "@vue/shared": "3.5.21", + "csstype": "^3.1.3" + } + }, + "node_modules/@vue/server-renderer": { + "version": "3.5.21", + "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.5.21.tgz", + "integrity": "sha512-qr8AqgD3DJPJcGvLcJKQo2tAc8OnXRcfxhOJCPF+fcfn5bBGz7VCcO7t+qETOPxpWK1mgysXvVT/j+xWaHeMWA==", + "dependencies": { + "@vue/compiler-ssr": "3.5.21", + "@vue/shared": "3.5.21" + }, + "peerDependencies": { + "vue": "3.5.21" + } + }, + "node_modules/@vue/shared": { + "version": "3.5.21", + "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.5.21.tgz", + "integrity": "sha512-+2k1EQpnYuVuu3N7atWyG3/xoFWIVJZq4Mz8XNOdScFI0etES75fbny/oU4lKWk/577P1zmg0ioYvpGEDZ3DLw==" + }, "node_modules/braces": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", @@ -336,6 +475,11 @@ "url": "https://paulmillr.com/funding/" } }, + "node_modules/csstype": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", + "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==" + }, "node_modules/detect-libc": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", @@ -349,6 +493,22 @@ "node": ">=0.10" } }, + "node_modules/entities": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==" + }, "node_modules/fill-range": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", @@ -401,6 +561,14 @@ "node": ">=0.12.0" } }, + "node_modules/magic-string": { + "version": "0.30.19", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.19.tgz", + "integrity": "sha512-2N21sPY9Ws53PZvsEpVtNuSW+ScYbQdp4b9qUaL+9QkHUrGFKo56Lg9Emg5s9V/qrtNBmiR01sYhUOwu3H+VOw==", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.5" + } + }, "node_modules/micromatch": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", @@ -415,6 +583,23 @@ "node": ">=8.6" } }, + "node_modules/nanoid": { + "version": "3.3.11", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", + "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, "node_modules/neo-async": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", @@ -428,6 +613,11 @@ "dev": true, "optional": true }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==" + }, "node_modules/picomatch": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", @@ -441,6 +631,33 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/postcss": { + "version": "8.5.6", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz", + "integrity": "sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "nanoid": "^3.3.11", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, "node_modules/readdirp": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz", @@ -518,7 +735,6 @@ "version": "1.2.1", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", - "dev": true, "engines": { "node": ">=0.10.0" } @@ -543,6 +759,26 @@ "engines": { "HBuilderX": "^3.1.0" } + }, + "node_modules/vue": { + "version": "3.5.21", + "resolved": "https://registry.npmjs.org/vue/-/vue-3.5.21.tgz", + "integrity": "sha512-xxf9rum9KtOdwdRkiApWL+9hZEMWE90FHh8yS1+KJAiWYh+iGWV1FquPjoO9VUHQ+VIhsCXNNyZ5Sf4++RVZBA==", + "dependencies": { + "@vue/compiler-dom": "3.5.21", + "@vue/compiler-sfc": "3.5.21", + "@vue/runtime-dom": "3.5.21", + "@vue/server-renderer": "3.5.21", + "@vue/shared": "3.5.21" + }, + "peerDependencies": { + "typescript": "*" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } } } } diff --git a/pages.json b/pages.json index 4db7dd0..08c97d9 100644 --- a/pages.json +++ b/pages.json @@ -36,6 +36,14 @@ "style": { "navigationBarTitleText": "金融" } + }, + { + "path" : "pages/register/register", + "style" : + { + "navigationBarTitleText" : "注册", + "navigationStyle": "custom" + } } ], "globalStyle": { diff --git a/pages/login/login.vue b/pages/login/login.vue index 0b4ea78..bc96af6 100644 --- a/pages/login/login.vue +++ b/pages/login/login.vue @@ -12,21 +12,24 @@ - + - + - - + + - - 刷新 + + 刷新验证码 记住我 @@ -35,8 +38,8 @@ 登录 没有账号? - 点击注册? - + 点击注册? + @@ -45,15 +48,24 @@ @@ -145,6 +174,11 @@ .login-form { padding: 10rpx 32rpx; + .captcha-img { + width: 200rpx; + height: 80rpx; + } + .reflash { width: 100%; display: flex; @@ -192,7 +226,7 @@ font-style: Expanded Semibold; font-size: 40rpx; leading-trim: NONE; - line-height: 28px; + line-height: 46rpx; letter-spacing: 0%; text-align: center; } @@ -207,7 +241,7 @@ // 文字 font-family: Work Sans; font-weight: 400; - font-size: 13px; + font-size: 26rpx; leading-trim: NONE; line-height: 100%; letter-spacing: -2%; diff --git a/pages/register/register.vue b/pages/register/register.vue new file mode 100644 index 0000000..e20b145 --- /dev/null +++ b/pages/register/register.vue @@ -0,0 +1,490 @@ + + + + + \ No newline at end of file diff --git a/static/login/Chevron right.png b/static/icon/Chevron right.png similarity index 100% rename from static/login/Chevron right.png rename to static/icon/Chevron right.png diff --git a/static/icon/Credit card.png b/static/icon/Credit card.png new file mode 100644 index 0000000000000000000000000000000000000000..6da626c4e2af49ccfc6ee9c5c1bdf1f99c183440 GIT binary patch literal 352 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz&H|6fVg?2=RS;(M3{v?36l5$8 za(7}_cTVOdki(Mh=e{Rx>{Awqf9;Ts zXquM5>cl$DfxAS({i~Ad1x7Q4*XvroFJYL({FD7g%VD0`0&E;-WEW4ryVQ3^fWd}I zovLbWyk5T^)SQ2OY(<58#ZCdanGE-?B+7nd3O^h+C-7u5n{X0O*oL{+*10QHZFuxm zx%+#;0ki!4BJa|ZnKPz1^12&*kG-ZRU?a>UaZ`Y&zv8{amvHk<*4h>h=bA$DPM&D! zvfuoJg*|7}HUVMxwTHt6cvzSZGGv-ua^h=a>D#b!#rpP=Ma-7Grc->ReBN{~3tRt1 u&dYQ0MzL3Hd_Qz|{wWU$-YPi5Hr~lH`0Y!jyXwFIVDNPHb6Mw<&;$UCd4P)m literal 0 HcmV?d00001 diff --git a/static/login/Globe.png b/static/icon/Globe.png similarity index 100% rename from static/login/Globe.png rename to static/icon/Globe.png diff --git a/static/login/Lock.png b/static/icon/Lock.png similarity index 100% rename from static/login/Lock.png rename to static/icon/Lock.png diff --git a/static/icon/Mail.png b/static/icon/Mail.png new file mode 100644 index 0000000000000000000000000000000000000000..9d088096d21157fb519c93b189675a95d26a3167 GIT binary patch literal 684 zcmV;d0#p5oP)e!jN?DpYu7h;-ryvhl~kKmk{@*uZJ9RvMG{8qq9rH@r|! zcOD%~X=nfPdpUFmq0eHs;;s{I@6r}90AtnB6P2niZ8bqd*sPOk!V~D_TCw8&XD(>=` zsrLU#AjN%jHWmsUEig{kY&52M(cm@SBa7d&My4@y$m?ZvwpZ4B2{2d%%NzF+LS38w zkih4>wxeIYE#rMfg~ofZUehojuRG5vsg43z+KCYb@6%4^g3Uu2BLGN@7l3l4|1|PbIacOUy58{2&5`1Vw`- zrKzp*hv)Z!dxry1I0d_~l6vu-aZm(~iHgA6BT(kjDT}> zgCm39yuM`}Q(%@17Um+cz5G95wFq2uHD@WHX419q0c)HH=4wtFR|gd;So{S!WaE@^ S4(c@k0000C?{xmK}n0$+@S6Okc$MA z2fWM7dTp=mjbm3G$?|%CX1@8|F@qMg<3+Au@D3RC@UyEP5CFFfV2OieEa1!cz?n7W z$(n4Ef-UfH=t46J8QA{Zd-`eJ###Wb7j^#FaLNSi>GM)!0ihtR0XoQ}gO=&hyRc8d z)DjTP11D?^0JZL-*5{zitR&Ak1OL)PwCRv>7_I`r8VV0Nz-X1= zCg)dyuuKf_@MrDta)ZOmroxFx5S>A{oT(`SbZXjL0Wdg<4)N8~gb!zda|xdTt~E>OV*y6Gs;EYzYdfSM5T-&*cK1U{JS}Z78MF4;Ez@tJlD>I=( zIG-}7wAx+G0#YWD=IAbbv^O_@FVmY?2&>&adKL1t7l3 z#umJ&0Ei*(LJjHbnm_Y(O#pJ;s$oS!t1hs?4(kp*273uP0=K-*YBrf{6BX8POAL~|Y=(0xx2-js(_V&|S?EMEWY+(Mic z0aUJI^z${SJf-}8h`RvO?pl3@3(wis*DG}ZH4D=5sw=b&aT|^^et^MRB4a~>R-hZv zO*p`K5jYdL2g$2lWB@AK6B#QZN1IqZo2S26^tTY>Bo3*Yxs`P_+N8p7uUbWwPHMCQFqgh&l#>E#g6&4*3rvG!Ngs*`REAfNH{^16X2XcQi^?&6Of#MaDphid=@b$!0e%vVgVGy zGjvNDSyslj91q2-vOUx4nSRsV>S+W28KOSvMwzb!-YQ_lpm-}3jxG{!fPX=NjEBm> z``HWJ@FIG00!t93abG&P5r&gDLEgE2EU}g*-YqO(sr(JJaitJn#a_}>?8Mmt(e1I` zPX{|BI)Vi_{3QieD@IGp$0kLNe>G9?VF@__rG{U$;P>#?x=E3fkKJFe!8$AZ5h8uV3~?d?OpHbSM8C+iIxjW(up~;C;@i4$qRWX zBzCo)OX1-A0~X*k1x+t#LsyA+ijo|`r?8yaAR$b`&i=O^1^%F%rWEr{9&kvg0G-iL z*MI@lhRu49koOdhvjru6A>2OX@O)YiAtpWOBpDkDcuXEit|Bk4k+{LAWLG3Q`xz0( zfnmFpQ~&USgW^MwD%f!VsDy7`jKeXM}nR zrT$Q1bJpq9Tci`zo1L75#54B9R06q?@qD1>0ehE;r;`ycqOYOjxLhH9ZQRt*yn2_d z$~%PAbH*i$!^_y)n@NDtjkBm)i1D1rpL4hbc1S0^j=b|}dr@wwlISrJ-EBp{M1qh~ z^6k#sB{vB;Z5LjUTb0BcjBdezla%g{7z>~^0R|T%e&sX?PAvLFbgIwYYo2Sxz@^64_8;7Z@D~_T VYSIM53e*4q002ovPDHLkV1lFUjJyB< literal 0 HcmV?d00001 diff --git a/static/login/Repeat.png b/static/icon/Repeat.png similarity index 100% rename from static/login/Repeat.png rename to static/icon/Repeat.png diff --git a/static/login/user.png b/static/icon/user.png similarity index 100% rename from static/login/user.png rename to static/icon/user.png diff --git a/uni_modules/vk-uview-ui/components/u-select/u-select.vue b/uni_modules/vk-uview-ui/components/u-select/u-select.vue index f88a2cc..8efdb30 100644 --- a/uni_modules/vk-uview-ui/components/u-select/u-select.vue +++ b/uni_modules/vk-uview-ui/components/u-select/u-select.vue @@ -260,7 +260,7 @@ export default { let num = 1; let column = this.list; // 只要有元素并且第一个元素有children属性,继续历遍 - while(column[0][this.childName]) { + while(column[0][this.childName] && column[0][this.childName].length>0) { column = column[0] ? column[0][this.childName] : {}; num ++; } diff --git a/uni_modules/vk-uview-ui/package-lock.json b/uni_modules/vk-uview-ui/package-lock.json new file mode 100644 index 0000000..5537ac9 --- /dev/null +++ b/uni_modules/vk-uview-ui/package-lock.json @@ -0,0 +1,264 @@ +{ + "name": "vk-uview-ui", + "version": "1.6.5", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "vk-uview-ui", + "version": "1.6.5", + "dependencies": { + "vue": "^3.5.21" + }, + "engines": { + "HBuilderX": "^3.1.0", + "uni-app": "^4.36", + "uni-app-x": "" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz", + "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.27.1.tgz", + "integrity": "sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.28.4", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.28.4.tgz", + "integrity": "sha512-yZbBqeM6TkpP9du/I2pUZnJsRMGGvOuIrhjzC1AwHwW+6he4mni6Bp/m8ijn0iOuZuPI2BfkCoSRunpyjnrQKg==", + "dependencies": { + "@babel/types": "^7.28.4" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/types": { + "version": "7.28.4", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.28.4.tgz", + "integrity": "sha512-bkFqkLhh3pMBUQQkpVgWDWq/lqzc2678eUyDlTBhRqhCHFguYYGM0Efga7tYk4TogG/3x0EEl66/OQ+WGbWB/Q==", + "dependencies": { + "@babel/helper-string-parser": "^7.27.1", + "@babel/helper-validator-identifier": "^7.27.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", + "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==" + }, + "node_modules/@vue/compiler-core": { + "version": "3.5.21", + "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.21.tgz", + "integrity": "sha512-8i+LZ0vf6ZgII5Z9XmUvrCyEzocvWT+TeR2VBUVlzIH6Tyv57E20mPZ1bCS+tbejgUgmjrEh7q/0F0bibskAmw==", + "dependencies": { + "@babel/parser": "^7.28.3", + "@vue/shared": "3.5.21", + "entities": "^4.5.0", + "estree-walker": "^2.0.2", + "source-map-js": "^1.2.1" + } + }, + "node_modules/@vue/compiler-dom": { + "version": "3.5.21", + "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.5.21.tgz", + "integrity": "sha512-jNtbu/u97wiyEBJlJ9kmdw7tAr5Vy0Aj5CgQmo+6pxWNQhXZDPsRr1UWPN4v3Zf82s2H3kF51IbzZ4jMWAgPlQ==", + "dependencies": { + "@vue/compiler-core": "3.5.21", + "@vue/shared": "3.5.21" + } + }, + "node_modules/@vue/compiler-sfc": { + "version": "3.5.21", + "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.5.21.tgz", + "integrity": "sha512-SXlyk6I5eUGBd2v8Ie7tF6ADHE9kCR6mBEuPyH1nUZ0h6Xx6nZI29i12sJKQmzbDyr2tUHMhhTt51Z6blbkTTQ==", + "dependencies": { + "@babel/parser": "^7.28.3", + "@vue/compiler-core": "3.5.21", + "@vue/compiler-dom": "3.5.21", + "@vue/compiler-ssr": "3.5.21", + "@vue/shared": "3.5.21", + "estree-walker": "^2.0.2", + "magic-string": "^0.30.18", + "postcss": "^8.5.6", + "source-map-js": "^1.2.1" + } + }, + "node_modules/@vue/compiler-ssr": { + "version": "3.5.21", + "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.5.21.tgz", + "integrity": "sha512-vKQ5olH5edFZdf5ZrlEgSO1j1DMA4u23TVK5XR1uMhvwnYvVdDF0nHXJUblL/GvzlShQbjhZZ2uvYmDlAbgo9w==", + "dependencies": { + "@vue/compiler-dom": "3.5.21", + "@vue/shared": "3.5.21" + } + }, + "node_modules/@vue/reactivity": { + "version": "3.5.21", + "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.5.21.tgz", + "integrity": "sha512-3ah7sa+Cwr9iiYEERt9JfZKPw4A2UlbY8RbbnH2mGCE8NwHkhmlZt2VsH0oDA3P08X3jJd29ohBDtX+TbD9AsA==", + "dependencies": { + "@vue/shared": "3.5.21" + } + }, + "node_modules/@vue/runtime-core": { + "version": "3.5.21", + "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.5.21.tgz", + "integrity": "sha512-+DplQlRS4MXfIf9gfD1BOJpk5RSyGgGXD/R+cumhe8jdjUcq/qlxDawQlSI8hCKupBlvM+3eS1se5xW+SuNAwA==", + "dependencies": { + "@vue/reactivity": "3.5.21", + "@vue/shared": "3.5.21" + } + }, + "node_modules/@vue/runtime-dom": { + "version": "3.5.21", + "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.5.21.tgz", + "integrity": "sha512-3M2DZsOFwM5qI15wrMmNF5RJe1+ARijt2HM3TbzBbPSuBHOQpoidE+Pa+XEaVN+czbHf81ETRoG1ltztP2em8w==", + "dependencies": { + "@vue/reactivity": "3.5.21", + "@vue/runtime-core": "3.5.21", + "@vue/shared": "3.5.21", + "csstype": "^3.1.3" + } + }, + "node_modules/@vue/server-renderer": { + "version": "3.5.21", + "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.5.21.tgz", + "integrity": "sha512-qr8AqgD3DJPJcGvLcJKQo2tAc8OnXRcfxhOJCPF+fcfn5bBGz7VCcO7t+qETOPxpWK1mgysXvVT/j+xWaHeMWA==", + "dependencies": { + "@vue/compiler-ssr": "3.5.21", + "@vue/shared": "3.5.21" + }, + "peerDependencies": { + "vue": "3.5.21" + } + }, + "node_modules/@vue/shared": { + "version": "3.5.21", + "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.5.21.tgz", + "integrity": "sha512-+2k1EQpnYuVuu3N7atWyG3/xoFWIVJZq4Mz8XNOdScFI0etES75fbny/oU4lKWk/577P1zmg0ioYvpGEDZ3DLw==" + }, + "node_modules/csstype": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", + "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==" + }, + "node_modules/entities": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==" + }, + "node_modules/magic-string": { + "version": "0.30.19", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.19.tgz", + "integrity": "sha512-2N21sPY9Ws53PZvsEpVtNuSW+ScYbQdp4b9qUaL+9QkHUrGFKo56Lg9Emg5s9V/qrtNBmiR01sYhUOwu3H+VOw==", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.5" + } + }, + "node_modules/nanoid": { + "version": "3.3.11", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", + "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==" + }, + "node_modules/postcss": { + "version": "8.5.6", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz", + "integrity": "sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "nanoid": "^3.3.11", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/vue": { + "version": "3.5.21", + "resolved": "https://registry.npmjs.org/vue/-/vue-3.5.21.tgz", + "integrity": "sha512-xxf9rum9KtOdwdRkiApWL+9hZEMWE90FHh8yS1+KJAiWYh+iGWV1FquPjoO9VUHQ+VIhsCXNNyZ5Sf4++RVZBA==", + "dependencies": { + "@vue/compiler-dom": "3.5.21", + "@vue/compiler-sfc": "3.5.21", + "@vue/runtime-dom": "3.5.21", + "@vue/server-renderer": "3.5.21", + "@vue/shared": "3.5.21" + }, + "peerDependencies": { + "typescript": "*" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + } + } +} diff --git a/uni_modules/vk-uview-ui/package.json b/uni_modules/vk-uview-ui/package.json index c9eb0e8..e4ee5e1 100644 --- a/uni_modules/vk-uview-ui/package.json +++ b/uni_modules/vk-uview-ui/package.json @@ -10,7 +10,7 @@ "vue3.0", "鸿蒙", "uview" -], + ], "repository": "https://gitee.com/vk-uni/vk-uview-ui.git", "engines": { "HBuilderX": "^3.1.0", @@ -98,5 +98,8 @@ } } } + }, + "dependencies": { + "vue": "^3.5.21" } -} \ No newline at end of file +} diff --git a/util/api.js b/util/api.js new file mode 100644 index 0000000..7e5d037 --- /dev/null +++ b/util/api.js @@ -0,0 +1,368 @@ +// api.js - 适配uView3+uni-app版本 + +// 基础配置 +const BASE_URL = 'http://192.168.1.43:3000/api' +const TIMEOUT = 10000 + +// 初始化时设置token +const token = uni.getStorageSync('token') +const commonHeaders = { + 'Content-Type': 'application/json' +} +if (token) { + commonHeaders['Authorization'] = `Bearer ${token}` +} + +// 请求队列,用于管理loading +let requestQueue = 0 +let loadingTimer = null + +// 显示加载动画 +const showLoading = () => { + requestQueue++ + if (loadingTimer) { + clearTimeout(loadingTimer) + loadingTimer = null + } + + loadingTimer = setTimeout(() => { + if (requestQueue > 0) { + uni.showLoading({ + title: '加载中...', + mask: true + }) + } + }, 300) +} + +// 隐藏加载动画 +const hideLoading = () => { + requestQueue-- + if (requestQueue <= 0) { + requestQueue = 0 + if (loadingTimer) { + clearTimeout(loadingTimer) + loadingTimer = null + } + uni.hideLoading() + } +} + +// 核心请求函数 +const request = (config) => { + return new Promise((resolve, reject) => { + // 请求配置处理 + const { + url, + method = 'GET', + data = {}, + params = {}, + header = {}, + showLoading = true + } = config + + // 处理请求参数 + let requestUrl = BASE_URL + url + let queryString = '' + + if (Object.keys(params).length > 0) { + queryString = Object.keys(params) + .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`) + .join('&') + requestUrl += (requestUrl.includes('?') ? '&' : '?') + queryString + } + + // 合并请求头 + const requestHeader = { + ...commonHeaders, + ...header + } + + // 显示loading + if (showLoading) { + uni.showLoading() + } + + // 发送请求 + uni.request({ + url: requestUrl, + method: method.toUpperCase(), + data: data, + header: requestHeader, + timeout: TIMEOUT, + success: (response) => { + // 处理响应 + const res = response.data + const statusCode = response.statusCode + + if (statusCode >= 200 && statusCode < 300) { + resolve(res) + } else { + // 处理HTTP错误状态 + handleError({ + response, + config + }) + reject(response) + } + }, + fail: (error) => { + console.log(error); + // 处理网络错误 + handleError({ + error, + config + }) + reject(error) + }, + complete: () => { + // 隐藏loading + if (showLoading) { + uni.hideLoading() + } + } + }) + }) +} + +// 错误处理函数 +const handleError = (errorInfo) => { + const { + response, + error, + config + } = errorInfo + + if (response) { + const { + statusCode, + data + } = response + + switch (statusCode) { + case 401: + // 未授权,清除token并根据当前页面跳转到相应的登录页 + uni.removeStorageSync('token') + uni.removeStorageSync('agentInfo') // 清除代理信息 + delete commonHeaders['Authorization'] + + // 获取当前页面栈 + const pages = getCurrentPages() + const currentPage = pages[pages.length - 1] + const currentRoute = currentPage ? currentPage.route : '' + + // 判断当前是否在代理相关页面 + if (currentRoute && currentRoute.includes('agent')) { + uni.redirectTo({ + url: '/pages/agent/mylogin' + }) + // uToast.error('') + uni.showToast({ + title: '代理登录已过期,请重新登录' + }) + } else { + uni.redirectTo({ + url: '/pages/user/mylogin' + }) + // uToast.error('登录已过期,请重新登录') + uni.showToast({ + title: '登录已过期,请重新登录' + }) + } + break + + case 403: + // 检查是否是用户被拉黑 + if (data.code === 'USER_BLACKLISTED') { + // 清除token并跳转到登录页 + uni.removeStorageSync('token') + delete commonHeaders['Authorization'] + uni.redirectTo({ + url: '/pages/user/mylogin' + }) + // uToast.error(data.message || '账户已被拉黑,请联系管理员') + uni.showToast({ + title: data.message || '账户已被拉黑,请联系管理员' + }) + } else if (data.code === 'PAYMENT_REQUIRED') { + // 需要支付,跳转到支付页面 + // 获取当前页面避免重复跳转 + const currentPages = getCurrentPages() + const currentPage = currentPages[currentPages.length - 1] + if (!currentPage || currentPage.route !== 'pages/payment/index') { + uni.redirectTo({ + url: '/pages/payment/index' + }) + uni.showToast({ + title: data.message || '您的账户尚未激活,请完成支付后再使用' + }) + // uToast.warning(data.message || '您的账户尚未激活,请完成支付后再使用') + } + } else { + // uToast.error(data.message || '权限不足') + uni.showToast({ + title: data.message || '权限不足' + }) + } + break + + case 404: + // uToast.error(data.message || '请求的资源不存在') + uni.showToast({ + title: data.message || '请求的资源不存在' + }) + break + + case 422: + // uToast.error(data.message || '请求参数错误') + uni.showToast({ + title: data.message || '请求参数错误' + }) + break + + case 429: + // uToast.error('请求过于频繁,请稍后再试') + uni.showToast({ + title: '请求过于频繁,请稍后再试' + }) + break + + case 500: + // uToast.error('服务器内部错误') + uni.showToast({ + title: '服务器内部错误' + }) + break + + case 400: + // 处理业务逻辑错误(如坏账等) + // uToast.error(data.error?.message || data.message || '请求失败') + uni.showToast({ + title: data.error?.message || data.message || '请求失败' + }) + break + + default: + // uToast.error(data.error?.message || data.message || '请求失败') + uni.showToast({ + title: data.error?.message || data.message || '请求失败' + }) + } + } else if (error) { + // 网络错误 + // uToast.error('网络连接失败,请检查网络设置') + uni.showToast({ + title: '网络连接失败,请检查网络设置' + }) + } else { + // 其他错误 + // uToast.error('请求配置错误') + uni.showToast({ + title: '请求配置错误' + }) + } +} + +// 封装常用的请求方法 +export const http = { + get: (url, config = {}) => request({ + url, + method: 'GET', + ...config + }), + post: (url, data = {}, config = {}) => request({ + url, + data, + method: 'POST', + ...config + }), + put: (url, data = {}, config = {}) => request({ + url, + data, + method: 'PUT', + ...config + }), + delete: (url, config = {}) => request({ + url, + method: 'DELETE', + ...config + }), + patch: (url, data = {}, config = {}) => request({ + url, + data, + method: 'PATCH', + ...config + }) +} + +// 设置token +export const setToken = (newToken) => { + if (newToken) { + commonHeaders['Authorization'] = `Bearer ${newToken}` + uni.setStorageSync('token', newToken) + } else { + delete commonHeaders['Authorization'] + uni.removeStorageSync('token') + } +} + +// 文件上传API +export const uploadAPI = { + // 上传图片 + uploadImage: (filePath, formData = {}) => { + return new Promise((resolve, reject) => { + uni.uploadFile({ + url: BASE_URL + '/upload/image', + filePath: filePath, + name: 'image', + formData: formData, + header: { + 'Authorization': commonHeaders['Authorization'] + }, + success: (uploadFileRes) => { + const data = JSON.parse(uploadFileRes.data) + resolve(data) + }, + fail: (error) => { + reject(error) + } + }) + }) + }, + + // 上传文件 + uploadFile: (filePath, formData = {}) => { + return new Promise((resolve, reject) => { + uni.uploadFile({ + url: BASE_URL + '/upload/file', + filePath: filePath, + name: 'file', + formData: formData, + header: { + 'Authorization': commonHeaders['Authorization'] + }, + success: (uploadFileRes) => { + const data = JSON.parse(uploadFileRes.data) + resolve(data) + }, + fail: (error) => { + reject(error) + } + }) + }) + } +} + + +export const distributionAPI = { + getLowerUsers: (params) => http.get('/agents/distribution', { + params + }), +} + +export default { + http, + setToken, + uploadAPI, + distributionAPI +} \ No newline at end of file diff --git a/util/common.js b/util/common.js new file mode 100644 index 0000000..198c5fa --- /dev/null +++ b/util/common.js @@ -0,0 +1,5 @@ +// 校验 +export const validatePhone = (phone) => { + const reg = /^1[3-9]\d{9}$/; + return reg.test(phone); +}; diff --git a/vite.config.js b/vite.config.js new file mode 100644 index 0000000..c85cf1f --- /dev/null +++ b/vite.config.js @@ -0,0 +1,15 @@ +import { + defineConfig +} from 'vite'; +import uni from '@dcloudio/vite-plugin-uni'; + +export default defineConfig({ + plugins: [uni()], + server: { + host: "0.0.0.0", // 指定服务器应该监听哪个IP地址,默认:localhost + port: 5173, // 指定开发服务器端口,默认:5173 + proxy: { // 为开发服务器配置自定义代理规则 + + } + } +}); \ No newline at end of file