| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339 |
- <template>
- <view class="work-page">
- <!-- 收入速览:钱在最上方,这是健康服务人员最关心的 -->
- <view class="income-card" @click="goEarnings">
- <view class="income-left">
- <text class="income-label">本月到手</text>
- <text class="income-value">¥{{ monthIncomeText }}</text>
- </view>
- <view class="income-right">
- <text class="income-sub">累计 ¥{{ totalIncomeText }}</text>
- <text class="income-sub">待确认 ¥{{ pendingIncomeText }}</text>
- <text class="income-arrow">›</text>
- </view>
- </view>
- <!-- 加载骨架 / 错误态 -->
- <LoadingSkeleton v-if="loading" :rows="4" />
- <ErrorState v-else-if="error" message="工单数据加载失败" @retry="reload" />
- <template v-else>
- <!-- 今日上门 -->
- <view class="group">
- <view class="group-head">
- <text class="group-title">今日上门</text>
- <text class="group-count">{{ todayList.length }} 单</text>
- </view>
- <view v-if="todayList.length === 0" class="empty-box">
- <text class="empty-text">今天没有安排,接单后就会出现在这里</text>
- </view>
- <view v-for="item in todayList" :key="item.id" class="order-card" @click="goDetail(item)">
- <view class="order-top">
- <view class="order-time-wrap">
- <text class="order-time">{{ item.startAt || item.orderDate }}</text>
- <text v-if="item.source === 'org_created'" class="source-tag">机构派单</text>
- </view>
- <text class="order-status" :style="{ background: statusBg(item.status) }">{{ statusText(item.status) }}</text>
- </view>
- <text class="order-family">{{ item.familyName || '客户家' }}</text>
- <text class="order-address">{{ item.address || '地址待确认' }}</text>
- <view class="order-bottom">
- <text class="order-type">{{ typeText(item.serviceType) }}</text>
- <text class="order-money">¥{{ incomeText(item.staffIncome) }}</text>
- </view>
- </view>
- </view>
- <!-- 待接单 -->
- <view class="group">
- <view class="group-head">
- <text class="group-title">待接单</text>
- <text class="group-count">{{ pendingList.length }} 单</text>
- </view>
- <view v-if="pendingList.length === 0" class="empty-box">
- <text class="empty-text">暂时没有新单,有新单会通知您</text>
- </view>
- <view v-for="item in pendingList" :key="item.id" class="order-card pending-card">
- <view class="order-top">
- <view class="order-time-wrap">
- <text class="order-time">{{ item.orderDate }} {{ item.startAt || '' }}</text>
- <text v-if="item.source === 'org_created'" class="source-tag">机构派单</text>
- </view>
- <text class="order-status" :style="{ background: statusBg(item.status) }">待接单</text>
- </view>
- <text class="order-family">{{ item.familyName || '客户家' }}</text>
- <text class="order-address">{{ item.address || '地址待确认' }}</text>
- <view class="order-bottom">
- <text class="order-type">{{ typeText(item.serviceType) }}</text>
- <text class="order-money">¥{{ incomeText(item.staffIncome) }}</text>
- </view>
- <button class="accept-btn" @click.stop="doAccept(item)">接这单</button>
- </view>
- </view>
- <!-- 进行中 -->
- <view class="group">
- <view class="group-head">
- <text class="group-title">进行中</text>
- <text class="group-count">{{ doingList.length }} 单</text>
- </view>
- <view v-if="doingList.length === 0" class="empty-box">
- <text class="empty-text">暂无进行中的单</text>
- </view>
- <view v-for="item in doingList" :key="item.id" class="order-card" @click="goDetail(item)">
- <view class="order-top">
- <view class="order-time-wrap">
- <text class="order-time">{{ item.orderDate }} {{ item.startAt || '' }}</text>
- <text v-if="item.source === 'org_created'" class="source-tag">机构派单</text>
- </view>
- <text class="order-status" :style="{ background: statusBg(item.status) }">{{ statusText(item.status) }}</text>
- </view>
- <text class="order-family">{{ item.familyName || '客户家' }}</text>
- <text class="order-address">{{ item.address || '地址待确认' }}</text>
- <view class="order-bottom">
- <text class="order-type">{{ typeText(item.serviceType) }}</text>
- <text class="order-money">¥{{ incomeText(item.staffIncome) }}</text>
- </view>
- </view>
- </view>
- <!-- 已完成 -->
- <view class="group">
- <view class="group-head">
- <text class="group-title">已完成</text>
- <text class="group-count">{{ doneList.length }} 单</text>
- </view>
- <view v-if="doneList.length === 0" class="empty-box">
- <text class="empty-text">还没有完成的单</text>
- </view>
- <view v-for="item in doneList" :key="item.id" class="order-card" @click="goDetail(item)">
- <view class="order-top">
- <view class="order-time-wrap">
- <text class="order-time">{{ item.orderDate }}</text>
- <text v-if="item.source === 'org_created'" class="source-tag">机构派单</text>
- </view>
- <text class="order-status" :style="{ background: statusBg(item.status) }">{{ statusText(item.status) }}</text>
- </view>
- <text class="order-family">{{ item.familyName || '客户家' }}</text>
- <view class="order-bottom">
- <text class="order-type">{{ item.arriveAt ? '到岗 ' + item.arriveAt : '' }}</text>
- <text class="order-money">¥{{ incomeText(item.staffIncome) }}</text>
- </view>
- </view>
- </view>
- <view class="footer-tip">
- <text class="footer-text">有疑问请联系机构对接人</text>
- </view>
- </template>
- </view>
- </template>
- <script>
- import { getMyServiceOrders, getServiceEarnings, acceptServiceOrder } from '@/utils/api.js'
- import LoadingSkeleton from '@/components/loading-skeleton.vue'
- import ErrorState from '@/components/error-state.vue'
- export default {
- components: { LoadingSkeleton, ErrorState },
- data() {
- return {
- todayList: [],
- pendingList: [],
- doingList: [],
- doneList: [],
- totalIncome: 0,
- monthIncome: 0,
- pendingIncome: 0,
- loading: true,
- error: false
- }
- },
- computed: {
- totalIncomeText() {
- return this.fenToYuan(this.totalIncome)
- },
- monthIncomeText() {
- return this.fenToYuan(this.monthIncome)
- },
- pendingIncomeText() {
- return this.fenToYuan(this.pendingIncome)
- }
- },
- onShow() {
- this.loadOrders()
- this.loadEarnings()
- },
- reload() {
- this.loadOrders()
- this.loadEarnings()
- },
- methods: {
- loadOrders() {
- this.loading = true
- this.error = false
- getMyServiceOrders().then(res => {
- if (!res || !res.data) return
- const groups = res.data
- this.todayList = this.pickGroup(groups, 'today')
- this.pendingList = this.pickGroup(groups, 'pending')
- this.doingList = this.pickGroup(groups, 'doing')
- this.doneList = this.pickGroup(groups, 'done')
- }).catch(() => {
- this.error = true
- }).finally(() => {
- this.loading = false
- })
- },
- loadEarnings() {
- getServiceEarnings().then(res => {
- if (!res || !res.data) return
- this.totalIncome = res.data.totalIncome || 0
- this.monthIncome = res.data.monthIncome || 0
- this.pendingIncome = res.data.pendingIncome || 0
- }).catch(() => {})
- },
- pickGroup(groups, key) {
- for (var i = 0; i < groups.length; i++) {
- if (groups[i].key === key) {
- return groups[i].list || []
- }
- }
- return []
- },
- doAccept(item) {
- var self = this
- uni.showModal({
- title: '确认接单',
- content: '接下这单后,请在服务时间准时上门。',
- success: function (res) {
- if (!res.confirm) return
- acceptServiceOrder(item.id).then(function (r) {
- if (r && r.code === 200) {
- uni.showToast({ title: '接单成功', icon: 'success' })
- self.loadOrders()
- self.loadEarnings()
- } else {
- uni.showToast({ title: (r && r.message) || '接单失败', icon: 'none' })
- }
- }).catch(function () {
- uni.showToast({ title: '接单失败', icon: 'none' })
- })
- }
- })
- },
- goDetail(item) {
- uni.navigateTo({ url: '/pages/work/detail?orderId=' + item.id })
- },
- goEarnings() {
- uni.navigateTo({ url: '/pages/work/earnings' })
- },
- statusText(status) {
- if (status === 'accepted') return '已接单'
- if (status === 'arrived') return '已到岗'
- if (status === 'doing') return '服务中'
- if (status === 'done') return '待客户确认'
- if (status === 'confirmed') return '已完成'
- if (status === 'pending') return '待接单'
- return '进行中'
- },
- statusBg(status) {
- if (status === 'confirmed') return '#0E8A4F'
- if (status === 'done') return '#B9770E'
- if (status === 'pending') return '#2E6FA8'
- return '#3B5A78'
- },
- typeText(type) {
- if (type === 'cleaning') return '保洁'
- if (type === 'care') return '照护'
- if (type === 'escort') return '陪诊'
- if (type === 'meal') return '助餐'
- return '上门服务'
- },
- fenToYuan(fen) {
- var n = fen || 0
- return (n / 100).toFixed(2)
- },
- incomeText(fen) {
- return this.fenToYuan(fen)
- }
- }
- }
- </script>
- <style scoped>
- .work-page {
- min-height: 100vh;
- background: #F5FAFE;
- padding: 20rpx 24rpx 40rpx;
- }
- .income-card {
- background: linear-gradient(135deg, #1F4E79, #2E6FA8);
- border-radius: 20rpx;
- padding: 32rpx 28rpx;
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 24rpx;
- }
- .income-left { display: flex; flex-direction: column; }
- .income-label { font-size: 24rpx; color: rgba(255,255,255,0.8); }
- .income-value { font-size: 52rpx; font-weight: 700; color: #fff; line-height: 1.3; }
- .income-right { display: flex; flex-direction: column; align-items: flex-end; position: relative; }
- .income-sub { font-size: 22rpx; color: rgba(255,255,255,0.82); line-height: 1.7; }
- .income-arrow { position: absolute; right: -4rpx; top: 50%; transform: translateY(-50%); font-size: 34rpx; color: rgba(255,255,255,0.6); }
- .group { margin-bottom: 28rpx; }
- .group-head {
- display: flex;
- justify-content: space-between;
- align-items: baseline;
- margin-bottom: 14rpx;
- padding: 0 4rpx;
- }
- .group-title { font-size: 30rpx; font-weight: 700; color: #1F4E79; }
- .group-count { font-size: 24rpx; color: #3B5A78; }
- .empty-box {
- background: #fff;
- border-radius: 16rpx;
- padding: 34rpx 24rpx;
- text-align: center;
- border: 1px solid #E3ECF4;
- }
- .empty-text { font-size: 26rpx; color: #94A3B2; }
- .order-card {
- background: #fff;
- border-radius: 16rpx;
- padding: 24rpx 24rpx 20rpx;
- margin-bottom: 16rpx;
- border: 1px solid #E3ECF4;
- }
- .pending-card { border-color: #C5DFF3; }
- .order-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12rpx; }
- .order-time-wrap { display: flex; align-items: center; }
- .order-time { font-size: 26rpx; color: #2E6FA8; font-weight: 600; }
- .source-tag {
- margin-left: 12rpx;
- font-size: 20rpx;
- color: #B9770E;
- background: #FEF3E2;
- border: 1rpx solid #B9770E;
- border-radius: 8rpx;
- padding: 2rpx 12rpx;
- line-height: 1.5;
- }
- .order-status { font-size: 20rpx; color: #fff; padding: 3rpx 14rpx; border-radius: 20rpx; }
- .order-family { display: block; font-size: 32rpx; font-weight: 700; color: #1E3A5F; margin-bottom: 6rpx; }
- .order-address { display: block; font-size: 25rpx; color: #3B5A78; margin-bottom: 14rpx; }
- .order-bottom { display: flex; justify-content: space-between; align-items: center; }
- .order-type { font-size: 24rpx; color: #3B5A78; }
- .order-money { font-size: 34rpx; font-weight: 700; color: #C0392B; }
- .accept-btn {
- margin-top: 18rpx;
- background: #2E6FA8;
- color: #fff;
- font-size: 30rpx;
- border-radius: 44rpx;
- line-height: 2.4;
- }
- .footer-tip { text-align: center; padding: 20rpx 0; }
- .footer-text { font-size: 23rpx; color: #94A3B2; }
- </style>
|