import store from '@/store' import api from '@/utils/api' // import { Message, MessageBox } from 'element-ui' import { Message } from 'element-ui' /** * @description: 向对频api 提交数据 */ export async function apiCrosFrequency (params) { const data = new URLSearchParams()// post对象参数 转成 字符串连接 data.append('macAdd', params.macAdd) data.append('id', params.id) const res = await api.post('crosFrequency', data) if (res.data.status === 1) { Message.success(res.data.msg) store.dispatch('fetchAirList')// 更新飞机列表 } else { Message.error(res.data.msg) } return res } /** * @description: 向改变订单承接任务api 提交数据,参数可以是数组 提交多个字段和字段内容 () ,并更新订单列表 * @param {*} id 订单id * @param {array string} type 主状态"main_status" 货物状态"shipment_status" 退款状态"refund_status" 执行飞机"by_plane_id" * @param {array string} val 修改字段的值 ps:by_plane_id值给'null' 字符串或者留空 数据库改为null */ export async function questAss (id, type, val) { const params = new URLSearchParams()// post对象参数 转成 字符串连接 params.append('id', id) // 判断 type 和 val 是否为数组 if (Array.isArray(type) && Array.isArray(val)) { if (type.length !== val.length) { return } for (let i = 0; i < type.length; i++) { params.append(type[i], val[i] === '' ? 'null' : val[i]) } } else if (typeof type === 'string' && typeof val === 'string') { params.append(type, val === '' ? 'null' : val) } else { return } const res = await api.post('questAss', params) if (res.data.status === 1) { Message.success(res.data.msg) store.dispatch('fetchPaidOrderList')// 更新订单列表 } else { Message.error(res.data.msg) store.dispatch('fetchPaidOrderList')// 更新订单列表 } return res } /** * @description: 获取订单列表 * @param {*} orderSerch 搜索条件 */ export async function getOrderList (orderSerch) { const params = new URLSearchParams()// post对象参数 转成 字符串连接 params.append('shop_id', orderSerch.shop_id) params.append('start_time', orderSerch.start_time) params.append('end_time', orderSerch.end_time) params.append('main_status', orderSerch.main_status) params.append('shipment_status', orderSerch.shipment_status) params.append('refund_status', orderSerch.refund_status) params.append('search', orderSerch.search) // 发送退款请求 const res = await api.post('getOrderList', params, 'Admin') if (res.data.status === 1) { Message.success('成功获取订单列表') } else { Message.error('获取订单列表失败') } return res } /** * @description: 退款函数 * @param {*} orderSn 订单号 * @param {*} shopId 商铺id * @param {*} refundPrice 退款金额 单位元 * @param {*} refundType 退款类型 'buyer'买家申请 'seller'卖家主动 */ export async function refund (orderSn, shopId, refundPrice, refundType) { // 构建请求参数 const params = new URLSearchParams() params.append('order_sn', orderSn) params.append('shop_id', shopId) params.append('refund_price', refundPrice) params.append('refund_type', refundType) // 发送退款请求 const res = await api.post('refund', params, 'Pay') if (res.data.status === 1) { Message.success('退款申请中...') console.log('退款成功', res.data.msg) } else { Message.error(res.data.msg) console.error('退款失败:', res.data.msg) } return res }