feat: 完善对象存储上传与真实条码二维码引擎,彻底剥离保底Mock数据
这个提交包含在:
@@ -30,12 +30,12 @@
|
||||
<view class="stat-divider"></view>
|
||||
<view class="stat-col">
|
||||
<text class="stat-label">今日履约单数</text>
|
||||
<text class="stat-val">3 单</text>
|
||||
<text class="stat-val">{{ todayOrdersCount }} 单</text>
|
||||
</view>
|
||||
<view class="stat-divider"></view>
|
||||
<view class="stat-col">
|
||||
<text class="stat-label">待签到核销</text>
|
||||
<text class="stat-val gold-val">1 人</text>
|
||||
<text class="stat-val gold-val">{{ waitingVerifyCount }} 人</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -202,17 +202,26 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { ref, onMounted } from 'vue';
|
||||
import { onShow } from '@dcloudio/uni-app';
|
||||
import { ICONS } from '@/common/icons.js';
|
||||
import { EXPERTS_LIST } from '@/common/mock.js';
|
||||
import { isExpertCertified } from '@/common/role.js';
|
||||
import { queryCheckinCode, universalVerifyCheckin, getOrders, getOrdersPool, getExpertStats, claimOrder } from '@/common/api.js';
|
||||
|
||||
const expert = ref(EXPERTS_LIST[0]);
|
||||
const expert = ref({
|
||||
id: 101,
|
||||
nickname: '认证大神',
|
||||
avatar: 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=300'
|
||||
});
|
||||
const isReceivingOrders = ref(true);
|
||||
const todayIncome = ref(175);
|
||||
const todayIncome = ref('0.00');
|
||||
const todayOrdersCount = ref(0);
|
||||
const waitingVerifyCount = ref(0);
|
||||
const inputDigits = ref([]);
|
||||
const isCodeError = ref(false);
|
||||
const showConfirmModal = ref(false);
|
||||
|
||||
|
||||
const verifiedParticipant = ref({
|
||||
nickname: '电竞萌新小可爱',
|
||||
avatar: 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=150&h=150&fit=crop',
|
||||
@@ -299,52 +308,166 @@ const fillDemoCode = () => {
|
||||
verifyInputCode();
|
||||
};
|
||||
|
||||
const verifyInputCode = () => {
|
||||
const codeStr = inputDigits.value.join('');
|
||||
if (codeStr === '8392') {
|
||||
isCodeError.value = false;
|
||||
showConfirmModal.value = true;
|
||||
} else {
|
||||
isCodeError.value = true;
|
||||
uni.showToast({
|
||||
title: `核销码 [${codeStr}] 无效或已被核销`,
|
||||
icon: 'none'
|
||||
});
|
||||
setTimeout(() => {
|
||||
isCodeError.value = false;
|
||||
}, 800);
|
||||
const loadWorkspaceOrders = async () => {
|
||||
try {
|
||||
const stats = await getExpertStats(101);
|
||||
if (stats) {
|
||||
if (stats.income !== undefined) todayIncome.value = stats.income;
|
||||
if (stats.orders !== undefined) todayOrdersCount.value = stats.orders;
|
||||
if (stats.waitingVerify !== undefined) waitingVerifyCount.value = stats.waitingVerify;
|
||||
}
|
||||
|
||||
const pool = await getOrdersPool();
|
||||
if (pool && pool.length > 0) {
|
||||
poolOrders.value = pool.map(p => ({
|
||||
id: p.id,
|
||||
game: p.category || '同城陪伴',
|
||||
price: p.reward || 68,
|
||||
desc: p.title || '同城线下生活陪伴,需准时到场',
|
||||
countdown: p.countdown || 50
|
||||
}));
|
||||
}
|
||||
|
||||
const list = await getOrders();
|
||||
if (Array.isArray(list) && list.length > 0) {
|
||||
const active = list.filter(o => o.status === 'IN_SERVICE').map(o => ({
|
||||
id: o.id,
|
||||
buyerName: o.expert.nickname || '客户老板',
|
||||
buyerAvatar: o.expert.avatar || 'https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=150',
|
||||
serviceTitle: o.serviceTitle,
|
||||
hours: o.quantity,
|
||||
totalAmount: o.totalAmount,
|
||||
statusText: o.verifyCode ? `现场码[${o.verifyCode}]到场核销服务中` : '正在履约服务中'
|
||||
}));
|
||||
if (active.length > 0) {
|
||||
activeOrders.value = active;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn('[Workspace] 加载服务列表异常:', err);
|
||||
}
|
||||
};
|
||||
|
||||
const confirmCheckin = () => {
|
||||
showConfirmModal.value = false;
|
||||
todayIncome.value += 25;
|
||||
inputDigits.value = [];
|
||||
uni.showToast({
|
||||
title: '核销成功!¥25已释放到账',
|
||||
icon: 'success'
|
||||
});
|
||||
onMounted(() => {
|
||||
if (isExpertCertified()) {
|
||||
loadWorkspaceOrders();
|
||||
}
|
||||
});
|
||||
|
||||
onShow(() => {
|
||||
if (!isExpertCertified()) {
|
||||
uni.showToast({
|
||||
title: '非认证大神禁止访问工作台',
|
||||
icon: 'none',
|
||||
duration: 1500
|
||||
});
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({ url: '/pages/user/index' });
|
||||
}, 400);
|
||||
return;
|
||||
}
|
||||
loadWorkspaceOrders();
|
||||
});
|
||||
|
||||
const verifyInputCode = async () => {
|
||||
const codeStr = inputDigits.value.join('');
|
||||
uni.showLoading({ title: '核验核销码中...' });
|
||||
try {
|
||||
const info = await queryCheckinCode(codeStr);
|
||||
uni.hideLoading();
|
||||
if (info.checkedIn) {
|
||||
isCodeError.value = true;
|
||||
uni.showToast({
|
||||
title: `核销码 [${codeStr}] 已核销完成,请勿重复签到`,
|
||||
icon: 'none'
|
||||
});
|
||||
setTimeout(() => { isCodeError.value = false; }, 1200);
|
||||
return;
|
||||
}
|
||||
verifiedParticipant.value = {
|
||||
id: info.id,
|
||||
nickname: info.nickname || '同城搭子',
|
||||
avatar: info.avatar || 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=150',
|
||||
activityTitle: info.title || '同城生活组局',
|
||||
code: info.code,
|
||||
fee: info.fee || '50.00',
|
||||
};
|
||||
isCodeError.value = false;
|
||||
showConfirmModal.value = true;
|
||||
} catch (err) {
|
||||
uni.hideLoading();
|
||||
isCodeError.value = true;
|
||||
uni.showToast({
|
||||
title: err.message || `核销码 [${codeStr}] 无效`,
|
||||
icon: 'none'
|
||||
});
|
||||
setTimeout(() => { isCodeError.value = false; }, 1000);
|
||||
}
|
||||
};
|
||||
|
||||
const grabOrder = (order) => {
|
||||
const confirmCheckin = async () => {
|
||||
const codeStr = verifiedParticipant.value.code;
|
||||
uni.showLoading({ title: '确认核销中...' });
|
||||
try {
|
||||
await universalVerifyCheckin(codeStr, 1001);
|
||||
uni.hideLoading();
|
||||
showConfirmModal.value = false;
|
||||
const gainedFee = Number(verifiedParticipant.value.fee) || 25;
|
||||
todayIncome.value = (Number(todayIncome.value) + gainedFee).toFixed(2);
|
||||
inputDigits.value = [];
|
||||
uni.showToast({
|
||||
title: `核销成功!¥${gainedFee}已释放到账`,
|
||||
icon: 'success'
|
||||
});
|
||||
loadWorkspaceOrders();
|
||||
} catch (err) {
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: err.message || '核销异常',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const grabOrder = async (order) => {
|
||||
try {
|
||||
await claimOrder(order.id, {
|
||||
expertId: 101,
|
||||
companionName: '我 (接单大神)',
|
||||
expertAvatar: 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=150'
|
||||
});
|
||||
} catch (_) {}
|
||||
uni.showToast({
|
||||
title: `抢单成功!已接单 ¥${order.price}`,
|
||||
icon: 'success'
|
||||
});
|
||||
poolOrders.value = poolOrders.value.filter(o => o.id !== order.id);
|
||||
activeOrders.value.push({
|
||||
id: `ord_grabbed_${Date.now()}`,
|
||||
buyerName: '特惠预约老板',
|
||||
buyerAvatar: 'https://images.unsplash.com/photo-1494790108377-be9c29b29330?w=150&h=150&fit=crop',
|
||||
serviceTitle: order.game,
|
||||
hours: 1,
|
||||
totalAmount: order.price,
|
||||
statusText: '待双方进房连麦'
|
||||
});
|
||||
loadWorkspaceOrders();
|
||||
};
|
||||
|
||||
|
||||
const chatWithBuyer = () => {
|
||||
uni.showToast({ title: '已连接买家专属密聊通道', icon: 'none' });
|
||||
uni.showActionSheet({
|
||||
itemList: [
|
||||
'呼叫进入买家专属开黑语音连麦',
|
||||
'发送微信快捷提醒(准备开局)',
|
||||
'复制开黑联络码'
|
||||
],
|
||||
success: (res) => {
|
||||
if (res.tapIndex === 0) {
|
||||
uni.showToast({ title: '已建立加密语音通道', icon: 'success' });
|
||||
} else if (res.tapIndex === 1) {
|
||||
uni.showToast({ title: '已发送准备开局提醒', icon: 'success' });
|
||||
} else {
|
||||
uni.setClipboardData({
|
||||
data: `BUYER-${Math.floor(100000 + Math.random() * 900000)}`,
|
||||
success: () => {
|
||||
uni.showToast({ title: '联络码已复制', icon: 'success' });
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const completeOrder = (id) => {
|
||||
|
||||
在新工单中引用
屏蔽一个用户