Commit aef6745e authored by xwq's avatar xwq

log

parent f4dc5257
......@@ -9,6 +9,41 @@ Page({
*/
data: {
},
successCallBack:function(res4){
const data = res4.data;
wx.setStorageSync('user', data)
wx.setStorageSync('user_token', data.token)
log.info(res4,"---------getUserInfo=success")
// Jade.UserManager.setUser(data)
// Jade.UserManager.setToken(data.token)
Jade.UserManager.authRequest({
url: Jade.getUrl("babies.json"),
success: (result) => {
if (typeof result.data === "object") {
wx.setStorageSync('baby', result.data)
} else {
wx.setStorageSync('baby', null)
}
log.info(result,"---------authRequest=success")
wx.redirectTo({
url: '/pages/takePhoto/takePhoto',
})
// if (options && options.success) {
// options.success(result)
// }
},
fail: err => {
wx.showToast({
title: '获取信息失败',
icon: 'none',
duration:2000
})
// if (options && options.success) {
// options.success(result)
// }
}
})
},
goIndex(){
// wx.setStorageSync('user', data)
......@@ -26,78 +61,121 @@ Page({
if (res1.confirm) {
wx.login({
success: res2 => {
console.log(res2);
log.info(res2,"---------登录")
// console.log(res,"---------登录");
var code = res2.code
wx.getUserInfo({
withCredentials: true,
success: res => {
log.info(res,"---------getUserInfo")
// console.log('getUserInfo')
wx.request({
url: Jade.getUrl("users/sign_in.json"),
method: 'POST',
data: {
code: code,
user_info: res.userInfo,
encrypted_data: res.encryptedData,
iv: res.iv
},
success: res4 => {
const data = res4.data;
wx.setStorageSync('user', data)
wx.setStorageSync('user_token', data.token)
log.info(res4,"---------getUserInfo=success")
// Jade.UserManager.setUser(data)
// Jade.UserManager.setToken(data.token)
Jade.UserManager.authRequest({
url: Jade.getUrl("babies.json"),
success: (result) => {
if (typeof result.data === "object") {
wx.setStorageSync('baby', result.data)
} else {
wx.setStorageSync('baby', null)
wx.request({
url: Jade.getUrl("users/sign_in.json"),
method: 'POST',
data: {
code: res2.code,
},
success: res4 => {
const data = res4.data;
wx.setStorageSync('user', data)
wx.setStorageSync('user_token', data.token)
log.info(res4,"---------getUserInfo=success")
// Jade.UserManager.setUser(data)
// Jade.UserManager.setToken(data.token)
Jade.UserManager.authRequest({
url: Jade.getUrl("babies.json"),
success: (result) => {
if (typeof result.data === "object") {
wx.setStorageSync('baby', result.data)
} else {
wx.setStorageSync('baby', null)
}
log.info(result,"---------authRequest=success")
wx.redirectTo({
url: '/pages/takePhoto/takePhoto',
})
},
fail: err => {
wx.showToast({
title: '获取信息失败',
icon: 'none',
duration:2000
})
// if (options && options.success) {
// options.success(result)
// }
}
log.info(result,"---------authRequest=success")
wx.redirectTo({
url: '/pages/takePhoto/takePhoto',
})
// if (options && options.success) {
// options.success(result)
// }
},
fail: err => {
wx.showToast({
title: '获取信息失败',
icon: 'none',
duration:2000
})
// if (options && options.success) {
// options.success(result)
// }
}
})
}
})
},
fail: err => {
log.error(err,"---------登录-fail")
wx.showToast({
title: '登录失败',
icon: 'none',
duration:2000,
complete:function(){
wx.redirectTo({
url: '/pages/photo/photo',
})
}
})
// wx.redirectTo({
// url: '/pages/photo/photo',
// })
// wx.onLoad()
}
})
})
}
})
// console.log(res,"---------登录");
// var code = res2.code
// if(wx.getUserProfile){
// wx.getUserProfile({
// // withCredentials: true,
// success: res => {
// log.info(res,"---------getUserInfo")
// console.log('getUserInfo',res)
// wx.request({
// url: Jade.getUrl("users/sign_in.json"),
// method: 'POST',
// data: {
// code: code,
// user_info: res.userInfo,
// encrypted_data: res.encryptedData,
// iv: res.iv
// },
// success: res4 => {
// this.successCallBack(res4)
// }
// })
// },
// fail: err => {
// console.log(err);
// log.error(err,"---------登录-fail")
// wx.showToast({
// title: '登录失败fail',
// icon: 'none',
// duration:2000,
// complete:function(){
// wx.redirectTo({
// url: '/pages/photo/photo',
// })
// }
// })
// }
// })
// }else{
// wx.getUserInfo({
// withCredentials: true,
// success: res => {
// log.info(res,"---------getUserInfo")
// console.log('getUserInfo',res)
// wx.request({
// url: Jade.getUrl("users/sign_in.json"),
// method: 'POST',
// data: {
// code: code,
// user_info: res.userInfo,
// encrypted_data: res.encryptedData,
// iv: res.iv
// },
// success: res4 => {
// this.successCallBack(res4)
// }
// })
// },
// fail: err => {
// log.error(err,"---------登录-fail")
// wx.showToast({
// title: '登录失败',
// icon: 'none',
// duration:2000,
// complete:function(){
// wx.redirectTo({
// url: '/pages/photo/photo',
// })
// }
// })
// }
// })
// }
}
})
} else if (res1.cancel) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment