增加来访核验
This commit is contained in:
@@ -4,7 +4,8 @@ Page({
|
|||||||
data: {
|
data: {
|
||||||
record: null,
|
record: null,
|
||||||
loading: true,
|
loading: true,
|
||||||
error: ''
|
error: '',
|
||||||
|
verifying: false
|
||||||
},
|
},
|
||||||
|
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
@@ -41,10 +42,16 @@ Page({
|
|||||||
'cancelled': '已取消'
|
'cancelled': '已取消'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// checkStatus 为字符串:'0' 未核销,'1' 已核销
|
||||||
|
const checkStatus = String(result.checkStatus)
|
||||||
|
const checkStatusText = checkStatus === '1' ? '已核销' : '未核销'
|
||||||
|
|
||||||
this.setData({
|
this.setData({
|
||||||
record: {
|
record: {
|
||||||
...formatRecord(result),
|
...formatRecord(result),
|
||||||
statusText: statusMap[result.status] || result.status
|
statusText: statusMap[result.status] || result.status,
|
||||||
|
checkStatus: checkStatus,
|
||||||
|
checkStatusText: checkStatusText
|
||||||
},
|
},
|
||||||
loading: false
|
loading: false
|
||||||
})
|
})
|
||||||
@@ -52,5 +59,32 @@ Page({
|
|||||||
console.error('加载预约记录详情失败', err)
|
console.error('加载预约记录详情失败', err)
|
||||||
this.setData({ loading: false, error: '加载失败,请稍后重试' })
|
this.setData({ loading: false, error: '加载失败,请稍后重试' })
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
async onVerify() {
|
||||||
|
const { record, verifying } = this.data
|
||||||
|
if (verifying || !record || !record.id) return
|
||||||
|
|
||||||
|
wx.showModal({
|
||||||
|
title: '确认核销',
|
||||||
|
content: '确定要核销该预约记录吗?',
|
||||||
|
confirmColor: '#1890ff',
|
||||||
|
success: async (res) => {
|
||||||
|
if (!res.confirm) return
|
||||||
|
|
||||||
|
this.setData({ verifying: true })
|
||||||
|
try {
|
||||||
|
await appointmentDB.notifyHost(record.id)
|
||||||
|
wx.showToast({ title: '核销成功', icon: 'success' })
|
||||||
|
// 刷新详情页
|
||||||
|
this.loadRecordDetail(record.id)
|
||||||
|
} catch (err) {
|
||||||
|
console.error('核销失败', err)
|
||||||
|
wx.showToast({ title: '核销失败,请重试', icon: 'none' })
|
||||||
|
} finally {
|
||||||
|
this.setData({ verifying: false })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -65,5 +65,18 @@
|
|||||||
<text class="detail-value">{{record.area}}</text>
|
<text class="detail-value">{{record.area}}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- 核销状态与操作 -->
|
||||||
|
<view class="detail-section">
|
||||||
|
<view class="detail-row">
|
||||||
|
<text class="detail-label">核销状态</text>
|
||||||
|
<text class="detail-value {{record.checkStatus === '1' ? 'text-success' : 'text-warning'}}">{{record.checkStatusText}}</text>
|
||||||
|
</view>
|
||||||
|
<view class="verify-btn-wrap" wx:if="{{record.checkStatus === '0'}}">
|
||||||
|
<view class="verify-btn {{verifying ? 'verify-btn-disabled' : ''}}" bindtap="onVerify">
|
||||||
|
{{verifying ? '核销中...' : '确认核销'}}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -133,4 +133,36 @@
|
|||||||
color: #333;
|
color: #333;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 核销状态文字 */
|
||||||
|
.text-warning {
|
||||||
|
color: #faad14;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-success {
|
||||||
|
color: #52c41a;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 核销按钮 */
|
||||||
|
.verify-btn-wrap {
|
||||||
|
padding-top: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.verify-btn {
|
||||||
|
width: 100%;
|
||||||
|
height: 80rpx;
|
||||||
|
line-height: 80rpx;
|
||||||
|
text-align: center;
|
||||||
|
background: linear-gradient(135deg, #1890ff 0%, #096dd9 100%);
|
||||||
|
color: #fff;
|
||||||
|
font-size: 30rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
border-radius: 12rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.verify-btn-disabled {
|
||||||
|
opacity: 0.6;
|
||||||
}
|
}
|
||||||
@@ -197,6 +197,21 @@ const appointmentDB = {
|
|||||||
data: { department }
|
data: { department }
|
||||||
})
|
})
|
||||||
return data || []
|
return data || []
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 核销通知被访人
|
||||||
|
* @param {string} id - 预约记录 id
|
||||||
|
* @returns {Promise<boolean>}
|
||||||
|
*/
|
||||||
|
async notifyHost(id) {
|
||||||
|
await request({
|
||||||
|
url: BASE_URL + API.NOTIFY_HOST,
|
||||||
|
method: 'POST',
|
||||||
|
header: { 'content-type': 'application/json' },
|
||||||
|
data: { id }
|
||||||
|
})
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -29,7 +29,8 @@ const API = {
|
|||||||
APPOINTMENT_CANCEL: '/api/wx-mini/appointment/cancel',
|
APPOINTMENT_CANCEL: '/api/wx-mini/appointment/cancel',
|
||||||
APPOINTMENT_DETAIL: '/api/wx-mini/appointment/detail',
|
APPOINTMENT_DETAIL: '/api/wx-mini/appointment/detail',
|
||||||
WXACODE: '/api/wx-mini/wxacode',
|
WXACODE: '/api/wx-mini/wxacode',
|
||||||
PERSON_SELECTOR: '/api/wx-mini/appointment/person/selector'
|
PERSON_SELECTOR: '/api/wx-mini/appointment/person/selector',
|
||||||
|
NOTIFY_HOST: '/visitor/notify-host'
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('[config] 当前环境:', wx.getAccountInfoSync().miniProgram.envVersion, 'BASE_URL:', BASE_URL)
|
console.log('[config] 当前环境:', wx.getAccountInfoSync().miniProgram.envVersion, 'BASE_URL:', BASE_URL)
|
||||||
|
|||||||
Reference in New Issue
Block a user