feat: 我的、设置、打印指南页面开发完成

This commit is contained in:
R524809
2026-05-07 16:32:49 +08:00
parent 0737c6165e
commit c732111e12
43 changed files with 1702 additions and 837 deletions
@@ -0,0 +1,10 @@
{
"navigationStyle": "custom",
"navigationBarTitleText": "设置",
"navigationBarTextStyle": "black",
"navigationBarBackgroundColor": "#F8F0E0",
"backgroundColor": "#F8F0E0",
"usingComponents": {
"nav-bar": "../../components3.0/nav-bar/nav-bar"
}
}
@@ -0,0 +1,59 @@
@import '../../style/theme.less';
page {
min-height: 100%;
background: @bg-header;
}
.settings-page {
min-height: 100vh;
background: @bg-header;
box-sizing: border-box;
}
.settings-body {
padding: @section-gap-xs @page-padding-x;
box-sizing: border-box;
}
.settings-section {
background: @bg-white;
border-radius: @radius-lg;
border: 1rpx solid rgba(124, 118, 106, 0.12);
box-shadow: @shadow;
overflow: hidden;
}
.settings-action {
display: flex;
align-items: center;
padding: 36rpx @page-padding-inner-x;
position: relative;
&::after {
content: '';
position: absolute;
left: @page-padding-inner-x;
right: @page-padding-inner-x;
bottom: 0;
height: 1rpx;
background: rgba(50, 46, 37, 0.08);
}
&:last-child::after {
display: none;
}
&:active {
background: rgba(50, 46, 37, 0.04);
}
}
.settings-action__text {
font-size: 30rpx;
color: @text-primary;
}
.settings-action--danger .settings-action__text {
color: #e53e3e;
}
@@ -0,0 +1,74 @@
import { clearUser } from '../../utils/auth';
Page({
onClearProfile() {
wx.showModal({
title: '确认删除',
content: '删除后头像和昵称将恢复为默认状态,是否继续?',
confirmColor: '#e53e3e',
success: (res) => {
if (res.confirm) {
this.doClearProfile();
}
},
});
},
async doClearProfile() {
wx.showLoading({ title: '处理中...', mask: true });
try {
const res = await wx.cloud.callFunction({
name: 'userSettings',
data: { action: 'clearProfile' },
});
const result = (res?.result as any) || {};
if (result.code !== 0) {
throw new Error(result.message || '操作失败');
}
clearUser();
wx.hideLoading();
wx.showToast({ title: '已删除', icon: 'success' });
} catch (e) {
wx.hideLoading();
console.error('clearProfile failed', e);
wx.showToast({ title: '操作失败,请稍后重试', icon: 'none' });
}
},
onDeleteAccount() {
wx.showModal({
title: '注销账户',
content:
'注销后您的所有数据(包括收藏、下载记录等)将被永久删除且无法恢复,确认要注销吗?',
confirmText: '确认注销',
confirmColor: '#e53e3e',
success: (res) => {
if (res.confirm) {
this.doDeleteAccount();
}
},
});
},
async doDeleteAccount() {
wx.showLoading({ title: '处理中...', mask: true });
try {
const res = await wx.cloud.callFunction({
name: 'userSettings',
data: { action: 'deleteAccount' },
});
const result = (res?.result as any) || {};
if (result.code !== 0) {
throw new Error(result.message || '操作失败');
}
clearUser();
wx.hideLoading();
wx.reLaunch({ url: '/pages/home/home' });
} catch (e) {
wx.hideLoading();
console.error('deleteAccount failed', e);
wx.showToast({ title: '操作失败,请稍后重试', icon: 'none' });
}
},
});
@@ -0,0 +1,16 @@
<view class="settings-page">
<nav-bar title="设置" />
<view class="settings-body">
<view class="settings-section">
<view class="settings-action" bindtap="onClearProfile">
<text class="settings-action__text">删除头像和昵称</text>
</view>
<view
class="settings-action settings-action--danger"
bindtap="onDeleteAccount">
<text class="settings-action__text">注销账户</text>
</view>
</view>
</view>
</view>