feat(tasks): 小程序扫码接单 — 个人中心入口 + scan 页
- miniprogram/src/utils/tasks.js:claimByCode/getMyTasks/parseTaskCode。 - 新增 pages/scan/index(jsx/scss/config):Taro.scanCode→解析 task_code→领单→展示我的接单。 - app.config.js 注册 pages/scan/index。 - mine/index.jsx 加「扫码接单」入口卡(navigateTo scan);mine/index.scss 加样式。 - 接单走 OPC/创业者身份(后端按账号 find-or-create);属小程序增量,web C 端暂不同步。 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { request } from './api';
|
||||
|
||||
/* 扫码接单(任务中心):大屏任务卡二维码 → 扫码 → 按 task_code 领取。
|
||||
接单走 OPC/创业者身份:由后端按本账号 find-or-create 平台 OPC 身份后领单。
|
||||
属小程序「我的」页增量,web C 端暂不做(见 小程序同步约束.md 第5节)。 */
|
||||
|
||||
/** 扫码领单:task_code → claimed */
|
||||
export async function claimByCode(code) {
|
||||
return request('POST', '/api/tasks/claim-by-code', { task_code: code }, true);
|
||||
}
|
||||
|
||||
/** 我的接单(已领取任务) */
|
||||
export async function getMyTasks() {
|
||||
return request('GET', '/api/tasks/my', {}, true);
|
||||
}
|
||||
|
||||
/** 解析扫码文本 → task_code:支持纯短码 / URL(?c=、?task_code=、末段) */
|
||||
export function parseTaskCode(raw) {
|
||||
const s = (raw || '').trim();
|
||||
if (!s) return '';
|
||||
if (s.includes('://') || s.includes('/') || s.includes('?')) {
|
||||
const m = s.match(/[?&](?:c|task_code|taskCode)=([^&]+)/);
|
||||
if (m) return decodeURIComponent(m[1]);
|
||||
const seg = s.split('?')[0].split('#')[0].split('/').filter(Boolean).pop();
|
||||
return (seg && /^TK-/i.test(seg)) ? seg : '';
|
||||
}
|
||||
return s;
|
||||
}
|
||||
Reference in New Issue
Block a user