App({
onLaunch: function () {
//调用API从本地缓存中获取数据
var logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
},
getUserInfo:function(cb){
var that = this
if(this.globalData.userInfo){
typeof cb == "function" && cb(this.globalData.userInfo)
}else{
//调用登录接口
wx.login({
success: function () {
wx.getUserInfo({
success: function (res) {
that.globalData.userInfo = res.userInfo
typeof cb == "function" && cb(that.globalData.userInfo)
}
})
}
})
}
},
globalData:{
userInfo:null
},
/*
* 快递查询
* http://www.kuaidiapi.cn/
* 快递公司编码必填
* 物流单号必填
*/
getExpressInfo:function(cor,num,cb){
var uid = '86640'
var key = '73cea0385e6943d2b4d255011ca950ae'
var order = num
var id = cor
var issign = false
wx.request({
url: 'http://www.kuaidiapi.cn/rest/?uid=' + uid + '&key=' + key + '&order=' + order + '&id=' + id + '&issign=' + issign,
data: {},
method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
// header: {}, // 设置请求的 header
success: function(res){
// success
// console.log(res)
cb && cb(res.data)
},
fail: function(res) {
// fail
},
complete: function(res) {
// complete
}
})
}
})