zjk
2026-09-04 cc0c86385cdef27783ca4f71f050ccddc30eb4e2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
<template>
  <view class="steps-card" :class="{ landscape: isLandscapeLayout }">
    <view class="steps-row">
      <template v-for="(step, index) in stepsList" :key="index">
        <view class="step-item">
          <view class="step-circle" :class="getCircleClass(index + 1)">
            <image :src="getStepIconSrc(step.icon, index + 1)" class="step-icon" mode="aspectFit"></image>
          </view>
          <text class="step-text" :class="getTextClass(index + 1)">{{ step.text }}</text>
        </view>
        <view class="step-line" v-if="index < stepsList.length - 1">
          <image :src="getArrowSrc(index + 1)" class="arrow-img" mode="aspectFit"></image>
        </view>
      </template>
    </view>
  </view>
</template>
 
<script setup>
import { computed, ref, onMounted, onUnmounted } from 'vue';
import qrActiveIcon from '../static/appointment-scan/qr-active.png';
import qrCompletedIcon from '../static/appointment-scan/qr-completed.png';
import idcardInactiveIcon from '../static/appointment-scan/idcard-inactive.png';
import idcardActiveIcon from '../static/appointment-scan/idcard-active.png';
import idcardCompletedIcon from '../static/appointment-scan/idcard-completed.png';
import faceInactiveIcon from '../static/appointment-scan/face-inactive.png';
import faceActiveIcon from '../static/appointment-scan/face-active.png';
import faceCompletedIcon from '../static/appointment-scan/face-completed.png';
import hostInactiveIcon from '../static/appointment-scan/host-inactive.png';
import hostActiveIcon from '../static/appointment-scan/host-active.png';
import hostCompletedIcon from '../static/appointment-scan/host-completed.png';
import formInactiveIcon from '../static/appointment-scan/form-inactive.png';
import formActiveIcon from '../static/appointment-scan/form-active.png';
import formCompletedIcon from '../static/appointment-scan/form-completed.png';
import printInactiveIcon from '../static/appointment-scan/print-inactive.png';
import printActiveIcon from '../static/appointment-scan/print-active.png';
import stepArrowActiveImage from '../static/appointment-scan/step-arrow-active.png';
import stepArrowInactiveImage from '../static/appointment-scan/step-arrow-inactive.png';
 
const isLandscapeLayout = ref(false);
const updateLayoutMode = () => {
    try {
        const windowInfo = uni.getWindowInfo ? uni.getWindowInfo() : uni.getSystemInfoSync();
        const viewportWidth = Number(windowInfo?.windowWidth || windowInfo?.screenWidth || 0);
        const viewportHeight = Number(windowInfo?.windowHeight || windowInfo?.screenHeight || 0);
        isLandscapeLayout.value = Boolean(viewportWidth && viewportHeight && viewportWidth > viewportHeight);
    } catch (error) {
        console.error('StepProgress 读取窗口尺寸失败:', error);
        isLandscapeLayout.value = false;
    }
};
 
let flowWindowResizeHandler = null;
const registerFlowWindowResize = () => {
    if (flowWindowResizeHandler || !uni.onWindowResize) {
        return;
    }
    flowWindowResizeHandler = () => {
        updateLayoutMode();
    };
    uni.onWindowResize(flowWindowResizeHandler);
};
const unregisterFlowWindowResize = () => {
    if (!flowWindowResizeHandler || !uni.offWindowResize) {
        flowWindowResizeHandler = null;
        return;
    }
    uni.offWindowResize(flowWindowResizeHandler);
    flowWindowResizeHandler = null;
};
 
onMounted(() => {
    updateLayoutMode();
    registerFlowWindowResize();
});
 
onUnmounted(() => {
    unregisterFlowWindowResize();
});
 
const props = defineProps({
  currentStep: {
    type: Number,
    default: 1
  },
  mode: {
    type: String,
    default: 'appointment' // 'appointment' 或 'online'
  },
  steps: {
    type: Array,
    default: () => []
  }
});
 
const stepsList = computed(() => {
  if (Array.isArray(props.steps) && props.steps.length > 0) {
    return props.steps;
  }
 
  if (props.mode === 'online') {
    return [
      { text: '身份证验证', icon: 'idcard' },
      { text: '人脸验证', icon: 'face' },
      { text: '接待人验证', icon: 'user' },
      { text: '完善登记信息', icon: 'form' },
      { text: '打印凭条', icon: 'print' }
    ];
  }
  if (props.mode === 'signout') {
    return [
      { text: '身份证验证', icon: 'idcard' },
      { text: '人脸验证', icon: 'face' },
      { text: '接待人验证', icon: 'user' }
    ];
  }
  return [
    { text: '预约码验证', icon: 'qr' },
    { text: '身份证验证', icon: 'idcard' },
    { text: '人脸验证', icon: 'face' },
    { text: '接待人验证', icon: 'user' },
    { text: '打印凭条', icon: 'print' }
  ];
});
 
const getCircleClass = (stepNum) => {
  if (stepNum < props.currentStep) return 'completed-circle';
  if (stepNum === props.currentStep) return 'active-circle';
  return 'inactive-circle';
};
 
const getTextClass = (stepNum) => {
  if (stepNum < props.currentStep) return 'completed-text';
  if (stepNum === props.currentStep) return 'active-text';
  return 'inactive-text';
};
 
const stepIconMap = {
  qr: {
    active: qrActiveIcon,
    completed: qrCompletedIcon,
    inactive: qrActiveIcon,
  },
  idcard: {
    active: idcardActiveIcon,
    completed: idcardCompletedIcon,
    inactive: idcardInactiveIcon,
  },
  face: {
    active: faceActiveIcon,
    completed: faceCompletedIcon,
    inactive: faceInactiveIcon,
  },
  user: {
    active: hostActiveIcon,
    completed: hostCompletedIcon,
    inactive: hostInactiveIcon,
  },
  form: {
    active: formActiveIcon,
    completed: formCompletedIcon,
    inactive: formInactiveIcon,
  },
  print: {
    active: printActiveIcon,
    completed: printInactiveIcon,
    inactive: printInactiveIcon,
  },
};
 
const getStepStatus = (stepNum) => {
  if (stepNum < props.currentStep) return 'completed';
  if (stepNum === props.currentStep) return 'active';
  return 'inactive';
};
 
const getStepIconSrc = (iconKey, stepNum) => {
  const iconGroup = stepIconMap[iconKey];
  if (!iconGroup) {
    return '';
  }
  return iconGroup[getStepStatus(stepNum)] || iconGroup.inactive;
};
 
const getArrowSrc = (stepNum) => {
  if (stepNum < props.currentStep) {
    return stepArrowActiveImage;
  }
  return stepArrowInactiveImage;
};
</script>
 
<style scoped>
/* 步骤卡片 */
.steps-card {
  width: 1008px;
  display: flex;
  flex-direction: column;
  margin-bottom: 24px;
  z-index: 1;
}
 
.steps-row {
  width: 1008px;
  height: 138px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}
 
.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 120px;
}
 
.step-circle {
  width: 82px;
  height: 82px;
  border-radius: 41px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}
 
.step-icon {
  width: 38px;
  height: 38px;
}
 
.completed-circle {
  background: #78A8FF;
  border: 1px solid #DDE9FF;
  box-shadow: 0px 10px 18px rgba(14, 49, 138, 0.22);
}
 
.active-circle {
  background: #FFFFFF;
  border: 2px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0px 12px 24px rgba(15, 45, 125, 0.27);
}
 
.inactive-circle {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0px 8px 14px rgba(8, 32, 86, 0.07);
}
 
.step-text {
  font-family: Inter, sans-serif;
  font-size: 23px;
  text-align: center;
}
 
.completed-text {
  font-weight: 800;
  color: rgba(255, 255, 255, 0.94);
}
 
.active-text {
  font-weight: 900;
  color: #FFFFFF;
}
 
.inactive-text {
  font-weight: 600;
  color: rgba(226, 235, 255, 0.66);
}
 
.step-line {
  flex: 1;
  height: 82px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 56px;
}
 
.arrow-img {
  width: 92px;
  height: 82px;
}
 
/* 横屏模式 */
.steps-card.landscape {
  width: 1824px;
}
.steps-card.landscape .steps-row {
  width: 1824px;
}
.steps-card.landscape .step-line {
  flex: 1; /* 让连接线自动撑开 */
  align-items: center;
  justify-content: center;
  display: flex;
}
.steps-card.landscape .step-item {
  flex: none;
  width: 150px;
}
</style>