diff --git a/src/models/wxShare.js b/src/models/wxShare.js index 3c5c08d..d877c50 100644 --- a/src/models/wxShare.js +++ b/src/models/wxShare.js @@ -35,31 +35,45 @@ Vue.prototype.wxShare = function(params) { // /mall/web/share/config?merchantNo=2&source=0 //首页 // /mall/web/share/config?merchantNo=2&source=1 // /mall/web/share/config?couponNO=2&source=1 - axios.get(wxconfigApi,{params:params}).then(function(response) { + var response = response + console.log('1111',response) var jsApiSignConfig = response.data.data.jsApiSignConfig var shareConfig = response.data.data.shareConfig wx.config({ - debug: false, // 开启调试模式,开发时可以开启 + debug: true, // 开启调试模式,开发时可以开启 appId: jsApiSignConfig.appId, // 必填,公众号的唯一标识 由接口返回 timestamp: jsApiSignConfig.timestamp, // 必填,生成签名的时间戳 由接口返回 nonceStr: jsApiSignConfig.nonceStr, // 必填,生成签名的随机串 由接口返回 signature: jsApiSignConfig.signature, // 必填,签名 由接口返回 - jsApiList: response.data.data.jsApiList + jsApiList: ['onMenuShareAppMessage'] }) - console.log('jsApiSignConfig',jsApiSignConfig) - console.log('shareConfig',shareConfig) + console.log("appId",jsApiSignConfig.appId) + console.log('timestamp',jsApiSignConfig.timestamp) + console.log('nonceStr',jsApiSignConfig.nonceStr) + console.log('signature',jsApiSignConfig.signature) + console.log('jsApiList',response.data.data.jsApiList) + + console.log('title',shareConfig.title) + console.log('desc',shareConfig.desc) + console.log('url',encodeURIComponent(shareConfig.url)) + console.log('img',shareConfig.img) wx.ready(() => { + alert(123) //获取“分享给朋友”按钮点击状态及自定义分享内容接口 wx.onMenuShareAppMessage({ // 分享给朋友 title: shareConfig.title, // 分享标题 desc: shareConfig.desc, // 分享描述 link: shareConfig.url, // 分享链接 默认以当前链接 imgUrl: shareConfig.img, // 分享图标 + success: function(res){ + alert(123) + alert(res) + } }) }) diff --git a/src/view/home.vue b/src/view/home.vue index 78cb8cd..b4331e3 100644 --- a/src/view/home.vue +++ b/src/view/home.vue @@ -109,7 +109,6 @@ this.getdefaultAddress() }, defaultCity (val,old){ - // console.log(this.merchantNo) this.wxShare({"merchantNo":this.merchantNo,"source":0,"url":encodeURIComponent(location.href)}) } }, @@ -233,7 +232,8 @@ //异步加载 this.getdefaultAddress() this.getAddress() - this.wxShare({"merchantNo":this.merchantNo,"source":0,"url":encodeURIComponent(location.href)}) + this.wxShare({"merchantNo":2,"source":0,"url":encodeURIComponent(location.href)}) + // console.log('url',encodeURIComponent(location.href)) }, destroyed () { diff --git a/src/view/poster.vue b/src/view/poster.vue index d48ef67..d503425 100644 --- a/src/view/poster.vue +++ b/src/view/poster.vue @@ -190,7 +190,7 @@ }, change (name) { this.addressValue = name - this.getName() + /// this.getName() }, getAddress (){ homeApi.getAddress().then(res => { @@ -226,6 +226,7 @@ } else { this.getPoster() } + }, //点击生成海报按钮 createImg (){ @@ -234,10 +235,22 @@ } else { this.createPoster() } + this.shareWenXin() + }, + //分享微信 + shareWenXin (){ + var merchantNo = this.getParam("merchantNo") + if ( merchantNo ){ + this.wxShare({"merchantNo":merchantNo,"source":1,"url":encodeURIComponent(location.href)}) + } else { + var coupon = this.getParam("no") + this.wxShare({"coupon":coupon,"source":1,"url":encodeURIComponent(location.href)}) + } } }, mounted() { - this.getNo() + this.getNo() + this.shareWenXin() } };