Skip to content

Commit

Permalink
Merge pull request #228 from 351655914/master
Browse files Browse the repository at this point in the history
#2 #38 第2次实验代码
  • Loading branch information
zengsn authored Nov 5, 2017
2 parents db6a113 + 20f6ce0 commit 6cdafe8
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 73 deletions.
1 change: 1 addition & 0 deletions 1514080901116/app.wxss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/**app.wxss**/
@import"style/weui.wxss"
.container {
height: 100%;
display: flex;
Expand Down
4 changes: 4 additions & 0 deletions 1514080901116/pages/images/base64.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 8 additions & 50 deletions 1514080901116/pages/index/index.js
Original file line number Diff line number Diff line change
@@ -1,54 +1,12 @@
//index.js
//获取应用实例
const app = getApp()

var base64 = require("../images/base64");
Page({
data: {
motto: 'Hello World',
userInfo: {},
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo')
},
//事件处理函数
bindViewTap: function() {
wx.navigateTo({
url: '../logs/logs'
})
},
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 => {
onLoad: function(){
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
icon20: base64.icon20,
icon60: base64.icon60
})
}
} else {
// 在没有 open-type=getUserInfo 版本的兼容处理
wx.getUserInfo({
success: res => {
app.globalData.userInfo = res.userInfo
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
})
},
inputChange: function (e) {
this.data.inputValue = e.detail.value;
}
},
getUserInfo: function(e) {
console.log(e)
app.globalData.userInfo = e.detail.userInfo
this.setData({
userInfo: e.detail.userInfo,
hasUserInfo: true
})
}
})
})
70 changes: 58 additions & 12 deletions 1514080901116/pages/index/index.wxml
Original file line number Diff line number Diff line change
@@ -1,13 +1,59 @@
<!--index.wxml-->
<view class="container">
<view class="userinfo">
<button wx:if="{{!hasUserInfo && canIUse}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 获取头像昵称 </button>
<block wx:else>
<image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" background-size="cover"></image>
<text class="userinfo-nickname">{{userInfo.nickName}}</text>
</block>
</view>
<view class="usermotto">
<text class="user-motto">{{motto}}</text>
</view>
<view class="page">
<view class="content" scroll-y="false">
<view class="search-bar">
<icon class="weui-icon-search_in-box" type="search" size="14"></icon>
<input placeholder="请输入关键词" bindchange="inputChange"/>
<button type="primary">查询</button>
</view>
<view class="page__bd">
<view class="weui-panel weui-panel_access">
<view class="weui-panel__hd"></view>
<view class="weui-panel__bd">
<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
<view class="weui-media-box__hd weui-media-box__hd_in-appmsg">
<image class="weui-media-box__thumb" src="{{icon60}}" />
</view>
<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
<view class="weui-media-box__title">幽默故事会</view>
<view class="weui-media-box__desc"></view>
</view>
</navigator>
<navigator url="" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
<view class="weui-media-box__hd weui-media-box__hd_in-appmsg">
<image class="weui-media-box__thumb" src="{{icon60}}" />
</view>
<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
<view class="weui-media-box__title">搞笑视频</view>
<view class="weui-media-box__desc"></view>
</view>
</navigator>
</view>
<view class="weui-panel__ft">
<view class="weui-cell weui-cell_access weui-cell_link">
<view class="weui-cell__bd">查看更多</view>
<view class="weui-cell__ft weui-cell__ft_in-access"></view>
</view>
</view>
</view>
<view class="weui-panel weui-panel_access">

<view class="weui-panel__bd">
<view class="weui-media-box weui-media-box_text">
<view class="weui-media-box__title weui-media-box__title_in-text">段子一</view>
<view class="weui-media-box__desc">你孤单的时候想干嘛?喝汽水,因为当你孤单你会想起谁(汽水)。</view>
</view>
<view class="weui-media-box weui-media-box_text">
<view class="weui-media-box__title weui-media-box__title_in-text">段子二</view>
<view class="weui-media-box__desc">我曾经得过精神分裂症,但现在我们已经康复了。</view>
</view>
</view>
<view class="weui-panel__ft">
<view class="weui-cell weui-cell_access weui-cell_link">
<view class="weui-cell__bd">查看更多</view>
<view class="weui-cell__ft weui-cell__ft_in-access"></view>
</view>
</view>
</view>
</view>
</view>
</view>
44 changes: 33 additions & 11 deletions 1514080901116/pages/index/index.wxss
Original file line number Diff line number Diff line change
@@ -1,21 +1,43 @@
/**index.wxss**/
.userinfo {
.content {
display: flex;
flex-direction: column;
align-items: center;
height: 100%;
}

.userinfo-avatar {
width: 128rpx;
height: 128rpx;
margin: 20rpx;
border-radius: 50%;
.search-bar {
z-index: 1;
}

.userinfo-nickname {
color: #aaa;
.search-bar button {
height: 70rpx;
line-height: 70rpx;
width: 140rpx;
position: fixed;
top: 20rpx;
left: 585rpx;
font-size: 30rpx;
color: #fbf9fe;
}

.usermotto {
margin-top: 200px;
.search-bar input {
background-color: #fff;
border-radius: 5px;
width: 480rpx;
height: 70rpx;
margin-top: 20rpx;
/*text-indent: 70rpx;*/
margin-bottom: 15rpx;
position: fixed;
top: 0;
left: 25rpx;
padding-left: 70rpx;
}


.weui-icon-search_in-box{
position: absolute;
top: 40rpx;
left: 40rpx;
z-index: 1;
}

0 comments on commit 6cdafe8

Please sign in to comment.