Browse Source

海报

feature/feature-compatible
fengchengzhi 7 years ago
parent
commit
9b92294516
3 changed files with 36 additions and 9 deletions
  1. 24
      src/models/wxShare.js
  2. 4
      src/view/home.vue
  3. 17
      src/view/poster.vue

24
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=0 //首页
// /mall/web/share/config?merchantNo=2&source=1 // /mall/web/share/config?merchantNo=2&source=1
// /mall/web/share/config?couponNO=2&source=1 // /mall/web/share/config?couponNO=2&source=1
axios.get(wxconfigApi,{params:params}).then(function(response) { axios.get(wxconfigApi,{params:params}).then(function(response) {
var response = response var response = response
console.log('1111',response)
var jsApiSignConfig = response.data.data.jsApiSignConfig var jsApiSignConfig = response.data.data.jsApiSignConfig
var shareConfig = response.data.data.shareConfig var shareConfig = response.data.data.shareConfig
wx.config({ wx.config({
debug: false, // 开启调试模式,开发时可以开启
debug: true, // 开启调试模式,开发时可以开启
appId: jsApiSignConfig.appId, // 必填,公众号的唯一标识 由接口返回 appId: jsApiSignConfig.appId, // 必填,公众号的唯一标识 由接口返回
timestamp: jsApiSignConfig.timestamp, // 必填,生成签名的时间戳 由接口返回 timestamp: jsApiSignConfig.timestamp, // 必填,生成签名的时间戳 由接口返回
nonceStr: jsApiSignConfig.nonceStr, // 必填,生成签名的随机串 由接口返回 nonceStr: jsApiSignConfig.nonceStr, // 必填,生成签名的随机串 由接口返回
signature: jsApiSignConfig.signature, // 必填,签名 由接口返回 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(() => { wx.ready(() => {
alert(123)
//获取“分享给朋友”按钮点击状态及自定义分享内容接口 //获取“分享给朋友”按钮点击状态及自定义分享内容接口
wx.onMenuShareAppMessage({ // 分享给朋友 wx.onMenuShareAppMessage({ // 分享给朋友
title: shareConfig.title, // 分享标题 title: shareConfig.title, // 分享标题
desc: shareConfig.desc, // 分享描述 desc: shareConfig.desc, // 分享描述
link: shareConfig.url, // 分享链接 默认以当前链接 link: shareConfig.url, // 分享链接 默认以当前链接
imgUrl: shareConfig.img, // 分享图标 imgUrl: shareConfig.img, // 分享图标
success: function(res){
alert(123)
alert(res)
}
}) })
}) })

4
src/view/home.vue

@ -109,7 +109,6 @@
this.getdefaultAddress() this.getdefaultAddress()
}, },
defaultCity (val,old){ defaultCity (val,old){
// console.log(this.merchantNo)
this.wxShare({"merchantNo":this.merchantNo,"source":0,"url":encodeURIComponent(location.href)}) this.wxShare({"merchantNo":this.merchantNo,"source":0,"url":encodeURIComponent(location.href)})
} }
}, },
@ -233,7 +232,8 @@
// //
this.getdefaultAddress() this.getdefaultAddress()
this.getAddress() 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 () { destroyed () {

17
src/view/poster.vue

@ -190,7 +190,7 @@
}, },
change (name) { change (name) {
this.addressValue = name this.addressValue = name
this.getName()
/// this.getName()
}, },
getAddress (){ getAddress (){
homeApi.getAddress().then(res => { homeApi.getAddress().then(res => {
@ -226,6 +226,7 @@
} else { } else {
this.getPoster() this.getPoster()
} }
}, },
// //
createImg (){ createImg (){
@ -234,10 +235,22 @@
} else { } else {
this.createPoster() 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() { mounted() {
this.getNo()
this.getNo()
this.shareWenXin()
} }
}; };
</script> </script>

Loading…
Cancel
Save