diff --git a/api/institutionalStructure.js b/api/institutionalStructure.js new file mode 100644 index 0000000..0d0e666 --- /dev/null +++ b/api/institutionalStructure.js @@ -0,0 +1,76 @@ +// 建制相关API +import { request } from '@/utils/request' + +/** + * 获取建制数据列表 + * @param {Object} params - 查询参数 + * @param {number} params.pageNum - 页码 + * @param {number} params.pageSize - 每页数量 + * @param {string} params.orderByColumn - 排序字段 + * @param {string} params.isAsc - 排序方式 + * @returns {Promise} 返回建制数据 + */ +export function getInstitutionalList(params = {}) { + const defaultParams = { + pageNum: 1, + pageSize: 10, + orderByColumn: 'createTime', + isAsc: 'descending' + } + + return request({ + url: '/app/formed/listFormed', + method: 'GET', + params: { ...defaultParams, ...params } + }) +} + +/** + * 获取建制详情 + * @param {string} id - 建制项目ID + * @returns {Promise} 返回建制详情 + */ +export function getInstitutionalDetail(id) { + return request({ + url: `/app/formed/getFormed/${id}`, + method: 'GET' + }) +} + +/** + * 创建建制项目 + * @param {Object} data - 项目数据 + * @returns {Promise} 返回创建结果 + */ +export function createInstitutional(data) { + return request({ + url: '/app/formed/createFormed', + method: 'POST', + data + }) +} + +/** + * 更新建制项目 + * @param {Object} data - 项目数据 + * @returns {Promise} 返回更新结果 + */ +export function updateInstitutional(data) { + return request({ + url: '/app/formed/updateFormed', + method: 'PUT', + data + }) +} + +/** + * 删除建制项目 + * @param {string} id - 项目ID + * @returns {Promise} 返回删除结果 + */ +export function deleteInstitutional(id) { + return request({ + url: `/app/formed/deleteFormed/${id}`, + method: 'DELETE' + }) +} \ No newline at end of file diff --git a/pages.json b/pages.json index 44872e2..23a368a 100644 --- a/pages.json +++ b/pages.json @@ -61,6 +61,15 @@ "enablePullDownRefresh": false, "navigationStyle": "custom" } + }, + { + "path" : "pages/walkInto/walkInto", + "style" : + { + "navigationBarTitleText": "", + "enablePullDownRefresh": false, + "navigationStyle": "custom" + } } ], diff --git a/pages/institutionalStructure/institutionalStructure.vue b/pages/institutionalStructure/institutionalStructure.vue index 36c03b7..00808ef 100644 --- a/pages/institutionalStructure/institutionalStructure.vue +++ b/pages/institutionalStructure/institutionalStructure.vue @@ -1,7 +1,7 @@ @@ -74,12 +164,13 @@ page { } .container { width: 100%; - height: 100%; + min-height: 100vh; display: flex; align-items: flex-start; flex-direction: column; background-color: #FFFBF5; padding: 0 11rpx; + padding-bottom: 40rpx; } .tile { display: flex; @@ -120,4 +211,29 @@ page { align-items: center; padding: 0 20rpx; } +.subRow{ + display: flex; +} +.subRow view{ + padding-right: 20px; + font-size: 18px; +} +.topLeft{ + font-size: 21px; + font-weight: 1000; + color: #522510; +} +.bottomRight{ + font-size: 18px; + font-weight: 1000; + color: #522510; +} +.loading, .empty { + display: flex; + justify-content: center; + align-items: center; + color: #999; + font-size: 28rpx; + background-color: #FFFBF5; +} \ No newline at end of file diff --git a/pages/walkInto/walkInto.vue b/pages/walkInto/walkInto.vue new file mode 100644 index 0000000..ee63b14 --- /dev/null +++ b/pages/walkInto/walkInto.vue @@ -0,0 +1,43 @@ + + + + + \ No newline at end of file diff --git a/utils/request.js b/utils/request.js new file mode 100644 index 0000000..461f6e3 --- /dev/null +++ b/utils/request.js @@ -0,0 +1,151 @@ +// 统一请求工具 +import { getTempToken, shouldUseTempToken } from '@/config/dev.js' + +const BASE_URL = 'http://192.168.2.7:4501' + +/** + * 统一请求方法 + * @param {Object} options - 请求配置 + * @param {string} options.url - 请求地址 + * @param {string} options.method - 请求方法 + * @param {Object} options.params - 查询参数 + * @param {Object} options.data - 请求体数据 + * @param {Object} options.header - 请求头 + * @returns {Promise} 返回请求结果 + */ +export function request(options = {}) { + return new Promise((resolve, reject) => { + // 获取token,优先使用本地存储的token,如果没有则使用临时token + const localToken = uni.getStorageSync('token') + let token = localToken + + // 如果本地没有token且启用了临时token,则使用临时token + if (!token && shouldUseTempToken()) { + token = getTempToken() + console.log('使用临时token进行开发测试') + } + + // 构建请求配置 + const requestOptions = { + url: BASE_URL + options.url, + method: options.method || 'GET', + header: { + 'Content-Type': 'application/json', + ...options.header + }, + success: (res) => { + // 请求成功处理 + if (res.statusCode === 200) { + resolve(res.data) + } else if (res.statusCode === 401) { + // 认证失败 + uni.showToast({ + title: '登录已过期,请重新登录', + icon: 'none' + }) + setTimeout(() => { + uni.navigateTo({ + url: '/pages/login/login' + }) + }, 1500) + reject(new Error('认证失败')) + } else { + // 其他错误 + uni.showToast({ + title: res.data?.msg || '请求失败', + icon: 'none' + }) + reject(new Error(res.data?.msg || '请求失败')) + } + }, + fail: (err) => { + // 请求失败处理 + console.error('请求失败:', err) + uni.showToast({ + title: '网络错误', + icon: 'none' + }) + reject(err) + } + } + + // 添加token到请求头 + if (token) { + requestOptions.header.Authorization = token + } + + // 添加参数 + if (options.params) { + requestOptions.data = options.params + } + + if (options.data) { + requestOptions.data = options.data + } + + // 发起请求 + uni.request(requestOptions) + }) +} + +/** + * GET请求 + * @param {string} url - 请求地址 + * @param {Object} params - 查询参数 + * @param {Object} header - 请求头 + * @returns {Promise} 返回请求结果 + */ +export function get(url, params = {}, header = {}) { + return request({ + url, + method: 'GET', + params, + header + }) +} + +/** + * POST请求 + * @param {string} url - 请求地址 + * @param {Object} data - 请求体数据 + * @param {Object} header - 请求头 + * @returns {Promise} 返回请求结果 + */ +export function post(url, data = {}, header = {}) { + return request({ + url, + method: 'POST', + data, + header + }) +} + +/** + * PUT请求 + * @param {string} url - 请求地址 + * @param {Object} data - 请求体数据 + * @param {Object} header - 请求头 + * @returns {Promise} 返回请求结果 + */ +export function put(url, data = {}, header = {}) { + return request({ + url, + method: 'PUT', + data, + header + }) +} + +/** + * DELETE请求 + * @param {string} url - 请求地址 + * @param {Object} header - 请求头 + * @returns {Promise} 返回请求结果 + */ +export function del(url, header = {}) { + return request({ + url, + method: 'DELETE', + header + }) +} \ No newline at end of file