food/src/utils/api/table.js

73 lines
2.2 KiB
JavaScript
Raw Normal View History

2023-09-20 21:33:11 +08:00
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)
}
}
/**
* @description: 向改变订单承接任务api 提交数据 () 并更新订单列表
2023-09-20 21:33:11 +08:00
* @param {*} id 订单id
* @param {*} state 主状态"main_status" 货物状态"shipment_status" 退款状态"refund_status"
* @param {*} val 修改字段的值
2023-09-20 21:33:11 +08:00
*/
export function questAss (id, state, val) {
const data = new URLSearchParams()// post对象参数 转成 字符串连接
data.append('id', id)
data.append('state', state)
data.append('val', val)
api.post('questAss', data).then(res => {
if (res.data.status === 1) {
Message.success(res.data.msg)
store.dispatch('fetchPaidOrderList')// 更新订单列表
2023-09-20 21:33:11 +08:00
} else {
Message.error(res.data.msg)
store.dispatch('fetchPaidOrderList')// 更新订单列表
2023-09-20 21:33:11 +08:00
}
})
}
/**
* @description: 退款函数
* @param {*} orderSn 订单号
* @param {*} shopId 商铺id
* @param {*} refundPrice 退款金额 单位元
* @param {*} refundType 退款类型
*/
export 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)
// 发送退款请求
api.post('refund', params, 'Pay')
.then(res => {
if (res.data.status === 1) {
Message.success('退款申请成功')
console.log('退款成功', res.data.msg)
} else {
Message.error('退款申请失败')
console.error('退款失败:', res.data.msg)
}
})
.catch(error => {
console.error('退款请求错误:', error)
})
}