Files

28 lines
1.7 KiB
Plaintext
Raw Permalink Normal View History

import { requestJson } from '@/services/api.uts'
export type HelpQuestion = { id: string, category: string, question: string, answer: string }
export const helpCategories: string[] = ['账户使用', '融资评估', '资料与隐私']
export async function fetchHelpQuestions(): Promise<HelpQuestion[]> {
const response = await requestJson('/help/faqs', 'GET', {})
const items = response['items']
if (items == null || !Array.isArray(items)) throw new Error('帮助内容响应不完整,请重试')
const results: HelpQuestion[] = []
;(items as any[]).forEach((value: any) => {
if (value == null || typeof value != 'object' || Array.isArray(value)) throw new Error('帮助内容响应不完整,请重试')
const item = value as UTSJSONObject
const id = item.getString('id'); const category = item.getString('category')
const question = item.getString('question'); const answer = item.getString('answer')
if (id == null || !/^[1-9][0-9]{0,9}$/.test(id) || parseFloat(id) > 2147483647
|| category == null || !helpCategories.includes(category) || question == null || question.trim().length == 0
|| answer == null || answer.trim().length == 0 || results.some((entry: HelpQuestion): boolean => entry.id == id))
throw new Error('帮助内容响应不完整,请重试')
const result: HelpQuestion = { id, category, question, answer }; results.push(result)
})
return results
}
export function contactCustomerService(): void {
// 后续在此接入各端客服渠道;当前不发起会话、拨号或发送反馈。
uni.showModal({ title: '联系客服', content: '客服服务暂未开放,请稍后再试。', showCancel: false, confirmText: '我知道了' })
}