From 1a9ccf0d02065f190e7d62a7aee194896599e0da Mon Sep 17 00:00:00 2001 From: hhhhjq <1030623463@qq.com> Date: Fri, 3 Nov 2017 12:52:30 +0800 Subject: [PATCH] =?UTF-8?q?#1=20#102=20=E7=AC=AC2=E6=AC=A1=E5=AE=9E?= =?UTF-8?q?=E9=AA=8C=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1514080901211/app.js | 51 ++++++------------------ 1514080901211/app.json | 27 ++++++++----- 1514080901211/app.wxss | 45 ++++++++++++++++----- 1514080901211/example/index.js | 43 ++++++++++++++++++++ 1514080901211/example/index.wxml | 31 ++++++++++++++ 1514080901211/example/index.wxss | 6 +++ 1514080901211/example/navbar/navbar.js | 27 +++++++++++++ 1514080901211/example/navbar/navbar.wxml | 19 +++++++++ 1514080901211/example/navbar/navbar.wxss | 12 ++++++ 9 files changed, 203 insertions(+), 58 deletions(-) create mode 100644 1514080901211/example/index.js create mode 100644 1514080901211/example/index.wxml create mode 100644 1514080901211/example/index.wxss create mode 100644 1514080901211/example/navbar/navbar.js create mode 100644 1514080901211/example/navbar/navbar.wxml create mode 100644 1514080901211/example/navbar/navbar.wxss diff --git a/1514080901211/app.js b/1514080901211/app.js index b5451904..a3804130 100644 --- a/1514080901211/app.js +++ b/1514080901211/app.js @@ -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 - } -}) \ No newline at end of file + onLaunch: function () { + console.log('App Launch') + }, + onShow: function () { + console.log('App Show') + }, + onHide: function () { + console.log('App Hide') + }, + globalData: { + hasLogin: false + } +}); \ No newline at end of file diff --git a/1514080901211/app.json b/1514080901211/app.json index 89f9716a..a745edeb 100644 --- a/1514080901211/app.json +++ b/1514080901211/app.json @@ -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 +} \ No newline at end of file diff --git a/1514080901211/app.wxss b/1514080901211/app.wxss index 06c6fc9c..47c06c3d 100644 --- a/1514080901211/app.wxss +++ b/1514080901211/app.wxss @@ -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; +} \ No newline at end of file diff --git a/1514080901211/example/index.js b/1514080901211/example/index.js new file mode 100644 index 00000000..6fefd094 --- /dev/null +++ b/1514080901211/example/index.js @@ -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 + }); + } +}); diff --git a/1514080901211/example/index.wxml b/1514080901211/example/index.wxml new file mode 100644 index 00000000..c4cb6624 --- /dev/null +++ b/1514080901211/example/index.wxml @@ -0,0 +1,31 @@ + + + 不签到,谁知道你读书了啊??? + + + + + + + + {{item.name}} + + + + + + + {{page}} + + + + + + + + + + + + + \ No newline at end of file diff --git a/1514080901211/example/index.wxss b/1514080901211/example/index.wxss new file mode 100644 index 00000000..3601c055 --- /dev/null +++ b/1514080901211/example/index.wxss @@ -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} \ No newline at end of file diff --git a/1514080901211/example/navbar/navbar.js b/1514080901211/example/navbar/navbar.js new file mode 100644 index 00000000..e2c366d9 --- /dev/null +++ b/1514080901211/example/navbar/navbar.js @@ -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 + }); + } +}); \ No newline at end of file diff --git a/1514080901211/example/navbar/navbar.wxml b/1514080901211/example/navbar/navbar.wxml new file mode 100644 index 00000000..3a70f54c --- /dev/null +++ b/1514080901211/example/navbar/navbar.wxml @@ -0,0 +1,19 @@ + + + + + + + {{item}} + + + + + + + + + + + + \ No newline at end of file diff --git a/1514080901211/example/navbar/navbar.wxss b/1514080901211/example/navbar/navbar.wxss new file mode 100644 index 00000000..24c24f76 --- /dev/null +++ b/1514080901211/example/navbar/navbar.wxss @@ -0,0 +1,12 @@ +page, +.page, +.page__bd{ + height: 100%; +} +.page__bd{ + padding-bottom: 0; +} +.weui-tab__content{ + padding-top: 60px; + text-align: center; +} \ No newline at end of file