Ver código fonte

debug wxshare

huanggang 7 anos atrás
pai
commit
bd21a7b117

+ 1 - 0
src/App.vue

@@ -11,6 +11,7 @@
     import Api from './lib/api'
     export default {
         created(){
+
             let _self = this;
             this.$store.commit('updateLoadingStatus', {isLoading: true});
             this.$http.jsonp(Api.memberInfo(),{_timeout:5000}).then(function (res)

+ 8 - 0
src/components/blocks/block_list.vue

@@ -2,6 +2,7 @@
     import Proxy from './util/proxy.js'
     import BlockUtil from './util/blockUtil.js'
     import {LoadMore} from 'vux'
+    import WechatShare from '../../wechat/WechatShare'
     export default {
         props: ['datasLink', "hot_id", "brand_id", "keyword", "special_id"],
         watch: {
@@ -38,6 +39,13 @@
         },
         created: function () {
             this.getDatas();
+            let shareMsg = {
+                title:'熊猫美妆商城',
+                desc: '熊猫美妆极速商城',
+                link: window.location.host+'/mobile/index.html',
+                img_url:'http://a.lrlz.com/data/upload/shop/store/goods/6/6_05342032688036066_1280.jpg'
+            };
+            let WxShare = new WechatShare(shareMsg)
         },
         beforeDestroy:function(){
             window.removeEventListener('scroll',this.loadMoreCallback);

+ 1 - 1
src/components/blocks/goods_list.vue

@@ -1,5 +1,5 @@
 <template>
-    <div>
+    <div style="margin-top: 2.5%;">
         <titles :special="special"></titles>
         <div class="goods_items">
             <goods-item v-for="goods in special.items" :key="goods" :item="goods" :proxy="proxy"></goods-item>

+ 1 - 1
src/components/blocks/hot_search.vue

@@ -1,5 +1,5 @@
 <template>
-    <div>
+    <div style="margin-top: 2.5%;">
         <titles :special="special"></titles>
         <flexbox class="flex-box" wrap="wrap" :gutter="0">
             <flexbox-item :span="1/4" v-for="item in special.items" :key="item">

+ 8 - 15
src/components/goods/goods_detail.vue

@@ -114,6 +114,7 @@
     import Api from '../../lib/api.js'
     import Proxy from '../blocks/util/proxy.js'
     import WebView from '../blocks/webview.vue'
+    import WechatShare from '../../wechat/WechatShare'
     export default {
         created(){
             this.$store.commit('updateLoadingStatus', {isLoading: true});
@@ -131,14 +132,13 @@
                 this.datas = res.body['datas'];
                 this.summary = res.body['datas'].summary;
                 this.$store.commit('updateLoadingStatus', {isLoading: false});
-
-                this.$store.commit(
-                    'updateWxShareMsg',{
-                        title:'熊猫美妆为您推荐:'+this.getOneSummary['goods_mobile_name'],
-                        desc:'熊猫美妆极速商城',
-                        link:window.location.href,
-                        imgUrl:this.getOneSummary['goods_image_url']
-                    });
+                let shareMsg = {
+                    title:'熊猫美妆为您推荐'+this.getOneSummary['goods_mobile_name'],
+                    desc: '熊猫美妆极速商城',
+                    link: window.location.href,
+                    img_url: this.getOneSummary['goods_image_url']
+                };
+                let WxShare = new WechatShare(shareMsg)
             },(err) => {
                 this.$vux.toast.show({
                 type: 'text',
@@ -151,13 +151,6 @@
                 document.body.scrollTop = 0;
         },
         beforeDestroy(){
-            this.$store.commit(
-                'updateWxShareMsg',{
-                    title:'熊猫美妆测试版',
-                    desc:'熊猫美妆即将上线',
-                    link:window.location.href,
-                    imgUrl:'http://manager.lrlz.com/data/upload/shop/store/goods/6/6_05065318508868273_360.jpg'
-                });
             document.body.removeEventListener('touchmove',this.noscroll,false);
         },
         data () {

+ 1 - 1
src/components/main/discovery/brandList.vue

@@ -12,7 +12,7 @@
                     }
                 ],
                 domProps: {
-                    innerHTML: "发现"
+                    innerHTML: "熊猫美妆"
                 }
             });
             return createElement(BlockList,{

+ 1 - 1
src/components/main/discovery/discovery.vue

@@ -1,6 +1,6 @@
 <template>
     <div>
-        <div v-document_title>发现</div>
+        <div v-document_title>熊猫美妆</div>
         <tab :class="{tab:true}">
             <tab-item :selected="routerPath('/main/discovery')" @on-item-click="onItemClick(0)">品牌</tab-item>
             <tab-item :selected="routerPath('/main/discovery/function')" @on-item-click="onItemClick(1)">功效</tab-item>

+ 9 - 1
src/components/main/mine/mine.vue

@@ -1,6 +1,6 @@
 <template>
     <div class="mine">
-        <div v-document_title>我的</div>
+        <div v-document_title>熊猫美妆</div>
         <group>
             <cell :title="userMsg.userName" :link="loginPath" style="padding: 30px 40px;">
                 <img slot="icon" v-bind:src="userMsg.userImg"
@@ -77,8 +77,16 @@
 <script>
     import {Group, Cell, Flexbox, FlexboxItem, Divider} from 'vux'
     import DefaultImg from '../../../assets/mine_logo_icon.png'
+    import WechatShare from '../../../wechat/WechatShare'
     export default {
         created(){
+            let shareMsg = {
+                title:'熊猫美妆商城',
+                desc: '熊猫美妆极速商城',
+                link: window.location.host+'/mobile/index.html',
+                img_url:'http://a.lrlz.com/data/upload/shop/store/goods/6/6_05342032688036066_1280.jpg'
+            };
+            let WxShare = new WechatShare(shareMsg);
             if (this.$store.state.isLogIn) {
                 this.userName = this.$store.state.user['name'];
                 this.userImg = this.$store.state.user['image'];

+ 9 - 1
src/components/main/shop-car/shopping_cart.vue

@@ -1,6 +1,6 @@
 <template>
     <div class="shopping_cart">
-        <div v-document_title>购物车</div>
+        <div v-document_title>熊猫美妆</div>
         <div class="free_info">
             <group>
                 <cell-box v-for="info in proxy.infos" :key="info"
@@ -83,8 +83,16 @@
     import Api from '../../../lib/api'
     import CarProxy from './CarProxy'
     import Actions from '../../../lib/Actions'
+    import WechatShare from '../../../wechat/WechatShare'
     export default {
         created(){
+            let shareMsg = {
+                title:'熊猫美妆商城',
+                desc: '熊猫美妆极速商城',
+                link: window.location.host+'/mobile/index.html',
+                img_url:'http://a.lrlz.com/data/upload/shop/store/goods/6/6_05342032688036066_1280.jpg'
+            };
+            let WxShare = new WechatShare(shareMsg);
             this.$store.commit('updateLoadingStatus', {isLoading: true});
             this.$http.jsonp(Api.shoppingCart(),{_timeout:5000}).then(function (res) {
                 if (res.body.code != 200) {

+ 1 - 1
src/lib/api.js

@@ -1,7 +1,7 @@
 class Api {
 
     static host() {
-        return "http://p.lrlz.com";
+        return "http://a.lrlz.com";
     }
 
     static special(special_id) {

+ 2 - 13
src/main.js

@@ -41,12 +41,6 @@ const store = new Vuex.Store({
             name:'',
             mobile:'',
             address:''
-        },
-        wechatShareMsg:{
-            title:'熊猫美妆测试版',
-            desc:'熊猫美妆即将上线',
-            link:window.location.host,
-            imgUrl:'http://manager.lrlz.com/data/upload/shop/store/goods/6/6_05065318508868273_360.jpg'
         }
     },
     mutations: {
@@ -73,12 +67,6 @@ const store = new Vuex.Store({
             state.address.mobile = payload.mobile;
             state.address.address = payload.address;
             state.address.aid = payload.aid;
-        },
-        updateWxShareMsg(state,payload){
-            state.wechatShareMsg.title = payload.title;
-            state.wechatShareMsg.desc = payload.desc;
-            state.wechatShareMsg.link = payload.link;
-            state.wechatShareMsg.imgUrl = payload.imgUrl;
         }
     }
 });
@@ -115,6 +103,7 @@ const scrollBehavior = (to, from, savedPosition) => {
     };
 };
 
+
 const router = new VueRouter({
     routes,
     scrollBehavior,
@@ -122,6 +111,7 @@ const router = new VueRouter({
 });
 
 router.beforeEach(function (to, from, next) {
+
     if (to.path.indexOf("schema") !== -1) {
         let schema = base64.decode(to.query.schema);
         let urlObj = CommonUtil.parseURL(schema);
@@ -138,7 +128,6 @@ router.beforeEach(function (to, from, next) {
     }
 });
 
-let Wechat_share = new WechatShare(store.state.wechatShareMsg);
 
 FastClick.attach(document.body);
 

+ 5 - 5
src/wechat/WechatShare.js

@@ -7,7 +7,8 @@ Vue.use(WechatPlugin);
 
 class WechatShare {
 
-    constructor(shareData) {
+    constructor(data) {
+
         this.url = "http://lrlz.sinaapp.com/lrlz?uri=" + encodeURIComponent((window.location.href + "#").substring(0, (window.location.href + "#").indexOf('#'))) + "&callback=";
         this.getJSONP(this.url, function (data) {
             let timestamp = data.timestamp,
@@ -34,9 +35,8 @@ class WechatShare {
                 ]
             });
         });
-        this.ready(shareData);
+        this.ready(data);
     }
-
     getJSONP(url, callback) {
         let cn = "callback" + (+new Date()),
             s = document.createElement("script");
@@ -74,7 +74,7 @@ class WechatShare {
                 title: data.title, // 分享标
                 desc: data.desc,
                 link: data.link,    //cookie读取
-                imgUrl: data.img,// 分享图标
+                imgUrl: data.img_url,// 分享图标
                 trigger: function (res) { 	// 不要尝试在trigger中使用ajax异步请求修改本次分享的内容,因为客户端分享操作是一个同步操作,这时候使用ajax的回包会还没有返回
                 },
                 success: function (res) {
@@ -92,7 +92,7 @@ class WechatShare {
                 title: data.title, // 分享标
                 desc: data.desc,
                 link: data.link,    //cookie读取
-                imgUrl: data.img,// 分享图标
+                imgUrl: data.img_url,// 分享图标
                 trigger: function (res) {
                     // 不要尝试在trigger中使用ajax异步请求修改本次分享的内容,因为客户端分享操作是一个同步操作,这时候使用ajax的回包会还没有返回
                 },