diff --git a/miniprogram/pages/my/my.ts b/miniprogram/pages/my/my.ts index 8192164..c2bff82 100644 --- a/miniprogram/pages/my/my.ts +++ b/miniprogram/pages/my/my.ts @@ -1,5 +1,6 @@ import { calcAge } from '../../utils/idCard/index' import type { UserInfo } from '../../api/index' +import { leFuService } from '../../lefu/index' /** 页面展示用用户信息 */ interface PageUserInfo { @@ -45,6 +46,23 @@ Page({ wx.navigateTo({ url: '/pages/helpCenter/helpCenter' }) }, + // 退出登录:清空 lefu 连接与本地信息,回到登录页 + onLogout() { + wx.showModal({ + title: '退出登录', + content: '确定要退出登录吗?', + confirmText: '退出', + cancelText: '取消', + success: (res) => { + if (!res.confirm) return + leFuService.disconnect() + leFuService.stopScan() + wx.clearStorageSync() + wx.reLaunch({ url: '/pages/login/login' }) + }, + }) + }, + /** * 生命周期函数--监听页面初次渲染完成 */ diff --git a/miniprogram/pages/my/my.wxml b/miniprogram/pages/my/my.wxml index bcabdde..a6a4859 100644 --- a/miniprogram/pages/my/my.wxml +++ b/miniprogram/pages/my/my.wxml @@ -37,6 +37,6 @@ - 退出登录 + 退出登录 \ No newline at end of file