feat: first commit

This commit is contained in:
eleanor.mao
2025-03-31 22:34:22 +08:00
commit d25187c9c8
390 changed files with 57031 additions and 0 deletions

54
src/utils/wx.ts Normal file
View File

@ -0,0 +1,54 @@
import Taro from '@tarojs/taro';
/**
* 获取微信配置
* @param scope
* @param tips
* @param force
* @returns
*/
export function getWxSetting(scope: keyof Taro.AuthSetting) {
return new Promise<boolean>(resolve => {
Taro.getSetting({
success(res) {
if (!res?.authSetting[scope]) {
resolve(false);
} else {
resolve(true);
}
},
fail() {
resolve(false);
},
});
});
}
export function authorize(scope: keyof Taro.AuthSetting, tips: string, force = true) {
return new Promise<boolean>(resolve => {
Taro.authorize({
scope,
success() {
return resolve(true);
},
fail() {
if (!force) return resolve(false);
Taro.showModal({
title: '提示',
content: tips,
showCancel: false,
success: () => {
Taro.openSetting({
success(result) {
if (!result.authSetting[scope]) resolve(false);
else resolve(true);
},
});
},
fail: () => resolve(false),
});
},
});
});
}