Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zby #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// app.js
App({
onLaunch() {
// 展示本地存储能力
const logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)

// 登录
wx.login({
success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
}
})
},
globalData: {
userInfo: null
}
})
15 changes: 15 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"pages":[
"pages/index/index",
"pages/logs/logs",
"pages/app/app"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "Weixin",
"navigationBarTextStyle":"black"
},
"style": "v2",
"sitemapLocation": "sitemap.json"
}
10 changes: 10 additions & 0 deletions app.wxss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**app.wxss**/
.container {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
padding: 200rpx 0;
box-sizing: border-box;
}
66 changes: 66 additions & 0 deletions pages/app/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// pages/app/app.js
Page({

/**
* 页面的初始数据
*/
data: {

},

/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {

},

/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {

},

/**
* 生命周期函数--监听页面显示
*/
onShow: function () {

},

/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {

},

/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {

},

/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {

},

/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {

},

/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {

}
})
3 changes: 3 additions & 0 deletions pages/app/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"usingComponents": {}
}
2 changes: 2 additions & 0 deletions pages/app/app.wxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<view>2021</view>
<view>JAN</view>
1 change: 1 addition & 0 deletions pages/app/app.wxss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* pages/app/app.wxss */
48 changes: 48 additions & 0 deletions pages/index/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// index.js
// 获取应用实例
const app = getApp()

Page({
data: {
motto: 'Hello World',
userInfo: {},
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo'),
canIUseGetUserProfile: false,
canIUseOpenData: wx.canIUse('open-data.type.userAvatarUrl') && wx.canIUse('open-data.type.userNickName') // 如需尝试获取用户信息可改为false
},
// 事件处理函数
bindViewTap() {
wx.navigateTo({
url: '../logs/logs'
})
},
onLoad() {
if (wx.getUserProfile) {
this.setData({
canIUseGetUserProfile: true
})
}
},
getUserProfile(e) {
// 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
wx.getUserProfile({
desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: (res) => {
console.log(res)
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
})
},
getUserInfo(e) {
// 不推荐使用getUserInfo获取用户信息,预计自2021年4月13日起,getUserInfo将不再弹出弹窗,并直接返回匿名的用户个人信息
console.log(e)
this.setData({
userInfo: e.detail.userInfo,
hasUserInfo: true
})
}
})
4 changes: 4 additions & 0 deletions pages/index/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"usingComponents": {},
"navigationBarBackgroundColor":"#2A81CA"
}
17 changes: 17 additions & 0 deletions pages/index/index.wxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<view class="top"><!--space-between使月份年份与头像间产生间距-->
<view style="display: flex;flex-direction: column;justify-content: space-around;font-size:25px;"><!--space-arpund使月份年份等距拉伸以填补头像高度-->
<view>2021</view>
<view>JAN</view>
</view>
<open-data style="width: 80px; border-radius:100%; overflow: hidden" type="userAvatarUrl"></open-data>
</view>
<view style="height:2px;background-color:white;"></view>
<view class="btns">
<view>Month</view>
<view class="active">Week</view>
<view>Add</view>
</view>
<view class="calendar">
<view class="week"wx:for="{{'SMTWWFS'}}">{{item}}</view>
<view class="date" wx:for="{{30}}">{{item + 1}}</view>
</view>
49 changes: 49 additions & 0 deletions pages/index/index.wxss
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
page {
background-color: #2A81CA;
color: white;
}

.top {
display: flex;
justify-content: space-between;
padding: 10px 20px;
}

.btns {
display: flex;
justify-content: space-between;
padding: 10px 20px;
box-shadow: 0px 17px 34px 0px rgba(0, 0, 0, 0.3);
}

.btns>view {
padding: 5px 0;
font-size: 18px;
}

.btns>view.active {
padding: 5px 20px;
border-radius: 20px;
box-shadow: 0px 17px 34px 0px rgba(0, 0, 0, 0.3);
background: linear-gradient(150deg, #73B7FB, #3F9CFA);
font-size: 18px;
}

.calendar {
/* display: flex; */
padding: 10px 0;
background-color: white;
color: black;
}
.date {
padding: 8px 0;
display: inline-block;
text-align: center;
width: 14.2857142857143%;
}
.week {
padding: 8px 0;
display: inline-block;
text-align: center;
width: 14.2857142857143%;
}
18 changes: 18 additions & 0 deletions pages/logs/logs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// logs.js
const util = require('../../utils/util.js')

Page({
data: {
logs: []
},
onLoad() {
this.setData({
logs: (wx.getStorageSync('logs') || []).map(log => {
return {
date: util.formatTime(new Date(log)),
timeStamp: log
}
})
})
}
})
4 changes: 4 additions & 0 deletions pages/logs/logs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"navigationBarTitleText": "查看启动日志",
"usingComponents": {}
}
6 changes: 6 additions & 0 deletions pages/logs/logs.wxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!--logs.wxml-->
<view class="container log-list">
<block wx:for="{{logs}}" wx:key="timeStamp" wx:for-item="log">
<text class="log-item">{{index + 1}}. {{log.date}}</text>
</block>
</view>
8 changes: 8 additions & 0 deletions pages/logs/logs.wxss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.log-list {
display: flex;
flex-direction: column;
padding: 40rpx;
}
.log-item {
margin: 10rpx;
}
74 changes: 74 additions & 0 deletions project.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"description": "项目配置文件",
"packOptions": {
"ignore": []
},
"setting": {
"urlCheck": true,
"es6": true,
"enhance": false,
"postcss": true,
"preloadBackgroundData": false,
"minified": true,
"newFeature": false,
"coverView": true,
"nodeModules": false,
"autoAudits": false,
"showShadowRootInWxmlPanel": true,
"scopeDataCheck": false,
"uglifyFileName": false,
"checkInvalidKey": true,
"checkSiteMap": true,
"uploadWithSourceMap": true,
"compileHotReLoad": false,
"useMultiFrameRuntime": false,
"useApiHook": false,
"useApiHostProcess": false,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"enableEngineNative": false,
"useIsolateContext": true,
"useCompilerModule": true,
"userConfirmedUseCompilerModuleSwitch": false,
"userConfirmedBundleSwitch": false,
"packNpmManually": false,
"packNpmRelationList": [],
"minifyWXSS": true
},
"compileType": "miniprogram",
"libVersion": "2.17.0",
"appid": "wx1753a643a845b44a",
"projectname": "Frontend01-02",
"debugOptions": {
"hidedInDevtools": []
},
"scripts": {},
"staticServerOptions": {
"baseURL": "",
"servePath": ""
},
"isGameTourist": false,
"condition": {
"search": {
"list": []
},
"conversation": {
"list": []
},
"game": {
"list": []
},
"plugin": {
"list": []
},
"gamePlugin": {
"list": []
},
"miniprogram": {
"list": []
}
}
}
7 changes: 7 additions & 0 deletions sitemap.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
"rules": [{
"action": "allow",
"page": "*"
}]
}
19 changes: 19 additions & 0 deletions utils/util.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const formatTime = date => {
const year = date.getFullYear()
const month = date.getMonth() + 1
const day = date.getDate()
const hour = date.getHours()
const minute = date.getMinutes()
const second = date.getSeconds()

return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}`
}

const formatNumber = n => {
n = n.toString()
return n[1] ? n : `0${n}`
}

module.exports = {
formatTime
}