18 changed files with 0 additions and 1080 deletions
@ -1,66 +0,0 @@ |
|||||
// pages/test-tools/api-test.js
|
|
||||
Page({ |
|
||||
|
|
||||
/** |
|
||||
* 页面的初始数据 |
|
||||
*/ |
|
||||
data: { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 生命周期函数--监听页面加载 |
|
||||
*/ |
|
||||
onLoad(options) { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 生命周期函数--监听页面初次渲染完成 |
|
||||
*/ |
|
||||
onReady() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 生命周期函数--监听页面显示 |
|
||||
*/ |
|
||||
onShow() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 生命周期函数--监听页面隐藏 |
|
||||
*/ |
|
||||
onHide() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 生命周期函数--监听页面卸载 |
|
||||
*/ |
|
||||
onUnload() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 页面相关事件处理函数--监听用户下拉动作 |
|
||||
*/ |
|
||||
onPullDownRefresh() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 页面上拉触底事件的处理函数 |
|
||||
*/ |
|
||||
onReachBottom() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 用户点击右上角分享 |
|
||||
*/ |
|
||||
onShareAppMessage() { |
|
||||
|
|
||||
} |
|
||||
}) |
|
||||
@ -1,2 +0,0 @@ |
|||||
<!--pages/test-tools/api-test.wxml--> |
|
||||
<text>pages/test-tools/api-test.wxml</text> |
|
||||
@ -1,66 +0,0 @@ |
|||||
// pages/test-tools/clear-storage.js
|
|
||||
Page({ |
|
||||
|
|
||||
/** |
|
||||
* 页面的初始数据 |
|
||||
*/ |
|
||||
data: { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 生命周期函数--监听页面加载 |
|
||||
*/ |
|
||||
onLoad(options) { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 生命周期函数--监听页面初次渲染完成 |
|
||||
*/ |
|
||||
onReady() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 生命周期函数--监听页面显示 |
|
||||
*/ |
|
||||
onShow() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 生命周期函数--监听页面隐藏 |
|
||||
*/ |
|
||||
onHide() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 生命周期函数--监听页面卸载 |
|
||||
*/ |
|
||||
onUnload() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 页面相关事件处理函数--监听用户下拉动作 |
|
||||
*/ |
|
||||
onPullDownRefresh() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 页面上拉触底事件的处理函数 |
|
||||
*/ |
|
||||
onReachBottom() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 用户点击右上角分享 |
|
||||
*/ |
|
||||
onShareAppMessage() { |
|
||||
|
|
||||
} |
|
||||
}) |
|
||||
@ -1,2 +0,0 @@ |
|||||
<!--pages/test-tools/clear-storage.wxml--> |
|
||||
<text>pages/test-tools/clear-storage.wxml</text> |
|
||||
@ -1,66 +0,0 @@ |
|||||
// pages/test-tools/connection-test.js
|
|
||||
Page({ |
|
||||
|
|
||||
/** |
|
||||
* 页面的初始数据 |
|
||||
*/ |
|
||||
data: { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 生命周期函数--监听页面加载 |
|
||||
*/ |
|
||||
onLoad(options) { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 生命周期函数--监听页面初次渲染完成 |
|
||||
*/ |
|
||||
onReady() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 生命周期函数--监听页面显示 |
|
||||
*/ |
|
||||
onShow() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 生命周期函数--监听页面隐藏 |
|
||||
*/ |
|
||||
onHide() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 生命周期函数--监听页面卸载 |
|
||||
*/ |
|
||||
onUnload() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 页面相关事件处理函数--监听用户下拉动作 |
|
||||
*/ |
|
||||
onPullDownRefresh() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 页面上拉触底事件的处理函数 |
|
||||
*/ |
|
||||
onReachBottom() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 用户点击右上角分享 |
|
||||
*/ |
|
||||
onShareAppMessage() { |
|
||||
|
|
||||
} |
|
||||
}) |
|
||||
@ -1,2 +0,0 @@ |
|||||
<!--pages/test-tools/connection-test.wxml--> |
|
||||
<text>pages/test-tools/connection-test.wxml</text> |
|
||||
@ -1,66 +0,0 @@ |
|||||
// pages/test-tools/fix-connection.js
|
|
||||
Page({ |
|
||||
|
|
||||
/** |
|
||||
* 页面的初始数据 |
|
||||
*/ |
|
||||
data: { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 生命周期函数--监听页面加载 |
|
||||
*/ |
|
||||
onLoad(options) { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 生命周期函数--监听页面初次渲染完成 |
|
||||
*/ |
|
||||
onReady() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 生命周期函数--监听页面显示 |
|
||||
*/ |
|
||||
onShow() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 生命周期函数--监听页面隐藏 |
|
||||
*/ |
|
||||
onHide() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 生命周期函数--监听页面卸载 |
|
||||
*/ |
|
||||
onUnload() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 页面相关事件处理函数--监听用户下拉动作 |
|
||||
*/ |
|
||||
onPullDownRefresh() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 页面上拉触底事件的处理函数 |
|
||||
*/ |
|
||||
onReachBottom() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 用户点击右上角分享 |
|
||||
*/ |
|
||||
onShareAppMessage() { |
|
||||
|
|
||||
} |
|
||||
}) |
|
||||
@ -1,2 +0,0 @@ |
|||||
<!--pages/test-tools/fix-connection.wxml--> |
|
||||
<text>pages/test-tools/fix-connection.wxml</text> |
|
||||
@ -1,66 +0,0 @@ |
|||||
// pages/test-tools/gross-weight-tester.js
|
|
||||
Page({ |
|
||||
|
|
||||
/** |
|
||||
* 页面的初始数据 |
|
||||
*/ |
|
||||
data: { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 生命周期函数--监听页面加载 |
|
||||
*/ |
|
||||
onLoad(options) { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 生命周期函数--监听页面初次渲染完成 |
|
||||
*/ |
|
||||
onReady() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 生命周期函数--监听页面显示 |
|
||||
*/ |
|
||||
onShow() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 生命周期函数--监听页面隐藏 |
|
||||
*/ |
|
||||
onHide() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 生命周期函数--监听页面卸载 |
|
||||
*/ |
|
||||
onUnload() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 页面相关事件处理函数--监听用户下拉动作 |
|
||||
*/ |
|
||||
onPullDownRefresh() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 页面上拉触底事件的处理函数 |
|
||||
*/ |
|
||||
onReachBottom() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 用户点击右上角分享 |
|
||||
*/ |
|
||||
onShareAppMessage() { |
|
||||
|
|
||||
} |
|
||||
}) |
|
||||
@ -1,2 +0,0 @@ |
|||||
<!--pages/test-tools/gross-weight-tester.wxml--> |
|
||||
<text>pages/test-tools/gross-weight-tester.wxml</text> |
|
||||
@ -1,66 +0,0 @@ |
|||||
// pages/test-tools/phone-test.js
|
|
||||
Page({ |
|
||||
|
|
||||
/** |
|
||||
* 页面的初始数据 |
|
||||
*/ |
|
||||
data: { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 生命周期函数--监听页面加载 |
|
||||
*/ |
|
||||
onLoad(options) { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 生命周期函数--监听页面初次渲染完成 |
|
||||
*/ |
|
||||
onReady() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 生命周期函数--监听页面显示 |
|
||||
*/ |
|
||||
onShow() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 生命周期函数--监听页面隐藏 |
|
||||
*/ |
|
||||
onHide() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 生命周期函数--监听页面卸载 |
|
||||
*/ |
|
||||
onUnload() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 页面相关事件处理函数--监听用户下拉动作 |
|
||||
*/ |
|
||||
onPullDownRefresh() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 页面上拉触底事件的处理函数 |
|
||||
*/ |
|
||||
onReachBottom() { |
|
||||
|
|
||||
}, |
|
||||
|
|
||||
/** |
|
||||
* 用户点击右上角分享 |
|
||||
*/ |
|
||||
onShareAppMessage() { |
|
||||
|
|
||||
} |
|
||||
}) |
|
||||
@ -1,2 +0,0 @@ |
|||||
<!--pages/test-tools/phone-test.wxml--> |
|
||||
<text>pages/test-tools/phone-test.wxml</text> |
|
||||
@ -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() |
|
||||
} |
|
||||
}) |
|
||||
@ -1,50 +0,0 @@ |
|||||
<!--pages/test-tools/test-mode-switch.wxml--> |
|
||||
<view class="container"> |
|
||||
<view class="header"> |
|
||||
<text class="title">黑白测试设置</text> |
|
||||
<text class="subtitle">调整应用的显示模式以进行黑白测试</text> |
|
||||
</view> |
|
||||
|
|
||||
<view class="setting-item"> |
|
||||
<view class="setting-label"> |
|
||||
<text class="label-text">深色模式</text> |
|
||||
<text class="label-desc">切换应用的明/暗主题</text> |
|
||||
</view> |
|
||||
<switch |
|
||||
class="setting-switch" |
|
||||
checked="{{isDarkMode}}" |
|
||||
bindchange="toggleDarkMode" |
|
||||
color="#1AAD19" |
|
||||
/> |
|
||||
</view> |
|
||||
|
|
||||
<view class="setting-item"> |
|
||||
<view class="setting-label"> |
|
||||
<text class="label-text">高对比度模式</text> |
|
||||
<text class="label-desc">启用黑白高对比度显示</text> |
|
||||
</view> |
|
||||
<switch |
|
||||
class="setting-switch" |
|
||||
checked="{{isHighContrast}}" |
|
||||
bindchange="toggleHighContrast" |
|
||||
color="#1AAD19" |
|
||||
/> |
|
||||
</view> |
|
||||
|
|
||||
<view class="button-group"> |
|
||||
<button |
|
||||
class="reset-button" |
|
||||
bindtap="resetAllSettings" |
|
||||
type="default" |
|
||||
> |
|
||||
重置为默认设置 |
|
||||
</button> |
|
||||
</view> |
|
||||
|
|
||||
<view class="tips"> |
|
||||
<text class="tip-text">提示:</text> |
|
||||
<text class="tip-content">1. 深色模式会改变应用的整体色调</text> |
|
||||
<text class="tip-content">2. 高对比度模式会将所有元素转为黑白并提高对比度</text> |
|
||||
<text class="tip-content">3. 这些设置会保存在本地,下次打开应用时自动应用</text> |
|
||||
</view> |
|
||||
</view> |
|
||||
@ -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; |
|
||||
} |
|
||||
@ -1 +0,0 @@ |
|||||
{"openid":"user_1760087570258_r8f3eepnw","page":1,"pageSize":20} |
|
||||
@ -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 |
|
||||
} |
|
||||
} |
|
||||
] |
|
||||
} |
|
||||
@ -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. 重新提交申请测试需要先有一个被拒绝的申请,在测试环境中可能会失败
|
|
||||
Loading…
Reference in new issue