提现功能需要添加

This commit is contained in:
bobobobo
2026-01-04 23:35:06 +08:00
parent a4ae562396
commit 42eba945e8
58 changed files with 4825 additions and 1015 deletions

45
utils/media.js Normal file
View File

@@ -0,0 +1,45 @@
/**
* 封装 uni.chooseImage返回 Promise便于 async/await 使用
* @param {Object} options - 透传给 uni.chooseImage 的配置
* @returns {Promise<Array<string>>} 返回选中的临时图片路径数组
*/
export function chooseImage(options = {}) {
// 默认配置
const defaultOptions = {
count: 1,
sourceType: ['album', 'camera'],
...options
}
return new Promise((resolve, reject) => {
uni.chooseImage({
...defaultOptions,
success(res) {
if (res.tempFilePaths && res.tempFilePaths.length > 0) {
resolve(res.tempFilePaths)
} else {
reject(new Error('未选择任何图片'))
}
},
fail(err) {
// 统一错误处理(如权限被拒、用户取消等)
let msg = '选择图片失败'
if (err.errMsg.includes('cancel')) {
msg = '用户取消选择'
} else if (
err.errMsg.includes('auth deny') ||
err.errMsg.includes('permission')
) {
msg = '请在设置中开启相册或相机权限'
}
// 可选:自动弹出 toast 提示
uni.showToast({
title: msg,
icon: 'none',
duration: 2000
})
reject(new Error(msg))
}
})
})
}