hookehuyr

fix 处理退款中状态显示问题

/*
* @Date: 2022-05-18 22:56:08
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-01-04 16:06:04
* @LastEditTime: 2024-05-25 22:35:00
* @FilePath: /meihuaApp/src/api/fn.js
* @Description: 文件描述
*/
......@@ -17,7 +17,7 @@ import Taro from '@tarojs/taro'
export const fn = (api) => {
return api
.then(res => {
if (res.data.code === 1) {
if (res.data.code) {
return res.data || true;
} else {
// tslint:disable-next-line: no-console
......
......@@ -381,21 +381,26 @@ const cancelOrder = (id) => {
if (res.confirm) {
if (id) {
// 取消订单
const { code, data, msg } = await orderCancelAPI({ id });
if (code) {
const { code } = await orderCancelAPI({ id });
// code=1退款成功/code=2退款中,都算取消成功
if (code === 1) {
Taro.showToast({
title: "取消成功",
icon: "success",
duration: 2000,
});
props.data.status = 2; // 取消订单状态置为已取消
} else {
// 通过状态文本查找状态code值
const key = Object.keys(STATUS_TEXT).find(key => STATUS_TEXT[key] === msg);
props.data.status = key; // 退款失败时,订单状态置为接口返回的状态
} else if (code === 2) {
Taro.showToast({
title: "请刷新后再试",
icon: "error",
title: "退款中,请稍后",
icon: "none",
duration: 2000,
});
props.data.status = 2; // 取消订单状态置为已取消
} else { // 退款失败
Taro.showToast({
title: `退款失败,请刷新后再试`,
icon: "none",
duration: 2000,
});
}
......