UNPKG

icx-meum-vue-common-module

Version:

icx-meum-vue-common-module

76 lines (69 loc) 2 kB
/** * Created by wangbagang on 2017/5/23. */ import wx from 'weixin-js-sdk' import axios from './http/index' let WX_APPID = '' const getJSsign = () => axios.post('https://weixin.icarbonx.com/getJSsign.do', { appId: WX_APPID, url: window.location.href.split('#')[0] }) export default { wx: wx, setAppId (appId) { WX_APPID = appId }, setWechatShare (title, desc, link, img) { getJSsign().then(res => { wx.config({ debug: false, appId: WX_APPID, timestamp: res.data.timestamp, nonceStr: res.data.noncestr, signature: res.data.signature, jsApiList: [ 'onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'startRecord', 'onVoiceRecordEnd', 'stopRecord', 'playVoice', 'pauseVoice', 'stopVoice', 'uploadVoice', 'translateVoice' ] }) wx.ready(function () { // 微信朋友圈 wx.onMenuShareTimeline({ title: title, link: link, imgUrl: img }) // 微信朋友 wx.onMenuShareAppMessage({ title: title, desc: desc, link: link, imgUrl: img, type: 'link' }) // QQ朋友 wx.onMenuShareQQ({ title: title, desc: desc, link: link, imgUrl: img }) }) }) }, getWechatShareLink (link, params) { return 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' + WX_APPID + '&redirect_uri=https://mainapi.icarbonx.com/wxMpController/oAuth.do?fromUri=' + encodeURIComponent(encodeURIComponent(link)) + '&response_type=code&scope=snsapi_userinfo&state=1#wechat_redirect' }, setWechatShareDefault () { this.setWechatShare('觅我', '数字化健康管理平台', 'https://main.icarbonx.com', 'https://mainvue.icarbonx.com' + require('../assets/images/default_share.png')) } }