Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eightfeet/share-wechat
https://github.com/eightfeet/share-wechat
Last synced: about 5 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/eightfeet/share-wechat
- Owner: eightfeet
- Created: 2017-12-13T08:56:38.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-21T08:28:20.000Z (over 5 years ago)
- Last Synced: 2024-09-28T05:16:21.814Z (about 2 months ago)
- Language: JavaScript
- Size: 66.4 KB
- Stars: 0
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### Install
```sh
npm i share-wechat
```### Validate Usage
```jsx
import wechat, { isWeChat, wechatShare } from 'share-wechat';export default class Home extends Component {
componentDidMount () {
wechat({
appId:"wx131a2112efd76636",
nonceStr:"4eb74bb9-53b7-4eb4-96...",
signature:"c859696a20f6a40e6929...",
timestamp:"1513240727...",
url:"url"
}, {
data : {
title: '分享标题',
desc: '分享描述',
link: '分享链接',
imgUrl: '分享图标',
},
success: {},
cancel: {}
}).then(() => {
console.log('success');
}).catch(() => {
...
});
}render() {
...
}
}```
### Api#### wechat(configs, shareData, url)
属性 | 说明 | 类型 | 默认值
-----|-----|-----|------
| configs | 微信config参数,{ debug, appId, timestamp, nonceStr, signature, jsApiList('默认包含所有分享') } | Object | 必填 |
| shareData | 分享参数,同下面 wechatShare 参数, { data, success, cancel } | Object | 非必填 |
| url | 微信的引入JS文件,默认为 http://res.wx.qq.com/open/js/jweixin-1.0.0.js | string | 非必填 |#### wechatShare(data, success, cancel)
属性 | 说明 | 类型 | 默认值
-----|-----|-----|------
| data | 微信分享设置,{ title, link, imgUrl, desc } | Object | 必填 |
| success | 分享成功回调 | function | 非必填 |
| cancel | 取消分享回调 | function | 非必填 |#### isWeChat()
判断是否微信环境