1 Star 0 Fork 103

AI / 租车小程序前端

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
app.js 3.08 KB
一键复制 编辑 原始数据 按行查看 历史
shensi88 提交于 2018-06-09 15:02 . 加入门店、门店定位
var aldstat=require("./utils/ald-stat.js");
//app.js
App({
onLaunch: function () {
var that = this;
wx.login({
success: function (res) {
if (res.code) {
var url = that.globalData.siteRoot + "/Mpa/Weixinopen/OnLogin";
//发起网络请求;
//发起网络请求
wx.request({
url: url,
method:"POST",
data: {
code: res.code
},
success: function (json) {
console.log(json);
if(json.statusCode!=200){
console.log("请求出错");
that.aldstat.sendEvent('请求出错',{
"url":url,
"message":json
});
return;
}
var result = json.data.result;
if (result.success) {
wx.setStorageSync('sessionId', result.sessionId);
console.log('sessionId=>', wx.getStorageSync('sessionId'));
console.log('userId=>',result.userId);
//有userId,就可以获取用户信息
if(result.userId){
url = that.globalData.siteRoot + "/api/services/app/weixinUser/GetWeixinUserByIdToMiniAsync";
wx.request({
url:url,
method:"POST",
data:{
id:result.userId
},
success:function(json){
console.log("用户信息=>",json);
if (json.statusCode != 200) {
console.log("请求出错");
that.aldstat.sendEvent('请求出错', {
"url": url,
"message": json
});
return;
}
that.globalData.userInfo=json.data.result;
}
})
}
}
}
})
} else {
console.log('登录失败!' + res.errMsg)
}
}
});
},
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,
//siteRoot:"https://das.mynatapp.cc",
siteRoot: "https://zuche.shensigzs.com",
//pickerDateObj: null,//取车信息
//returnDateObj: null,//还车信息
//pickerTimeObj: null,//取车信息
//returnTimeObj: null,//还车信息
day: null,
//pickUpStore: null,
//returnStore: null,
phoneNumber:null,
pickUpCar:null,//以后都使用这个
returnCar:null//以后都使用这个
}
})
JavaScript
1
https://gitee.com/xiaoyangge/zuchemini.git
git@gitee.com:xiaoyangge/zuchemini.git
xiaoyangge
zuchemini
租车小程序前端
master

搜索帮助