1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- var wxJssdkMixin = function () {
- return {
- data() {
- return {
- appId: 'wx91c4152b60ca91a3', // 微信公众号appId
- jsApiList: ['updateAppMessageShareData', 'onMenuShareAppMessage', 'updateTimelineShareData', 'onMenuShareTimeline'], // 微信配置可用权限
- }
- },
- methods: {
- setWxConfig(callback) {
- const url = 'https://www.caimei365.com/serviceSettlement.html?id=0'
- SettlementService.getWxConfig({
- appId: this.appId,
- url
- }, (res) => {
- const data = res.data
- const wx = window.wx
- console.log(data)
- if (this.isWeChat()) {
- wx.config({
- debug: true, // dev === 'development' 开启调试模式,调用的所有 api 的返回值会在客户端 alert 出来,若要查看传入的参数,可以在 pc 端打开,参数信息会通过 log 打出,仅在 pc 端时才会打印。
- appId: this.appId, // 必填,公众号的唯一标识
- timestamp: data.timestamp, // 必填,生成签名的时间戳
- nonceStr: data.noncestr, // 必填,生成签名的随机串
- signature: data.signature, // 必填,签名
- jsApiList: this.jsApiList // 必填,需要使用的 JS 接口列表
- })
- callback && callback(wx)
- wx.error(function (err) {
- console.warn(err)
- })
- }
- })
- },
- isWeChat() {
- return /MicroMessenger/i.test(navigator.userAgent);
- },
- setWxReady(wx) {
- console.log('wx', wx)
- wx.ready(function () {
- // wx.onMenuShareAppMessage({
- // title: '采美商城', // 分享标题
- // desc: '采美商城', // 分享描述
- // link: 'https://www.caimei365.com/serviceSettlement.html?id=0', // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
- // imgUrl: 'https://static.caimei365.com/app/img/serviceProvider/H5/search-content-bg.png',
- // success: () => {
- // },
- // fail: () => {
- // window.location.reload();
- // }
- // })
- // wx.onMenuShareTimeline({
- // title: '采美商城', // 分享标题
- // desc: '采美商城', // 分享描述
- // link: 'https://www.caimei365.com/serviceSettlement.html?id=0', // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
- // imgUrl: 'https://static.caimei365.com/app/img/serviceProvider/H5/search-content-bg.png',
- // success: () => {
- // },
- // fail: () => {
- // }
- // })
- wx.updateAppMessageShareData({
- title: '采美商城', // 分享标题
- desc: '采美商城', // 分享描述
- link: 'https://www.caimei365.com/serviceSettlement.html?id=0', // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
- imgUrl: 'https://static.caimei365.com/app/img/serviceProvider/H5/search-content-bg.png',
- success: () => {
- },
- fail: () => {
- }
- })
- wx.updateTimelineShareData({
- title: '采美商城', // 分享标题
- desc: '采美商城', // 分享描述
- link: 'https://www.caimei365.com/serviceSettlement.html?id=0', // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
- imgUrl: 'https://static.caimei365.com/app/img/serviceProvider/H5/search-content-bg.png',
- success: () => {
- },
- fail: () => {
- }
- })
- })
- }
- }
- }
- }()
|