|
|
|
@ -3,6 +3,7 @@ import Vue from 'vue' |
|
|
|
import wx from 'weixin-js-sdk' |
|
|
|
import axios from 'axios' |
|
|
|
import utilsModel from './utils-model' |
|
|
|
import wxShareApi from '../api/wxShare' |
|
|
|
//微信分享功能
|
|
|
|
|
|
|
|
//Vue.prototype.wxShareL = function(link,params) {
|
|
|
|
@ -13,28 +14,12 @@ import utilsModel from './utils-model' |
|
|
|
//// .request({
|
|
|
|
//// params : params,
|
|
|
|
//// }),
|
|
|
|
// var getNews = function(params) =>
|
|
|
|
// utilsModel
|
|
|
|
// .config({
|
|
|
|
// method: 'GET',
|
|
|
|
// url: '/mall/web/share/config',
|
|
|
|
// })
|
|
|
|
// .request({
|
|
|
|
// params : params,
|
|
|
|
// })
|
|
|
|
// getNews(params).then(res => {
|
|
|
|
// console.log(res)
|
|
|
|
// })
|
|
|
|
//
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
Vue.prototype.wxShare = function(params) { |
|
|
|
//var params = params || {}
|
|
|
|
var wxconfigApi = 'http://1hjz.3ncto.com.cn/mall/web/share/config'; |
|
|
|
console.log(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 |
|
|
|
@ -48,20 +33,9 @@ Vue.prototype.wxShare = function(params) { |
|
|
|
timestamp: jsApiSignConfig.timestamp, // 必填,生成签名的时间戳 由接口返回
|
|
|
|
nonceStr: jsApiSignConfig.nonceStr, // 必填,生成签名的随机串 由接口返回
|
|
|
|
signature: jsApiSignConfig.signature, // 必填,签名 由接口返回
|
|
|
|
jsApiList: ['onMenuShareAppMessage'] |
|
|
|
jsApiList: ['onMenuShareAppMessage','onMenuShareTimeline','onMenuShareQQ','onMenuShareWeibo','onMenuShareQZone'] |
|
|
|
}) |
|
|
|
// 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.onMenuShareAppMessage({ // 分享给朋友
|
|
|
|
@ -72,7 +46,47 @@ Vue.prototype.wxShare = function(params) { |
|
|
|
success: function(res){ |
|
|
|
} |
|
|
|
}) |
|
|
|
//转发到朋友圈
|
|
|
|
wx.onMenuShareTimeline({ |
|
|
|
title: shareConfig.title, // 分享标题
|
|
|
|
desc: shareConfig.desc, // 分享描述
|
|
|
|
link: shareConfig.url, // 分享链接 默认以当前链接
|
|
|
|
imgUrl: shareConfig.img, // 分享图标
|
|
|
|
success: function(res){ |
|
|
|
} |
|
|
|
}); |
|
|
|
//微信分享qq
|
|
|
|
wx.onMenuShareQQ({ |
|
|
|
title: shareConfig.title, // 分享标题
|
|
|
|
desc: shareConfig.desc, // 分享描述
|
|
|
|
link: shareConfig.url, // 分享链接 默认以当前链接
|
|
|
|
imgUrl: shareConfig.img, // 分享图标
|
|
|
|
success: function(res){ |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
//获取“分享到腾讯微博”按钮点击状态及自定义分享内容接口
|
|
|
|
wx.onMenuShareWeibo({ |
|
|
|
title: shareConfig.title, // 分享标题
|
|
|
|
desc: shareConfig.desc, // 分享描述
|
|
|
|
link: shareConfig.url, // 分享链接 默认以当前链接
|
|
|
|
imgUrl: shareConfig.img, // 分享图标
|
|
|
|
success: function(res){ |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
//获取“分享到QQ空间”按钮点击状态及自定义分享内容接口(即将废弃)
|
|
|
|
wx.onMenuShareQZone({ |
|
|
|
title: shareConfig.title, // 分享标题
|
|
|
|
desc: shareConfig.desc, // 分享描述
|
|
|
|
link: shareConfig.url, // 分享链接 默认以当前链接
|
|
|
|
imgUrl: shareConfig.img, // 分享图标
|
|
|
|
success: function(res){ |
|
|
|
} |
|
|
|
}); |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|