forked from hzuapps/web-wechat-2017
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
203 additions
and
58 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,39 +1,14 @@ | ||
//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 | ||
|
||
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 | ||
// 所以此处加入 callback 以防止这种情况 | ||
if (this.userInfoReadyCallback) { | ||
this.userInfoReadyCallback(res) | ||
} | ||
} | ||
}) | ||
} | ||
} | ||
}) | ||
}, | ||
globalData: { | ||
userInfo: null | ||
} | ||
}) | ||
onLaunch: function () { | ||
console.log('App Launch') | ||
}, | ||
onShow: function () { | ||
console.log('App Show') | ||
}, | ||
onHide: function () { | ||
console.log('App Hide') | ||
}, | ||
globalData: { | ||
hasLogin: false | ||
} | ||
}); |
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,12 +1,19 @@ | ||
{ | ||
"pages":[ | ||
"pages/index/index", | ||
"pages/logs/logs" | ||
"pages": [ | ||
"example/index", | ||
"example/navbar/navbar" | ||
], | ||
"window":{ | ||
"backgroundTextStyle":"light", | ||
"navigationBarBackgroundColor": "#fff", | ||
"navigationBarTitleText": "大型考试签到打卡", | ||
"navigationBarTextStyle":"black" | ||
} | ||
} | ||
"window": { | ||
"navigationBarTextStyle": "black", | ||
"navigationBarTitleText": "考试打卡机", | ||
"navigationBarBackgroundColor": "#f8f8f8", | ||
"backgroundColor": "#f8f8f8" | ||
}, | ||
"networkTimeout": { | ||
"request": 10000, | ||
"connectSocket": 10000, | ||
"uploadFile": 10000, | ||
"downloadFile": 10000 | ||
}, | ||
"debug": 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,10 +1,35 @@ | ||
/**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{ | ||
background-color: #F8F8F8; | ||
font-size: 16px; | ||
font-family: -apple-system-font,Helvetica Neue,Helvetica,sans-serif; | ||
} | ||
.page__hd { | ||
padding: 40px; | ||
} | ||
.page__bd { | ||
padding-bottom: 40px; | ||
} | ||
.page__bd_spacing { | ||
padding-left: 15px; | ||
padding-right: 15px; | ||
} | ||
|
||
.page__ft{ | ||
padding-bottom: 10px; | ||
text-align: center; | ||
} | ||
|
||
.page__title { | ||
text-align: left; | ||
font-size: 20px; | ||
font-weight: 400; | ||
} | ||
|
||
.page__desc { | ||
margin-top: 5px; | ||
color: #888888; | ||
text-align: left; | ||
font-size: 14px; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
Page({ | ||
data: { | ||
list: [ | ||
{ | ||
id: 'form', | ||
name: '考试倒计时', | ||
open: false, | ||
pages: ['navbar'] | ||
}, | ||
{ | ||
id: 'widget', | ||
name: '每日签到', | ||
open: false, | ||
pages: ['navbar'] | ||
}, | ||
{ | ||
id: 'feedback', | ||
name: '考试TIPS', | ||
open: false, | ||
pages: ['navbar'] | ||
}, | ||
{ | ||
id: 'nav', | ||
name: '日常吐槽', | ||
open: false, | ||
pages: ['navbar'] | ||
} | ||
] | ||
}, | ||
kindToggle: function (e) { | ||
var id = e.currentTarget.id, list = this.data.list; | ||
for (var i = 0, len = list.length; i < len; ++i) { | ||
if (list[i].id == id) { | ||
list[i].open = !list[i].open | ||
} else { | ||
list[i].open = false | ||
} | ||
} | ||
this.setData({ | ||
list: list | ||
}); | ||
} | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<view class="page"> | ||
<view class="page__hd"> | ||
<view class="page__title">不签到,谁知道你读书了啊???</view> | ||
|
||
</view> | ||
<view class="page__bd page__bd_spacing"> | ||
<view class="kind-list"> | ||
<block wx:for="{{list}}" wx:key="id"> | ||
<view class="kind-list__item"> | ||
<view id="{{item.id}}" class="weui-flex kind-list__item-hd {{item.open ? 'kind-list__item-hd_show' : ''}}" bindtap="kindToggle"> | ||
<view class="weui-flex__item">{{item.name}}</view> | ||
<image class="kind-list__img" src="images/icon_nav_{{item.id}}.png"></image> | ||
</view> | ||
<view class="kind-list__item-bd {{item.open ? 'kind-list__item-bd_show' : ''}}"> | ||
<view class="weui-cells {{item.open ? 'weui-cells_show' : ''}}"> | ||
<block wx:for="{{item.pages}}" wx:for-item="page" wx:key="*this"> | ||
<navigator url="{{page}}/{{page}}" class="weui-cell weui-cell_access"> | ||
<view class="weui-cell__bd">{{page}}</view> | ||
<view class="weui-cell__ft weui-cell__ft_in-access"></view> | ||
</navigator> | ||
</block> | ||
</view> | ||
</view> | ||
</view> | ||
</block> | ||
</view> | ||
</view> | ||
<view class="page__ft"> | ||
<image src="images/icon_footer.png" style="width: 84px; height: 19px;"></image> | ||
</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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/*! | ||
* WeUI v1.1.1 (https://github.com/weui/weui-wxss) | ||
* Copyright 2017 Tencent, Inc. | ||
* Licensed under the MIT license | ||
*/ | ||
.weui-flex{-webkit-box-align:center;-webkit-align-items:center;align-items:center}.weui-cells{margin-top:0;opacity:0;-webkit-transform:translateY(-50%);transform:translateY(-50%);-webkit-transition:.3s;transition:.3s}.weui-cells:after,.weui-cells:before{display:none}.weui-cells_show{opacity:1;-webkit-transform:translateY(0);transform:translateY(0)}.weui-cell:before{right:15px}.kind-list__item{margin:10px 0;background-color:#fff;border-radius:2px;overflow:hidden}.kind-list__item:first-child{margin-top:0}.kind-list__img{width:30px;height:30px}.kind-list__item-hd{padding:20px;-webkit-transition:opacity .3s;transition:opacity .3s}.kind-list__item-hd_show{opacity:.4}.kind-list__item-bd{height:0;overflow:hidden}.kind-list__item-bd_show{height:auto} |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
var sliderWidth = 96; // 需要设置slider的宽度,用于计算中间位置 | ||
|
||
Page({ | ||
data: { | ||
tabs: ["四级考试", "六级考试", "研究生考试"], | ||
activeIndex: 1, | ||
sliderOffset: 0, | ||
sliderLeft: 0 | ||
}, | ||
onLoad: function () { | ||
var that = this; | ||
wx.getSystemInfo({ | ||
success: function(res) { | ||
that.setData({ | ||
sliderLeft: (res.windowWidth / that.data.tabs.length - sliderWidth) / 2, | ||
sliderOffset: res.windowWidth / that.data.tabs.length * that.data.activeIndex | ||
}); | ||
} | ||
}); | ||
}, | ||
tabClick: function (e) { | ||
this.setData({ | ||
sliderOffset: e.currentTarget.offsetLeft, | ||
activeIndex: e.currentTarget.id | ||
}); | ||
} | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<view class="page"> | ||
<view class="page__bd"> | ||
<view class="weui-tab"> | ||
<view class="weui-navbar"> | ||
<block wx:for="{{tabs}}" wx:key="*this"> | ||
<view id="{{index}}" class="weui-navbar__item {{activeIndex == index ? 'weui-bar__item_on' : ''}}" bindtap="tabClick"> | ||
<view class="weui-navbar__title">{{item}}</view> | ||
</view> | ||
</block> | ||
<view class="weui-navbar__slider" style="left: {{sliderLeft}}px; transform: translateX({{sliderOffset}}px); -webkit-transform: translateX({{sliderOffset}}px);"></view> | ||
</view> | ||
<view class="weui-tab__panel"> | ||
<view class="weui-tab__content" hidden="{{activeIndex != 0}}">四级考试</view> | ||
<view class="weui-tab__content" hidden="{{activeIndex != 1}}">六级考试</view> | ||
<view class="weui-tab__content" hidden="{{activeIndex != 2}}">研究生考试</view> | ||
</view> | ||
</view> | ||
</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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
page, | ||
.page, | ||
.page__bd{ | ||
height: 100%; | ||
} | ||
.page__bd{ | ||
padding-bottom: 0; | ||
} | ||
.weui-tab__content{ | ||
padding-top: 60px; | ||
text-align: center; | ||
} |