# egg-weapp-sdk
[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Test coverage][codecov-image]][codecov-url]
[![David deps][david-image]][david-url]
[![Known Vulnerabilities][snyk-image]][snyk-url]
[![npm download][download-image]][download-url]
[npm-image]: https://img.shields.io/npm/v/egg-weapp-sdk.svg?style=flat-square
[npm-url]: https://npmjs.org/package/egg-weapp-sdk
[travis-image]: https://img.shields.io/travis/eggjs/egg-weapp-sdk.svg?style=flat-square
[travis-url]: https://travis-ci.org/eggjs/egg-weapp-sdk
[codecov-image]: https://img.shields.io/codecov/c/github/eggjs/egg-weapp-sdk.svg?style=flat-square
[codecov-url]: https://codecov.io/github/eggjs/egg-weapp-sdk?branch=master
[david-image]: https://img.shields.io/david/eggjs/egg-weapp-sdk.svg?style=flat-square
[david-url]: https://david-dm.org/eggjs/egg-weapp-sdk
[snyk-image]: https://snyk.io/test/npm/egg-weapp-sdk/badge.svg?style=flat-square
[snyk-url]: https://snyk.io/test/npm/egg-weapp-sdk
[download-image]: https://img.shields.io/npm/dm/egg-weapp-sdk.svg?style=flat-square
[download-url]: https://npmjs.org/package/egg-weapp-sdk
可移步[中文文档](README.zh_CN.md)
## Dependencies
- egg-redis
- [qcloud-weapp-client-sdk](https://github.com/tencentyun/weapp-client-sdk) for Weapp Client
Egg-weapp-sdk should be interacted with qcloud-weapp-client-sdk in Weapp Client
## Demo
> [egg-24time](https://github.com/seasonstar/egg-24time)
Server [Egg,Mysql,Redis, ES6]
> [weapp-24time](https://github.com/seasonstar/weapp-24time)
Weapp Client
## Install
```bash
$ npm i egg-weapp-sdk --save
```
## Usage
```js
// {app_root}/config/plugin.js
exports.redis = {
enable: true,
package: 'egg-redis',
};
exports.weappSDK = {
enable: true,
package: 'egg-weapp-sdk',
};
```
## Configuration
```js
// {app_root}/config/config.default.js
module.exports = appInfo => {
const config = {};
config.redis = {
client: {
host: '127.0.0.1',
port: '6379',
password: '',
db: '0',
},
};
// replace your appId and appSecret of WEAPP
config.weappSDK = {
appId: 'xxxxxxxxxxx',
appSecret: 'xxxxxxxxxxxxxxxxxx',
};
return config;
};
```
- Why and What: Manage weapp user session independently, use Redis to store session.
see [config/config.default.js](config/config.default.js) for more detail.
- Two methods:
1. Login: loginService.login()
2. Check: loginService.check()
## Example
<!-- example here -->
```js
// app/controller/weapp.js
module.exports = app => {
class WeappController extends app.Controller {
* login() {
const { ctx, app } = this;
const loginService = app.weapp.LoginService.create(ctx.request, ctx.response);
yield loginService.login()
.then(data => {
ctx.body = data;
});
}
* user() {
const { ctx, app } = this;
const loginService = app.weapp.LoginService.create(ctx.request, ctx.response);
yield loginService.check()
.then(data => {
ctx.body = {
code: 0,
message: 'ok',
data: {
userInfo: data.userInfo,
},
};
});
}
}
return WeappController;
};
```
## Credits && Inspiration
[腾讯云微信小程序客户端 SDK](https://github.com/tencentyun/weapp-client-sdk)
## Questions & Suggestions
Please open an issue [here](https://github.com/eggjs/egg/issues).
## License
[MIT](LICENSE)
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Egg的微信小程序登录会话管理SDK.zip (25个子文件)
open_weixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxcxxxxxxxxxxxxcxvcvcv
.eslintrc 37B
lib
helper
WXBizDataCrypt.js 899B
jscode2session.js 1KB
uuid.js 157B
service-base.js 461B
config.js 705B
index.js 178B
auth
login-service-error.js 200B
login-service.js 3KB
constants.js 509B
auth-api.js 1KB
auth-api-error.js 190B
agent.js 101B
.autod.conf.js 340B
.travis.yml 170B
app.js 351B
LICENSE 1KB
package.json 1KB
.vimrc 32B
README.zh_CN.md 4KB
.gitignore 72B
.eslintignore 23B
appveyor.yml 265B
README.md 3KB
config
config.default.js 183B
共 25 条
- 1
资源评论
极致人生-010
- 粉丝: 2906
- 资源: 2822
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功