index.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <div>
  3. {{JSON.stringify(detail)}}
  4. </div>
  5. </template>
  6. <script>
  7. import axios from 'axios';
  8. export default {
  9. name: "index",
  10. data () {
  11. return {
  12. detail: {},
  13. title: '',
  14. twitterTitle: '',
  15. jumpUrl: ''
  16. }
  17. },
  18. head() {
  19. return {
  20. type: '',
  21. title: this.title,
  22. meta: [
  23. {
  24. name: 'twitter:card',
  25. content: 'summary_large_image'
  26. },
  27. {
  28. name: 'twitter:url',
  29. content: this.jumpUrl
  30. },
  31. {
  32. name: 'twitter:title',
  33. content: this.twitterTitle
  34. },
  35. {
  36. name: 'twitter:image',
  37. content: this.detail.postBizData.imagePath || ''
  38. },
  39. {
  40. name: 'twitter:image:width',
  41. content: '1280'
  42. },
  43. {
  44. name: 'twitter:image:height',
  45. content: '720'
  46. },
  47. ]
  48. }
  49. },
  50. async asyncData (params) {
  51. let {route} = params;
  52. let {data} = await axios.post('https://denettestapi.piaoquantv.com/denet/post/getDetail', {
  53. baseInfo: {
  54. token: ''
  55. },
  56. params: {
  57. postId: route.params.id || ''
  58. }
  59. })
  60. if (data.data && data.data.postBizData && typeof data.data.postBizData == 'string') {
  61. data.data.postBizData = JSON.parse(data.data.postBizData)
  62. }
  63. return {
  64. detail: data.data,
  65. }
  66. }
  67. }
  68. </script>
  69. <style scoped>
  70. </style>