Skip to content

Commit

Permalink
知乎-微信小程序 demo: 底部 tab 及对应一级页面的UI 搭建
Browse files Browse the repository at this point in the history
  • Loading branch information
Rebecca_Han committed Oct 18, 2016
1 parent ce37627 commit fbf9cf5
Show file tree
Hide file tree
Showing 53 changed files with 1,462 additions and 0 deletions.
30 changes: 30 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//app.js
App({
onLaunch: function () {
//调用API从本地缓存中获取数据
var logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
},
getUserInfo:function(cb){
var that = this
if(this.globalData.userInfo){
typeof cb == "function" && cb(this.globalData.userInfo)
}else{
//调用登录接口
wx.login({
success: function () {
wx.getUserInfo({
success: function (res) {
that.globalData.userInfo = res.userInfo
typeof cb == "function" && cb(that.globalData.userInfo)
}
})
}
})
}
},
globalData:{
userInfo:null
}
})
52 changes: 52 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"pages":[
"pages/index/index",
"pages/discovery/discovery",
"pages/notify/notify",
"pages/chat/chat",
"pages/more/more"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#0068C4",
"navigationBarTitleText": "知乎",
"navigationBarTextStyle":"white"
},
"tabBar": {
"color": "#626567",
"selectedColor": "#2A8CE5",
"backgroundColor": "#FBFBFB",
"borderStyle": "white",
"list": [{
"pagePath": "pages/index/index",
"text": "",
"iconPath": "images/index.png",
"selectedIconPath": "images/index_focus.png"
}, {
"pagePath": "pages/discovery/discovery",
"text": "",
"iconPath": "images/discovery.png",
"selectedIconPath": "images/discovery_focus.png"
}, {
"pagePath": "pages/notify/notify",
"text": "",
"iconPath": "images/ring.png",
"selectedIconPath": "images/ring_focus.png"
}, {
"pagePath": "pages/chat/chat",
"text": "",
"iconPath": "images/chat.png",
"selectedIconPath": "images/chat_focus.png"
}, {
"pagePath": "pages/more/more",
"text": "",
"iconPath": "images/burger.png",
"selectedIconPath": "images/burger_focus.png"
}]
},
"networkTimeout": {
"request": 10000,
"downloadFile": 10000
},
"debug": true
}
126 changes: 126 additions & 0 deletions app.wxss
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/**app.wxss**/
.container {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
/*padding: 200rpx 0;*/
box-sizing: border-box;
background: #F0F4F3;
}

.container.withtab{
margin: 105rpx 0 0 0;
/*top: 105rpx;*/
}
.flex-wrp{
display: flex;
}
.flex-tab{
flex-flow: row nowrap;
justify-content: space-around;
align-items: stretch;
}
.flex-item{
flex-grow: 1;
text-align: center;
}
.top-tab{
width: 750rpx;
height: 100rpx;
background: #298DE5;
color: #8CCEFD;
font-size: 28rpx;
line-height: 100rpx;
box-shadow: 0 2px 2px #bebebe;
margin: 0 0 8rpx 0;
position: fixed;
top: 0;
}
.toptab.active{
color: #ffffff;
border-bottom: solid 2px #ffffff;
}
.container{
padding: 0;
font-size: 14rpx;
color: #000;
}
.container .feed-item{
width: 690rpx;
padding: 30rpx 30rpx 20rpx;
margin: 7rpx 0 6rpx 0;
background: #ffffff;
border-top: 1px solid #eee;
border-bottom: 1px solid #eee;
box-shadow: 0 2px 5px #eeeeee;
}
.container .feed-item .feed-source{
width: 690rpx;
left: 0;
height: 50rpx;
}
.container .feed-item .feed-source .avatar{
position: relative;
display: inline-block;
}
.container .feed-item .feed-source a{
display: inline-block;
height: 40rpx;
}
.container .feed-item .feed-source .avatar image{
/*position: absolute;*/
display: inline-block;
width: 45rpx;
height: 45rpx;
border-radius: 45rpx;
top: 10rpx;
vertical-align: middle;
}
.container .feed-item .feed-source text{
/*position: absolute;*/
display: inline-block;
height: 40rpx;
line-height: 40rpx;
vertical-align: middle;
margin: 0 0 0 15rpx;
color: #a0acac;
font-size: 16rpx;
}
.container .feed-item .feed-source .item-more{
display: inline-block;
width: 40rpx;
height: 45rpx;
float: right;
}
.container .feed-item .feed-content{
padding: 10rpx 0 0 0;
}
.container .feed-item .feed-content .question text{
font-size: 28rpx;
font-weight: 600px;
line-height: 40rpx;
text-space: 5rpx;
}
.container .feed-item .feed-content .answer-body{
padding: 10rpx 0 0 0;
/*height: 10rpx;*/
font-size: 24rpx;
line-height: 28rpx;
color: #5b5b5b;
}
.container .feed-item .feed-content .answer-actions{
width: 690rpx;
padding: 10rpx 0 0;
color: #a0acac;
}
.container .feed-item .feed-content .answer-actions view{
display: inline-block;
vertical-align: text-bottom;
padding: 0 10rpx 0 0;
font-size: 24rpx;
}
.container .feed-item .feed-content .answer-actions .dot ::after{
content: "•";
}
Binary file added images/1444983318907-_DSC1826.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/24213.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/24280.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/allread.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/book.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/burger.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/burger_focus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/chat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/chat_focus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/discovery.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/discovery_focus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/draft.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/eye.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/icon1.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/icon8.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/icon9.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/index.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/index_focus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/lighting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/live.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/more.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/recent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/ring.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/ring_focus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/star.png
Binary file added images/zhi.png
29 changes: 29 additions & 0 deletions pages/answer/answer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//index.js
//获取应用实例
var app = getApp()
Page({
data: {
motto: '知乎--微信小程序版',
userInfo: {}
},
//事件处理函数
bindViewTap: function() {
wx.navigateTo({
url: '../more/more'
})
},
onLoad: function () {
console.log('onLoad')
var that = this
//调用应用实例的方法获取全局数据
app.getUserInfo(function(userInfo){
//更新数据
that.setData({
userInfo:userInfo
})
})
},
tapName: function(event){
console.log(event)
}
})
Loading

0 comments on commit fbf9cf5

Please sign in to comment.