refactor: 项目重构,仅保留 login 和 supplementPersonal 页面
删除 11 个旧页面、组件、lefu SDK、旧资源文件。 新增 request 封装(GET/POST/PUT)、api 层、utils/common 身份证工具。 重写 login(登录流程提取到 app.ts) 和 supplementPersonal(简化表单逻辑)。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
439f560218
commit
83d909b95b
@@ -1,10 +1,8 @@
|
||||
import type { ApiResponse, HttpMethod, RequestOptions } from './types'
|
||||
import { BASE_URL, TIMEOUT } from './config'
|
||||
|
||||
export type { ApiResponse, RequestOptions }
|
||||
|
||||
// const BASE_URL = 'http://10.10.10.10:8889/' // 测试环境
|
||||
const BASE_URL = 'https://device.shuziweidao.com/gateway/' // 正式环境
|
||||
|
||||
let _loadingCount = 0
|
||||
|
||||
const _showLoading = (title: string): void => {
|
||||
@@ -29,7 +27,7 @@ const request = <T = any>(
|
||||
|
||||
const header: Record<string, string> = { 'content-type': contentType }
|
||||
const token = wx.getStorageSync('token') as string
|
||||
if (token) header['X-Access-Token'] = token
|
||||
if (token) header['abtoken'] = token
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
wx.request({
|
||||
@@ -37,17 +35,14 @@ const request = <T = any>(
|
||||
data,
|
||||
method,
|
||||
header,
|
||||
timeout: TIMEOUT,
|
||||
success: (res) => {
|
||||
if (loading) _hideLoading()
|
||||
const body = res.data as ApiResponse<T>
|
||||
if (body.code === 200) {
|
||||
if (body.code === '00000') {
|
||||
resolve(body)
|
||||
} else if (body.code === 401) {
|
||||
wx.clearStorageSync()
|
||||
wx.reLaunch({ url: '/pages/login/login' })
|
||||
reject(body)
|
||||
} else {
|
||||
wx.showToast({ title: body.message || '请求失败', icon: 'none' })
|
||||
wx.showToast({ title: body.msg || '请求失败', icon: 'none' })
|
||||
reject(body)
|
||||
}
|
||||
},
|
||||
@@ -77,12 +72,3 @@ export const put = <T = any>(
|
||||
data?: Record<string, any>,
|
||||
options?: RequestOptions,
|
||||
): Promise<ApiResponse<T>> => request<T>(url, data, 'PUT', options)
|
||||
|
||||
export const del = <T = any>(
|
||||
url: string,
|
||||
data?: Record<string, any>,
|
||||
options?: RequestOptions,
|
||||
): Promise<ApiResponse<T>> => request<T>(url, data, 'DELETE', {
|
||||
contentType: 'application/x-www-form-urlencoded',
|
||||
...options,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user