MobileHeader.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. <template>
  2. <div class="mobile-nav">
  3. <!-- <div class="mobile-modal" v-if="showStoreInfo || showShare" @click="cancelModal">
  4. <div class="mobile-modal-box" v-if="showStoreInfo" @click="stopPropagation($event)">
  5. <div class="mobile-modal-header">联系方式<i @click="showStoreInfo = false" class="icon-guanbi iconfont"></i></div>
  6. <div class="mobile-modal-content" v-if="showDefaultAddr">
  7. <div>商家地址:深圳市南山区英唐大厦6楼</div>
  8. <div class="content-line link-url">在线咨询</div>
  9. <div>致电:<a href="tel:0755-96586323" class="content-line link-url">0755-96586323</a></div>
  10. <div>邮件:<a href="mailto:yrsc@usoftchina.com" class="content-line link-url">yrsc@usoftchina.com</a></div>
  11. </div>
  12. <div class="mobile-modal-content" v-if="!showDefaultAddr">
  13. <div>商家地址:{{store.enterprise.enAddress || store.enterprise.address}}</div>
  14. <div class="content-line link-url">在线咨询</div>
  15. <div>致电:<a :href="'tel:'+store.enterprise.enTel" class="content-line link-url">{{store.enterprise.enTel}}</a></div>
  16. <div>邮件:<a :href="'mailto:'+store.enterprise.enEmail" class="content-line link-url">{{store.enterprise.enEmail}}</a></div>
  17. </div>
  18. </div>
  19. <div class="mobile-share-box" v-if="showShare" @click="stopPropagation($event)">
  20. <div class="share-area">
  21. <ul>
  22. <li class="share-item" @click="shareWeChat">
  23. <i class="icon-weixin iconfont" style="color: #07af12;"></i>
  24. <span>微信</span>
  25. </li>
  26. <li class="share-item" @click="shareQQ">
  27. <i class="icon-qq1 iconfont" style="color: #5872f4;"></i>
  28. <span>QQ</span>
  29. </li>
  30. <li class="share-item" @click="shareWeibo">
  31. <i class="icon-ff0000 iconfont" style="color: #ff0000;"></i>
  32. <span>微博</span>
  33. </li>
  34. <li class="share-item" @click="shareMessage">
  35. <i class="icon-msnui-msg-invert iconfont" style="color: #25cdb7"></i>
  36. <span>短信</span>
  37. <a href="sms:" class="hide" id="share-sms"></a>
  38. </li>
  39. <li class="share-item" @click="shareEmail">
  40. <i class="icon-youjian iconfont" style="height: .57rem;font-size: .41rem;color:#f18215;"></i>
  41. <span>邮件</span>
  42. <a href="mailto:" class="hide" id="share-mail"></a>
  43. </li>
  44. <li class="share-item" @click="flash">
  45. <i class="icon-shuaxin iconfont" style="color: #2584cd;"></i>
  46. <span>刷新</span>
  47. </li>
  48. <li class="share-item" @click="copyLink" id="copyLink" :data-clipboard-text="url">
  49. <i class="icon-lianjie iconfont" style="color: #73b0df;"></i>
  50. <span>复制链接</span>
  51. </li>
  52. </ul>
  53. </div>
  54. <div class="cancel-share" @click="showShare=false">取消</div>
  55. </div>
  56. </div>-->
  57. <div class="mobile-header" :class="{'mobile-center-header': showEnHeader}" v-if="showHeader && !showMainSearch">
  58. <a @click="goLastPage"><i class="iconfont icon-fanhui"></i></a>
  59. <p>{{title}}
  60. <span @click="goMainSearch" v-if="showSearchIcon"><i class="icon-sousuo iconfont"></i>搜索</span>
  61. </p>
  62. <p v-show="showEnHeader" class="en-name"><img :src="`/images/mobile/center/${user.data.enterprise.uu ? 'en' : 'self'}.png`" alt="">{{currentEnName}}</p>
  63. </div>
  64. <main-search v-if="showMainSearch" @cancelSearchAction="onCancelSearch"></main-search>
  65. <!-- <i v-show="rightIcon=='share'" class="iconfont icon-fenxiang" @click="showShare = true" @touchmove="onTouchMove($event)"></i>
  66. <i v-show="rightIcon=='phone'" class="iconfont icon-dianhua" @click="showLink" @touchmove="onTouchMove($event)"></i>-->
  67. </div>
  68. </template>
  69. <script>
  70. // import Clipboard from 'clipboard'
  71. import MainSearch from '~/components/mobile/search/MainSearch.vue'
  72. export default {
  73. data () {
  74. return {
  75. // showStoreInfo: false,
  76. // showShare: false,
  77. // rightIcon: 'phone',
  78. // showDefaultAddr: true,
  79. // url: '',
  80. // clipboard: {},
  81. showMainSearch: false,
  82. title: '优软商城',
  83. showHeader: false,
  84. showSearchIcon: true
  85. // showSearch: false
  86. }
  87. },
  88. components: {
  89. MainSearch
  90. },
  91. watch: {
  92. $route: function (val, oldVal) {
  93. this.showMainSearch = false
  94. this.title = this.initHeader(val.path, val.query)
  95. }
  96. },
  97. created () {
  98. this.title = this.initHeader(this.$route.path, this.$route.query)
  99. },
  100. computed: {
  101. brandDetail () {
  102. return this.$store.state.brandDetail.detail.data
  103. },
  104. store () {
  105. return this.$store.state.shop.storeInfo.store.data
  106. },
  107. component () {
  108. return this.$store.state.componentDetail.detail.data
  109. },
  110. showEnHeader () {
  111. return this.startWith(this.$route.path, '/mobile/center')
  112. }
  113. // showHeader () {
  114. // return this.$route.path !== '/' || !this.$route.path || this.$route.path === ''
  115. // },
  116. // showSearch () {
  117. // return this.$route.path !== '/' && !this.$route.path.startsWith('/mobile/search')
  118. // }
  119. },
  120. // mounted () {
  121. // let _this = this
  122. // _this.url = window.location.href
  123. // _this.clipboard = new Clipboard('#copyLink')
  124. // _this.clipboard.on('success', e => {
  125. // _this.clipboard.destroy()
  126. // _this.showShare = false
  127. // })
  128. // _this.clipboard.on('error', e => {
  129. // alert('浏览器不支持自动复制,请手动复制')
  130. // _this.clipboard.destroy()
  131. // })
  132. // },
  133. methods: {
  134. goLastPage: function () {
  135. window.history.back(-1)
  136. },
  137. initHeader: function (val, query) {
  138. // if (val !== '/' || !val || val === '') {
  139. // this.showHeader = true
  140. // this.showSearch = !val.startsWith('/mobile/search')
  141. // } else {
  142. // this.showHeader = false
  143. // this.showSearch = false
  144. // }
  145. this.showSearchIcon = false
  146. this.showHeader = val && val !== '/' && val !== '/mobile/applyPurchase/list' && !this.startWith(val, '/mobile/supplier')
  147. // this.showSearch = val !== '/' && !this.startWith(val, '/mobile/search')
  148. let title = '优软商城'
  149. if (this.startWith(val, '/mobile/brand/componentDetail/')) {
  150. title = this.component.code
  151. // this.rightIcon = 'share'
  152. } else if (this.startWith(val, '/mobile/brand/brandCenter')) {
  153. title = '品牌墙'
  154. // this.rightIcon = 'share'
  155. } else if (this.startWith(val, '/mobile/brand/')) {
  156. if (this.brandDetail.nameCn) {
  157. if (this.brandDetail.nameCn !== this.brandDetail.nameEn) {
  158. title = this.brandDetail.nameEn + '(' + this.brandDetail.nameCn + ')'
  159. } else {
  160. title = this.brandDetail.nameCn
  161. }
  162. } else {
  163. if (this.component.brand.nameCn !== this.component.brand.nameEn) {
  164. title = this.component.brand.nameEn + '(' + this.component.brand.nameCn + ')'
  165. } else {
  166. title = this.component.brand.nameCn
  167. }
  168. }
  169. // this.rightIcon = 'share'
  170. } else if (this.startWith(val, '/mobile/shop/')) {
  171. title = this.store.storeName
  172. // this.rightIcon = 'phone'
  173. } else if (this.startWith(val, '/mobile/shop')) {
  174. title = '店铺列表'
  175. // this.rightIcon = 'phone'
  176. } else if (this.startWith(val, '/mobile/center/vendor/product')) {
  177. if (this.$route.query.providerType === 'enterprise') {
  178. title = '企业产品库'
  179. } else if (this.$route.query.providerType === 'person') {
  180. title = '个人产品库'
  181. } else {
  182. title = '在售产品'
  183. }
  184. // this.rightIcon = 'phone'
  185. } else if (this.startWith(val, '/mobile/search')) {
  186. title = '搜索结果'
  187. // this.rightIcon = 'share'
  188. } else if (this.startWith(val, '/mobile/user/info/personal')) {
  189. this.showSearchIcon = false
  190. title = '个人信息'
  191. } else if (this.startWith(val, '/mobile/user/info/admin')) {
  192. this.showSearchIcon = false
  193. title = '管理员信息'
  194. } else if (this.startWith(val, '/mobile/product')) {
  195. this.showSearchIcon = false
  196. title = '产品详情'
  197. } else {
  198. this.showSearchIcon = true
  199. title = '优软商城'
  200. // this.rightIcon = 'phone'
  201. }
  202. return title
  203. },
  204. // showLink: function () {
  205. // this.showStoreInfo = true
  206. // if (this.$route.path.startsWith('/mobile/shop/')) {
  207. // this.showDefaultAddr = false
  208. // } else {
  209. // this.showDefaultAddr = true
  210. // }
  211. // },
  212. // shareWeibo: function () {
  213. // let _shareUrl = 'http://v.t.sina.com.cn/share/share.php?&appkey=895033136' // 真实的appkey,必选参数
  214. // _shareUrl += '&url=' + encodeURIComponent(document.location) // 参数url设置分享的内容链接|默认当前页location,可选参数
  215. // _shareUrl += '&title=' + encodeURIComponent(document.title) // 参数title设置分享的标题|默认当前页标题,可选参数
  216. // _shareUrl += '&source=' + encodeURIComponent('')
  217. // _shareUrl += '&sourceUrl=' + encodeURIComponent('')
  218. // _shareUrl += '&content=' + 'utf-8' // 参数content设置页面编码gb2312|utf-8,可选参数
  219. // _shareUrl += '&pic=' + encodeURIComponent('') // 参数pic设置图片链接|默认为空,可选参数
  220. // window.open(_shareUrl)
  221. // this.showShare = false
  222. // },
  223. // shareWeChat: function () {
  224. // },
  225. // shareQQ: function () {
  226. // let url = encodeURIComponent(document.location)
  227. // let title = encodeURIComponent(document.title)
  228. // let source = encodeURIComponent('')
  229. // let desc = '优软商城'
  230. // let pics = 'http://dfs.ubtob.com/group1/M00/4F/C3/CgpkyFnxWjOAMy5DAAlh1PrLlc8684.png'
  231. // window.open('http://connect.qq.com/widget/shareqq/index.html?url=' +
  232. // url + '&title=' + title + '&source=' + source + '&desc=' + desc + '&pics=' + pics)
  233. // this.showShare = false
  234. // },
  235. // shareMessage: function () {
  236. // document.getElementById('share-sms').click()
  237. // },
  238. // shareEmail: function () {
  239. // document.getElementById('share-mail').click()
  240. // },
  241. // flash: function () {
  242. // window.location.reload()
  243. // },
  244. // copyLink: function () {
  245. // let _this = this
  246. // _this.url = window.location.href
  247. // _this.clipboard = new Clipboard('#copyLink')
  248. // },
  249. // onTouchMove: function (e) {
  250. // let width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth
  251. // let height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight
  252. // let x = Math.min(width - 40, e.touches[0].clientX)
  253. // let y = Math.min(height - 40, e.touches[0].clientY)
  254. // x = Math.max(0, x)
  255. // y = Math.max(0, y)
  256. // e.preventDefault()
  257. // e.target.style.left = x * 2 / 100.0 + 'rem'
  258. // e.target.style.top = y * 2 / 100.0 + 'rem'
  259. // },
  260. onCancelSearch: function () {
  261. this.showMainSearch = false
  262. },
  263. // cancelModal: function () {
  264. // this.showStoreInfo = false
  265. // this.showShare = false
  266. // },
  267. stopPropagation: function (event) {
  268. event.stopPropagation()
  269. },
  270. goMainSearch: function () {
  271. this.showMainSearch = true
  272. this.$store.dispatch('searchData/getSearchHistory')
  273. },
  274. startWith: function (str, s) {
  275. let reg = new RegExp('^' + s)
  276. return reg.test(str)
  277. }
  278. }
  279. }
  280. </script>
  281. <style lang="scss" scoped>
  282. .mobile-header{
  283. position: fixed;
  284. top: 0;
  285. z-index: 10;
  286. width:100%;
  287. height:.88rem;
  288. line-height: .88rem;
  289. /*border-bottom:.01rem solid #ccc;*/
  290. background: #3e82f5;
  291. padding:0 .2rem 0 .1rem;
  292. color:#fff;
  293. }
  294. .mobile-header p{
  295. overflow: hidden;
  296. text-overflow: ellipsis;
  297. white-space: nowrap;
  298. font-size:.36rem;
  299. text-align: center;
  300. margin: 0;
  301. width: 6rem;
  302. padding-left: 1rem;
  303. }
  304. .mobile-header a{
  305. font-size:.28rem;
  306. color:#fff;
  307. position: absolute;
  308. }
  309. .mobile-header a i{
  310. font-size: .48rem;
  311. margin-right: -.1rem;
  312. }
  313. .mobile-header p span {
  314. position: absolute;
  315. right: .4rem;
  316. font-size: .28rem;
  317. }
  318. .mobile-header p span i {
  319. font-size: .28rem;
  320. }
  321. .mobile-nav >i{
  322. font-size: .4rem;
  323. position: fixed;
  324. right: .25rem;
  325. top: .25rem;
  326. z-index: 1000;
  327. color: #fff;
  328. background: rgba( 0, 0, 0, .251 );
  329. width: .8rem;
  330. height: .8rem;
  331. line-height: .8rem;
  332. border-radius: 100%;
  333. padding-left: .2rem;
  334. }
  335. .hide {
  336. display: none;
  337. }
  338. .search-content {
  339. margin-left: .5rem;
  340. input {
  341. color: #333;
  342. }
  343. }
  344. .mobile-center-header {
  345. height: 1.26rem;
  346. line-height: 1.26rem;
  347. p {
  348. line-height: normal;
  349. margin-top: .13rem;
  350. &.en-name {
  351. font-size: .3rem;
  352. margin-top: .06rem;
  353. img {
  354. width: .31rem;
  355. margin-right: .05rem;
  356. }
  357. }
  358. }
  359. }
  360. </style>