index.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. postId: '',
  14. postBizData: {
  15. imagePath: ''
  16. }
  17. },
  18. title: '',
  19. twitterTitle: 'deNet',
  20. jumpUrl: 'https://de-net-test.piaoquantv.com/'
  21. }
  22. },
  23. head() {
  24. return {
  25. type: '',
  26. title: this.title,
  27. meta: [
  28. {
  29. name: 'twitter:card',
  30. content: 'summary_large_image'
  31. },
  32. {
  33. name: 'twitter:url',
  34. content: this.jumpUrl + this.detail.postId
  35. },
  36. {
  37. name: 'twitter:title',
  38. content: this.twitterTitle
  39. },
  40. {
  41. name: 'twitter:image',
  42. content: this.detail.postBizData.imagePath || ''
  43. },
  44. {
  45. name: 'twitter:image:width',
  46. content: '1280'
  47. },
  48. {
  49. name: 'twitter:image:height',
  50. content: '720'
  51. },
  52. ]
  53. }
  54. },
  55. async asyncData (params) {
  56. let {route} = params;
  57. let {data} = await axios.post('https://denettestapi.piaoquantv.com/denet/post/getDetail', {
  58. baseInfo: {
  59. token: ''
  60. },
  61. params: {
  62. postId: route.params.id || ''
  63. }
  64. })
  65. if (data.code == 0) {
  66. if (data.data && data.data.postBizData && typeof data.data.postBizData == 'string') {
  67. data.data.postBizData = JSON.parse(data.data.postBizData)
  68. }
  69. return {
  70. detail: data.data,
  71. }
  72. }
  73. }
  74. }
  75. </script>
  76. <style scoped>
  77. </style>