import BlackSpot from "@/assets/icons/GuideCheck/BlackSpot.png"; import Taro from "@tarojs/taro"; import { Button, Icon, Text, Textarea } from "@tarojs/components"; import formatPrice from "@/utils/formatPrice"; import { useState, useEffect } from "react"; import withLayout from "@/layouts"; import { getOrderSub, refund } from "@/services/payOrder"; import image from "@/assets/icons/ProCard/8kb.jpg"; import food from "@/assets/icons/ProCard/food.png"; import ProCard_hot from "@/assets/icons/ProCard/ProCard_hot.png"; import CustomNav from "@/components/CustomNav"; import "./style.less"; import formatTime from "@/utils/formatTime"; const options = [ { title: "计划有变,没时间消费", key: 1, }, { title: "误认为是外卖", key: 2, }, { title: "没看清楚使用规则,要用时才发现限制很多", key: 3, }, { title: "预约不上", key: 4, }, { title: "店里更优惠", key: 5, }, { title: "网友/朋友评价不好", key: 6, }, ]; export default withLayout((props) => { const { router, person } = props; const { id } = props.router.params; const [view, setView] = useState(true); const [view2, setView2] = useState(false); const [view3, setView3] = useState(false); const [view4, setView4] = useState(false); const [view5, setView5] = useState(false); const [view6, setView6] = useState(false); // 说明 const [explain, setExplain] = useState(); const [list, setList] = useState([]); // 总价 totalPrice const [totalPrice, setTotalPrice] = useState({}); const [checkeds, setCheckeds] = useState([1]); const getData = (orderId) => { Taro.showLoading(); getOrderSub({ pageNum: 1, pageSize: 50, orderId: orderId, }).then((res) => { setList(res.records); Taro.hideLoading(); }); }; useEffect(() => { getData(id); }, []); const viewOK = (e) => { if (checkeds.indexOf(e.key) > -1) { setCheckeds(checkeds.filter((x) => x != e.key)); } else { let arr = checkeds; arr.push(e.key); setCheckeds([...arr]); } }; const onRefund = () => { // console.log(explain, checkeds, "----onRefund----"); refund(id, { refundDecription: checkeds?.map(x => options.filter(y => y.key == x)[0]?.title).join(';'), refundReason: explain, }).then((res) => { Taro.showToast({ title: "退款成功", icon: "none", duration: 2000, }); Taro.navigateBack({ delta: 1 }) }); }; useEffect(() => { let total = { cashback: 0, //已获返现 charges: 0, //实付金额 refundPrice: 0, //退款金额 }; list.map((x) => { total.cashback += x.cashback; total.charges += x.charges; total.refundPrice += x.charges - x.cashback; }); setTotalPrice(total); }, [list]); return ( 商品信息 {/* 商品信息结束 */} {(list || []).map((item) => { return ( 返现¥{formatPrice(item.cashback)} {item.packageDescription} 数量:{item.amount}张 ¥{formatPrice(item.unitPrice)}元 门市价{formatPrice(item.standardPrice)}元 有效期:{formatTime(item?.startTime, "yyyy/MM/dd")}- {formatTime(item.endTime, "yyyy/MM/dd")} ); })} {/* 卡片结束 */} 退款原因 {/* 退款结束 */} {options.map((x) => { return ( -1 ? "bg2" : `Refund-star-view${x.key}` }`} key={x.key} onClick={() => viewOK(x)} > {x.title} ); })} 退款说明