import request from '@/utils/request/index.js'
import config from '@/config/config.js'
/**
 * 预警上报模块
 */




// 上传图片、视频接口
export const uploadFile = (file) => {
	return new Promise((resolve, reject) => {
		uni.uploadFile({
			url: config.baseUrl + 'api/util/upload/img/', //仅为示例，非真实的接口地
			name: 'file',
			filePath: file,
			success: (res) => {
				let result = JSON.parse(res.data ?? '{}')
				if (result.message) {
					uni.showToast({
						title: result.message,
						duration: 1500,
						mask: true,
						icon: 'none'
					});
					return resolve(null);
				}
				resolve(config.fileUrl + result.img_url);
			},
			fail: (e) => {
				resolve(null);
			}
		});
	})
}

// 预警保存
export const saveAftersaleInfo = async (data) => {
	const res = await request.post(`api/api_gateway?method=after_sale.after_sale_manage.aftersale_info_save`,
		data);
	return res?.data;
}
