| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532 |
- <template>
- <view class="detail-page">
- <LoadingSkeleton v-if="loading" :rows="4" />
- <ErrorState v-else-if="error" message="工单详情加载失败" @retry="loadDetail" />
- <EmptyState v-else-if="!order.id" icon="🔍" title="未找到该工单" desc="该工单可能已取消,可返回工作台查看" action-text="返回列表" @action="backToWorkbench" />
- <template v-else>
- <!-- 头部客户信息 -->
- <view class="head-card">
- <view class="head-top">
- <view class="head-no-wrap">
- <text class="order-no">{{ order.orderNo || '' }}</text>
- <text v-if="order.source === 'org_created'" class="source-tag">机构派单</text>
- </view>
- <text class="head-status" :style="{ background: statusBg(order.status) }">{{ statusText(order.status) }}</text>
- </view>
- <text class="family-name">{{ order.familyName || '客户家' }}</text>
- <text class="addr">{{ order.address || '地址待确认' }}</text>
- <view class="time-row" v-if="order.startAt">
- <text class="time-label">服务时间</text>
- <text class="time-value">{{ order.startAt }}{{ order.endAt ? ' ~ ' + order.endAt : '' }}</text>
- </view>
- <view class="time-row" v-if="order.remark">
- <text class="time-label">备注</text>
- <text class="time-value">{{ order.remark }}</text>
- </view>
- </view>
- <!-- 收入卡(服务人员最关心) -->
- <view class="money-card">
- <view class="money-col">
- <text class="money-label">本单到手</text>
- <text class="money-value">¥{{ fenToYuan(order.staffIncome) }}</text>
- </view>
- <view class="money-col">
- <text class="money-label">本单金额</text>
- <text class="money-value">¥{{ fenToYuan(order.amount) }}</text>
- </view>
- </view>
- <!-- 已到岗凭证 -->
- <view class="sec-card" v-if="order.status !== 'pending' && order.status !== 'accepted'">
- <view class="sec-head">
- <text class="sec-title">到岗凭证</text>
- <text v-if="order.arriveAt" class="sec-ok">✓ {{ order.arriveAt }}</text>
- </view>
- <image v-if="order.arrivePhoto" :src="order.arrivePhoto" class="arrive-photo" mode="aspectFit" />
- <text v-else-if="order.status === 'arrived' || order.status === 'doing' || order.status === 'done' || order.status === 'confirmed'" class="sec-empty">尚未上传门牌照</text>
- </view>
- <!-- 动作区:按状态只显示一步 -->
- <view class="action-card" v-if="order.status === 'pending'">
- <button class="main-btn" @click="doAccept">接这单</button>
- <text class="hint">接单后请准时上门,到岗时打卡</text>
- </view>
- <view class="action-card" v-if="order.status === 'accepted'">
- <button class="main-btn" @click="doArrive">到岗打卡</button>
- <text class="hint">到客户家后,拍照门牌并点击打卡(自动记录时间和位置)</text>
- </view>
- <view class="action-card" v-if="order.status === 'arrived' || order.status === 'doing'">
- <view class="sec-head">
- <text class="sec-title">本次服务内容</text>
- </view>
- <view v-if="order.items.length === 0" class="empty-box">
- <text class="sec-empty">本次服务无固定项目,完成拍照即可</text>
- </view>
- <view v-for="(item, idx) in order.items" :key="idx" class="item-row">
- <text class="item-name">{{ item.name }}</text>
- <view class="item-done">
- <text class="item-state" :style="{ color: item.done == 1 ? '#0E8A4F' : '#3B5A78' }">{{ item.done == 1 ? '✓ 已做' : '未做' }}</text>
- </view>
- </view>
- <view class="photo-grid">
- <view v-for="(p, pi) in order.finishPhotos" :key="pi" class="photo-cell">
- <image :src="p" class="photo-img" mode="aspectFill" />
- </view>
- <view class="photo-cell add-cell" @click="choosePhoto">
- <text class="add-text">+ 拍照</text>
- </view>
- </view>
- <button class="main-btn" @click="doFinish" :loading="finishing">完成服务</button>
- <text class="hint">完成后生成客户确认码,请客户核对</text>
- </view>
- <view class="action-card" v-if="order.status === 'done'">
- <view class="confirm-code-box">
- <text class="code-label">客户确认码</text>
- <text class="code-value">{{ order.clientConfirmCode }}</text>
- <text class="code-tip">请告知客户这 6 位数字,客户确认后即完成结算</text>
- </view>
- <view class="code-input-row">
- <input class="code-input" v-model="confirmCode" type="number" maxlength="6" placeholder="输入客户确认码" />
- <button class="confirm-btn" @click="doConfirm" :loading="confirming">确认</button>
- </view>
- <text class="hint">若客户不便操作,可请机构对接人代确认</text>
- </view>
- <view class="action-card" v-if="order.status === 'confirmed'">
- <view class="done-box">
- <text class="done-icon">✓</text>
- <text class="done-title">本单已完成</text>
- <text class="done-sub">¥{{ fenToYuan(order.staffIncome) }} 已计入收入</text>
- </view>
- <!-- M3 评价入口:confirmed 且未评过(后端 evalDone / 本地已提交记忆)才展示 -->
- <view v-if="!evalDone" class="eval-entry">
- <button class="main-btn eval-btn" @click="goEval">去评价</button>
- <text class="hint">评价仅服务人员可查看,用于档案沉淀</text>
- </view>
- <view v-else class="eval-done-box">
- <text class="eval-done-text">已评价 ✓ 感谢您的反馈</text>
- </view>
- </view>
- <view class="back-tip">
- <text class="back-text">有疑问请联系机构对接人</text>
- </view>
- </template>
- </view>
- </template>
- <script>
- import {
- getServiceOrderDetail,
- acceptServiceOrder,
- arriveServiceOrder,
- finishServiceOrder,
- confirmServiceOrder,
- uploadFile
- } from '@/utils/api.js'
- import LoadingSkeleton from '@/components/loading-skeleton.vue'
- import ErrorState from '@/components/error-state.vue'
- import EmptyState from '@/components/empty-state.vue'
- export default {
- components: { LoadingSkeleton, ErrorState, EmptyState },
- data() {
- return {
- orderId: null,
- order: {
- status: 'pending',
- items: [],
- finishPhotos: []
- },
- confirmCode: '',
- finishing: false,
- confirming: false,
- loading: true,
- error: false,
- locating: false
- }
- },
- computed: {
- // 是否已评价:后端 order/detail 无 evalDone 字段(M3 回执确认),只用本地提交记忆 evalSubmittedOrders
- evalDone() {
- var arr = uni.getStorageSync('evalSubmittedOrders')
- if (!Array.isArray(arr)) return false
- for (var i = 0; i < arr.length; i++) {
- if (String(arr[i]) === String(this.orderId)) return true
- }
- return false
- }
- },
- onLoad(options) {
- this.orderId = options.orderId || null
- this.loadDetail()
- },
- onShow() {
- this.loadDetail()
- },
- methods: {
- loadDetail() {
- if (!this.orderId) {
- this.loading = false
- return
- }
- this.loading = true
- this.error = false
- getServiceOrderDetail(this.orderId).then(res => {
- if (res && res.data) {
- this.order = res.data
- }
- }).catch(() => {
- this.error = true
- }).finally(() => {
- this.loading = false
- })
- },
- backToWorkbench() {
- var pages = getCurrentPages()
- if (pages.length > 1) {
- uni.navigateBack()
- } else {
- uni.switchTab({ url: '/pages/work/index' })
- }
- },
- doAccept() {
- var self = this
- uni.showModal({
- title: '确认接单',
- content: '接下后请准时上门。',
- success: function (r) {
- if (!r.confirm) return
- acceptServiceOrder(self.orderId).then(function (res) {
- if (res && res.code === 200) {
- uni.showToast({ title: '接单成功', icon: 'success' })
- self.loadDetail()
- } else {
- uni.showToast({ title: (res && res.message) || '接单失败', icon: 'none' })
- }
- }).catch(function () {
- uni.showToast({ title: '接单失败', icon: 'none' })
- })
- }
- })
- },
- doArrive() {
- var self = this
- if (this.locating) return
- this.locating = true
- uni.showLoading({ title: '定位中...' })
- uni.getLocation({
- type: 'gcj02',
- success: function (loc) {
- uni.hideLoading()
- self.locating = false
- var lat = loc.latitude
- var lng = loc.longitude
- self.pickPhoto(function (photoUrl) {
- if (!photoUrl) {
- uni.showToast({ title: '请先拍门牌照', icon: 'none' })
- return
- }
- arriveServiceOrder({
- orderId: self.orderId,
- lat: lat,
- lng: lng,
- photo: photoUrl
- }).then(function (res) {
- if (res && res.code === 200) {
- uni.showToast({ title: '已到岗', icon: 'success' })
- self.loadDetail()
- } else {
- uni.showToast({ title: (res && res.message) || '打卡失败', icon: 'none' })
- }
- }).catch(function () {
- uni.showToast({ title: '打卡失败', icon: 'none' })
- })
- })
- },
- fail: function () {
- uni.hideLoading()
- self.locating = false
- uni.showModal({
- title: '定位不可用',
- content: '无法获取位置,是否跳过定位直接拍照打卡?',
- success: function (r) {
- if (!r.confirm) return
- self.pickPhoto(function (photoUrl) {
- if (!photoUrl) {
- uni.showToast({ title: '请先拍门牌照', icon: 'none' })
- return
- }
- arriveServiceOrder({
- orderId: self.orderId,
- photo: photoUrl
- }).then(function (res) {
- if (res && res.code === 200) {
- uni.showToast({ title: '已到岗', icon: 'success' })
- self.loadDetail()
- } else {
- uni.showToast({ title: (res && res.message) || '打卡失败', icon: 'none' })
- }
- }).catch(function () {
- uni.showToast({ title: '打卡失败', icon: 'none' })
- })
- })
- }
- })
- }
- })
- },
- choosePhoto() {
- var self = this
- this.pickPhoto(function (photoUrl) {
- if (!photoUrl) return
- var cur = self.order.finishPhotos || []
- cur = cur.concat([photoUrl])
- self.order.finishPhotos = cur
- })
- },
- pickPhoto(cb) {
- var self = this
- uni.chooseImage({
- count: 1,
- success: function (res) {
- var filePath = res.tempFilePaths[0]
- uni.showLoading({ title: '上传中...' })
- uploadFile(filePath).then(function (resp) {
- uni.hideLoading()
- var url = resp && resp.data && resp.data.url
- if (url) {
- cb(url)
- } else {
- uni.showToast({ title: '上传失败', icon: 'none' })
- }
- }).catch(function () {
- uni.hideLoading()
- uni.showToast({ title: '上传失败', icon: 'none' })
- })
- }
- })
- },
- doFinish() {
- var self = this
- if (this.finishing) return
- this.finishing = true
- var items = JSON.stringify(this.order.items || [])
- var photos = (this.order.finishPhotos || []).join(',')
- finishServiceOrder({
- orderId: this.orderId,
- items: items,
- photos: photos
- }).then(function (res) {
- self.finishing = false
- if (res && res.code === 200) {
- uni.showModal({
- title: '服务完成',
- content: '客户确认码:' + (res.data && res.data.clientConfirmCode ? res.data.clientConfirmCode : ''),
- showCancel: false,
- success: function () {
- self.loadDetail()
- }
- })
- } else {
- uni.showToast({ title: (res && res.message) || '提交失败', icon: 'none' })
- }
- }).catch(function () {
- self.finishing = false
- uni.showToast({ title: '提交失败', icon: 'none' })
- })
- },
- doConfirm() {
- var self = this
- if (this.confirming) return
- if (!this.confirmCode) {
- uni.showToast({ title: '请输入确认码', icon: 'none' })
- return
- }
- this.confirming = true
- confirmServiceOrder({
- orderId: this.orderId,
- code: this.confirmCode
- }).then(function (res) {
- self.confirming = false
- if (res && res.code === 200) {
- uni.showToast({ title: '已完成', icon: 'success' })
- self.loadDetail()
- } else {
- uni.showToast({ title: (res && res.message) || '确认失败', icon: 'none' })
- }
- }).catch(function () {
- self.confirming = false
- uni.showToast({ title: '确认失败', icon: 'none' })
- })
- },
- goEval() {
- uni.navigateTo({ url: '/pages/eval/submit?orderId=' + this.orderId })
- },
- 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'
- },
- fenToYuan(fen) {
- var n = fen || 0
- return (n / 100).toFixed(2)
- }
- }
- }
- </script>
- <style scoped>
- .detail-page {
- min-height: 100vh;
- background: #F5FAFE;
- padding: 20rpx 24rpx 40rpx;
- }
- .head-card {
- background: #fff;
- border-radius: 20rpx;
- padding: 28rpx 26rpx;
- margin-bottom: 20rpx;
- border: 1px solid #E3ECF4;
- }
- .head-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12rpx; }
- .head-no-wrap { display: flex; align-items: center; }
- .order-no { font-size: 22rpx; color: #94A3B2; }
- .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;
- }
- .head-status { font-size: 20rpx; color: #fff; padding: 3rpx 14rpx; border-radius: 20rpx; }
- .family-name { display: block; font-size: 36rpx; font-weight: 700; color: #1E3A5F; margin-bottom: 6rpx; }
- .addr { display: block; font-size: 25rpx; color: #3B5A78; margin-bottom: 14rpx; }
- .time-row { display: flex; margin-top: 8rpx; }
- .time-label { width: 130rpx; font-size: 24rpx; color: #3B5A78; }
- .time-value { flex: 1; font-size: 24rpx; color: #1E3A5F; }
- .money-card {
- background: #fff;
- border-radius: 20rpx;
- padding: 24rpx 26rpx;
- margin-bottom: 20rpx;
- display: flex;
- border: 1px solid #E3ECF4;
- }
- .money-col { flex: 1; display: flex; flex-direction: column; align-items: center; }
- .money-label { font-size: 23rpx; color: #3B5A78; }
- .money-value { font-size: 40rpx; font-weight: 700; color: #C0392B; margin-top: 4rpx; }
- .sec-card, .action-card {
- background: #fff;
- border-radius: 20rpx;
- padding: 24rpx 26rpx;
- margin-bottom: 20rpx;
- border: 1px solid #E3ECF4;
- }
- .sec-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14rpx; }
- .sec-title { font-size: 28rpx; font-weight: 700; color: #1F4E79; }
- .sec-ok { font-size: 24rpx; color: #0E8A4F; }
- .sec-empty { font-size: 24rpx; color: #94A3B2; }
- .arrive-photo { width: 100%; height: 300rpx; border-radius: 12rpx; }
- .empty-box { padding: 20rpx 0; }
- .item-row {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 16rpx 0;
- border-bottom: 1px solid #F5FAFE;
- }
- .item-name { font-size: 27rpx; color: #1E3A5F; }
- .item-state { font-size: 26rpx; }
- .photo-grid { display: flex; flex-wrap: wrap; margin: 18rpx 0; }
- .photo-cell { width: 190rpx; height: 190rpx; margin: 8rpx; border-radius: 12rpx; overflow: hidden; }
- .photo-img { width: 100%; height: 100%; }
- .add-cell {
- background: #E8F3FC;
- border: 1px dashed #C5DFF3;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .add-text { color: #2E6FA8; font-size: 30rpx; }
- .main-btn {
- margin-top: 16rpx;
- background: #2E6FA8;
- color: #fff;
- font-size: 30rpx;
- border-radius: 44rpx;
- line-height: 2.4;
- }
- .hint { display: block; font-size: 22rpx; color: #94A3B2; text-align: center; margin-top: 12rpx; }
- .confirm-code-box {
- background: #F0F6FB;
- border-radius: 14rpx;
- padding: 24rpx;
- text-align: center;
- margin-bottom: 20rpx;
- }
- .code-label { display: block; font-size: 24rpx; color: #3B5A78; }
- .code-value { display: block; font-size: 64rpx; font-weight: 700; letter-spacing: 12rpx; color: #1F4E79; margin: 8rpx 0; }
- .code-tip { display: block; font-size: 22rpx; color: #94A3B2; }
- .code-input-row { display: flex; align-items: center; }
- .code-input {
- flex: 1;
- height: 84rpx;
- background: #F7FAFD;
- border: 1px solid #E3ECF4;
- border-radius: 12rpx;
- padding: 0 20rpx;
- font-size: 32rpx;
- text-align: center;
- }
- .confirm-btn {
- margin-left: 16rpx;
- background: #0E8A4F;
- color: #fff;
- font-size: 28rpx;
- border-radius: 12rpx;
- height: 84rpx;
- line-height: 84rpx;
- padding: 0 40rpx;
- }
- .done-box { text-align: center; padding: 20rpx 0; }
- .done-icon { display: block; font-size: 72rpx; color: #0E8A4F; font-weight: 700; }
- .done-title { display: block; font-size: 32rpx; font-weight: 700; color: #1E3A5F; margin-top: 8rpx; }
- .done-sub { display: block; font-size: 25rpx; color: #3B5A78; margin-top: 8rpx; }
- .eval-entry {
- margin-top: 16rpx;
- border-top: 1rpx solid #F5FAFE;
- padding-top: 20rpx;
- }
- .eval-btn { margin-top: 0; }
- .eval-done-box {
- margin-top: 16rpx;
- border-top: 1rpx solid #F5FAFE;
- padding-top: 20rpx;
- text-align: center;
- }
- .eval-done-text {
- font-size: 26rpx;
- color: #0E8A4F;
- font-weight: 600;
- }
- .back-tip { text-align: center; padding: 16rpx 0; }
- .back-text { font-size: 23rpx; color: #94A3B2; }
- </style>
|