//包装好的 get 和 post 请求 common包
module.exports = {
get(apiUrl, yes, error) {
my.httpRequest({
url: apiUrl,
header: { 'Content-Type': 'application/json' },
method: 'GET',
success: yes,
fail: error
})
},
post(apiUrl, params, yes, error) {
my.httpRequest({
url: apiUrl,
data: params,
header: { 'Content-Type': 'application/x-www-form-urlencoded' },
method: 'POST',
success: yes,
fail: error
})
}
}
var that=this 一定要!!!
//界面使用
onLoad() {
//!!!this 指向修改
var that=this
//加载时返回用户信息
// contentReq.reportsList()
const http = require('../../common/com')
http.get('http://你自己的apiurl/et_access_token',function(res){
if(res.data){
console.log(res.data)
that.setData({
data:res.data
//你要赋值的data
})
}
},function(err){
console.log('error'+JSON.stringify(err))
})
},
ps:今天又是和bug说byebye的一天!