template.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <div :class="mobile ? 'mobileMain' : ''" :style="{marginTop: mainMarginTop, marginBottom: mobile ? '0px' : '30px !important'}">
  3. <div v-if="!mobile"></div>
  4. </div>
  5. </template>
  6. <script>
  7. import {
  8. mapState
  9. } from "vuex"
  10. import qs from "qs"
  11. export default {
  12. name: 'SeoLearnList',
  13. data() {
  14. return {
  15. baseUrl: '',
  16. mobile: false,
  17. // firstLoad: true,
  18. isWeixinApp: true,
  19. }
  20. },
  21. head() {
  22. const {
  23. title = "",
  24. keyword = "",
  25. description = "",
  26. h1 = "",
  27. canonical = "",
  28. metaLocation
  29. } = this.head || {}
  30. let obj = {
  31. title: title,
  32. meta: [{
  33. name: "keywords",
  34. content: keyword
  35. }, {
  36. name: "description",
  37. content: description
  38. }, {
  39. name: "h1",
  40. content: h1
  41. }],
  42. link: [{
  43. rel: "canonical",
  44. href: canonical
  45. }]
  46. }
  47. if (metaLocation) {
  48. obj.meta.push({
  49. name: "location",
  50. content: metaLocation
  51. })
  52. }
  53. return obj
  54. },
  55. computed: {
  56. ...mapState(["deviceType"]),
  57. showWxHeader() {
  58. return !this.deviceType.app && !this.isWeixinApp &&
  59. (this.deviceType.android || this.deviceType.ios)
  60. },
  61. mainMarginTop() {
  62. if (this.mobile && this.showWxHeader) {
  63. return '64px !important'
  64. } else if (this.mobile) {
  65. return '0px !important'
  66. } else {
  67. return '20px !important'
  68. }
  69. },
  70. },
  71. mounted() {
  72. this.baseUrl = this.$store.state.domainConfig.siteUrl
  73. this.isWeixinApp = navigator.userAgent.indexOf("miniProgram") > -1
  74. },
  75. methods: {
  76. }
  77. }
  78. </script>
  79. <style lang="scss">
  80. </style>