Skip to content

Commit

Permalink
hzuapps#2 hzuapps#19 第2次实验代码(修改版)
Browse files Browse the repository at this point in the history
  • Loading branch information
panxiaomian committed Nov 5, 2017
1 parent 9c7121a commit 40ff3ee
Show file tree
Hide file tree
Showing 6 changed files with 864 additions and 130 deletions.
57 changes: 23 additions & 34 deletions 1514080901223/app.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,28 @@
//app.js
App({
onLaunch: function () {
// 展示本地存储能力
var logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)

// 登录
wx.login({
success: 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
import {log, promiseHandle} from 'utils/util';

// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
if (this.userInfoReadyCallback) {
this.userInfoReadyCallback(res)
}
}
})
}
}
})
App({
getUserInfo(cb) {
if (typeof cb !== "function") return;
let that = this;
if (that.globalData.userInfo) {
cb(that.globalData.userInfo);
} else {
promiseHandle(wx.login).then(() => promiseHandle(wx.getUserInfo)).then(res => {
that.globalData.userInfo = res.userInfo;
cb(that.globalData.userInfo);
}).catch(err => {
log(err);
});
}
},

globalData: {
userInfo: null
},

//自定义配置
settings: {
debug: true, //是否调试模式
moreLink: 'http://github.com/oopsguy'
}
})
});
8 changes: 4 additions & 4 deletions 1514080901223/app.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"pages":[
"pages/index/index",
"pages/logs/logs"
"pages/detail/detail"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "WeChat",
"navigationBarTextStyle":"black"
"navigationBarBackgroundColor": "#E14848",
"navigationBarTitleText": "事项助手",
"navigationBarTextStyle":"white"
}
}
79 changes: 69 additions & 10 deletions 1514080901223/app.wxss
Original file line number Diff line number Diff line change
@@ -1,10 +1,69 @@
/**app.wxss**/
.container {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
padding: 200rpx 0;
box-sizing: border-box;
}
@import 'style/weui.wxss';
page {
font-family: 'microsoft yahei ui';
font-size: 28rpx;
background-color: #1D1D26;
color: #FFF;
}

/*float action*/
.float-container {
position: fixed;
bottom: 40rpx;
right: 40rpx;
overflow: hidden;
}
.float-action {
width: 100rpx;
height: 100rpx;
border-radius: 50%;
box-shadow: 2px 2px 10px rgba(0, 0, 0, .5);
background: #E14848;
z-index: 100;
text-align: center;
opacity: .5;
margin-left: 40rpx;
float: right;
}
.float-action:active {
opacity: 1
}
.float-action image {
width: 60rpx;
height: 60rpx;
margin-top: 20rpx;
}

.bg-normal {
background: #46BC62 !important;
}
.bg-warning {
background: #ECAA5B !important;
}
.bg-danger {
background: #E14848 !important;
}

.color-primary {
color: #46BC62 !important;
}
.color-warning {
color: #ECAA5B !important;
}
.color-danger {
color: #E14848 !important;
}

.border-normal {
border: 2rpx solid #46BC62 !important;
}
.border-warning {
border: 2rpx solid #ECAA5B !important;
}
.border-danger {
border: 2rpx solid #E14848 !important;
}

.text-center {
text-align: center !important;
}
Loading

0 comments on commit 40ff3ee

Please sign in to comment.