update code
parent
adfb0eea94
commit
e2eb86a3cf
|
@ -25,7 +25,7 @@ App({
|
|||
globalData: {
|
||||
paramDeptId:'',
|
||||
userProjectId:'',
|
||||
appId: "wxc44b5d588f599758",
|
||||
appId: "wxc44b5d588f599758",
|
||||
// 智慧工地后台接口访问域名
|
||||
// reqUrl:"http://wxw.ngrok.makalu.cc",
|
||||
//reqUrl:'https://jaapplets.makalu.cc',
|
||||
|
@ -95,6 +95,7 @@ App({
|
|||
"appId":"wxc44b5d588f599758",
|
||||
},
|
||||
success:(res)=>{
|
||||
wx.setStorageSync("token","eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImRjYzEwMTI5LWM0Y2ItNDAyMS1iNzEzLTFlOTMzODdmOWEwYyJ9.zpE5EZ7Zz0yj8Z7lJTUUnASBy7wXqVG2eZlxOu7rTHz0oeDyJY8FO5uSkWMwkQvK_Uk3tc9qt5jbtc46BCN1vQ");
|
||||
wx.setStorageSync('openId', res.data.openid)
|
||||
}
|
||||
})
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
function request (url, method, data, header = {}) {
|
||||
wx.showLoading({
|
||||
title: '加载中'
|
||||
})
|
||||
return new Promise((resolve, reject) => {
|
||||
wx.request({
|
||||
url: app.globalData.reqUrl+ url,
|
||||
method: method,
|
||||
data: data,
|
||||
header: {
|
||||
'content-type': 'application/json',
|
||||
'Authorization': 'Bearer '+wx.getStorageSync('cookie').toString(),
|
||||
...header
|
||||
},
|
||||
success: function (res) {
|
||||
wx.hideLoading()
|
||||
resolve(res.data)
|
||||
},
|
||||
fail: function (error) {
|
||||
wx.hideLoading()
|
||||
reject(error)
|
||||
},
|
||||
complete: function () {
|
||||
wx.hideLoading()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
function get (obj) {
|
||||
return request(obj.url, 'GET', obj.data)
|
||||
}
|
||||
function post (obj) {
|
||||
return request(obj.url, 'POST', obj.data)
|
||||
}
|
||||
|
||||
export default {
|
||||
request,
|
||||
get,
|
||||
post
|
||||
}
|
Loading…
Reference in New Issue