main.vue 8.0 KB

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