MobileHeader.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <div>
  3. <div class="mobile-modal" v-if="showStoreInfo || showShare">
  4. <div class="mobile-modal-box" v-if="showStoreInfo">
  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>致电:<span class="content-line link-url">0755-96586323</span></div>
  10. </div>
  11. <div class="mobile-modal-content" v-if="!showDefaultAddr">
  12. <div>商家地址:{{store.enterprise.enAddress || store.enterprise.address}}</div>
  13. <div class="content-line link-url">在线咨询</div>
  14. <div>致电:<span class="content-line link-url">{{store.enterprise.enTel}}</span></div>
  15. </div>
  16. </div>
  17. <div class="mobile-share-box" v-if="showShare">
  18. <div class="share-area">
  19. <ul>
  20. <li class="share-item" @click="shareWeChat">
  21. <img src="/images/mobile/@2x/share/weChat@2x.png" alt="">
  22. <span>微信</span>
  23. </li>
  24. <li class="share-item">
  25. <img src="/images/mobile/@2x/share/QQ@2x.png" alt="">
  26. <span>QQ</span>
  27. </li>
  28. <li class="share-item" @click="shareWeibo">
  29. <img src="/images/mobile/@2x/share/sina@2x.png" alt="">
  30. <span>微博</span>
  31. </li>
  32. <li class="share-item">
  33. <img src="/images/mobile/@2x/share/message@2x.png" alt="">
  34. <span>短信</span>
  35. </li>
  36. <li class="share-item">
  37. <img src="/images/mobile/@2x/share/email@2x.png" alt="">
  38. <span>邮件</span>
  39. </li>
  40. <li class="share-item">
  41. <img src="/images/mobile/@2x/share/flash@2x.png" alt="">
  42. <span>刷新</span>
  43. </li>
  44. <li class="share-item">
  45. <img src="/images/mobile/@2x/share/copylink@2x.png" alt="">
  46. <span>复制链接</span>
  47. </li>
  48. </ul>
  49. </div>
  50. <div class="cancel-share" @click="showShare=false">取消</div>
  51. </div>
  52. </div>
  53. <div class="mobile-header">
  54. <a class="iconfont icon-fanhui" @click="goLastPage">返回</a>
  55. <p>{{title}}</p>
  56. <i v-show="rightIcon=='share'" class="iconfont icon-fenxiang" @click="showShare = true"></i>
  57. <i v-show="rightIcon=='phone'" class="iconfont icon-dianhua" @click="showLink"></i>
  58. </div>
  59. </div>
  60. </template>
  61. <script>
  62. export default {
  63. data () {
  64. return {
  65. showStoreInfo: false,
  66. showShare: false,
  67. rightIcon: 'share',
  68. showDefaultAddr: true
  69. }
  70. },
  71. computed: {
  72. brandDetail () {
  73. return this.$store.state.brandDetail.detail.data
  74. },
  75. title () {
  76. return this.initHeader(this.$route.path)
  77. },
  78. store () {
  79. return this.$store.state.shop.storeInfo.store.data
  80. },
  81. component () {
  82. return this.$store.state.componentDetail.detail.data
  83. }
  84. },
  85. methods: {
  86. goLastPage: function () {
  87. window.history.back(-1)
  88. },
  89. initHeader: function (val) {
  90. let title = '优软商城'
  91. if (val.startsWith('/mobile/brand/')) {
  92. if (this.brandDetail.nameCn) {
  93. if (this.brandDetail.nameCn !== this.brandDetail.nameEn) {
  94. title = this.brandDetail.nameEn + '(' + this.brandDetail.nameCn + ')'
  95. } else {
  96. title = this.brandDetail.nameCn
  97. }
  98. } else {
  99. if (this.component.brand.nameCn !== this.component.brand.nameEn) {
  100. title = this.component.brand.nameEn + '(' + this.component.brand.nameCn + ')'
  101. } else {
  102. title = this.component.brand.nameCn
  103. }
  104. }
  105. this.rightIcon = 'share'
  106. } else if (val.startsWith('/mobile/shop')) {
  107. title = '店铺列表'
  108. this.rightIcon = 'phone'
  109. } else if (val.startsWith('/mobile/merchantDescription/')) {
  110. title = '商家简介'
  111. this.rightIcon = 'phone'
  112. } else if (val.startsWith('/mobile/user')) {
  113. title = '我的收藏'
  114. this.rightIcon = 'phone'
  115. } else if (val.startsWith('/mobile/search')) {
  116. title = '搜索结果'
  117. this.rightIcon = 'share'
  118. } else {
  119. title = '优软商城'
  120. this.rightIcon = 'phone'
  121. }
  122. return title
  123. },
  124. showLink: function () {
  125. this.showStoreInfo = true
  126. if (this.title === '商家简介') {
  127. this.showDefaultAddr = false
  128. } else {
  129. this.showDefaultAddr = true
  130. }
  131. },
  132. shareWeibo: function () {
  133. let _shareUrl = 'http://v.t.sina.com.cn/share/share.php?&appkey=895033136' // 真实的appkey,必选参数
  134. _shareUrl += '&url=' + encodeURIComponent(document.location) // 参数url设置分享的内容链接|默认当前页location,可选参数
  135. _shareUrl += '&title=' + encodeURIComponent(document.title) // 参数title设置分享的标题|默认当前页标题,可选参数
  136. _shareUrl += '&source=' + encodeURIComponent('')
  137. _shareUrl += '&sourceUrl=' + encodeURIComponent('')
  138. _shareUrl += '&content=' + 'utf-8' // 参数content设置页面编码gb2312|utf-8,可选参数
  139. _shareUrl += '&pic=' + encodeURIComponent('') // 参数pic设置图片链接|默认为空,可选参数
  140. window.open(_shareUrl, '_blank', 'width=' + 300 + ',height=' + 300 + ',top=' + 300 + ',left=' + 300 + ',toolbar=no,menubar=no,scrollbars=no, resizable=1,location=no,status=0')
  141. }
  142. }
  143. }
  144. </script>
  145. <style lang="scss" scoped>
  146. @import '~assets/scss/mobileCommon';
  147. .mobile-header{
  148. width:100%;
  149. position: fixed;
  150. top: 0;
  151. z-index:10000;
  152. height:.88rem;
  153. display:flex;
  154. justify-content:space-around;
  155. align-items:center;
  156. border-bottom:.02rem solid #ccc;
  157. background: #3e82f5;
  158. padding:0 .2rem 0 .1rem;
  159. color:#fff;
  160. }
  161. .mobile-header p{
  162. flex:1;
  163. font-size:.36rem;
  164. text-align: center;
  165. margin-top:.2rem;
  166. }
  167. .mobile-header a{
  168. font-size:.28rem;
  169. color:#fff;
  170. }
  171. .mobile-header i{
  172. font-size:.4rem;
  173. }
  174. </style>