commit 61fcf7dd7129292fe8f079aea8c76cf6742ceabe
Author: yuhawu <15545526+yuhawu@user.noreply.gitee.com>
Date: Mon Nov 24 10:25:20 2025 +0800
初始提交:知书小程序项目
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..e69de29
diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644
index 0000000..b91d231
--- /dev/null
+++ b/.vscode/launch.json
@@ -0,0 +1,15 @@
+{
+ // 使用 IntelliSense 了解相关属性。
+ // 悬停以查看现有属性的描述。
+ // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "type": "pwa-chrome",
+ "request": "launch",
+ "name": "Launch Chrome against localhost",
+ "url": "https://api.buzhiyushu.cn",
+ "webRoot": "${workspaceFolder}"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/App.vue b/App.vue
new file mode 100644
index 0000000..6c36b9b
--- /dev/null
+++ b/App.vue
@@ -0,0 +1,85 @@
+
+
+
+
+
+
+
+
+
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..4183138
--- /dev/null
+++ b/README.md
@@ -0,0 +1,63 @@
+# 图书上传系统 - 页面拆分说明
+
+## 已完成工作
+
+已将原有的单页面应用拆分为三个独立页面:
+
+1. **首页(pages/index/index.vue)**
+ - 重新设计为导航页面
+ - 提供两种上传方式的入口:ISBN上传和仅书名上传
+ - 简洁直观的UI,便于用户选择
+
+2. **ISBN上传页面(pages/isbn-upload/index.vue)**
+ - 专门用于ISBN扫码上传
+ - 包含扫码功能、书籍信息填写、图片上传等功能
+ - 与原页面中的ISBN上传部分功能一致
+
+3. **仅书名上传页面(pages/title-upload/index.vue)**
+ - 专门用于根据书名搜索上传
+ - 包含书名搜索、结果选择、图片上传等功能
+ - 与原页面中的仅书名上传部分功能一致
+
+## 下一步操作
+
+为完成系统集成,需要进行以下操作:
+
+1. **更新pages.json配置文件**
+ - 添加新创建的页面路径
+ ```json
+ {
+ "pages": [
+ {
+ "path": "pages/index/index",
+ "style": {
+ "navigationBarTitleText": "图书上传系统"
+ }
+ },
+ {
+ "path": "pages/isbn-upload/index",
+ "style": {
+ "navigationBarTitleText": "ISBN上传"
+ }
+ },
+ {
+ "path": "pages/title-upload/index",
+ "style": {
+ "navigationBarTitleText": "仅书名上传"
+ }
+ }
+ // 其他已有页面...
+ ]
+ }
+ ```
+
+2. **测试新页面功能**
+ - 确保所有功能正常运行
+ - 检查页面间的跳转是否流畅
+ - 验证各项功能是否与原系统一致
+
+## 注意事项
+
+- 拆分后的页面共用同样的组件和样式
+- 保留了原始功能,只是将其分散到不同页面
+- 如有UI上的问题,可能需要调整相应的样式
\ No newline at end of file
diff --git a/api/kongfz.js b/api/kongfz.js
new file mode 100644
index 0000000..5b9e8d0
--- /dev/null
+++ b/api/kongfz.js
@@ -0,0 +1,650 @@
+/**
+ * 孔夫子旧书网API服务
+ */
+
+/**
+ * 登录孔夫子旧书网
+ * @param {string} username - 用户名
+ * @param {string} password - 密码
+ * @returns {Promise<{success: boolean, token: string, message: string}>} - 登录结果
+ */
+export function login(username, password) {
+ return new Promise((resolve, reject) => {
+ if (!username || !password) {
+ resolve({
+ success: false,
+ message: '请输入用户名和密码'
+ });
+ return;
+ }
+
+ // 构建请求参数
+ const url = 'https://login.kongfz.com/Pc/Login/account';
+ const data = {
+ loginName: username,
+ loginPass: password,
+ autoLogin: '0',
+ returnUrl: 'http://user.kongfz.com/'
+ };
+
+ // 发送请求
+ uni.request({
+ url: url,
+ method: 'POST',
+ data: data,
+ header: {
+ 'Content-Type': 'application/x-www-form-urlencoded'
+ // 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
+ },
+ success: (res) => {
+ console.log("登录...", res)
+ // 检查登录是否成功
+ if (res.data && res.data.indexOf(
+ "window.location.href='https://login.kongfz.cn/Pc/Session/rsync") !== -1) {
+ // 提取PHPSESSID
+ const cookies = res.cookies;
+ let phpsessid = '';
+
+ if (cookies && cookies.length > 0) {
+ for (const cookie of cookies) {
+ if (cookie.indexOf('PHPSESSID=') !== -1) {
+ phpsessid = cookie.split('PHPSESSID=')[1].split(';')[0];
+ break;
+ }
+ }
+ }
+
+ if (phpsessid) {
+ resolve({
+ success: true,
+ token: phpsessid,
+ message: '登录成功'
+ });
+ } else {
+ resolve({
+ success: false,
+ message: '登录失败: 未找到PHPSESSID'
+ });
+ }
+ } else {
+ // 尝试解析错误信息
+ try {
+ const data = JSON.parse(res.data);
+ if (data.errCode === 1001) {
+ resolve({
+ success: false,
+ message: '登录失败: 账号或密码错误'
+ });
+ } else if (data.errInfo) {
+ resolve({
+ success: false,
+ message: `登录失败: ${data.errInfo}`
+ });
+ } else {
+ resolve({
+ success: false,
+ message: '登录失败: 未知错误'
+ });
+ }
+ } catch (e) {
+ resolve({
+ success: false,
+ message: '登录失败: 响应不包含成功跳转信息'
+ });
+ }
+ }
+ },
+ fail: (err) => {
+ reject(new Error(`登录请求失败: ${err.errMsg}`));
+ }
+ });
+ });
+}
+
+/**
+ * 获取商品列表
+ * @param {string} token - 登录令牌
+ * @param {Object} params - 查询参数
+ * @param {function} onProgress - 进度回调
+ * @returns {Promise} - 商品列表
+ */
+export function fetchItems(token, params = {}, onProgress = null) {
+ return new Promise((resolve, reject) => {
+ if (!token) {
+ reject(new Error('请先登录获取Token'));
+ return;
+ }
+ // const token = 'ebb26189289d0dc068f9aac748881bccf890e694';
+ const url = 'https://seller.kongfz.com/pc-gw/book-manage-service/client/pc/goods/unSold/list';
+ const headers = {
+ 'Cookie': `PHPSESSID=${token}`,
+ // 'Cookie': 'PHPSESSID=ebb26189289d0dc068f9aac748881bccf890e694'
+ // 'User-Agent' 头在浏览器环境中无法设置,会被拒绝
+ // 'Content-Type': 'application/json'
+ };
+
+ let page = 1;
+ const size = 50;
+ const allItemIds = [];
+
+ const fetchPage = () => {
+ // 准备请求体
+ const requestBody = {
+ "requestType": "onSale", // 标识 出售中
+ "isItemSnEqual": "0",
+ "page": page,
+ "size": size
+ };
+
+ // 添加可选参数
+ if (params.itemSn) requestBody.itemSn = params.itemSn;
+ if (params.priceMin) requestBody.priceMin = params.priceMin;
+ if (params.priceMax) requestBody.priceMax = params.priceMax;
+ if (params.startCreateTime) requestBody.startCreateTime = params.startCreateTime;
+ if (params.endCreateTime) requestBody.endCreateTime = params.endCreateTime;
+
+ // 调用进度回调
+ if (onProgress) {
+ onProgress(`正在获取第 ${page} 页数据...`);
+ // 添加请求参数日志
+ if (page === 1) {
+ onProgress(`请求参数: ${JSON.stringify(requestBody)}`);
+ }
+ }
+ console.log("请求参数", requestBody)
+
+ // 发送请求
+ uni.request({
+ url: url,
+ method: 'POST',
+ data: requestBody,
+ header: headers,
+ success: (res) => {
+ if (res.statusCode !== 200) {
+ console.error('API 失败响应:', res);
+ reject(new Error(`API返回错误: HTTP ${res.statusCode}`));
+ return;
+ }
+
+ const data = res.data;
+ if (!data.status) {
+ console.error('API 失败响应:', data);
+ reject(new Error(`API返回错误: ${data.errMessage || '未知错误'}`));
+ return;
+ }
+
+ // 获取商品列表
+ const result = data.result || {};
+ const productInfo = result.productInfoPageResult || {};
+ const items = productInfo.list || [];
+ const pager = productInfo.pager || {};
+
+ // 提取商品ID
+ for (const item of items) {
+ const itemId = item.itemId;
+ if (itemId) {
+ allItemIds.push({
+ id: itemId,
+ status: 'wait'
+ });
+ }
+ }
+
+ // 更新状态
+ const totalPages = pager.pages || 0;
+ const totalCount = pager.count || 0;
+ if (onProgress) {
+ onProgress(`获取到 ${items.length} 个商品 (第 ${page}/${totalPages} 页)`);
+ // 添加更详细的商品信息
+ if (items.length > 0) {
+ const firstItem = items[0];
+ onProgress(
+ `商品示例: ID=${firstItem.itemId}, 标题=${firstItem.title || '无标题'}, 价格=${firstItem.price || '未知'}`
+ );
+ }
+ // 添加总数信息
+ onProgress(`当前已获取: ${allItemIds.length}/${totalCount} 个商品`);
+ }
+
+ // 检查是否还有下一页
+ if (page >= totalPages) {
+ if (onProgress) {
+ onProgress(`拉取完成,共获取 ${allItemIds.length} 个商品`);
+ if (allItemIds.length === 0) {
+ onProgress('未找到符合条件的商品,请检查筛选条件');
+ } else {
+ onProgress(
+ `商品ID示例: ${allItemIds.slice(0, 3).map(item => item.id).join(', ')}${allItemIds.length > 3 ? '...' : ''}`
+ );
+ }
+ }
+ resolve(allItemIds);
+ } else {
+ page++;
+ // 延迟1秒后获取下一页
+ if (onProgress) {
+ onProgress(`等待1秒后获取下一页...`);
+ }
+ setTimeout(fetchPage, 1000);
+ }
+ },
+ fail: (err) => {
+ const errorMsg = `拉取商品失败: ${err.errMsg}`;
+ if (onProgress) {
+ onProgress(errorMsg);
+ onProgress('请检查网络连接是否正常');
+ onProgress('请确认登录状态是否有效');
+ }
+ reject(new Error(errorMsg));
+ }
+ });
+ };
+
+ // 开始获取第一页
+ fetchPage();
+ });
+}
+
+/**
+ * 获取商品模板字段
+ * @param {string} token - 登录令牌
+ * @param {string} itemId - 商品ID
+ * @returns {Promise