Эх сурвалжийг харах

微博、QQ分享,复制链接,刷新

yangc 8 жил өмнө
parent
commit
46195c0d08

+ 1 - 0
app.html

@@ -51,4 +51,5 @@
 <body {{ BODY_ATTRS }}>
 <body {{ BODY_ATTRS }}>
 {{ APP }}
 {{ APP }}
 </body>
 </body>
+<!--<script src="https://cdn.bootcss.com/clipboard.js/1.7.1/clipboard.min.js"></script>-->
 </html>
 </html>

+ 1 - 1
components/default/Header.vue

@@ -104,7 +104,7 @@
         this.toggleEnterprises()
         this.toggleEnterprises()
         this.$http.get(`/user/authentication/${en.uu}`).then(() => {
         this.$http.get(`/user/authentication/${en.uu}`).then(() => {
           this.$store.dispatch('loadUserInfo')
           this.$store.dispatch('loadUserInfo')
-//          window.location.reload()
+          window.location.reload()
         })
         })
       }
       }
     },
     },

+ 53 - 7
components/mobile/MobileHeader.vue

@@ -21,7 +21,7 @@
               <img src="/images/mobile/@2x/share/weChat@2x.png" alt="">
               <img src="/images/mobile/@2x/share/weChat@2x.png" alt="">
               <span>微信</span>
               <span>微信</span>
             </li>
             </li>
-            <li class="share-item">
+            <li class="share-item" @click="shareQQ">
               <img src="/images/mobile/@2x/share/QQ@2x.png" alt="">
               <img src="/images/mobile/@2x/share/QQ@2x.png" alt="">
               <span>QQ</span>
               <span>QQ</span>
             </li>
             </li>
@@ -29,19 +29,20 @@
               <img src="/images/mobile/@2x/share/sina@2x.png" alt="">
               <img src="/images/mobile/@2x/share/sina@2x.png" alt="">
               <span>微博</span>
               <span>微博</span>
             </li>
             </li>
-            <li class="share-item">
+            <li class="share-item" @click="shareMessage">
               <img src="/images/mobile/@2x/share/message@2x.png" alt="">
               <img src="/images/mobile/@2x/share/message@2x.png" alt="">
               <span>短信</span>
               <span>短信</span>
             </li>
             </li>
-            <li class="share-item">
+            <li class="share-item" @click="shareEmail">
               <img src="/images/mobile/@2x/share/email@2x.png" alt="">
               <img src="/images/mobile/@2x/share/email@2x.png" alt="">
               <span>邮件</span>
               <span>邮件</span>
+              <a href="mailto:yangc@usoftchina.com" class="hide" id="share-mail"></a>
             </li>
             </li>
-            <li class="share-item">
+            <li class="share-item" @click="flash">
               <img src="/images/mobile/@2x/share/flash@2x.png" alt="">
               <img src="/images/mobile/@2x/share/flash@2x.png" alt="">
               <span>刷新</span>
               <span>刷新</span>
             </li>
             </li>
-            <li class="share-item">
+            <li class="share-item" @click="copyLink" id="copyLink"  :data-clipboard-text="url">
               <img src="/images/mobile/@2x/share/copylink@2x.png" alt="">
               <img src="/images/mobile/@2x/share/copylink@2x.png" alt="">
               <span>复制链接</span>
               <span>复制链接</span>
             </li>
             </li>
@@ -59,13 +60,16 @@
   </div>
   </div>
 </template>
 </template>
 <script>
 <script>
+  import Clipboard from 'clipboard'
   export default {
   export default {
     data () {
     data () {
       return {
       return {
         showStoreInfo: false,
         showStoreInfo: false,
         showShare: false,
         showShare: false,
         rightIcon: 'share',
         rightIcon: 'share',
-        showDefaultAddr: true
+        showDefaultAddr: true,
+        url: '',
+        clipboard: {}
       }
       }
     },
     },
     computed: {
     computed: {
@@ -82,6 +86,19 @@
         return this.$store.state.componentDetail.detail.data
         return this.$store.state.componentDetail.detail.data
       }
       }
     },
     },
+    mounted () {
+      let _this = this
+      _this.url = window.location.href
+      _this.clipboard = new Clipboard('#copyLink')
+      _this.clipboard.on('success', e => {
+        _this.clipboard.destroy()
+        _this.showShare = false
+      })
+      _this.clipboard.on('error', e => {
+        alert('浏览器不支持自动复制,请手动复制')
+        _this.clipboard.destroy()
+      })
+    },
     methods: {
     methods: {
       goLastPage: function () {
       goLastPage: function () {
         window.history.back(-1)
         window.history.back(-1)
@@ -137,7 +154,33 @@
         _shareUrl += '&sourceUrl=' + encodeURIComponent('')
         _shareUrl += '&sourceUrl=' + encodeURIComponent('')
         _shareUrl += '&content=' + 'utf-8'   // 参数content设置页面编码gb2312|utf-8,可选参数
         _shareUrl += '&content=' + 'utf-8'   // 参数content设置页面编码gb2312|utf-8,可选参数
         _shareUrl += '&pic=' + encodeURIComponent('')  // 参数pic设置图片链接|默认为空,可选参数
         _shareUrl += '&pic=' + encodeURIComponent('')  // 参数pic设置图片链接|默认为空,可选参数
-        window.open(_shareUrl, '_blank', 'width=' + 300 + ',height=' + 300 + ',top=' + 300 + ',left=' + 300 + ',toolbar=no,menubar=no,scrollbars=no, resizable=1,location=no,status=0')
+        window.open(_shareUrl)
+        this.showShare = false
+      },
+      shareWeChat: function () {
+      },
+      shareQQ: function () {
+        let url = encodeURIComponent(document.location)
+        let title = encodeURIComponent(document.title)
+        let source = encodeURIComponent('')
+        let desc = '优软商城'
+        let pics = 'http://dfs.ubtob.com/group1/M00/4F/C3/CgpkyFnxWjOAMy5DAAlh1PrLlc8684.png'
+        window.open('http://connect.qq.com/widget/shareqq/index.html?url=' +
+          url + '&title=' + title + '&source=' + source + '&desc=' + desc + '&pics=' + pics)
+        this.showShare = false
+      },
+      shareMessage: function () {
+      },
+      shareEmail: function () {
+        document.getElementById('share-mail').click()
+      },
+      flash: function () {
+        window.location.reload()
+      },
+      copyLink: function () {
+        let _this = this
+        _this.url = window.location.href
+        _this.clipboard = new Clipboard('#copyLink')
       }
       }
     }
     }
   }
   }
@@ -171,4 +214,7 @@
   .mobile-header i{
   .mobile-header i{
     font-size:.4rem;
     font-size:.4rem;
   }
   }
+  .hide {
+    display: none;
+  }
 </style>
 </style>

+ 0 - 4
components/mobile/brand/ComponentDetail.vue

@@ -108,10 +108,6 @@
       component () {
       component () {
         return this.$store.state.componentDetail.detail.data
         return this.$store.state.componentDetail.detail.data
       },
       },
-//      stores () {
-//        console.log(this.$store.state.componentStore.store.data)
-//        return this.$store.state.componentStore.store.data
-//      },
       storeList () {
       storeList () {
         let storeList = this.$store.state.componentInformation.information.data
         let storeList = this.$store.state.componentInformation.information.data
         let _self = this
         let _self = this

+ 1 - 0
package.json

@@ -8,6 +8,7 @@
     "axios": "^0.15.3",
     "axios": "^0.15.3",
     "bezier-easing": "^2.0.3",
     "bezier-easing": "^2.0.3",
     "bootstrap": "^3.3.7",
     "bootstrap": "^3.3.7",
+    "clipboard": "^1.7.1",
     "cookiejar": "^2.1.1",
     "cookiejar": "^2.1.1",
     "cross-env": "^3.1.4",
     "cross-env": "^3.1.4",
     "element-ui": "^1.3.7",
     "element-ui": "^1.3.7",