MobileHeader.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  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 && 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. this.startWith(this.$route.path, '/mobile/order') ||
  113. this.startWith(this.$route.path, '/mobile/user/address')
  114. }
  115. // showHeader () {
  116. // return this.$route.path !== '/' || !this.$route.path || this.$route.path === ''
  117. // },
  118. // showSearch () {
  119. // return this.$route.path !== '/' && !this.$route.path.startsWith('/mobile/search')
  120. // }
  121. },
  122. // mounted () {
  123. // let _this = this
  124. // _this.url = window.location.href
  125. // _this.clipboard = new Clipboard('#copyLink')
  126. // _this.clipboard.on('success', e => {
  127. // _this.clipboard.destroy()
  128. // _this.showShare = false
  129. // })
  130. // _this.clipboard.on('error', e => {
  131. // alert('浏览器不支持自动复制,请手动复制')
  132. // _this.clipboard.destroy()
  133. // })
  134. // },
  135. methods: {
  136. goLastPage: function () {
  137. window.history.back(-1)
  138. },
  139. initHeader: function (val, query) {
  140. this.showSearchIcon = false
  141. this.showHeader = val && val !== '/' && val !== '/mobile/applyPurchase/list' && !this.startWith(val, '/mobile/supplier')
  142. // this.showSearch = val !== '/' && !this.startWith(val, '/mobile/search')
  143. let title = '优软商城'
  144. if (this.startWith(val, '/mobile/brand/componentDetail/')) {
  145. title = this.component.code
  146. // this.rightIcon = 'share'
  147. } else if (this.startWith(val, '/mobile/brand/brandCenter')) {
  148. title = '品牌墙'
  149. // this.rightIcon = 'share'
  150. } else if (this.startWith(val, '/mobile/brand/')) {
  151. if (this.brandDetail.nameCn) {
  152. if (this.brandDetail.nameCn !== this.brandDetail.nameEn) {
  153. title = this.brandDetail.nameEn + '(' + this.brandDetail.nameCn + ')'
  154. } else {
  155. title = this.brandDetail.nameCn
  156. }
  157. } else {
  158. if (this.component.brand.nameCn !== this.component.brand.nameEn) {
  159. title = this.component.brand.nameEn + '(' + this.component.brand.nameCn + ')'
  160. } else {
  161. title = this.component.brand.nameCn
  162. }
  163. }
  164. // this.rightIcon = 'share'
  165. } else if (this.startWith(val, '/mobile/shop/')) {
  166. title = this.store.storeName
  167. // this.rightIcon = 'phone'
  168. } else if (this.startWith(val, '/mobile/shop')) {
  169. title = '店铺列表'
  170. // this.rightIcon = 'phone'
  171. } else if (this.startWith(val, '/mobile/center/vendor/productList')) {
  172. title = '产品信息'
  173. // this.rightIcon = 'phone'
  174. } else if (this.startWith(val, '/mobile/center/vendor/productdetails')) {
  175. title = '产品信息'
  176. // this.rightIcon = 'phone'
  177. } else if (this.startWith(val, '/mobile/center/vendor/material')) {
  178. title = '库存管理'
  179. } else if (this.startWith(val, '/mobile/center/vendor/product')) {
  180. if (this.$route.query.providerType === 'enterprise') {
  181. title = '产品库'
  182. } else if (this.$route.query.providerType === 'person') {
  183. title = '出入库'
  184. } else {
  185. title = '在售产品'
  186. }
  187. // this.rightIcon = 'phone'
  188. } else if (this.startWith(val, '/mobile/search')) {
  189. title = '搜索结果'
  190. // this.rightIcon = 'share'
  191. } else if (this.startWith(val, '/mobile/user/info/personal')) {
  192. this.showSearchIcon = false
  193. title = '个人信息'
  194. } else if (this.startWith(val, '/mobile/user/info/admin')) {
  195. this.showSearchIcon = false
  196. title = '管理员信息'
  197. } else if (this.startWith(val, '/mobile/user/address')) {
  198. this.showSearchIcon = false
  199. title = '收货地址信息'
  200. } else if (this.startWith(val, '/mobile/product')) {
  201. this.showSearchIcon = false
  202. title = '产品详情'
  203. } else if (val === '/mobile/user/bindEnterprise') {
  204. this.showSearchIcon = false
  205. title = '信息确认'
  206. } else if (this.startWith(val, '/mobile/center/vendor/attentionBus')) {
  207. this.showSearchIcon = false
  208. title = '优软商城'
  209. } else if (this.startWith(val, '/mobile/store')) {
  210. this.showSearchIcon = false
  211. title = '开店申请'
  212. } else if (this.startWith(val, '/mobile/center/user/cart')) {
  213. this.showSearchIcon = false
  214. title = '购物车'
  215. } else if (this.startWith(val, '/mobile/center/user/payCenter')) {
  216. this.showSearchIcon = false
  217. if (this.$route.query.type) {
  218. title = '付款账户'
  219. } else {
  220. title = '应付对账'
  221. }
  222. } else if (this.startWith(val, '/mobile/center/user/invoice')) {
  223. this.showSearchIcon = false
  224. title = '发票管理'
  225. } else if (this.startWith(val, '/mobile/center/vendor/payCenter')) {
  226. this.showSearchIcon = false
  227. if (this.$route.query.type) {
  228. title = '收款账户'
  229. } else {
  230. title = '应收对账'
  231. }
  232. } else if (this.startWith(val, '/mobile/center/user/pay')) {
  233. this.showSearchIcon = false
  234. title = '确认订单'
  235. } else if (this.startWith(val, '/mobile/center/user/doPay')) {
  236. this.showSearchIcon = false
  237. title = '待付款订单'
  238. } else if (this.startWith(val, '/mobile/order/details')) {
  239. this.showSearchIcon = false
  240. title = '订单详情'
  241. } else if (this.startWith(val, '/mobile/order/logistics')) {
  242. this.showSearchIcon = false
  243. title = '物流信息'
  244. } else if (this.startWith(val, '/mobile/order/b2border')) {
  245. title = '采购订单'
  246. } else if (this.startWith(val, '/mobile/order')) {
  247. this.showSearchIcon = false
  248. if (query.type === 'buyer') {
  249. title = '采购订单'
  250. } else {
  251. title = '销售订单'
  252. }
  253. } else if (this.startWith(val, '/mobile/center/vendor/invoice')) {
  254. this.showSearchIcon = false
  255. title = '发票管理'
  256. } else if (this.startWith(val, '/mobile/center/vendor/sample')) {
  257. this.showSearchIcon = false
  258. title = '打样管理'
  259. } else if (this.startWith(val, '/mobile/center/vendor/approval')) {
  260. this.showSearchIcon = false
  261. title = '打样管理'
  262. } else if (this.startWith(val, '/mobile/center/vendor/customer')) {
  263. this.showSearchIcon = false
  264. title = '客户资料'
  265. } else {
  266. this.showSearchIcon = true
  267. title = '优软商城'
  268. // this.rightIcon = 'phone'
  269. }
  270. return title
  271. },
  272. // showLink: function () {
  273. // this.showStoreInfo = true
  274. // if (this.$route.path.startsWith('/mobile/shop/')) {
  275. // this.showDefaultAddr = false
  276. // } else {
  277. // this.showDefaultAddr = true
  278. // }
  279. // },
  280. // shareWeibo: function () {
  281. // let _shareUrl = 'http://v.t.sina.com.cn/share/share.php?&appkey=895033136' // 真实的appkey,必选参数
  282. // _shareUrl += '&url=' + encodeURIComponent(document.location) // 参数url设置分享的内容链接|默认当前页location,可选参数
  283. // _shareUrl += '&title=' + encodeURIComponent(document.title) // 参数title设置分享的标题|默认当前页标题,可选参数
  284. // _shareUrl += '&source=' + encodeURIComponent('')
  285. // _shareUrl += '&sourceUrl=' + encodeURIComponent('')
  286. // _shareUrl += '&content=' + 'utf-8' // 参数content设置页面编码gb2312|utf-8,可选参数
  287. // _shareUrl += '&pic=' + encodeURIComponent('') // 参数pic设置图片链接|默认为空,可选参数
  288. // window.open(_shareUrl)
  289. // this.showShare = false
  290. // },
  291. // shareWeChat: function () {
  292. // },
  293. // shareQQ: function () {
  294. // let url = encodeURIComponent(document.location)
  295. // let title = encodeURIComponent(document.title)
  296. // let source = encodeURIComponent('')
  297. // let desc = '优软商城'
  298. // let pics = 'http://dfs.ubtob.com/group1/M00/4F/C3/CgpkyFnxWjOAMy5DAAlh1PrLlc8684.png'
  299. // window.open('http://connect.qq.com/widget/shareqq/index.html?url=' +
  300. // url + '&title=' + title + '&source=' + source + '&desc=' + desc + '&pics=' + pics)
  301. // this.showShare = false
  302. // },
  303. // shareMessage: function () {
  304. // document.getElementById('share-sms').click()
  305. // },
  306. // shareEmail: function () {
  307. // document.getElementById('share-mail').click()
  308. // },
  309. // flash: function () {
  310. // window.location.reload()
  311. // },
  312. // copyLink: function () {
  313. // let _this = this
  314. // _this.url = window.location.href
  315. // _this.clipboard = new Clipboard('#copyLink')
  316. // },
  317. // onTouchMove: function (e) {
  318. // let width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth
  319. // let height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight
  320. // let x = Math.min(width - 40, e.touches[0].clientX)
  321. // let y = Math.min(height - 40, e.touches[0].clientY)
  322. // x = Math.max(0, x)
  323. // y = Math.max(0, y)
  324. // e.preventDefault()
  325. // e.target.style.left = x * 2 / 100.0 + 'rem'
  326. // e.target.style.top = y * 2 / 100.0 + 'rem'
  327. // },
  328. onCancelSearch: function () {
  329. this.showMainSearch = false
  330. },
  331. // cancelModal: function () {
  332. // this.showStoreInfo = false
  333. // this.showShare = false
  334. // },
  335. stopPropagation: function (event) {
  336. event.stopPropagation()
  337. },
  338. goMainSearch: function () {
  339. this.showMainSearch = true
  340. this.$store.dispatch('searchData/getSearchHistory')
  341. },
  342. startWith: function (str, s) {
  343. return this.baseUtils.startWith(str, s)
  344. }
  345. }
  346. }
  347. </script>
  348. <style lang="scss" scoped>
  349. .mobile-header{
  350. position: fixed;
  351. top: 0;
  352. z-index: 10;
  353. width:100%;
  354. height:.88rem;
  355. line-height: .88rem;
  356. /*border-bottom:.01rem solid #ccc;*/
  357. background: #3e82f5;
  358. padding:0 .2rem 0 .1rem;
  359. color:#fff;
  360. }
  361. .mobile-header p{
  362. overflow: hidden;
  363. text-overflow: ellipsis;
  364. white-space: nowrap;
  365. font-size:.36rem;
  366. text-align: center;
  367. margin: 0;
  368. width: 6rem;
  369. padding-left: 1rem;
  370. }
  371. .mobile-header a{
  372. font-size:.28rem;
  373. color:#fff;
  374. position: absolute;
  375. }
  376. .mobile-header a i{
  377. font-size: .48rem;
  378. margin-right: -.1rem;
  379. }
  380. .mobile-header p span {
  381. position: absolute;
  382. right: .4rem;
  383. font-size: .28rem;
  384. }
  385. .mobile-header p span i {
  386. font-size: .28rem;
  387. }
  388. .mobile-nav >i{
  389. font-size: .4rem;
  390. position: fixed;
  391. right: .25rem;
  392. top: .25rem;
  393. z-index: 1000;
  394. color: #fff;
  395. background: rgba( 0, 0, 0, .251 );
  396. width: .8rem;
  397. height: .8rem;
  398. line-height: .8rem;
  399. border-radius: 100%;
  400. padding-left: .2rem;
  401. }
  402. .hide {
  403. display: none;
  404. }
  405. .search-content {
  406. margin-left: .5rem;
  407. input {
  408. color: #333;
  409. }
  410. }
  411. .mobile-center-header {
  412. height: 1.26rem;
  413. line-height: 1.26rem;
  414. p {
  415. line-height: normal;
  416. margin-top: .13rem;
  417. &.en-name {
  418. font-size: .3rem;
  419. margin-top: .06rem;
  420. img {
  421. width: .31rem;
  422. margin-right: .05rem;
  423. }
  424. }
  425. }
  426. }
  427. </style>