“mitao”
2026-04-27 200b3b191dda9e9bde524a62ad315ed7f3c15fe7
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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
<template>
    <view class="container">
        <view class="custom-navbar" :style="{ paddingTop: statusBarHeight + 'px' }">
            <view class="nav-content">
                <image class="back-icon" src="/static/image/home/left.png" mode="aspectFit" @tap="goBack"></image>
                <text class="nav-title">帮助中心</text>
                <view class="nav-right-placeholder"></view>
            </view>
        </view>
 
        <view class="top-bg">
            <image class="bg-img" src="https://mxcd.zhinenganguan.com/file/2026-03-30/5d3dd485-5af1-4913-ba22-c27f668c4660.png" mode="widthFix"></image>
        </view>
 
        <view class="content">
            <view class="service-card">
                <view class="service-info">
                    <view class="info-item">
                        <text class="label">客服电话:</text>
                        <text class="phone">{{ displayServicePhone }}</text>
                    </view>
                    <view class="info-item">
                        <text class="time">{{ displayServiceOnlineTime }}</text>
                    </view>
                </view>
                <image class="service-icon" src="/static/image/mine/Weixin.png" mode="aspectFit"></image>
            </view>
 
            <view class="contact-btn" @tap="handleContact">
                <image class="btn-icon" src="/static/image/mine/listen.png" mode="aspectFit"></image>
                <text>人工客服</text>
            </view>
 
            <view class="faq-section">
                <view class="section-title">常见问题</view>
                <view class="faq-list">
                    <view v-if="faqList.length === 0" class="empty-box">
                        <text class="empty-text">暂无常见问题</text>
                    </view>
                    <block v-for="(item, index) in faqList" :key="item.id || index">
                        <view class="faq-item" @tap="goFaqDetail(item)">
                            <text class="faq-title">{{ index + 1 }}、{{ item.title }}</text>
                            <u-icon name="arrow-right" color="#999" size="14"></u-icon>
                        </view>
                    </block>
                </view>
            </view>
        </view>
    </view>
</template>
 
<script setup lang="ts">
import { computed, ref } from 'vue'
import { onLoad, onShow } from '@dcloudio/uni-app'
import { getHelpCenter } from './service'
 
interface HelpCenterQuestionItem {
    id: number | null
    title: string
}
 
interface HelpCenterData {
    servicePhone: string
    serviceOnlineTime: string
    questions: HelpCenterQuestionItem[]
}
 
const statusBarHeight = ref(20)
const helpCenterData = ref<HelpCenterData>(createDefaultHelpCenter())
 
const displayServicePhone = computed(() => {
    return helpCenterData.value.servicePhone || '--'
})
const displayServiceOnlineTime = computed(() => {
    return helpCenterData.value.serviceOnlineTime || '人工客服在线时间暂未配置'
})
const faqList = computed(() => helpCenterData.value.questions)
 
/**
 * 创建帮助中心默认值,避免首屏访问空对象。
 */
function createDefaultHelpCenter(): HelpCenterData {
    return {
        servicePhone: '',
        serviceOnlineTime: '',
        questions: [],
    }
}
 
/**
 * 页面加载时初始化状态栏高度。
 */
onLoad(() => {
    const systemInfo = uni.getSystemInfoSync()
    statusBarHeight.value = systemInfo.statusBarHeight || 20
})
 
/**
 * 页面显示时刷新帮助中心数据。
 */
onShow(() => {
    loadHelpCenter()
})
 
/**
 * 拉取帮助中心首页聚合数据。
 */
async function loadHelpCenter() {
    try {
        const response = await getHelpCenter()
        if (response?.code !== 0 || !response.data) {
            return
        }
        helpCenterData.value = normalizeHelpCenter(response.data)
    } catch {
        // 请求层会统一处理异常提示。
    }
}
 
/**
 * 将接口数据归一化为页面可直接渲染的结构。
 */
function normalizeHelpCenter(value: unknown): HelpCenterData {
    const source = (value && typeof value === 'object' ? value : {}) as Record<string, unknown>
    return {
        servicePhone: normalizeOptionalText(source.servicePhone),
        serviceOnlineTime: normalizeOptionalText(source.serviceOnlineTime),
        questions: normalizeQuestions(source.questions),
    }
}
 
/**
 * 将常见问题列表归一化。
 */
function normalizeQuestions(value: unknown): HelpCenterQuestionItem[] {
    if (!Array.isArray(value)) {
        return []
    }
    return value.map((item) => {
        const source = (item && typeof item === 'object' ? item : {}) as Record<string, unknown>
        return {
            id: normalizeOptionalNumber(source.id),
            title: normalizeOptionalText(source.title) || '常见问题',
        }
    })
}
 
/**
 * 返回上一页。
 */
function goBack() {
    uni.navigateBack()
}
 
/**
 * 拨打系统设置中的客服电话,未配置时给出兜底提示。
 */
function handleContact() {
    const servicePhone = normalizePhoneNumber(helpCenterData.value.servicePhone)
    if (!servicePhone) {
        uni.showToast({
            title: '暂未配置客服电话',
            icon: 'none',
        })
        return
    }
    uni.makePhoneCall({
        phoneNumber: servicePhone,
        fail() {
            uni.showToast({
                title: '拨号失败,请检查客服电话配置',
                icon: 'none',
            })
        },
    })
}
 
/**
 * 跳转到常见问题详情页。
 */
function goFaqDetail(item: HelpCenterQuestionItem) {
    if (!item.id) {
        return
    }
    uni.navigateTo({
        url: `/pages/help/help?id=${item.id}`,
    })
}
 
/**
 * 将可选文本归一化为空字符串。
 */
function normalizeOptionalText(value: unknown) {
    if (typeof value !== 'string') {
        return ''
    }
    return value.trim()
}
 
/**
 * 清洗客服电话,兼容空格、横杠和中文括号等展示字符。
 */
function normalizePhoneNumber(value: unknown) {
    if (typeof value !== 'string') {
        return ''
    }
    return value
        .trim()
        .replace(/[()()\s-]/g, '')
        .replace(/(?!^)\+/g, '')
}
 
/**
 * 将可选数字归一化为空值。
 */
function normalizeOptionalNumber(value: unknown) {
    const parsedValue = Number(value)
    if (!Number.isFinite(parsedValue)) {
        return null
    }
    return parsedValue
}
</script>
 
<style lang="scss" scoped>
    page {
        background-color: #F8F6F4;
    }
 
    .container {
        width: 100vw;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        background-color: #F8F6F4;
        position: relative;
    }
 
    /* 顶部背景 */
    .top-bg {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        z-index: 0;
        
        .bg-img {
            width: 100%;
            height: auto;
        }
    }
 
    /* 自定义导航栏 */
    .custom-navbar {
        width: 100%;
        position: relative;
        z-index: 100;
        background-color: transparent;
    }
 
    .nav-content {
        height: 88rpx;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 32rpx;
        
    }
 
    .back-icon {
        width: 40rpx;
        height: 40rpx;
    }
 
    .nav-title {
        font-size: 36rpx;
        color: #1A1A1A;
        font-weight: bold;
    }
 
    .nav-right-placeholder {
        width: 40rpx;
    }
 
    .content {
        position: relative;
        z-index: 1;
        padding: 40rpx;
        padding-right: 0rpx !important;
    }
 
    /* 客服卡片 */
    .service-card {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 40rpx;
        // padding-right: 20rpx;
    }
 
    .service-info {
        .info-item {
            margin-bottom: 12rpx;
            
            &:last-child {
                margin-bottom: 0;
            }
        }
        
        .label {
            font-size: 32rpx;
            color: #1A1A1A;
            font-weight: bold;
        }
        
        .phone {
            font-size: 36rpx;
            color: #1A1A1A;
            font-weight: bold;
            display: block;
            margin-top: 8rpx;
        }
        
        .time {
            font-size: 24rpx;
            color: #86909C;
        }
    }
 
    .service-icon {
        width: 200rpx;
        height: 200rpx;
    }
 
    /* 客服按钮 */
    .contact-btn {
        width: 670rpx;
        height: 88rpx;
        background-color: #D32E29;
        border-radius: 16rpx;
        display: flex;
        justify-content: center;
        align-items: center;
        color: #FFFFFF;
        font-size: 32rpx;
        font-weight: 500;
        margin-bottom: 60rpx;
        box-shadow: 0 4rpx 12rpx rgba(211, 46, 41, 0.2);
 
        .btn-icon {
            width: 36rpx;
            height: 36rpx;
            margin-right: 12rpx;
        }
    }
 
    /* 常见问题 */
    .section-title {
        font-size: 32rpx;
        color: #1A1A1A;
        font-weight: bold;
        margin-bottom: 24rpx;
    }
 
    .faq-list {
        background-color: #FFFFFF;
        border-radius: 16rpx;
        padding: 0 24rpx;
    }
 
    .empty-box {
        height: 120rpx;
        display: flex;
        align-items: center;
        justify-content: center;
    }
 
    .empty-text {
        font-size: 26rpx;
        color: #999999;
    }
 
    .faq-item {
        height: 100rpx;
        display: flex;
        align-items: center;
        justify-content: space-between;
        border-bottom: 1px solid #F2F3F5;
        
        &:last-child {
            border-bottom: none;
        }
 
        .faq-title {
            flex: 1;
            font-size: 28rpx;
            color: #1A1A1A;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            padding-right: 20rpx;
        }
    }
</style>