index.vue 2.92 KB
<template>
  <view class="callback-page">
    <view>
      <view v-if="pay_status === PAY_STATUS.FAIL" class="text-prompts">
        <image
          src="https://cdn.ipadbiz.cn/xys/booking/shibai.png"
          mode="widthFix"
          class="status-icon"
        />
        <view class="text">支付失败</view>
      </view>
      <view v-else class="text-prompts">
        <image
          src="https://cdn.ipadbiz.cn/xys/booking/%E6%88%90%E5%8A%9F@2x.png?imageMogr2/thumbnail/200x/strip/quality/70"
          mode="widthFix"
          class="status-icon"
        />
        <!-- <view class="text">支付完成</view> -->
      </view>
      <view class="appointment-information">
        <view class="info-item"
          >参观人数:<text>{{ billInfo?.total_qty || 0 }} 人</text></view
        >
        <view class="info-item"
          >参访时间:<text>{{ billInfo?.datetime || '--' }}</text></view
        >
        <view class="info-item"
          >支付金额:<text>¥ {{ billInfo?.total_amt || 0 }}</text></view
        >
      </view>
      <view style="padding: 16rpx; display: flex; justify-content: center; margin-top: 32rpx">
        <nut-button color="#A67939" size="small" @click="returnMerchant">返回首页</nut-button>
      </view>
    </view>
  </view>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import Taro, { useRouter } from '@tarojs/taro'
import { onAuthBillInfoAPI } from '@/api/index'
import { useGo } from '@/hooks/useGo'
import { formatDatetime } from '@/utils/tools'

const router = useRouter()
const go = useGo()

const billInfo = ref({})
const PAY_STATUS = {
  SUCCESS: '0',
  FAIL: '1',
  UNKNOWN: '2'
}
const pay_status = ref('0') // Default to success as per logic

const out_trade_no = router.params.out_trade_no

const getBillInfo = async () => {
  if (!out_trade_no) {
    return
  }

  try {
    // Get order details
    const { code, data } = await onAuthBillInfoAPI({ order_id: out_trade_no })
    if (code && data) {
      data.datetime = data && formatDatetime(data)
      billInfo.value = data
    } else {
      // Handle error if needed
    }
  } catch (e) {
    console.error(e)
  }
}

const returnMerchant = () => {
  go('/pages/index/index')
}

onMounted(() => {
  getBillInfo()
})
</script>

<style lang="less">
.callback-page {
  padding: 32rpx;
  background: #fff;
  min-height: 100vh;

  .text-prompts {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 64rpx;
    padding-top: 64rpx;

    .status-icon {
      width: 200rpx;
      height: 200rpx;
    }

    .text {
      margin-top: 32rpx;
      font-size: 38rpx;
      color: #333;
    }
  }

  .appointment-information {
    background: #f8f8f8;
    padding: 32rpx;
    border-radius: 16rpx;

    .info-item {
      margin-bottom: 16rpx;
      font-size: 29rpx;
      color: #666;

      text {
        color: #333;
        font-weight: 500;
        margin-left: 16rpx;
      }
    }
  }
}
</style>