Initial Commit
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
// index.js
|
||||
const { appointmentDB } = require('../../utils/cloud')
|
||||
const app = getApp()
|
||||
|
||||
Page({
|
||||
data: {
|
||||
isLoggedIn: false,
|
||||
latestRecord: null
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
if (app.globalData.isLoggedIn) {
|
||||
this.onLoginReady()
|
||||
} else {
|
||||
app.loginReadyCallback = () => {
|
||||
this.onLoginReady()
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onShow() {
|
||||
if (app.globalData.isLoggedIn) {
|
||||
this.loadLatestRecord()
|
||||
}
|
||||
},
|
||||
|
||||
onLoginReady() {
|
||||
this.setData({ isLoggedIn: true })
|
||||
this.loadLatestRecord()
|
||||
},
|
||||
|
||||
async loadLatestRecord() {
|
||||
if (!this.data.isLoggedIn) {
|
||||
this.setData({ latestRecord: null })
|
||||
return
|
||||
}
|
||||
try {
|
||||
const openid = app.globalData.userInfo.openid
|
||||
const record = await appointmentDB.getLatest(openid)
|
||||
if (record) {
|
||||
this.setData({ latestRecord: this.formatRecord(record) })
|
||||
} else {
|
||||
this.setData({ latestRecord: null })
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('加载最新预约失败', err)
|
||||
this.setData({ latestRecord: null })
|
||||
}
|
||||
},
|
||||
|
||||
formatRecord(record) {
|
||||
const date = record.createTime
|
||||
let createTimeStr = ''
|
||||
if (date) {
|
||||
if (typeof date === 'object' && date.$date) {
|
||||
createTimeStr = new Date(date.$date).toLocaleString('zh-CN')
|
||||
} else {
|
||||
createTimeStr = new Date(date).toLocaleString('zh-CN')
|
||||
}
|
||||
}
|
||||
return { ...record, createTime: createTimeStr }
|
||||
},
|
||||
|
||||
goAppointment() {
|
||||
wx.navigateTo({
|
||||
url: '/pages/appointment/appointment'
|
||||
})
|
||||
},
|
||||
|
||||
goRecords() {
|
||||
wx.navigateTo({
|
||||
url: '/pages/records/records'
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"usingComponents": {},
|
||||
"navigationBarTitleText": "访客预约系统"
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<!--index.wxml-->
|
||||
<view class="page">
|
||||
<!-- loading 遮罩 -->
|
||||
<view class="loading-mask" wx:if="{{!isLoggedIn}}">
|
||||
<view class="loading-spinner"></view>
|
||||
<text class="loading-text">正在获取身份信息...</text>
|
||||
</view>
|
||||
|
||||
<view class="header">
|
||||
<view class="header-icon">🏢</view>
|
||||
<text class="header-title">访客预约系统</text>
|
||||
<text class="header-subtitle">协能工厂区域访问管理</text>
|
||||
</view>
|
||||
|
||||
<view class="action-list">
|
||||
<view class="action-card" bindtap="goAppointment">
|
||||
<view class="action-icon-wrap action-icon-blue">
|
||||
<text class="action-icon-text">📅</text>
|
||||
</view>
|
||||
<view class="action-info">
|
||||
<text class="action-title">访客预约</text>
|
||||
<text class="action-desc">选择预约时间和预约人,提交预约信息</text>
|
||||
</view>
|
||||
<text class="action-arrow">›</text>
|
||||
</view>
|
||||
|
||||
<view class="action-card" bindtap="goRecords">
|
||||
<view class="action-icon-wrap action-icon-green">
|
||||
<text class="action-icon-text">📋</text>
|
||||
</view>
|
||||
<view class="action-info">
|
||||
<text class="action-title">预约记录</text>
|
||||
<text class="action-desc">查看预约记录、进度及取消预约</text>
|
||||
</view>
|
||||
<text class="action-arrow">›</text>
|
||||
</view>
|
||||
|
||||
<!-- 最新预约摘要 -->
|
||||
<view class="latest-card" wx:if="{{latestRecord}}">
|
||||
<view class="latest-header">
|
||||
<text class="latest-title">最新预约</text>
|
||||
<view class="status-tag status-{{latestRecord.status}}">{{latestRecord.statusText}}</view>
|
||||
</view>
|
||||
<view class="latest-body">
|
||||
<view class="latest-row">
|
||||
<text class="latest-label">访客</text>
|
||||
<text class="latest-value">{{latestRecord.name}}</text>
|
||||
</view>
|
||||
<view class="latest-row">
|
||||
<text class="latest-label">时间</text>
|
||||
<text class="latest-value">{{latestRecord.date}} {{latestRecord.time}}</text>
|
||||
</view>
|
||||
<view class="latest-row">
|
||||
<text class="latest-label">区域</text>
|
||||
<text class="latest-value">{{latestRecord.area}}</text>
|
||||
</view>
|
||||
<view class="latest-row">
|
||||
<text class="latest-label">被访人</text>
|
||||
<text class="latest-value">{{latestRecord.hostName}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="latest-footer" bindtap="goRecords">
|
||||
<text class="latest-link">查看全部记录 ›</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="footer">
|
||||
<text class="footer-text">协能工厂 · 访客管理</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,228 @@
|
||||
/**index.wxss**/
|
||||
page {
|
||||
background-color: #f5f7fa;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.page {
|
||||
padding: 40rpx 32rpx;
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 60rpx 0 40rpx;
|
||||
}
|
||||
|
||||
.header-icon {
|
||||
font-size: 100rpx;
|
||||
margin-bottom: 24rpx;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
/* loading 遮罩 */
|
||||
.loading-mask {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: #f5f7fa;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
.loading-spinner {
|
||||
width: 64rpx;
|
||||
height: 64rpx;
|
||||
border: 6rpx solid #e0e0e0;
|
||||
border-top: 6rpx solid #1890ff;
|
||||
border-radius: 50%;
|
||||
animation: spin 0.8s linear infinite;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
from { transform: rotate(0deg); }
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
.loading-text {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.header-title {
|
||||
font-size: 44rpx;
|
||||
font-weight: 700;
|
||||
color: #1a1a1a;
|
||||
margin-bottom: 12rpx;
|
||||
}
|
||||
|
||||
.header-subtitle {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
/* 功能卡片 */
|
||||
.action-list {
|
||||
margin-top: 24rpx;
|
||||
}
|
||||
|
||||
.action-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: #fff;
|
||||
border-radius: 20rpx;
|
||||
padding: 36rpx 32rpx;
|
||||
margin-bottom: 24rpx;
|
||||
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.06);
|
||||
}
|
||||
|
||||
.action-card:active {
|
||||
background: #f0f0f0;
|
||||
}
|
||||
|
||||
.action-icon-wrap {
|
||||
width: 88rpx;
|
||||
height: 88rpx;
|
||||
border-radius: 20rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-right: 28rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.action-icon-blue {
|
||||
background: rgba(24, 144, 255, 0.1);
|
||||
}
|
||||
|
||||
.action-icon-green {
|
||||
background: rgba(82, 196, 26, 0.1);
|
||||
}
|
||||
|
||||
.action-icon-text {
|
||||
font-size: 44rpx;
|
||||
}
|
||||
|
||||
.action-info {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.action-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
color: #1a1a1a;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.action-desc {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.action-arrow {
|
||||
font-size: 40rpx;
|
||||
color: #ccc;
|
||||
margin-left: 16rpx;
|
||||
}
|
||||
|
||||
/* 最新预约卡片 */
|
||||
.latest-card {
|
||||
background: #fff;
|
||||
border-radius: 20rpx;
|
||||
padding: 28rpx 32rpx;
|
||||
margin-top: 8rpx;
|
||||
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.06);
|
||||
}
|
||||
|
||||
.latest-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 20rpx;
|
||||
padding-bottom: 16rpx;
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
}
|
||||
|
||||
.latest-title {
|
||||
font-size: 28rpx;
|
||||
font-weight: 600;
|
||||
color: #1a1a1a;
|
||||
}
|
||||
|
||||
.status-tag {
|
||||
font-size: 22rpx;
|
||||
padding: 4rpx 16rpx;
|
||||
border-radius: 16rpx;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.status-pending {
|
||||
background: rgba(250, 173, 20, 0.1);
|
||||
color: #faad14;
|
||||
}
|
||||
|
||||
.status-approved {
|
||||
background: rgba(82, 196, 26, 0.1);
|
||||
color: #52c41a;
|
||||
}
|
||||
|
||||
.status-rejected {
|
||||
background: rgba(255, 77, 79, 0.1);
|
||||
color: #ff4d4f;
|
||||
}
|
||||
|
||||
.status-cancelled {
|
||||
background: rgba(0, 0, 0, 0.04);
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.latest-body {
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.latest-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 8rpx 0;
|
||||
}
|
||||
|
||||
.latest-label {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.latest-value {
|
||||
font-size: 24rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.latest-footer {
|
||||
padding-top: 16rpx;
|
||||
border-top: 1rpx solid #f0f0f0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.latest-link {
|
||||
font-size: 24rpx;
|
||||
color: #1890ff;
|
||||
}
|
||||
|
||||
.footer {
|
||||
margin-top: 120rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.footer-text {
|
||||
font-size: 24rpx;
|
||||
color: #ccc;
|
||||
}
|
||||
Reference in New Issue
Block a user