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
+70 -2
View File
@@ -1,7 +1,75 @@
type AlbumAuthState = 'unknown' | 'granted' | 'denied';
const ALBUM_SCOPE = 'scope.writePhotosAlbum';
Page({
data: {},
data: {
albumAuthState: 'unknown' as AlbumAuthState,
},
onLoad() {
// 静态说明页,无额外逻辑
this.refreshAlbumAuthState();
},
onShow() {
this.refreshAlbumAuthState();
},
refreshAlbumAuthState() {
wx.getSetting({
success: (res) => {
const auth = res.authSetting?.[ALBUM_SCOPE];
let state: AlbumAuthState = 'unknown';
if (auth === true) {
state = 'granted';
} else if (auth === false) {
state = 'denied';
}
this.setData({ albumAuthState: state });
},
fail: () => {
this.setData({ albumAuthState: 'unknown' });
},
});
},
onHandleAlbumPerm() {
const { albumAuthState } = this.data;
// 已被拒绝过:只能去系统设置打开
if (albumAuthState === 'denied') {
wx.openSetting({
success: (res) => {
const granted = !!res.authSetting?.[ALBUM_SCOPE];
this.setData({
albumAuthState: granted ? 'granted' : 'denied',
});
if (granted) {
wx.showToast({
title: '已开启相册权限',
icon: 'success',
duration: 1500,
});
}
},
});
return;
}
// 未授权过:直接发起授权请求
wx.authorize({
scope: ALBUM_SCOPE,
success: () => {
this.setData({ albumAuthState: 'granted' });
wx.showToast({
title: '已开启相册权限',
icon: 'success',
duration: 1500,
});
},
fail: () => {
this.setData({ albumAuthState: 'denied' });
},
});
},
});