xcx/app.js
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
//app.js
App({
onLaunch: function() {
//默认获取微信openid
this.getOpendId(function(data) {
if (data) {
console.log("app-openid加载=" + data)
}
});
// this.refresh();
},
//获取微信openid接口
getOpendId: function(callback) {
var that = this;
wx.login({
success: res => {
wx.request({
url: that.globalData.apiUrl,
data: {
code: res.code,
action: 'getXcxLogin'
},
header: {
'content-type': 'application/json',
'Cookie': wx.getStorageSync('sessionId'),
},
success: function(resOpendId) {
if (resOpendId.data.status == 1) {
wx.setStorageSync('sessionId', 'ASP.NET_SessionId=' +resOpendId.data.sessionId);
that.globalData.openid = resOpendId.data.data.openid;
callback(resOpendId.data.data.openid)
}
}
})
}
});
},
//定时任务,每隔二十分钟刷新session
refresh: function() {
var that = this;
setInterval(that.getOpendId, 20 * 60 * 1000);
},
//是否登录
isLogin: function(callback) {
var userId = wx.getStorageSync('userId');
if (wx.getStorageSync('userId')) {
callback(userId)
} else {
wx.redirectTo({
url: '/pages/login/login'
});
callback(userId)
}
},
//根据openid获取用户信息接口
getUserByOpenId: function(callback) {
var that = this;
wx.request({
url: that.globalData.apiUrl,
后面还有 31 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。
