MobileHeader.vue 15 KB

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