wxapi ,分享到朋友圈,分享到给别人

// import wx from 'weixin-js-sdk'
var wx = require('weixin-js-sdk');
// import api from "@/api";
const wxApi = {
  /**
   * [wxRegister 微信Api初始化]
   * @param {Function} callback [ready回调函数]
   */
  wxRegister () {
    $.ajax({
      url:'http://sf-college.szbiu.com/zgame/',
      data: {
        m: 'biu_common',
        a: 'get_share_info',
        nowurl: location.href.split('#')[0]
      },
      withCredentials: true,
      success:function (result) {
        let tmp = JSON.parse(result);
        let jssdk_info = tmp.other_info.jssdkinfo;
        wx.config({
          debug: false,
          appId: jssdk_info.appId,
          timestamp: jssdk_info.timestamp,
          nonceStr: jssdk_info.nonceStr,
          signature: jssdk_info.signature,
          jsApiList: [
            'onMenuShareTimeline',
            'onMenuShareAppMessage',
            'hideMenuItems',
          ]
        });
        wx.ready(
          function () {

            wx.onMenuShareAppMessage({
              title: '南头街道党史学习教育知识竞答',
              desc: '学党史 悟思想 办实事 开新局',
              link:'http://polymers.szbiu.com/nantou_H5/index.html',
              imgUrl: 'http://polymers.szbiu.com/nantou_H5/static/images/wxshare.jpg',
              type: '', // 分享类型,music、video或link,不填默认为link
              dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空
              success: function () {
                // 用户确认分享后执行的回调函数
                // api.post('todayshare').then(response => {
                //   console.log('分享成功的返回',response.data);
                //
                // });
              },
              cancel: function () {
              }
            });
            wx.onMenuShareTimeline({
              title: '南头街道党史学习教育知识竞答',
              desc: '学党史 悟思想 办实事 开新局',
              link:'http://polymers.szbiu.com/nantou_H5/index.html',
              imgUrl: 'http://polymers.szbiu.com/nantou_H5/static/images/wxshare.jpg',
              type: '', // 分享类型,music、video或link,不填默认为link
              dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空
              success: function () {
                // 用户确认分享后执行的回调函数
                // api.post('todayshare').then(response => {
                //   console.log('分享成功的返回',response.data);
                //
                // });
              },
              cancel: function () {
              }
            });
            wx.hideMenuItems({
              menuList: ['menuItem:share:qq', 'menuItem:share:weiboApp', 'menuItem:share:QZone', 'menuItem:copyUrl', 'menuItem:originPage', 'menuItem:openWithQQBrowser', 'menuItem:openWithSafari', 'menuItem:share:email'],
            });
      })
      }});
  }
  /**
   * [ShareTimeline 微信分享到朋友圈]
   * @param {[type]} option [分享信息]
   * @param {[type]} success [成功回调]
   * @param {[type]} error [失败回调]
   */

}
export default wxApi
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值