Skip to content

Commit

Permalink
add assets
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnyshao committed May 21, 2019
1 parent bc5702f commit fd46106
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 10 deletions.
4 changes: 4 additions & 0 deletions README-zh_CN.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
[English](https://github.com/jonnyshao/wefetch) | 简体中文
## 支持的小程序平台

![WeChat](https://github.com/jonnyshao/wefetch/blob/master/assets/wechat.png) | ![AliPay](https://github.com/jonnyshao/wefetch/blob/master/assets/alipay.png) | ![DingDing](https://github.com/jonnyshao/wefetch/blob/master/assets/dingding.png) | ![Baidu](https://github.com/jonnyshao/wefetch/blob/master/assets/baidu.png) |
--- | --- | --- | --- |
Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ |
# wefetch
[![platform](https://badgen.net/badge/platform/微信,支付宝,百度?list=1&color=green)](https://github.com/jonnyshao/wefetch)
[![install size](https://packagephobia.now.sh/badge?p=wefetch)](https://packagephobia.now.sh/result?p=wefetch)
Expand Down
5 changes: 5 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
English | [简体中文](https://github.com/jonnyshao/wefetch/blob/master/README-zh_CN.md)
## mini program platform Support

![WeChat](https://github.com/jonnyshao/wefetch/blob/master/assets/wechat.png) | ![AliPay](https://github.com/jonnyshao/wefetch/blob/master/assets/alipay.png) | ![DingDing](https://github.com/jonnyshao/wefetch/blob/master/assets/dingding.png) | ![Baidu](https://github.com/jonnyshao/wefetch/blob/master/assets/baidu.png) |
--- | --- | --- | --- |
Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ |

# wefetch

Expand Down
Binary file added assets/alipay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/baidu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dingding.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/mini-program.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/platform_wechat.jpeg
Binary file not shown.
Binary file added assets/wechat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions exmaple/api/requst.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const wf = require('wefetch');

class Request {
constructor() {
this.queue = {};
Expand All @@ -13,7 +12,8 @@ class Request {
}
setInterceptor(instance, url) {
instance.before.use(req => {
req.header.Authorization = 'type in your token';
console.log('request--parmas', req)
req.header.authorization = 'type in your token';
if (Object.keys(this.queue).length === 0) {
const type = req.config.eventType
if (type) {
Expand All @@ -39,7 +39,7 @@ class Request {
if (Object.keys(this.queue).length === 0) {
wx.hideLoading()
}
console.log('instance res', res)
console.log('response', res)
return res;
})
}
Expand Down
2 changes: 2 additions & 0 deletions exmaple/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ App({
// 获取用户信息
wx.getSetting({
success: res => {
console.log(res)
if (res.authSetting['scope.userInfo']) {
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
wx.getUserInfo({
success: res => {
console.log(res)
// 可以将 res 发送给后台解码出 unionId
this.globalData.userInfo = res.userInfo

Expand Down
17 changes: 10 additions & 7 deletions exmaple/pages/index/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ const wf = require('wefetch')

wf.defaults.baseUrl = 'http://localhost:3000'
wf.before.use(req => {
console.log(req)
return req
})
wf.after.use(res => {
console.log(res)
return res
})
wf.postJson('/postJson')
wf.get('/get', { data: { title: '标题' },header:{title: 'this is a title'} })
wf.get('/get', { data: { title: '标题' },header:{title: 'this is a title'},config:{eventType: 'user'} })
//获取应用实例
const app = getApp()

Expand All @@ -28,7 +33,9 @@ Page({
// get({title: 'this is a get request'},{eventType:'get'}).then(() =>{
// console.log('get request')
// })
wf.get('/get',{data:{title: 'title'},config:{eventTyep: 'get'}})
wf.get('/get',{data:{title: 'title'},config:{eventTyep: 'get'},header: {
Authorization: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTAyLCJ1c2VybmFtZSI6IjEzOTE2NzM5OTM4IiwiY29tcGFueSI6MTEsImlhdCI6MTU1Nzg0MTUyOSwiZXhwIjoxNTU4NDQ2MzI5fQ.7JcYLazsriB6PXENOpuVQk-dki7cOIdErPPFYIX6y6U'
}})
},
// post 请求
postRequest(){
Expand Down Expand Up @@ -63,11 +70,7 @@ Page({
console.log('download request')
console.log(res)
})
wf.onProcess('download',res => {
console.log('下载进度', res.progress)
console.log('已经下载的数据长度', res.totalBytesWritten)
console.log('预期需要下载的数据总长度', res.totalBytesExpectedToWrite)
})

},
// retry 请求
retryRequest(){
Expand Down

0 comments on commit fd46106

Please sign in to comment.