npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wechat-js-123

v0.0.5

Published

from sofish modify by https://github.com/WLHB/js

Downloads

5

Readme

重要提示:

目前,新版的微信 js 出来了,你可能暂时不需要这个版本了。详情见:微信 JSSDK 说明。这个版本非常强大,可以传图图片、语音,同时也有更高的要求,需要签名。


wechat.js

微信打开 DEMO 地址:http://sofish.github.io/wechat.js,或者扫一扫下面的二维码进行分享:

sofish/wechat.js

安装

使用 bower 管理 wechat.js 的依赖:

$ bower install wechat.js --save

更新 wechat.js 依赖版本:

$ bower update

下面是 API 详解,使用可参考上面 DEMO 的源代码。微信的 API 是有点恶心的,也不断在变,如果发现问题请给提 issue 或者 pull-request 吧。

1、使用指南

一、唯一接口:wechat,有「分享」+ 「操作」两种类型

// 分享
wechat('friend', data, callback);           // 朋友
wechat('timeline', data, callback);         // 朋友圈
wechat('weibo', data, callback);            // 微博
wechat('email', data, callback);            // 邮件分享

// 操作
wechat('hideToolbar', callback);            // 隐藏底部菜单
wechat('hideOptionMenu', callback);         // 隐藏右上角分享按钮
wechat('showOptionMenu', callback);         // 显示右上角分享按钮
wechat('closeWebView');                     // 关闭webview
wechat('scanQRCode');                       // 跳转到扫描二维码页面
wechat('imagePreview', imgData, callback);  // 图片预览/查看大图
// imgData = {
//   current: 'picture1.jpg',               // 要预览的当前张url
//   urls: ['picture1.jpg', 'picture2.jpg'] // 所有图片的url列表
// }

wechat('network', callback);                // 查看用户当前网络
// 1. wifi
// 2. edge 非 wifi,包含 3G/2G
// 3. fail 网络断开连接
// 4. wwan 2g/3g

二、data 「属性」支持函数

因为有些数据是需要拼接,或者在点击分享按钮的时候可能才存在的,但是又不想写很麻烦时机判断,这里 data 中支持传入函数,比如:

// 一般的数据
var data = {
  'app': 'APP ID',    // 选填,默认为空
  'img': '图片 URL',   // 选填,默认为空或者当前页面第一张图片
  'link': '链接',
  'desc': '描述',
  'title': '标题'
};

// 假设我们在一个单页应用,title 可能是 js 在数据载入后才有的,那么可以这样来:
var getTitle = function() {
  return document.title;
};

// 这个数据 ,最终 wechat.js 会自动转换
var data = {
  // 这里需要特别说明的是,建议不要用新浪微博的图片地址,要么你试试,哈哈
  'img': '图片 URL',
  
  'link': '链接',
  'desc': '描述',
  'title': getTitle()
};

// 发送邮件
var data = {
    title: "邮件标题",
    content: "邮件内容"
};

三、回调

var callback = function() {
  // 返回的数据并不统一,接口已经尽量统一,我觉得微信公司现在缺 js 程序员
  // 也有一些是很恶心的
  console && console.log(argument);
};

wechat('timeline', data, callback);

2、授权

MIT License