PaymentHistoryDialog.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <van-popup
  3. v-model:show="dialogVisible"
  4. round
  5. position="bottom"
  6. :style="{ height: '80%' }"
  7. >
  8. <div class="p-4 flex flex-col h-full">
  9. <!-- Header -->
  10. <div class="flex justify-between items-center mb-4">
  11. <div class="text-gray-400 cursor-pointer" @click="handleClose">取消</div>
  12. <div class="text-lg font-medium">购买记录</div>
  13. <div class="w-8"></div>
  14. </div>
  15. <!-- Loading State -->
  16. <van-loading v-if="loading" class="self-center my-8" />
  17. <!-- Empty State -->
  18. <van-empty v-else-if="!records.length" description="暂无购买记录" />
  19. <!-- Records List -->
  20. <div v-else class="flex-1 overflow-y-auto">
  21. <div v-for="(record, index) in records" :key="index" class="bg-gray-50 rounded-lg p-4 mb-4">
  22. <div class="flex justify-between items-center mb-2">
  23. <span class="text-gray-600">购买手机号:</span>
  24. <span>{{ record.mobile }}</span>
  25. </div>
  26. <div class="flex justify-between items-center mb-2">
  27. <span class="text-gray-600">支付时间:</span>
  28. <span>{{ record.createdAt }}</span>
  29. </div>
  30. <div class="flex justify-between items-center mb-2">
  31. <span class="text-gray-600">支付金额:</span>
  32. <span class="text-red-500">¥{{ (record.balance / 100 ).toFixed(2) }}</span>
  33. </div>
  34. <div class="flex justify-between items-center">
  35. <span class="text-gray-600">商品名称:</span>
  36. <span>{{ record.promotionGoods?.memberCardName }}</span>
  37. </div>
  38. </div>
  39. <div v-if="goodsDetail && goodsDetail.paidSlogan" v-html="goodsDetail.paidSlogan" class="p-2"></div>
  40. </div>
  41. </div>
  42. </van-popup>
  43. </template>
  44. <script setup>
  45. import { ref, computed, watch, inject } from "vue";
  46. import { showToast } from "vant";
  47. import { useRoute, useRouter } from "vue-router";
  48. import { request } from "@/utils";
  49. const [route, router] = [useRoute(), useRouter()];
  50. const props = defineProps({
  51. show: Boolean,
  52. onClose: Function,
  53. onConfirm: Function,
  54. openId: String
  55. });
  56. const goodsDetail = inject('goodsDetail')
  57. // 使用computed处理show
  58. const dialogVisible = computed({
  59. get: () => props.show,
  60. set: (value) => emit("update:show", value),
  61. });
  62. const emit = defineEmits(["update:show"]);
  63. // 数据相关
  64. const loading = ref(false);
  65. const records = ref([]);
  66. // 处理关闭
  67. const handleClose = () => {
  68. dialogVisible.value = false
  69. props.onClose?.();
  70. };
  71. // 获取购买记录
  72. const fetchRecords = async () => {
  73. try {
  74. loading.value = true;
  75. const { data } = await request.get(`/archivesService/member/promotionGoods/order/paginate`, {
  76. params: {
  77. openId: props.openId,
  78. page: 1,
  79. // size: 1,
  80. }
  81. });
  82. records.value = data.list;
  83. } finally {
  84. loading.value = false;
  85. }
  86. };
  87. watch(() => [dialogVisible.value, props.openId], () => {
  88. if (dialogVisible.value && props.openId) {
  89. fetchRecords()
  90. }
  91. })
  92. </script>
  93. <style scoped>
  94. :deep(.van-field) {
  95. background-color: #f5f5f5 !important;
  96. }
  97. :deep(.van-field__control) {
  98. color: #333;
  99. }
  100. :deep(.van-popup) {
  101. background-color: white;
  102. }
  103. </style>