Skip to content

Commit

Permalink
fetch修改为普通wx.request
Browse files Browse the repository at this point in the history
  • Loading branch information
liujians committed Jan 5, 2017
1 parent 9cd00a4 commit 2efc7e0
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 56 deletions.
4 changes: 2 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ App({
},
globalData:{
userInfo:null,
ip:"http://"+"192.168.1.110"+":8022",
wsip:"ws://"+"192.168.1.110"+":8022"
ip:"http://"+"192.168.165.11"+":8022",
wsip:"ws://"+"192.168.165.11"+":8022"
}
})
108 changes: 54 additions & 54 deletions utils/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,68 +36,68 @@ function getUser(obj){
obj.setData({
hidden: false
})
fetch(app.globalData.ip+'/getUser.php')
.then(
function(response) {
if (response.status !== 200) {
console.log('错误码: ' +
response.status);
return;
}
console.log(response)
// Examine the text in the response
response.json().then(function(data) {
console.log(data);
// fetch(app.globalData.ip+'/getUser.php')
// .then(
// function(response) {
// if (response.status !== 200) {
// console.log('错误码: ' +
// response.status);
// return;
// }
// console.log(response)
// // Examine the text in the response
// response.json().then(function(data) {
// console.log(data);
// setTimeout(function(){
// obj.setData({
// list:data,
// hidden: true,
// toast1Hidden:false,
// toastText:"拿到数据"
// })
// wx.stopPullDownRefresh()
// },3000)
// });
// }
// )
// .catch(function(err) {
// obj.setData({
// hidden: true
// })
// console.log('Fetch Error :-S', err);
// });

wx.request({
url: app.globalData.ip+'/getUser.php',
data: {},
header: {
'Content-Type': 'application/json'
},
success: function(res) {
setTimeout(function(){
obj.setData({
list:data,
list:res.data,
hidden: true,
toast1Hidden:false,
toastText:"拿到数据"
})
wx.stopPullDownRefresh()
},3000)
});
}
)
.catch(function(err) {
obj.setData({
hidden: true
})
console.log('Fetch Error :-S', err);
});

// wx.request({
// url: app.globalData.ip+'/getUser.php',
// data: {},
// header: {
// 'Content-Type': 'application/json'
// },
// success: function(res) {
// setTimeout(function(){
// obj.setData({
// list:res.data,
// hidden: true,
// toast1Hidden:false,
// toastText:"拿到数据"
// })
// wx.stopPullDownRefresh()
// },3000)
},3000)

// },
// fail:function(err){
// setTimeout(function(){
// obj.setData({
// list:res.data,
// hidden: true,
// toast1Hidden:false,
// toastText:"请检查server"
// })
// wx.stopPullDownRefresh()
// },3000)
// console.log(err);
// }
// })
},
fail:function(err){
setTimeout(function(){
obj.setData({
list:res.data,
hidden: true,
toast1Hidden:false,
toastText:"请检查server"
})
wx.stopPullDownRefresh()
},3000)
console.log(err);
}
})
}
function getMoments(obj){
wx.request({
Expand Down

0 comments on commit 2efc7e0

Please sign in to comment.