ReceiveCoupon.vue 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <window-size :show-back-nav="false">
  3. <div class="icon-wrapper">
  4. <svg v-if="state==='SUCCESS'" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" class="icon-success">
  5. <path fill="currentColor" d="M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896zm-55.808 536.384-99.52-99.584a38.4 38.4 0 1 0-54.336 54.336l126.72 126.72a38.272 38.272 0 0 0 54.336 0l262.4-262.464a38.4 38.4 0 1 0-54.272-54.336L456.192 600.384z"></path>
  6. </svg>
  7. <svg v-if="state==='FAILURE'" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" class="icon-failure">
  8. <path d="M511.999488 65.290005C265.29162 65.290005 65.290517 265.291109 65.290517 511.998977c0 246.708891 200.001103 446.709995 446.708971 446.709995S958.70846 758.707868 958.70846 511.998977C958.70846 265.291109 758.707356 65.290005 511.999488 65.290005L511.999488 65.290005zM716.82855 637.854383c6.803963 6.819313 6.803963 17.856693 0 24.676006l-54.298673 54.29765c-6.819313 6.804986-17.85567 6.820336-24.676006 0L511.999488 590.973656 386.144082 716.828039c-6.819313 6.804986-17.871019 6.804986-24.676006 0l-54.29765-54.29765c-6.804986-6.804986-6.804986-17.856693 0-24.676006l125.869732-125.855406L307.170426 386.144594c-6.804986-6.819313-6.804986-17.871019 0-24.676006l54.29765-54.298673c6.820336-6.803963 17.856693-6.803963 24.676006 0l125.855406 125.870756 125.854383-125.870756c6.820336-6.803963 17.856693-6.803963 24.676006 0l54.298673 54.298673c6.803963 6.804986 6.803963 17.856693 0 24.676006L590.973144 511.998977 716.82855 637.854383 716.82855 637.854383zM716.82855 637.854383" fill="#FF696A"></path>
  9. </svg>
  10. <div class="result_title">
  11. <p>{{title}}</p>
  12. </div>
  13. <div class="result_subtitle">
  14. <p>{{response}}</p>
  15. </div>
  16. </div>
  17. </window-size>
  18. </template>
  19. <script setup>
  20. import router from "../../router";
  21. import {receiveSalesmanCoupon} from "../../api/coupon";
  22. import {computed, ref} from "vue";
  23. const key = router.currentRoute.value.params.key
  24. const response = ref('')
  25. const state = ref('WAITING')
  26. const title = computed(() => {
  27. switch (state.value) {
  28. case 'SUCCESS':
  29. return '领取成功'
  30. case 'FAILURE':
  31. return '领取失败'
  32. default:
  33. return ''
  34. }
  35. })
  36. receiveSalesmanCoupon(key).then(res => {
  37. response.value = res
  38. state.value = 'SUCCESS'
  39. }).catch((err) => {
  40. response.value = err
  41. state.value = 'FAILURE'
  42. })
  43. </script>
  44. <style scoped>
  45. .icon-wrapper {
  46. width: 100%;
  47. text-align: center;
  48. margin-top: 80px;
  49. }
  50. .icon-success {
  51. color: #67c23a;
  52. width: 128px;
  53. height: 128px;
  54. }
  55. .icon-failure {
  56. width: 128px;
  57. height: 128px;
  58. }
  59. .result_title {
  60. margin-top: 20px;
  61. }
  62. .result_title > p {
  63. margin: 0;
  64. font-size: 20px;
  65. color: #303133;
  66. line-height: 1.3;
  67. }
  68. .result_subtitle {
  69. margin-top: 10px;
  70. }
  71. .result_subtitle > p {
  72. margin: 0;
  73. font-size: 14px;
  74. color: #606266;
  75. line-height: 1.3;
  76. }
  77. </style>