Kaynağa Gözat

[add] wechat share

x 5 yıl önce
ebeveyn
işleme
827447486a
2 değiştirilmiş dosya ile 35 ekleme ve 2 silme
  1. 4 2
      src/views/home/Index.vue
  2. 31 0
      src/views/shop/GoodsCon.vue

+ 4 - 2
src/views/home/Index.vue

@@ -681,6 +681,7 @@ import Loading from "@components/Loading";
 import debounce from "lodash.debounce";
 import { goShopDetail } from "@libs/order";
 import JPush from "@libs/jpush";
+import WeChat from "@libs/pay";
 const HAS_COUPON_WINDOW = "has_coupon_window";
 const LONGITUDE = "user_longitude";
 const LATITUDE = "user_latitude";
@@ -876,6 +877,7 @@ export default {
   },
   mounted: function() {
     JPush.init();
+    WeChat.init();
     this.getFollow();
     this.getHomeData();
     this.getCoupon();
@@ -970,7 +972,7 @@ export default {
           "message",
           function(event) {
             loc = event.data; // 接收位置信息 LONGITUDE
-            console.log("location", loc);
+            // console.log("location", loc);
             if (loc && loc.module == "geolocation") {
               cookie.set(LATITUDE, loc.lat);
               cookie.set(LONGITUDE, loc.lng);
@@ -978,7 +980,7 @@ export default {
               cookie.remove(LATITUDE);
               cookie.remove(LONGITUDE);
               //定位组件在定位失败后,也会触发message, event.data为null
-              console.log("定位失败");
+              // console.log("定位失败");
             }
           },
           false

+ 31 - 0
src/views/shop/GoodsCon.vue

@@ -598,6 +598,7 @@ import ProductWindow from "@components/ProductWindow";
 import StorePoster from "@components/StorePoster";
 import ShareInfo from "@components/ShareInfo";
 import debounce from "lodash.debounce";
+import WeChat from "@libs/pay"
 import { goShopDetail } from "@libs/order";
 import {
   getProductDetail,
@@ -894,6 +895,21 @@ export default {
         this.posters = false;
         console.log("todo wechat friend");
         // todo wechat send to friend
+        
+        var data = this.storeInfo;
+        var message = {
+          title: data.store_name,
+          description: data.store_info,
+          thumb: data.image,
+          media: {
+            type: Wechat.Type.WEBPAGE,
+            webpageUrl: "http://www.shotshock.shop/"
+          }
+        };
+        WeChat.shareLink(message, function(success) {
+          if(success) console.log("share success !");
+          else console.log("share falied !");
+        });
       }
     },
     shareCode: function(value) {
@@ -909,6 +925,21 @@ export default {
       // this.posterImageStatus = !this.posterImageStatus;
       this.posters = false;
       console.log("todo wechat friends");
+      
+      var data = this.storeInfo;
+      var message = {
+        title: data.store_name,
+        description: data.store_info,
+        thumb: data.image,
+        media: {
+          type: Wechat.Type.WEBPAGE,
+          webpageUrl: "http://www.shotshock.shop"
+        }
+      };
+      WeChat.shareLink(message, function(success) {
+        if(success) console.log("share success !");
+        else console.log("share falied !");
+      }, false);
     },
     //产品详情接口;
     productCon: function() {