CollectionBox.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <div class="col-box">
  3. <div class="col" :class="showT ? 'tuck' : 'cancel'" @click="collect">
  4. <div v-if="showT"><img src="@/assets/col.png" alt="" />收藏</div>
  5. <div v-else><img src="@/assets/cancelcol.png" alt="" />取消收藏</div>
  6. </div>
  7. </div>
  8. </template>
  9. <script>
  10. export default {
  11. props: {
  12. showT: {
  13. type: Boolean,
  14. default: true,
  15. },
  16. param: {
  17. type: Object,
  18. default: () => {
  19. return {};
  20. },
  21. },
  22. },
  23. data() {
  24. return {};
  25. },
  26. methods: {
  27. collect() {
  28. if (this.showT) {
  29. let { questionId, goodsId, orderGoodsId, examId, doMode } = this.param;
  30. this.$request
  31. .collectQuestion({
  32. examId,
  33. questionId,
  34. goodsId,
  35. orderGoodsId,
  36. doMode
  37. })
  38. .then((res) => {
  39. this.$message.success("收藏成功");
  40. this.$emit("sumit");
  41. });
  42. } else {
  43. this.$request
  44. .deleteCollectQuestion(this.param.collectQuestionId)
  45. .then((res) => {
  46. this.$message.success("取消收藏成功");
  47. this.$emit("sumit");
  48. });
  49. }
  50. },
  51. },
  52. };
  53. </script>
  54. <style scoped lang="scss">
  55. .col-box {
  56. width: 970px;
  57. position: absolute;
  58. bottom: 0;
  59. padding: 12px 0;
  60. border-top: 1px solid #eeeeee;
  61. }
  62. .col {
  63. width: 100%;
  64. display: flex;
  65. justify-content: center;
  66. margin-left: 32px;
  67. border-radius: 4px;
  68. cursor: pointer;
  69. div {
  70. height: 30px;
  71. line-height: 30px;
  72. display: flex;
  73. align-items: center;
  74. font-size: 13px;
  75. }
  76. img {
  77. margin-right: 4px;
  78. }
  79. }
  80. .tuck {
  81. width: 68px;
  82. border: 1px solid #3f8dfd;
  83. color: #3f8dfd;
  84. background: #f2f7ff;
  85. }
  86. .cancel {
  87. width: 86px;
  88. color: #ffffff;
  89. background: #f9c03c;
  90. }
  91. </style>