MobileHeader.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  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/product')) {
  178. if (this.$route.query.providerType === 'enterprise') {
  179. title = '公司产品库'
  180. } else if (this.$route.query.providerType === 'person') {
  181. title = '个人产品库'
  182. } else {
  183. title = '在售产品'
  184. }
  185. // this.rightIcon = 'phone'
  186. } else if (this.startWith(val, '/mobile/search')) {
  187. title = '搜索结果'
  188. // this.rightIcon = 'share'
  189. } else if (this.startWith(val, '/mobile/user/info/personal')) {
  190. this.showSearchIcon = false
  191. title = '个人信息'
  192. } else if (this.startWith(val, '/mobile/user/info/admin')) {
  193. this.showSearchIcon = false
  194. title = '管理员信息'
  195. } else if (this.startWith(val, '/mobile/user/address')) {
  196. this.showSearchIcon = false
  197. title = '收货地址信息'
  198. } else if (this.startWith(val, '/mobile/product')) {
  199. this.showSearchIcon = false
  200. title = '产品详情'
  201. } else if (val === '/mobile/user/bindEnterprise') {
  202. this.showSearchIcon = false
  203. title = '信息确认'
  204. } else if (this.startWith(val, '/mobile/center/vendor/attentionBus')) {
  205. this.showSearchIcon = false
  206. title = '优软商城'
  207. } else if (this.startWith(val, '/mobile/store')) {
  208. this.showSearchIcon = false
  209. title = '开店申请'
  210. } else if (this.startWith(val, '/mobile/center/user/cart')) {
  211. this.showSearchIcon = false
  212. title = '购物车'
  213. } else if (this.startWith(val, '/mobile/center/user/payCenter')) {
  214. this.showSearchIcon = false
  215. title = '应付对账'
  216. } else if (this.startWith(val, '/mobile/center/user/invoice')) {
  217. this.showSearchIcon = false
  218. title = '发票管理'
  219. } else if (this.startWith(val, '/mobile/center/vendor/payCenter')) {
  220. this.showSearchIcon = false
  221. title = '应收对账'
  222. } else if (this.startWith(val, '/mobile/center/user/pay')) {
  223. this.showSearchIcon = false
  224. title = '确认订单'
  225. } else if (this.startWith(val, '/mobile/center/user/doPay')) {
  226. this.showSearchIcon = false
  227. title = '待付款订单'
  228. } else if (this.startWith(val, '/mobile/order/details')) {
  229. this.showSearchIcon = false
  230. title = '订单详情'
  231. } else if (this.startWith(val, '/mobile/order/logistics')) {
  232. this.showSearchIcon = false
  233. title = '物流信息'
  234. } else if (this.startWith(val, '/mobile/order')) {
  235. this.showSearchIcon = false
  236. if (query.type === 'buyer') {
  237. title = '采购订单'
  238. } else {
  239. title = '销售订单'
  240. }
  241. } else if (this.startWith(val, '/mobile/center/vendor/invoice')) {
  242. this.showSearchIcon = false
  243. title = '发票管理'
  244. } else {
  245. this.showSearchIcon = true
  246. title = '优软商城'
  247. // this.rightIcon = 'phone'
  248. }
  249. return title
  250. },
  251. // showLink: function () {
  252. // this.showStoreInfo = true
  253. // if (this.$route.path.startsWith('/mobile/shop/')) {
  254. // this.showDefaultAddr = false
  255. // } else {
  256. // this.showDefaultAddr = true
  257. // }
  258. // },
  259. // shareWeibo: function () {
  260. // let _shareUrl = 'http://v.t.sina.com.cn/share/share.php?&appkey=895033136' // 真实的appkey,必选参数
  261. // _shareUrl += '&url=' + encodeURIComponent(document.location) // 参数url设置分享的内容链接|默认当前页location,可选参数
  262. // _shareUrl += '&title=' + encodeURIComponent(document.title) // 参数title设置分享的标题|默认当前页标题,可选参数
  263. // _shareUrl += '&source=' + encodeURIComponent('')
  264. // _shareUrl += '&sourceUrl=' + encodeURIComponent('')
  265. // _shareUrl += '&content=' + 'utf-8' // 参数content设置页面编码gb2312|utf-8,可选参数
  266. // _shareUrl += '&pic=' + encodeURIComponent('') // 参数pic设置图片链接|默认为空,可选参数
  267. // window.open(_shareUrl)
  268. // this.showShare = false
  269. // },
  270. // shareWeChat: function () {
  271. // },
  272. // shareQQ: function () {
  273. // let url = encodeURIComponent(document.location)
  274. // let title = encodeURIComponent(document.title)
  275. // let source = encodeURIComponent('')
  276. // let desc = '优软商城'
  277. // let pics = 'http://dfs.ubtob.com/group1/M00/4F/C3/CgpkyFnxWjOAMy5DAAlh1PrLlc8684.png'
  278. // window.open('http://connect.qq.com/widget/shareqq/index.html?url=' +
  279. // url + '&title=' + title + '&source=' + source + '&desc=' + desc + '&pics=' + pics)
  280. // this.showShare = false
  281. // },
  282. // shareMessage: function () {
  283. // document.getElementById('share-sms').click()
  284. // },
  285. // shareEmail: function () {
  286. // document.getElementById('share-mail').click()
  287. // },
  288. // flash: function () {
  289. // window.location.reload()
  290. // },
  291. // copyLink: function () {
  292. // let _this = this
  293. // _this.url = window.location.href
  294. // _this.clipboard = new Clipboard('#copyLink')
  295. // },
  296. // onTouchMove: function (e) {
  297. // let width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth
  298. // let height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight
  299. // let x = Math.min(width - 40, e.touches[0].clientX)
  300. // let y = Math.min(height - 40, e.touches[0].clientY)
  301. // x = Math.max(0, x)
  302. // y = Math.max(0, y)
  303. // e.preventDefault()
  304. // e.target.style.left = x * 2 / 100.0 + 'rem'
  305. // e.target.style.top = y * 2 / 100.0 + 'rem'
  306. // },
  307. onCancelSearch: function () {
  308. this.showMainSearch = false
  309. },
  310. // cancelModal: function () {
  311. // this.showStoreInfo = false
  312. // this.showShare = false
  313. // },
  314. stopPropagation: function (event) {
  315. event.stopPropagation()
  316. },
  317. goMainSearch: function () {
  318. this.showMainSearch = true
  319. this.$store.dispatch('searchData/getSearchHistory')
  320. },
  321. startWith: function (str, s) {
  322. return this.baseUtils.startWith(str, s)
  323. }
  324. }
  325. }
  326. </script>
  327. <style lang="scss" scoped>
  328. .mobile-header{
  329. position: fixed;
  330. top: 0;
  331. z-index: 10;
  332. width:100%;
  333. height:.88rem;
  334. line-height: .88rem;
  335. /*border-bottom:.01rem solid #ccc;*/
  336. background: #3e82f5;
  337. padding:0 .2rem 0 .1rem;
  338. color:#fff;
  339. }
  340. .mobile-header p{
  341. overflow: hidden;
  342. text-overflow: ellipsis;
  343. white-space: nowrap;
  344. font-size:.36rem;
  345. text-align: center;
  346. margin: 0;
  347. width: 6rem;
  348. padding-left: 1rem;
  349. }
  350. .mobile-header a{
  351. font-size:.28rem;
  352. color:#fff;
  353. position: absolute;
  354. }
  355. .mobile-header a i{
  356. font-size: .48rem;
  357. margin-right: -.1rem;
  358. }
  359. .mobile-header p span {
  360. position: absolute;
  361. right: .4rem;
  362. font-size: .28rem;
  363. }
  364. .mobile-header p span i {
  365. font-size: .28rem;
  366. }
  367. .mobile-nav >i{
  368. font-size: .4rem;
  369. position: fixed;
  370. right: .25rem;
  371. top: .25rem;
  372. z-index: 1000;
  373. color: #fff;
  374. background: rgba( 0, 0, 0, .251 );
  375. width: .8rem;
  376. height: .8rem;
  377. line-height: .8rem;
  378. border-radius: 100%;
  379. padding-left: .2rem;
  380. }
  381. .hide {
  382. display: none;
  383. }
  384. .search-content {
  385. margin-left: .5rem;
  386. input {
  387. color: #333;
  388. }
  389. }
  390. .mobile-center-header {
  391. height: 1.26rem;
  392. line-height: 1.26rem;
  393. p {
  394. line-height: normal;
  395. margin-top: .13rem;
  396. &.en-name {
  397. font-size: .3rem;
  398. margin-top: .06rem;
  399. img {
  400. width: .31rem;
  401. margin-right: .05rem;
  402. }
  403. }
  404. }
  405. }
  406. </style>