|
|
@@ -119,9 +119,117 @@ Page({ |
|
|
|
title: weapNote.carpage.title
|
|
|
|
})
|
|
|
|
});
|
|
|
|
// 登录
|
|
|
|
var scene = decodeURIComponent(options.scene);
|
|
|
|
that.setData({
|
|
|
|
scene: scene
|
|
|
|
});
|
|
|
|
app.getLocation();
|
|
|
|
if (app.globalData.token){}else{
|
|
|
|
that.userLogin()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 用户登录
|
|
|
|
*/
|
|
|
|
userLogin: function () {
|
|
|
|
var that = this;
|
|
|
|
// 登录
|
|
|
|
wx.login({
|
|
|
|
success: ({
|
|
|
|
code
|
|
|
|
}) => {
|
|
|
|
wx.getSystemInfo({
|
|
|
|
success: function (res) {
|
|
|
|
that.setData({
|
|
|
|
systemInfo: JSON.stringify(res)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
var usrdata = {
|
|
|
|
appId: config.weapp.AppId,
|
|
|
|
code: code,
|
|
|
|
sceneAddress: app.globalData.sceneAddress,
|
|
|
|
scene: that.data.scene,
|
|
|
|
systemInfo: that.data.systemInfo
|
|
|
|
};
|
|
|
|
if (app.globalData.locationInfo) {
|
|
|
|
usrdata = {
|
|
|
|
appId: config.weapp.AppId,
|
|
|
|
code: code,
|
|
|
|
sceneAddress: app.globalData.sceneAddress,
|
|
|
|
latitude: "" + app.globalData.locationInfo.latitude,
|
|
|
|
longitude: "" + app.globalData.locationInfo.longitude,
|
|
|
|
scene: that.data.scene,
|
|
|
|
systemInfo: that.data.systemInfo
|
|
|
|
};
|
|
|
|
}
|
|
|
|
Http.post({
|
|
|
|
url: config.api.login,
|
|
|
|
data: usrdata
|
|
|
|
})
|
|
|
|
.then(res => {
|
|
|
|
app.globalData.token = res.data.token;
|
|
|
|
Http.setToken(res.data.token);
|
|
|
|
that.checkUserCarStatus();
|
|
|
|
that.getUserInfo();
|
|
|
|
return Http.post({
|
|
|
|
url: config.api.checkUserStatus,
|
|
|
|
data: {}
|
|
|
|
});
|
|
|
|
})
|
|
|
|
.then(res => {
|
|
|
|
console.log("checkUserStatus:res", res);
|
|
|
|
})
|
|
|
|
.catch(err => {
|
|
|
|
console.log("checkUserStatus:err", err);
|
|
|
|
if (err.code == 11004) {
|
|
|
|
// 用户昵称未授权
|
|
|
|
wx.redirectTo({
|
|
|
|
url: "/pages/getuserinfo/index"
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 检查用户是否有车
|
|
|
|
*/
|
|
|
|
checkUserCarStatus: function () {
|
|
|
|
var that = this;
|
|
|
|
Http.get({
|
|
|
|
url: config.api.userCarCount,
|
|
|
|
data: {}
|
|
|
|
}).then(res => {
|
|
|
|
if (res.data > 0) {
|
|
|
|
// 用户名下有车
|
|
|
|
app.globalData.phone = res.data.phone;
|
|
|
|
app.globalData.supportCar = true;
|
|
|
|
// 共同登录
|
|
|
|
that.userCarLogin();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 获取用户信息
|
|
|
|
*/
|
|
|
|
getUserInfo: function () {
|
|
|
|
// 获取用户信息
|
|
|
|
wx.getSetting({
|
|
|
|
success: res => {
|
|
|
|
if (res.authSetting["scope.userInfo"]) {
|
|
|
|
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
|
|
|
|
wx.getUserInfo({
|
|
|
|
success: res => {
|
|
|
|
// 可以将 res 发送给后台解码出 unionId
|
|
|
|
console.log("getUserInfo", res);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
jumpToAdd: function() {
|
|
|
|
wx.navigateTo({
|
|
|
|
url: `/pages/addPark/addPark?flags=managepalte`
|
|
|
|