384b957617
- utils/tasks.js 增 listSquare/getTask/grabById(/opc/tasks 平台公开端点,带 token 取 can_accept) - pages/tasks 任务广场(公开可见,卡片含可接/条件不符徽标+原因,点击进详情,抢单) - pages/task-detail 任务详情(说明/预算/模式/截止/交付/发包方 + 按 can_accept 放行抢单/报名) - app.config 注册两页;「我的」页加「任务广场」入口(在扫码接单前) - Soft UI 浅色柔彩样式;build:weapp 通过
44 lines
1.6 KiB
JavaScript
44 lines
1.6 KiB
JavaScript
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);
|
|
}
|
|
|
|
/** 任务广场(公开):已发布 + C端可见任务,登录后附带 can_accept/accept_reasons */
|
|
export async function listSquare(withAuth = false) {
|
|
return request('GET', '/opc/tasks', {}, withAuth);
|
|
}
|
|
|
|
/** 任务详情(公开) */
|
|
export async function getTask(id, withAuth = false) {
|
|
return request('GET', `/opc/tasks/${encodeURIComponent(id)}`, {}, withAuth);
|
|
}
|
|
|
|
/** 抢单/报名(需登录) */
|
|
export async function grabById(id) {
|
|
return request('POST', `/opc/tasks/${encodeURIComponent(id)}/grab`, {}, 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;
|
|
}
|