main.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <template>
  2. <div id="main">
  3. <header-view v-if="!isInFrame"></header-view>
  4. <main-header></main-header>
  5. <christmas v-if="isOpen" @listenopen="listenOpen"></christmas>
  6. <main-nav></main-nav>
  7. <nuxt/>
  8. <footer-view></footer-view>
  9. <right-bar></right-bar>
  10. </div>
  11. </template>
  12. <script>
  13. import { Header, Footer, RightBar, Christmas } from '~components/default'
  14. import { MainHeader, MainNav } from '~components/main'
  15. export default {
  16. name: 'main',
  17. components: {
  18. HeaderView: Header,
  19. FooterView: Footer,
  20. Christmas,
  21. RightBar,
  22. MainHeader,
  23. MainNav
  24. },
  25. data () {
  26. return {
  27. isOpen: false
  28. }
  29. },
  30. head () {
  31. return {
  32. title: this.title,
  33. meta: [
  34. {hid: 'description', name: 'description', content: this.description},
  35. {hid: 'keywords', name: 'keywords', content: this.keywords}
  36. ]
  37. }
  38. },
  39. mounted () {
  40. let user = this.user.logged
  41. let count = 1
  42. let self = this
  43. const nowDate = new Date()
  44. const activeStartDate = new Date('2017/12/20 00:00:00')
  45. const activeEndDate = new Date('2017/12/25 00:00:00')
  46. if (nowDate > activeStartDate && nowDate < activeEndDate) {
  47. const endTime = window.localStorage.getItem('endTime')
  48. if (endTime) {
  49. if (!user) {
  50. setInterval(function () {
  51. count++
  52. if (count >= 30) {
  53. count = 1
  54. self.isOpen = true
  55. }
  56. }, 1000)
  57. } else if (nowDate.getTime() - endTime >= 1000 * 60 * 2) {
  58. this.isOpen = true
  59. window.localStorage.setItem('endTime', nowDate.getTime())
  60. } else {
  61. this.isOpen = false
  62. }
  63. } else {
  64. this.isOpen = true
  65. window.localStorage.setItem('endTime', nowDate.getTime())
  66. }
  67. } else {
  68. this.isOpen = false
  69. }
  70. },
  71. methods: {
  72. listenOpen () {
  73. this.isOpen = false
  74. }
  75. },
  76. computed: {
  77. user () {
  78. return this.$store.state.option.user
  79. },
  80. isInFrame () {
  81. let cookies = this.$store.state.option.cookies
  82. let cookieArr = cookies.split(';')
  83. let cookieObj = {}
  84. for (let i = 0; i < cookieArr.length; i++) {
  85. let tmpArr = cookieArr[i].split('=') || []
  86. if (tmpArr.length === 2) {
  87. cookieObj[tmpArr[0].trim()] = tmpArr[1].trim()
  88. }
  89. }
  90. return cookieObj.type === 'erp' || this.$route.query.type === 'erp'
  91. },
  92. title () {
  93. let path = this.$route.path
  94. if (path === '/product/kind/home') {
  95. return '电子元器件器件选型参数型号查询器件类别分类大全-优软商城'
  96. } else if (path.startsWith('/product/kind/')) {
  97. return this.kinds[this.kinds.length - 1].nameCn + '产品品牌型号大全-优软商城'
  98. } else if (path.startsWith('/product/component/')) {
  99. return this.componentDetail.brand.nameCn + this.componentDetail.code + '参数|供应商|数据手册中文资料|规格书-优软商城'
  100. } else if (path.startsWith('/product/brand/brandList/')) {
  101. return 'IC电子元器件品牌中心品牌大全-优软商城'
  102. } else if (path.startsWith('/product/brand/')) {
  103. return this.brandDetail.nameEn + '(' + this.brandDetail.nameCn + ')产品分类及产品型号大全-优软商城'
  104. } else if (path === '/provider/factories') {
  105. return 'IC电子元器件厂家原厂直销原厂专卖店大全-优软商城'
  106. } else if (path === '/provider/home') {
  107. return 'IC电子元器件代理商经销商专营店大全-优软商城'
  108. } else if (path === '/news') {
  109. return 'IC电子元器件行业市场资讯新闻-优软商城'
  110. } else if (path.startsWith('/news/')) {
  111. return this.newsDetail.title + '-电子元器件行业资讯-优软商城' || 'IC电子元器件行业市场资讯新闻-优软商城'
  112. } else if (path === '/search') {
  113. return this.$route.query.w + '-产品搜索-优软商城'
  114. } else if (path === '/searchStore') {
  115. return this.$route.query.w + '-店铺搜索-优软商城'
  116. } else {
  117. return '【优软商城】IC电子元器件现货采购交易平台商城'
  118. }
  119. },
  120. description () {
  121. let path = this.$route.path
  122. if (path === '/product/kind/home') {
  123. return '优软商城电子元器件器件型号查询器件类别分类大全,优软商城提供元器件智能选型服务,能让您完美的找到热门型号的替代型号产品,一键搜索功能让您快速找到您想要的型号。'
  124. } else if (path.startsWith('/product/kind/')) {
  125. return '优软商城' + this.kinds[this.kinds.length - 1].nameCn + '产品品牌型号大全,能让您快速的找到' + this.kinds[this.kinds.length - 1].nameCn + '产品品牌型号。'
  126. } else if (path.startsWith('/product/component/')) {
  127. return '优软商城提供' + this.componentDetail.brand.nameCn + this.componentDetail.code + '数据手册中文资料规格书下载,' + this.componentDetail.code + '供应商及参数报价。'
  128. } else if (path.startsWith('/product/brand/brandList/')) {
  129. return 'IC电子元器件品牌中心品牌大全,优软商城品牌中心汇聚国内国际电子元器件品牌,全力打造国家级元器件电商品台。'
  130. } else if (path.startsWith('/product/brand/')) {
  131. return this.brandDetail.brief
  132. } else if (path === '/provider/factories') {
  133. return 'IC电子元器件厂家原厂直销原厂专卖店大全,优软商城原厂专区提供IC电子元器件厂家原厂直销原厂专卖店大全。'
  134. } else if (path === '/provider/home') {
  135. return 'IC电子元器件代理商经销商专营店大全,优软商城代理经销专区提供IC电子元器件代理商经销商专卖店大全。'
  136. } else if (path === '/news') {
  137. return '优软商城电子元器件采购网提供精准的电子快讯,电子资讯,电子元器件资讯。'
  138. } else if (path.startsWith('/news/')) {
  139. return this.newsDetail.summary
  140. } else {
  141. return '优软商城(usoftmall.com)是中国领先的IC电子元器件现货采购交易网上商城,提供上千万种电子元器件现货采购交易,采购电子元器件就上优软商城!'
  142. }
  143. },
  144. keywords () {
  145. let path = this.$route.path
  146. if (path === '/product/kind/home') {
  147. return '电子元器件分类,电子元器件参数,电子元器件型号,电子元器件类别'
  148. } else if (path.startsWith('/product/kind/')) {
  149. return this.kinds[this.kinds.length - 1].nameCn
  150. } else if (path.startsWith('/product/component/')) {
  151. return this.componentDetail.code + '供应商,' + this.componentDetail.code + '数据手册,' + this.componentDetail.code + '规格书'
  152. } else if (path.startsWith('/product/brand/brandList/')) {
  153. return 'ic,元器件,品牌'
  154. } else if (path.startsWith('/product/brand/')) {
  155. return this.brandDetail.nameEn + '(' + this.brandDetail.nameCn
  156. } else if (path === '/provider/factories') {
  157. return '电子元器件原厂,电子元器件厂家'
  158. } else if (path === '/provider/home') {
  159. return 'ic代理商,ic经销商,电子元器件代理商 , 电子元器件经销商'
  160. } else if (path === '/news') {
  161. return '元器件新闻,电子资讯,电子元器件资讯'
  162. } else if (path.startsWith('/news/')) {
  163. return ''
  164. } else {
  165. return '优软商城'
  166. }
  167. },
  168. kinds () {
  169. return this.$store.state.product.kind.kindsParentWithBother.data
  170. },
  171. componentDetail () {
  172. return this.$store.state.componentDetail.detail.data
  173. },
  174. brandDetail () {
  175. return this.$store.state.brandDetail.detail.data
  176. },
  177. newsDetail () {
  178. return this.$store.state.newsData.detailNews.detailNews.data
  179. }
  180. }
  181. }
  182. </script>