main.vue 8.1 KB

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