index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <view class="preview-resume">
  3. <nav-bar title="简历预览" color="#000" class="nav-bar">
  4. <view class="import-btn" slot="right" v-if="resumeId" @click="getResumePDF">导出</view>
  5. </nav-bar>
  6. <view class="tabs">
  7. <view class="tab" :class="{ active: index === activeIndex }" v-for="(tab, index) in tabs" :key="index" @click="handleChangeTab(index)">
  8. <view class="tab-name">{{ tab.name }}</view>
  9. <view class="tab-active"></view>
  10. </view>
  11. </view>
  12. <scroll-view class="content" :scroll-y="true">
  13. <previewResume v-if="activeIndex == 0"></previewResume>
  14. <indexCard v-else-if="activeIndex == 1"></indexCard>
  15. <chatCard v-else-if="activeIndex == 2"></chatCard>
  16. </scroll-view>
  17. </view>
  18. </template>
  19. <script>
  20. import navBar from "@/components/nav-bar/index.vue";
  21. import previewResume from '@/components/resume/preview-resume.vue';
  22. import indexCard from '@/components/resume/index-card.vue';
  23. import chatCard from '@/components/resume/chat-card.vue';
  24. import { exportResumePdf } from '@/utils/util'
  25. export default {
  26. components: {
  27. navBar,
  28. previewResume,
  29. indexCard,
  30. chatCard
  31. },
  32. data() {
  33. return {
  34. tabs: [
  35. {
  36. name: '在线简历'
  37. },
  38. {
  39. name: '首页卡片'
  40. },
  41. {
  42. name: '沟通卡片'
  43. }
  44. ],
  45. activeIndex: 0,
  46. resumeId: null,
  47. loading: false,
  48. }
  49. },
  50. onLoad(options) {
  51. if (options.type) {
  52. // type: index首页卡片、chat沟通卡片
  53. if (options.type === 'index') {
  54. this.activeIndex = 1
  55. } else if (options.type === 'chat') {
  56. this.activeIndex = 2
  57. }
  58. }
  59. uni.$on('getResumeIdByComponent', (id) => {
  60. this.resumeId = id
  61. })
  62. },
  63. onUnload() {
  64. uni.$off('getResumeIdByComponent')
  65. },
  66. methods: {
  67. handleChangeTab(index) {
  68. this.activeIndex = index
  69. },
  70. // 获取简历并导出
  71. getResumePDF() {
  72. exportResumePdf(this.resumeId)
  73. }
  74. }
  75. }
  76. </script>
  77. <style lang="scss" scoped>
  78. .nav-bar {
  79. height: 96rpx;
  80. background: #fff;
  81. }
  82. .import-btn {
  83. font-size: 24rpx;
  84. font-weight: 400;
  85. color: rgba(153, 153, 153, 1);
  86. }
  87. .preview-resume {
  88. display: flex;
  89. flex-direction: column;
  90. height: 100vh;
  91. background: rgba(241, 245, 248, 1);
  92. }
  93. // tabs栏
  94. .tabs {
  95. display: flex;
  96. justify-content: center;
  97. background-color: #fff;
  98. height: 90rpx;
  99. padding-top: 10rpx;
  100. .tab {
  101. padding: 24rpx 32rpx 12rpx;
  102. .tab-name {
  103. color: rgba(51, 51, 51, 1);
  104. line-height: 32rpx;
  105. }
  106. .tab-active {
  107. width: 50rpx;
  108. height: 6rpx;
  109. border-radius: 6rpx;
  110. margin: 6rpx auto 0;
  111. }
  112. }
  113. .active {
  114. .tab-name {
  115. color: rgba(1, 107, 246, 1);
  116. font-weight: bold;
  117. }
  118. .tab-active {
  119. background: rgba(1, 107, 246, 1);
  120. }
  121. }
  122. }
  123. .content {
  124. height: 100px;
  125. flex: 1;
  126. margin-top: 32rpx;
  127. }
  128. </style>