代码拉取完成,页面将自动刷新
//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,
}
})
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。