hookehuyr

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

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