feat(credit): 新增信用订单功能模块
- 添加信用订单创建页面,支持填写拖欠方、金额、年数等信息 - 实现附件上传功能,支持图片和文档文件上传预览 - 集成城市选择组件,方便用户选择所在地区 - 添加服务协议勾选确认机制 - 在app配置中注册信用订单相关路由 - 重构文件上传API,新增uploadFileByPath方法支持路径上传 - 更新发现页面,集成店铺网点查询和定位功能 - 实现下拉刷新和无限滚动加载更多网点数据 - 添加地图导航和电话拨打功能 - 优化网点列表显示,按距离排序并显示距离信息
This commit is contained in:
@@ -56,6 +56,42 @@ const computeSignature = (accessKeySecret: string, canonicalString: string): str
|
||||
/**
|
||||
* 上传阿里云OSS
|
||||
*/
|
||||
export async function uploadFileByPath(filePath: string) {
|
||||
return new Promise((resolve: (result: FileRecord) => void, reject) => {
|
||||
if (!filePath) {
|
||||
reject(new Error('缺少 filePath'))
|
||||
return
|
||||
}
|
||||
|
||||
// 统一走同一个上传接口:既支持图片,也支持文档等文件(由后端决定白名单/大小限制)
|
||||
Taro.uploadFile({
|
||||
url: 'https://server.websoft.top/api/oss/upload',
|
||||
filePath,
|
||||
name: 'file',
|
||||
header: {
|
||||
'content-type': 'application/json',
|
||||
TenantId
|
||||
},
|
||||
success: (res) => {
|
||||
try {
|
||||
const data = JSON.parse(res.data);
|
||||
if (data.code === 0) {
|
||||
resolve(data.data)
|
||||
} else {
|
||||
reject(new Error(data.message || '上传失败'))
|
||||
}
|
||||
} catch (_error) {
|
||||
reject(new Error('解析响应数据失败'))
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log('上传请求失败', err);
|
||||
reject(new Error('上传请求失败'))
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export async function uploadFile() {
|
||||
return new Promise(async (resolve: (result: FileRecord) => void, reject) => {
|
||||
Taro.chooseImage({
|
||||
@@ -64,32 +100,12 @@ export async function uploadFile() {
|
||||
sourceType: ['album', 'camera'],
|
||||
success: async (res) => {
|
||||
const tempFilePath = res.tempFilePaths[0];
|
||||
// 上传图片到OSS
|
||||
Taro.uploadFile({
|
||||
url: 'https://server.websoft.top/api/oss/upload',
|
||||
filePath: tempFilePath,
|
||||
name: 'file',
|
||||
header: {
|
||||
'content-type': 'application/json',
|
||||
TenantId
|
||||
},
|
||||
success: (res) => {
|
||||
try {
|
||||
const data = JSON.parse(res.data);
|
||||
if (data.code === 0) {
|
||||
resolve(data.data)
|
||||
} else {
|
||||
reject(new Error(data.message || '上传失败'))
|
||||
}
|
||||
} catch (error) {
|
||||
reject(new Error('解析响应数据失败'))
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log('上传请求失败', err);
|
||||
reject(new Error('上传请求失败'))
|
||||
}
|
||||
})
|
||||
try {
|
||||
const record = await uploadFileByPath(tempFilePath)
|
||||
resolve(record)
|
||||
} catch (e) {
|
||||
reject(e)
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log('选择图片失败', err);
|
||||
|
||||
Reference in New Issue
Block a user