1 Star 0 Fork 0

ZhuoZi200/yinzuo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
app.js 5.04 KB
一键复制 编辑 原始数据 按行查看 历史
ZhuoZi200 提交于 2020-04-06 13:25 . 最后修改的版本
//app.js
App({
onLaunch: function() {
// 展示本地存储能力
var logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
// 登录
wx.login({
success: res => {
console.log(res.code,'res.code1111111111')
this.globalData.code = res.code
///
// wx.request({
// url: 'http://39.100.225.244:8080/yinzuo/login',
// menthod:'GET',
// data: {
// code: res.code, //获取登录凭证
// userName: "luohuiduo",
// phone: 1345678998
// },
// success: res => {
// let temp = res.data //res.data即为后端返回的数据
// myThis.globalData.userDetails = temp.data.student
// console.log("request请求成功,返回的数据为:", temp)
// console.log("存储到全局变量中的数据为:", temp.data.student)
// }
// })
///
}
})
// 获取用户信息
wx.getSetting({
success: res => {
if (res.authSetting['scope.userInfo']) {
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
wx.getUserInfo({
success: res => {
// 可以将 res 发送给后台解码出 unionId
var that = this;
var userName = res.userInfo.nickName;
var pic = res.userInfo.avatarUrl;
this.globalData.userInfo = res.userInfo
console.log(res.userInfo.nickName,'res.userInfo')
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
if (this.userInfoReadyCallback) {
this.userInfoReadyCallback(res)
}
console.log(res.userInfo, 'res.userInfo')
wx.request({
url: 'https://www.enjoyyz.com:8443/yinzuo/login',
menthod: 'GET',
data: {
code: that.globalData.code,
userName: userName,
pic: pic
},
success: res => {
console.log(res.data.data);
that.globalData.openid = res.data.data.openid;
that.globalData.userid = res.data.data.userid;
that.globalData.nickName = res.data.data.nickname;
that.globalData.phone = res.data.data.phone;
that.globalData.userType = res.data.data.userType;
that.globalData.platform = res.data.data.platform;
that.globalData.couponExit = res.data.data.couponExit;
console.log(that.globalData.openid,'that.globalData.openid')
console.log(that.globalData.userType, 'that.globalData.userType')
console.log(that.globalData.userid, 'that.globalData.userid')
console.log(that.globalData.platform, 'that.globalData.platform')
console.log(that.globalData.couponExit, 'that.globalData.couponExit')
},
fail: res => {
console.log(res)
console.log('登录失败')
},
})
}
})
}
}
})
},
globalData: {
// wjc parts
userInfo: null,
openid: null,
session_key: null,
currentStatus: null,
courseIndex: null, //课程列表的数组下标
openedid:null,
teachers: [],
teacher:{},
classes: {},
teacherID: null,
classesID: null,
teacherDetail: null,
classeDetail: null,
searchResult:{},
platform:null,
gameChoice:null,
levelCode:null,
levelCode_code:null,
system:null,
courseType:null,
shichang:null,
shichang1:null,
code:null,
openid:null,
userid:null,
userType:null,
platform:null,
paycoupon:null,
couponId:0,
couponId1: null,
couponExit:null,
nickName:null,
phone:null,
teacherid:null,
evaluted:null,
commentData:null,
commentDate:null,
couponusered:0,
}
})
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhuozi200/yinzuo.git
git@gitee.com:zhuozi200/yinzuo.git
zhuozi200
yinzuo
yinzuo
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385