- 新增系统设置、壁纸、图标包、设备管理、通讯录、通话、短信、相册、文件、应用、告警、信息、首页布局、账号安全、绑定手机号、法律条款等页面 - utils/api.ts 补齐设备操作、策略、壁纸、图标包等 /api/v1/client/** 接口,新增多文件上传 - 新增 utils/sse.ts 与 utils/wx-session.ts - 「更多/进入」指示统一改为图片箭头,首卡统一 .hero-card 高度,页面首卡贴顶 - AGENTS.md 补充功能对接状态与小程序 UI 约定
67 lines
1.6 KiB
TypeScript
67 lines
1.6 KiB
TypeScript
import type { CallRecord } from '../../utils/api'
|
|
import { getCallPage, syncCallRecords } from '../../utils/api'
|
|
import { getDeviceSn } from '../../utils/token'
|
|
|
|
Page({
|
|
data: {
|
|
records: [] as CallRecord[],
|
|
direction: '',
|
|
loading: false
|
|
},
|
|
|
|
onShow() {
|
|
this.load()
|
|
},
|
|
|
|
onFilter() {
|
|
wx.showActionSheet({
|
|
itemList: ['全部', '呼入', '呼出'],
|
|
success: (res) => {
|
|
const direction = res.tapIndex === 1 ? 'IN' : res.tapIndex === 2 ? 'OUT' : ''
|
|
this.setData({ direction })
|
|
this.load()
|
|
}
|
|
})
|
|
},
|
|
|
|
async onSync() {
|
|
const sn = getDeviceSn()
|
|
if (!sn) {
|
|
this.toast('请先选择设备')
|
|
return
|
|
}
|
|
wx.showLoading({ title: '同步中' })
|
|
try {
|
|
await syncCallRecords(sn)
|
|
wx.hideLoading()
|
|
this.toast('已请求设备上报通话记录')
|
|
setTimeout(() => this.load(), 800)
|
|
} catch (err) {
|
|
wx.hideLoading()
|
|
this.toast((err as Error).message || '同步失败')
|
|
}
|
|
},
|
|
|
|
async load() {
|
|
const sn = getDeviceSn()
|
|
if (!sn) {
|
|
this.toast('请先选择设备')
|
|
return
|
|
}
|
|
if (this.data.loading) return
|
|
this.setData({ loading: true })
|
|
try {
|
|
const result = await getCallPage(sn, 1, 30, this.data.direction || undefined)
|
|
this.setData({ records: result.list || result.records || [] })
|
|
} catch (err) {
|
|
this.toast((err as Error).message || '记录加载失败')
|
|
} finally {
|
|
this.setData({ loading: false })
|
|
}
|
|
},
|
|
|
|
toast(title: string) {
|
|
wx.showToast({ title, icon: 'none', duration: 1800 })
|
|
}
|
|
})
|