MobileHeader.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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>致电:<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">
  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">
  58. <a class="iconfont icon-fanhui" @click="goLastPage">返回</a>
  59. <p>{{title}}</p>
  60. <i v-show="rightIcon=='share'" class="iconfont icon-fenxiang" @click="showShare = true"></i>
  61. <i v-show="rightIcon=='phone'" class="iconfont icon-dianhua" @click="showLink"></i>
  62. </div>
  63. </div>
  64. </template>
  65. <script>
  66. import Clipboard from 'clipboard'
  67. export default {
  68. data () {
  69. return {
  70. showStoreInfo: false,
  71. showShare: false,
  72. rightIcon: 'share',
  73. showDefaultAddr: true,
  74. url: '',
  75. clipboard: {}
  76. }
  77. },
  78. computed: {
  79. brandDetail () {
  80. return this.$store.state.brandDetail.detail.data
  81. },
  82. title () {
  83. return this.initHeader(this.$route.path)
  84. },
  85. store () {
  86. return this.$store.state.shop.storeInfo.store.data
  87. },
  88. component () {
  89. return this.$store.state.componentDetail.detail.data
  90. }
  91. },
  92. mounted () {
  93. let _this = this
  94. _this.url = window.location.href
  95. _this.clipboard = new Clipboard('#copyLink')
  96. _this.clipboard.on('success', e => {
  97. _this.clipboard.destroy()
  98. _this.showShare = false
  99. })
  100. _this.clipboard.on('error', e => {
  101. alert('浏览器不支持自动复制,请手动复制')
  102. _this.clipboard.destroy()
  103. })
  104. },
  105. methods: {
  106. goLastPage: function () {
  107. window.history.back(-1)
  108. },
  109. initHeader: function (val) {
  110. let title = '优软商城'
  111. if (val.startsWith('/mobile/brand/')) {
  112. if (this.brandDetail.nameCn) {
  113. if (this.brandDetail.nameCn !== this.brandDetail.nameEn) {
  114. title = this.brandDetail.nameEn + '(' + this.brandDetail.nameCn + ')'
  115. } else {
  116. title = this.brandDetail.nameCn
  117. }
  118. } else {
  119. if (this.component.brand.nameCn !== this.component.brand.nameEn) {
  120. title = this.component.brand.nameEn + '(' + this.component.brand.nameCn + ')'
  121. } else {
  122. title = this.component.brand.nameCn
  123. }
  124. }
  125. this.rightIcon = 'share'
  126. } else if (val.startsWith('/mobile/shop')) {
  127. title = '店铺列表'
  128. this.rightIcon = 'phone'
  129. } else if (val.startsWith('/mobile/merchantDescription/')) {
  130. title = '商家简介'
  131. this.rightIcon = 'phone'
  132. } else if (val.startsWith('/mobile/user')) {
  133. title = '我的收藏'
  134. this.rightIcon = 'phone'
  135. } else if (val.startsWith('/mobile/search')) {
  136. title = '搜索结果'
  137. this.rightIcon = 'share'
  138. } else {
  139. title = '优软商城'
  140. this.rightIcon = 'phone'
  141. }
  142. return title
  143. },
  144. showLink: function () {
  145. this.showStoreInfo = true
  146. if (this.title === '商家简介') {
  147. this.showDefaultAddr = false
  148. } else {
  149. this.showDefaultAddr = true
  150. }
  151. },
  152. shareWeibo: function () {
  153. let _shareUrl = 'http://v.t.sina.com.cn/share/share.php?&appkey=895033136' // 真实的appkey,必选参数
  154. _shareUrl += '&url=' + encodeURIComponent(document.location) // 参数url设置分享的内容链接|默认当前页location,可选参数
  155. _shareUrl += '&title=' + encodeURIComponent(document.title) // 参数title设置分享的标题|默认当前页标题,可选参数
  156. _shareUrl += '&source=' + encodeURIComponent('')
  157. _shareUrl += '&sourceUrl=' + encodeURIComponent('')
  158. _shareUrl += '&content=' + 'utf-8' // 参数content设置页面编码gb2312|utf-8,可选参数
  159. _shareUrl += '&pic=' + encodeURIComponent('') // 参数pic设置图片链接|默认为空,可选参数
  160. window.open(_shareUrl)
  161. this.showShare = false
  162. },
  163. shareWeChat: function () {
  164. },
  165. shareQQ: function () {
  166. let url = encodeURIComponent(document.location)
  167. let title = encodeURIComponent(document.title)
  168. let source = encodeURIComponent('')
  169. let desc = '优软商城'
  170. let pics = 'http://dfs.ubtob.com/group1/M00/4F/C3/CgpkyFnxWjOAMy5DAAlh1PrLlc8684.png'
  171. window.open('http://connect.qq.com/widget/shareqq/index.html?url=' +
  172. url + '&title=' + title + '&source=' + source + '&desc=' + desc + '&pics=' + pics)
  173. this.showShare = false
  174. },
  175. shareMessage: function () {
  176. document.getElementById('share-sms').click()
  177. },
  178. shareEmail: function () {
  179. document.getElementById('share-mail').click()
  180. },
  181. flash: function () {
  182. window.location.reload()
  183. },
  184. copyLink: function () {
  185. let _this = this
  186. _this.url = window.location.href
  187. _this.clipboard = new Clipboard('#copyLink')
  188. }
  189. }
  190. }
  191. </script>
  192. <style lang="scss" scoped>
  193. @import '~assets/scss/mobileCommon';
  194. .mobile-header{
  195. width:100%;
  196. position: fixed;
  197. top: 0;
  198. z-index:10000;
  199. height:.88rem;
  200. display:flex;
  201. justify-content:space-around;
  202. align-items:center;
  203. border-bottom:.02rem solid #ccc;
  204. background: #3e82f5;
  205. padding:0 .2rem 0 .1rem;
  206. color:#fff;
  207. }
  208. .mobile-header p{
  209. flex:1;
  210. font-size:.36rem;
  211. text-align: center;
  212. margin-top:.2rem;
  213. }
  214. .mobile-header a{
  215. font-size:.28rem;
  216. color:#fff;
  217. }
  218. .mobile-header i{
  219. font-size:.4rem;
  220. }
  221. .hide {
  222. display: none;
  223. }
  224. </style>