|
@@ -1,6 +1,6 @@
|
|
|
// pages/orders/order-detail.ts
|
|
|
import drawQrcode from "../../utils/weapp.qrcode.esm";
|
|
|
-import { api_userPaymentOrderDetail } from "../../api/login";
|
|
|
+import { api_userPaymentCancelRefund, api_userPaymentOrderDetail, api_userPaymentOrderRefundPayment } from "../../api/login";
|
|
|
|
|
|
// 获取应用实例
|
|
|
Page({
|
|
@@ -48,6 +48,8 @@ Page({
|
|
|
showCanvas: false, // 是否显示二维码
|
|
|
canvasImg: "" as string,
|
|
|
showService: false,
|
|
|
+ refoundStatus: false,
|
|
|
+ refoundValue: "" // 退款内容
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -88,6 +90,7 @@ Page({
|
|
|
createTime: result.createTime,
|
|
|
wechatStatus: result.wechatStatus,
|
|
|
goods: tempGoods,
|
|
|
+ refundOrderId: result.refundOrderId,
|
|
|
refundTime: result.refundTime,
|
|
|
refundAmount: this.formatPrice(result.refundAmount || 0, 'ALL'),
|
|
|
refundStyleStr
|
|
@@ -108,7 +111,6 @@ Page({
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
} catch (error) {
|
|
|
console.log(error, "error");
|
|
@@ -185,7 +187,9 @@ Page({
|
|
|
},
|
|
|
onTimeout() {
|
|
|
// 轮询10次查询订单状态
|
|
|
- const { goodsInfo, timerCount, timer } = this.data
|
|
|
+ const goodsInfo = this.data.goodsInfo
|
|
|
+ const timerCount = this.data.timerCount
|
|
|
+ const timer = this.data.timer
|
|
|
if(goodsInfo.wechatStatus === 'WAIT_PAY' && timerCount <= 10) {
|
|
|
let count = timerCount
|
|
|
const tempT = setTimeout(async () => {
|
|
@@ -213,4 +217,76 @@ Page({
|
|
|
showService: event.detail
|
|
|
})
|
|
|
},
|
|
|
+ /** 申请退款 */
|
|
|
+ async cancelRefound() {
|
|
|
+ try {
|
|
|
+ const {data} = await api_userPaymentCancelRefund(this.data.goodsInfo.refundOrderId)
|
|
|
+ console.log(data, 'data')
|
|
|
+ if(data.code == 200) {
|
|
|
+ wx.showToast({ title: '取消退款成功', icon: 'none' })
|
|
|
+ wx.navigateBack({
|
|
|
+ delta: 1
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ wx.showToast({ title: data.message, icon: 'none' })
|
|
|
+ }
|
|
|
+ } catch {}
|
|
|
+ },
|
|
|
+ /** 申请退款 */
|
|
|
+ useRefound() {
|
|
|
+ this.setData({
|
|
|
+ refoundStatus: true,
|
|
|
+ refoundValue: ""
|
|
|
+ })
|
|
|
+ },
|
|
|
+ textareaInput(e: { detail: any }) {
|
|
|
+ this.setData({
|
|
|
+ refoundValue: e.detail.value
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onRefoundClose() {
|
|
|
+ this.setData({
|
|
|
+ refoundStatus: false,
|
|
|
+ refoundValue: ''
|
|
|
+ })
|
|
|
+ },
|
|
|
+ async onRefound() {
|
|
|
+ console.log(this.data.refoundValue, 'value')
|
|
|
+ const refoundValue = this.data.refoundValue
|
|
|
+ if(!refoundValue) {
|
|
|
+ wx.showToast({ title: '请输入退款原因', icon: 'none' })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ const { goods, orderNo } = this.data.goodsInfo
|
|
|
+ console.log(this.data.goodsInfo, 'goodsInfo')
|
|
|
+ const details: any = []
|
|
|
+ goods.forEach((item: any) => {
|
|
|
+ details.push({
|
|
|
+ num: item.goodsNum,
|
|
|
+ onlyRefund: false,
|
|
|
+ userPaymentOrderDetailId: item.id,
|
|
|
+ refundAmount: item.currentPrice
|
|
|
+ })
|
|
|
+ })
|
|
|
+ const params = {
|
|
|
+ merOrderNo: orderNo,
|
|
|
+ serviceCharge: false,
|
|
|
+ refundReason: refoundValue,
|
|
|
+ serviceChargeFee: 0,
|
|
|
+ userRefundOrderDetails: details
|
|
|
+ }
|
|
|
+ const {data} = await api_userPaymentOrderRefundPayment(params)
|
|
|
+ if(data.code == 200) {
|
|
|
+ wx.showToast({ title: '申请成功', icon: 'none' })
|
|
|
+ setTimeout(() => {
|
|
|
+ wx.navigateBack({
|
|
|
+ delta: 1
|
|
|
+ })
|
|
|
+ }, 2000);
|
|
|
+ } else {
|
|
|
+ wx.showToast({ title: data.message, icon: 'none' })
|
|
|
+ }
|
|
|
+ } catch {}
|
|
|
+ }
|
|
|
})
|