-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #533 from hhhhjq/master
- Loading branch information
Showing
3 changed files
with
40 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,23 @@ | ||
//index.js | ||
//获取应用实例 | ||
const app = getApp() | ||
|
||
Page({ | ||
Page({ | ||
data: { | ||
motto: 'Hello HZU', | ||
userInfo: {}, | ||
hasUserInfo: false, | ||
textColor: 'red', | ||
textClass: 'description', | ||
showScroll: true, | ||
canIUse: wx.canIUse('button.open-type.getUserInfo') | ||
}, | ||
//事件处理函数 | ||
bindViewTap: function() { | ||
console.dir('bindViewTap') | ||
wx.navigateTo({ | ||
url: '../logs/logs' | ||
}) | ||
}, | ||
changeColor: function() { | ||
//console.log('changeColor') | ||
var me = this; | ||
if (me.data.textClass == 'description') { | ||
this.setData({ | ||
textClass: 'blue' | ||
}) | ||
} else { | ||
this.setData({ | ||
textClass: 'description' | ||
}) | ||
} | ||
//this.data.textColor = 'blue' | ||
}, | ||
naviToView: function() { | ||
wx.navigateTo({ | ||
url: "../comp/view" | ||
}) | ||
}, | ||
naviToScrollView: function () { | ||
wx.navigateTo({ | ||
url: "../comp/scroll" | ||
result: [] | ||
}, | ||
|
||
onLoad: function () { | ||
var that = this; | ||
wx.request({ | ||
url: 'https://infoaas.com/data/hzc.json', | ||
method: 'GET', | ||
header: { | ||
'content-type': 'application/json' | ||
}, | ||
success: function (res) { | ||
that.setData({ | ||
result: res.data | ||
}) | ||
} | ||
}) | ||
}, | ||
onLoad: function () { | ||
if (app.globalData.userInfo) { | ||
this.setData({ | ||
userInfo: app.globalData.userInfo, | ||
hasUserInfo: true | ||
}) | ||
} else if (this.data.canIUse){ | ||
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 | ||
// 所以此处加入 callback 以防止这种情况 | ||
app.userInfoReadyCallback = res => { | ||
this.setData({ | ||
userInfo: res.userInfo, | ||
hasUserInfo: true | ||
}) | ||
} | ||
} else { | ||
// 在没有 open-type=getUserInfo 版本的兼容处理 | ||
wx.getUserInfo({ | ||
success: res => { | ||
app.globalData.userInfo = res.userInfo | ||
this.setData({ | ||
userInfo: res.userInfo, | ||
hasUserInfo: true | ||
}) | ||
} | ||
}) | ||
} | ||
}, | ||
getUserInfo: function(e) { | ||
console.log(e) | ||
app.globalData.userInfo = e.detail.userInfo | ||
this.setData({ | ||
userInfo: e.detail.userInfo, | ||
hasUserInfo: true | ||
}) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,5 @@ | ||
|
||
<view class="page"> | ||
<view class="page__hd"> | ||
<view class="page__title">不签到!?谁知道你读书了啊喂???</view> | ||
<view class="weui-cells weui-cells_after-title"> | ||
<navigator url="/pages/demo/scrollView" class="weui-cell weui-cell_access" hover-class="weui-cell_active"> | ||
<view class="weui-cell__hd"> | ||
<image src="{{icon}}" style="margin-right: 5px;vertical-align: middle;width:20px; height: 50px;"></image> | ||
</view> | ||
<view class="weui-cell__bd">考试签到</view> | ||
<view class="weui-cell__ft weui-cell__ft_in-access">抢个前排!</view> | ||
|
||
</navigator> | ||
<navigator url="/pages/navbar/navbar" class="weui-cell weui-cell_access" hover-class="weui-cell_active"> | ||
<view class="weui-cell__hd"> | ||
<image src="{{icon}}" style="margin-right: 5px;vertical-align: middle;width:20px; height: 50px;"></image> | ||
</view> | ||
<view class="weui-cell__bd">考试倒计时</view> | ||
<view class="weui-cell__ft weui-cell__ft_in-access">别说没提醒你?</view> | ||
|
||
</navigator> | ||
<navigator url="/pages/navbar/navbar" class="weui-cell weui-cell_access" hover-class="weui-cell_active"> | ||
<view class="weui-cell__hd"> | ||
<image src="{{icon}}" style="margin-right: 5px;vertical-align: middle;width:20px; height: 50px;"></image> | ||
</view> | ||
<view class="weui-cell__bd">考试TIPS</view> | ||
<view class="weui-cell__ft weui-cell__ft_in-access">万一有用呢?</view> | ||
|
||
</navigator> | ||
|
||
</view> | ||
</view> | ||
</view> | ||
<view wx:for="{{result}}" wx:for-item="item"> | ||
|
||
<view>{{index}}:{{item}}</view> | ||
|
||
</view> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
/**index.wxss**/ | ||
.page__hd { | ||
padding: 20px; | ||
.userinfo { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
} | ||
|
||
.page__title { | ||
text-align: left; | ||
font-size: 35px; | ||
font-weight: 400; | ||
.userinfo-avatar { | ||
width: 128rpx; | ||
height: 128rpx; | ||
margin: 20rpx; | ||
border-radius: 50%; | ||
} | ||
|
||
.userinfo-nickname { | ||
color: #aaa; | ||
} | ||
|
||
.usermotto { | ||
margin-top: 200px; | ||
} |