Skip to content

Commit

Permalink
Merge pull request #533 from hhhhjq/master
Browse files Browse the repository at this point in the history
#5 #102 第5次实验代码
  • Loading branch information
zengsn authored Dec 18, 2017
2 parents 670a29b + 1db4783 commit 16f365a
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 116 deletions.
95 changes: 18 additions & 77 deletions 1514080901211/pages/index/index.js
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
})
}
})
38 changes: 5 additions & 33 deletions 1514080901211/pages/index/index.wxml
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>
23 changes: 17 additions & 6 deletions 1514080901211/pages/index/index.wxss
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;
}

0 comments on commit 16f365a

Please sign in to comment.