From 63cf1437a849535bf7968118ab819bdaa066ca16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E9=A3=9E=E6=B4=8B?= <15778543+xufeiyang6017@user.noreply.gitee.com> Date: Fri, 5 Dec 2025 13:40:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=89=80=E6=9C=89=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E6=96=87=E4=BB=B6=EF=BC=9Adebug=E3=80=81test=E3=80=81?= =?UTF-8?q?test-tools=E7=9B=AE=E5=BD=95=E5=8F=8Aserver-example=E4=B8=8B?= =?UTF-8?q?=E7=9A=84=E6=B5=8B=E8=AF=95=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/test-tools/api-test.js | 66 ----- pages/test-tools/api-test.wxml | 2 - pages/test-tools/clear-storage.js | 66 ----- pages/test-tools/clear-storage.wxml | 2 - pages/test-tools/connection-test.js | 66 ----- pages/test-tools/connection-test.wxml | 2 - pages/test-tools/fix-connection.js | 66 ----- pages/test-tools/fix-connection.wxml | 2 - pages/test-tools/gross-weight-tester.js | 66 ----- pages/test-tools/gross-weight-tester.wxml | 2 - pages/test-tools/phone-test.js | 66 ----- pages/test-tools/phone-test.wxml | 2 - pages/test-tools/test-mode-switch.js | 139 --------- pages/test-tools/test-mode-switch.wxml | 50 ---- pages/test-tools/test-mode-switch.wxss | 149 ---------- server-example/test-request.json | 1 - ...test_results_2025-11-28T07-49-43-353Z.json | 59 ---- server-example/test_settlement_api.js | 274 ------------------ 18 files changed, 1080 deletions(-) delete mode 100644 pages/test-tools/api-test.js delete mode 100644 pages/test-tools/api-test.wxml delete mode 100644 pages/test-tools/clear-storage.js delete mode 100644 pages/test-tools/clear-storage.wxml delete mode 100644 pages/test-tools/connection-test.js delete mode 100644 pages/test-tools/connection-test.wxml delete mode 100644 pages/test-tools/fix-connection.js delete mode 100644 pages/test-tools/fix-connection.wxml delete mode 100644 pages/test-tools/gross-weight-tester.js delete mode 100644 pages/test-tools/gross-weight-tester.wxml delete mode 100644 pages/test-tools/phone-test.js delete mode 100644 pages/test-tools/phone-test.wxml delete mode 100644 pages/test-tools/test-mode-switch.js delete mode 100644 pages/test-tools/test-mode-switch.wxml delete mode 100644 pages/test-tools/test-mode-switch.wxss delete mode 100644 server-example/test-request.json delete mode 100644 server-example/test_results_2025-11-28T07-49-43-353Z.json delete mode 100644 server-example/test_settlement_api.js diff --git a/pages/test-tools/api-test.js b/pages/test-tools/api-test.js deleted file mode 100644 index 5ab8317..0000000 --- a/pages/test-tools/api-test.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/test-tools/api-test.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad(options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady() { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow() { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide() { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload() { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh() { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom() { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage() { - - } -}) \ No newline at end of file diff --git a/pages/test-tools/api-test.wxml b/pages/test-tools/api-test.wxml deleted file mode 100644 index 52cc2b5..0000000 --- a/pages/test-tools/api-test.wxml +++ /dev/null @@ -1,2 +0,0 @@ - -pages/test-tools/api-test.wxml \ No newline at end of file diff --git a/pages/test-tools/clear-storage.js b/pages/test-tools/clear-storage.js deleted file mode 100644 index 8106aaa..0000000 --- a/pages/test-tools/clear-storage.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/test-tools/clear-storage.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad(options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady() { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow() { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide() { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload() { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh() { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom() { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage() { - - } -}) \ No newline at end of file diff --git a/pages/test-tools/clear-storage.wxml b/pages/test-tools/clear-storage.wxml deleted file mode 100644 index f03c1cd..0000000 --- a/pages/test-tools/clear-storage.wxml +++ /dev/null @@ -1,2 +0,0 @@ - -pages/test-tools/clear-storage.wxml \ No newline at end of file diff --git a/pages/test-tools/connection-test.js b/pages/test-tools/connection-test.js deleted file mode 100644 index 2d1276a..0000000 --- a/pages/test-tools/connection-test.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/test-tools/connection-test.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad(options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady() { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow() { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide() { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload() { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh() { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom() { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage() { - - } -}) \ No newline at end of file diff --git a/pages/test-tools/connection-test.wxml b/pages/test-tools/connection-test.wxml deleted file mode 100644 index f6f0398..0000000 --- a/pages/test-tools/connection-test.wxml +++ /dev/null @@ -1,2 +0,0 @@ - -pages/test-tools/connection-test.wxml \ No newline at end of file diff --git a/pages/test-tools/fix-connection.js b/pages/test-tools/fix-connection.js deleted file mode 100644 index e00ffd0..0000000 --- a/pages/test-tools/fix-connection.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/test-tools/fix-connection.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad(options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady() { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow() { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide() { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload() { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh() { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom() { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage() { - - } -}) \ No newline at end of file diff --git a/pages/test-tools/fix-connection.wxml b/pages/test-tools/fix-connection.wxml deleted file mode 100644 index a9e8c39..0000000 --- a/pages/test-tools/fix-connection.wxml +++ /dev/null @@ -1,2 +0,0 @@ - -pages/test-tools/fix-connection.wxml \ No newline at end of file diff --git a/pages/test-tools/gross-weight-tester.js b/pages/test-tools/gross-weight-tester.js deleted file mode 100644 index 34bee83..0000000 --- a/pages/test-tools/gross-weight-tester.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/test-tools/gross-weight-tester.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad(options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady() { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow() { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide() { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload() { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh() { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom() { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage() { - - } -}) \ No newline at end of file diff --git a/pages/test-tools/gross-weight-tester.wxml b/pages/test-tools/gross-weight-tester.wxml deleted file mode 100644 index be81f4b..0000000 --- a/pages/test-tools/gross-weight-tester.wxml +++ /dev/null @@ -1,2 +0,0 @@ - -pages/test-tools/gross-weight-tester.wxml \ No newline at end of file diff --git a/pages/test-tools/phone-test.js b/pages/test-tools/phone-test.js deleted file mode 100644 index d7319c4..0000000 --- a/pages/test-tools/phone-test.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/test-tools/phone-test.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad(options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady() { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow() { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide() { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload() { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh() { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom() { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage() { - - } -}) \ No newline at end of file diff --git a/pages/test-tools/phone-test.wxml b/pages/test-tools/phone-test.wxml deleted file mode 100644 index 1e321e5..0000000 --- a/pages/test-tools/phone-test.wxml +++ /dev/null @@ -1,2 +0,0 @@ - -pages/test-tools/phone-test.wxml \ No newline at end of file diff --git a/pages/test-tools/test-mode-switch.js b/pages/test-tools/test-mode-switch.js deleted file mode 100644 index f7df78b..0000000 --- a/pages/test-tools/test-mode-switch.js +++ /dev/null @@ -1,139 +0,0 @@ -// pages/test-tools/test-mode-switch.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - isDarkMode: false, - isHighContrast: false - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad(options) { - // 从本地存储获取当前模式设置 - const darkMode = wx.getStorageSync('isDarkMode') || false - const highContrast = wx.getStorageSync('isHighContrast') || false - this.setData({ - isDarkMode: darkMode, - isHighContrast: highContrast - }) - this.applyModeSettings() - }, - - /** - * 切换深色/浅色模式 - */ - toggleDarkMode(e) { - const isDarkMode = e.detail.value - this.setData({ isDarkMode }) - wx.setStorageSync('isDarkMode', isDarkMode) - this.applyModeSettings() - }, - - /** - * 切换高对比度模式 - */ - toggleHighContrast(e) { - const isHighContrast = e.detail.value - this.setData({ isHighContrast }) - wx.setStorageSync('isHighContrast', isHighContrast) - this.applyModeSettings() - }, - - /** - * 应用模式设置 - */ - applyModeSettings() { - const { isDarkMode, isHighContrast } = this.data - - // 创建或删除高对比度样式 - this.createOrRemoveHighContrastStyle(isHighContrast) - - // 更新窗口背景和导航栏样式 - this.updateWindowStyle(isDarkMode) - - console.log(`黑白测试模式设置: 深色模式=${isDarkMode}, 高对比度=${isHighContrast}`) - wx.showToast({ - title: '模式已更新', - icon: 'success' - }) - }, - - /** - * 创建或删除高对比度样式 - */ - createOrRemoveHighContrastStyle(enable) { - // 移除旧的高对比度样式 - const oldStyle = wx.createSelectorQuery().select('#highContrastStyle') - oldStyle.context((res) => { - if (res.context) { - wx.removeStyleSheet('#highContrastStyle') - } - }) - - if (enable) { - // 创建高对比度样式 - const styleContent = ` - /* 高对比度样式 */ - * { - filter: grayscale(100%) contrast(120%) !important; - } - - /* 确保文字可读性 */ - text, span, div, p { - color: #000 !important; - background-color: #fff !important; - } - - /* 按钮和交互元素 */ - button, .btn { - border: 2px solid #000 !important; - color: #000 !important; - background-color: #fff !important; - } - ` - - // 动态添加样式 - const styleSheet = document.createElement('style') - styleSheet.id = 'highContrastStyle' - styleSheet.textContent = styleContent - document.head.appendChild(styleSheet) - } - }, - - /** - * 更新窗口样式 - */ - updateWindowStyle(isDarkMode) { - wx.setNavigationBarColor({ - frontColor: isDarkMode ? '#ffffff' : '#000000', - backgroundColor: isDarkMode ? '#000000' : '#ffffff', - animation: { - duration: 400, - timingFunc: 'easeInOut' - } - }) - - wx.setBackgroundColor({ - backgroundColor: isDarkMode ? '#000000' : '#ffffff', - backgroundColorTop: isDarkMode ? '#000000' : '#ffffff', - backgroundColorBottom: isDarkMode ? '#000000' : '#ffffff' - }) - }, - - /** - * 重置所有设置 - */ - resetAllSettings() { - this.setData({ - isDarkMode: false, - isHighContrast: false - }) - wx.setStorageSync('isDarkMode', false) - wx.setStorageSync('isHighContrast', false) - this.applyModeSettings() - } -}) \ No newline at end of file diff --git a/pages/test-tools/test-mode-switch.wxml b/pages/test-tools/test-mode-switch.wxml deleted file mode 100644 index 1fb3963..0000000 --- a/pages/test-tools/test-mode-switch.wxml +++ /dev/null @@ -1,50 +0,0 @@ - - - - 黑白测试设置 - 调整应用的显示模式以进行黑白测试 - - - - - 深色模式 - 切换应用的明/暗主题 - - - - - - - 高对比度模式 - 启用黑白高对比度显示 - - - - - - - - - - 提示: - 1. 深色模式会改变应用的整体色调 - 2. 高对比度模式会将所有元素转为黑白并提高对比度 - 3. 这些设置会保存在本地,下次打开应用时自动应用 - - \ No newline at end of file diff --git a/pages/test-tools/test-mode-switch.wxss b/pages/test-tools/test-mode-switch.wxss deleted file mode 100644 index 73d1bf2..0000000 --- a/pages/test-tools/test-mode-switch.wxss +++ /dev/null @@ -1,149 +0,0 @@ -/** pages/test-tools/test-mode-switch.wxss **/ -.container { - padding: 40rpx 30rpx; - background-color: #fff; - min-height: 100vh; -} - -.header { - text-align: center; - margin-bottom: 60rpx; -} - -.title { - font-size: 36rpx; - font-weight: bold; - color: #333; - display: block; - margin-bottom: 20rpx; -} - -.subtitle { - font-size: 26rpx; - color: #666; - display: block; - line-height: 1.5; -} - -.setting-item { - display: flex; - align-items: center; - justify-content: space-between; - padding: 30rpx 0; - border-bottom: 1rpx solid #f0f0f0; -} - -.setting-label { - flex: 1; - margin-right: 30rpx; -} - -.label-text { - font-size: 30rpx; - color: #333; - display: block; - margin-bottom: 8rpx; -} - -.label-desc { - font-size: 24rpx; - color: #999; - display: block; - line-height: 1.4; -} - -.setting-switch { - transform: scale(1.2); -} - -.button-group { - margin-top: 60rpx; - padding: 0 20rpx; -} - -.reset-button { - width: 100%; - height: 90rpx; - line-height: 90rpx; - font-size: 30rpx; - border-radius: 15rpx; - border: 2rpx solid #1AAD19; - color: #1AAD19; - background-color: #fff; -} - -.reset-button:active { - background-color: #f0f0f0; -} - -.tips { - margin-top: 60rpx; - padding: 30rpx; - background-color: #f8f8f8; - border-radius: 15rpx; - border-left: 4rpx solid #1AAD19; -} - -.tip-text { - font-size: 28rpx; - font-weight: bold; - color: #333; - display: block; - margin-bottom: 15rpx; -} - -.tip-content { - font-size: 24rpx; - color: #666; - display: block; - margin-bottom: 10rpx; - line-height: 1.5; -} - -/* 深色模式适配 */ -.container.dark-mode { - background-color: #1a1a1a; -} - -.container.dark-mode .title { - color: #fff; -} - -.container.dark-mode .subtitle { - color: #ccc; -} - -.container.dark-mode .setting-item { - border-bottom-color: #333; -} - -.container.dark-mode .label-text { - color: #fff; -} - -.container.dark-mode .label-desc { - color: #999; -} - -.container.dark-mode .reset-button { - border-color: #4CAF50; - color: #4CAF50; - background-color: #1a1a1a; -} - -.container.dark-mode .reset-button:active { - background-color: #333; -} - -.container.dark-mode .tips { - background-color: #2a2a2a; - border-left-color: #4CAF50; -} - -.container.dark-mode .tip-text { - color: #fff; -} - -.container.dark-mode .tip-content { - color: #ccc; -} \ No newline at end of file diff --git a/server-example/test-request.json b/server-example/test-request.json deleted file mode 100644 index 988f3cd..0000000 --- a/server-example/test-request.json +++ /dev/null @@ -1 +0,0 @@ -{"openid":"user_1760087570258_r8f3eepnw","page":1,"pageSize":20} \ No newline at end of file diff --git a/server-example/test_results_2025-11-28T07-49-43-353Z.json b/server-example/test_results_2025-11-28T07-49-43-353Z.json deleted file mode 100644 index 8c2c370..0000000 --- a/server-example/test_results_2025-11-28T07-49-43-353Z.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "timestamp": "2025-11-28T07:49:43.354Z", - "baseUrl": "http://localhost:3003", - "testData": { - "openid": "test_openid_1764316183092", - "userId": "test_user_id_1764316183092", - "collaborationid": "supplier", - "company": "测试供应商公司", - "province": "北京市", - "city": "北京市", - "district": "海淀区", - "detailedaddress": "中关村科技园区", - "cooperation": "wholesale", - "phone": "13800138000", - "applicationId": "mock_application_id_1764316183154" - }, - "results": [ - { - "name": "上传文件", - "status": "passed", - "data": "https://example.com/uploaded/test_business_license.jpg" - }, - { - "name": "提交入驻申请", - "status": "passed", - "data": { - "success": true, - "data": { - "applicationId": "mock_application_id_1764316183154" - } - } - }, - { - "name": "获取入驻状态", - "status": "passed", - "data": { - "success": true, - "data": { - "partnerstatus": "underreview", - "id": "mock_application_id_1764316183154" - } - } - }, - { - "name": "撤回入驻申请", - "status": "passed", - "data": { - "success": true - } - }, - { - "name": "重新提交入驻申请", - "status": "passed", - "data": { - "success": true - } - } - ] -} \ No newline at end of file diff --git a/server-example/test_settlement_api.js b/server-example/test_settlement_api.js deleted file mode 100644 index 701c9b9..0000000 --- a/server-example/test_settlement_api.js +++ /dev/null @@ -1,274 +0,0 @@ -// 立即入驻功能API接口测试脚本 -const axios = require('axios'); -const fs = require('fs'); -const path = require('path'); - -// 服务器基础URL - 根据实际情况修改 -const BASE_URL = 'http://localhost:3003'; - -// 测试用的临时数据 -const testData = { - openid: 'test_openid_' + Date.now(), - userId: 'test_user_id_' + Date.now(), - collaborationid: 'supplier', // 合作商身份ID - company: '测试供应商公司', - province: '北京市', - city: '北京市', - district: '海淀区', - detailedaddress: '中关村科技园区', - cooperation: 'wholesale', // 合作模式 - phone: null, - applicationId: null // 将在测试过程中设置 -}; - -// 测试结果 -const testResults = []; - -// 测试函数 - 统一处理测试结果 -async function runTest(testName, testFunction) { - console.log(`\n===== 开始测试: ${testName} =====`); - try { - const result = await testFunction(); - testResults.push({ name: testName, status: 'passed', data: result }); - console.log(`✅ 测试通过: ${testName}`); - return result; - } catch (error) { - testResults.push({ name: testName, status: 'failed', error: error.message }); - console.error(`❌ 测试失败: ${testName}`, error.message); - return null; - } -} - -// 1. 测试上传文件接口 -async function testUploadFile() { - console.log('测试上传文件接口...'); - - // 注意:实际测试需要准备一个测试图片文件 - // 这里我们模拟一个成功的上传结果,因为实际文件上传需要物理文件 - const mockUploadResult = { - success: true, - data: { - fileUrl: 'https://example.com/uploaded/test_business_license.jpg' - } - }; - - console.log('模拟文件上传成功:', mockUploadResult.data.fileUrl); - return mockUploadResult.data.fileUrl; - - // 以下是实际上传文件的代码(需要准备测试文件) - /* - const formData = new FormData(); - formData.append('file', fs.createReadStream('./test_license.jpg')); - formData.append('openid', testData.openid); - formData.append('userId', testData.userId); - formData.append('fileType', 'license'); - - const response = await axios.post(`${BASE_URL}/api/settlement/upload`, formData, { - headers: { - 'Content-Type': 'multipart/form-data' - } - }); - - if (response.data.success) { - return response.data.data.fileUrl; - } else { - throw new Error(response.data.message || '文件上传失败'); - } - */ -} - -// 2. 测试提交入驻申请接口 -async function testSubmitApplication(businessLicenseUrl) { - console.log('测试提交入驻申请接口...'); - - const submitData = { - openid: testData.openid, - collaborationid: testData.collaborationid, - company: testData.company, - province: testData.province, - city: testData.city, - district: testData.district, - detailedaddress: testData.detailedaddress, - cooperation: testData.cooperation, - phone: testData.phone, - businesslicenseurl: businessLicenseUrl, - proofurl: 'https://example.com/uploaded/test_proof.jpg', // 模拟的证明文件URL - brandurl: 'https://example.com/uploaded/test_brand.jpg' // 模拟的品牌授权URL - }; - - try { - const response = await axios.post(`${BASE_URL}/api/settlement/submit`, submitData); - - if (response.data.success) { - testData.applicationId = response.data.data.applicationId; - console.log('入驻申请提交成功,申请ID:', testData.applicationId); - return response.data; - } else { - throw new Error(response.data.message || '提交入驻申请失败'); - } - } catch (error) { - console.error('提交入驻申请时的HTTP错误:', error.message); - // 模拟成功响应以便继续测试流程 - const mockResponse = { - success: true, - data: { - applicationId: 'mock_application_id_' + Date.now() - } - }; - testData.applicationId = mockResponse.data.applicationId; - console.log('使用模拟的成功响应,申请ID:', testData.applicationId); - return mockResponse; - } -} - -// 3. 测试获取入驻状态接口 -async function testGetSettlementStatus() { - console.log('测试获取入驻状态接口...'); - - try { - const response = await axios.get(`${BASE_URL}/api/settlement/status/${testData.userId}`); - - if (response.data.success) { - console.log('获取入驻状态成功,状态:', response.data.data.partnerstatus); - return response.data; - } else { - throw new Error(response.data.message || '获取入驻状态失败'); - } - } catch (error) { - console.error('获取入驻状态时的HTTP错误:', error.message); - // 模拟成功响应 - const mockResponse = { - success: true, - data: { - partnerstatus: 'underreview', - id: testData.applicationId - } - }; - console.log('使用模拟的成功响应,状态:', mockResponse.data.partnerstatus); - return mockResponse; - } -} - -// 4. 测试撤回入驻申请接口 -async function testWithdrawApplication() { - console.log('测试撤回入驻申请接口...'); - - if (!testData.applicationId) { - throw new Error('没有可用的申请ID'); - } - - try { - const response = await axios.post( - `${BASE_URL}/api/settlement/withdraw/${testData.applicationId}`, - { openid: testData.openid } - ); - - if (response.data.success) { - console.log('撤回入驻申请成功'); - return response.data; - } else { - throw new Error(response.data.message || '撤回入驻申请失败'); - } - } catch (error) { - console.error('撤回入驻申请时的HTTP错误:', error.message); - // 模拟成功响应 - const mockResponse = { success: true }; - console.log('使用模拟的成功响应'); - return mockResponse; - } -} - -// 5. 测试重新提交入驻申请接口(需要先有被拒绝的申请) -async function testResubmitApplication() { - console.log('测试重新提交入驻申请接口...'); - - if (!testData.applicationId) { - throw new Error('没有可用的申请ID'); - } - - try { - const response = await axios.post( - `${BASE_URL}/api/settlement/resubmit/${testData.applicationId}`, - { openid: testData.openid } - ); - - if (response.data.success) { - console.log('重新提交入驻申请成功'); - return response.data; - } else { - throw new Error(response.data.message || '重新提交入驻申请失败'); - } - } catch (error) { - console.error('重新提交入驻申请时的HTTP错误:', error.message); - // 模拟成功响应 - const mockResponse = { success: true }; - console.log('使用模拟的成功响应'); - return mockResponse; - } -} - -// 主测试流程 -async function runAllTests() { - console.log('\n========== 开始执行立即入驻功能API测试 =========='); - console.log('测试环境:', BASE_URL); - console.log('测试用户:', testData.openid); - - try { - // 1. 上传文件测试 - const businessLicenseUrl = await runTest('上传文件', testUploadFile); - - // 2. 提交入驻申请测试 - await runTest('提交入驻申请', () => testSubmitApplication(businessLicenseUrl)); - - // 3. 获取入驻状态测试 - await runTest('获取入驻状态', testGetSettlementStatus); - - // 4. 撤回入驻申请测试 - await runTest('撤回入驻申请', testWithdrawApplication); - - // 5. 重新提交入驻申请测试(注意:在实际场景中,需要先有被拒绝的申请) - // 由于测试环境限制,这里可能会失败,这是预期行为 - await runTest('重新提交入驻申请', testResubmitApplication); - - } finally { - // 打印测试总结 - console.log('\n========== 测试总结 =========='); - const passed = testResults.filter(r => r.status === 'passed').length; - const failed = testResults.filter(r => r.status === 'failed').length; - - console.log(`总测试数: ${testResults.length}`); - console.log(`通过: ${passed}`); - console.log(`失败: ${failed}`); - - if (failed > 0) { - console.log('\n失败的测试:'); - testResults.forEach(result => { - if (result.status === 'failed') { - console.log(`- ${result.name}: ${result.error}`); - } - }); - } - - // 保存测试结果到文件 - const resultFileName = `test_results_${new Date().toISOString().replace(/[:.]/g, '-')}.json`; - fs.writeFileSync( - path.join(__dirname, resultFileName), - JSON.stringify({ - timestamp: new Date().toISOString(), - baseUrl: BASE_URL, - testData: testData, - results: testResults - }, null, 2) - ); - console.log(`\n测试结果已保存到: ${resultFileName}`); - } -} - -// 执行测试 -runAllTests(); - -// 注意事项: -// 1. 运行此测试脚本前,请确保服务器已经启动 -// 2. 对于文件上传测试,需要准备一个实际的图片文件并修改相关代码 -// 3. 测试结果会保存在当前目录下的test_results_时间戳.json文件中 -// 4. 重新提交申请测试需要先有一个被拒绝的申请,在测试环境中可能会失败 \ No newline at end of file