Skip to content

Commit

Permalink
Merge pull request #698 from tracyebo/master
Browse files Browse the repository at this point in the history
#697 提交实验八小程序代码
  • Loading branch information
zengsn authored May 13, 2019
2 parents 451cb1f + 011c855 commit ef29a95
Show file tree
Hide file tree
Showing 18 changed files with 633 additions and 0 deletions.
45 changes: 45 additions & 0 deletions students/1714080903201/小程序/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//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);
// 发送 res.code 到后台换取 openId, sessionKey, unionId

// 获取用户信息
wx.getSetting({
success: res => {
if (res.authSetting['scope.userInfo']) {
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
wx.getUserInfo({
success: res => {
// 可以将 res 发送给后台解码出 unionId
this.globalData.userInfo = res.userInfo
wx.setStorageSync("avatar", res.userInfo.avatarUrl);
wx.setStorageSync("nickname", res.userInfo.nickName);
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
if (this.userInfoReadyCallback) {
this.userInfoReadyCallback(res)
}
}
})
if (this.loginCallback) {
this.loginCallback(res)
}
}
}
})
}
})
},
globalData: {
userInfo: null
}
})
12 changes: 12 additions & 0 deletions students/1714080903201/小程序/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"pages": [
"pages/index/index"
],
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#f8f8f8",
"navigationBarTitleText": "个性签名",
"navigationBarTextStyle": "black"
},
"sitemapLocation": "sitemap.json"
}
14 changes: 14 additions & 0 deletions students/1714080903201/小程序/app.wxss
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**app.wxss**/
.container {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
padding: 200rpx 0;
box-sizing: border-box;
}

page {
background-color: #f8f8f8;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit ef29a95

Please sign in to comment.