unknown 2 years ago
parent 5354548a4e
commit 969635ec0a

@ -0,0 +1,31 @@
/*
* Eslint config file
* Documentation: https://eslint.org/docs/user-guide/configuring/
* Install the Eslint extension before using this feature.
*/
module.exports = {
env: {
es6: true,
browser: true,
node: true,
},
ecmaFeatures: {
modules: true,
},
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
globals: {
wx: true,
App: true,
Page: true,
getCurrentPages: true,
getApp: true,
Component: true,
requirePlugin: true,
requireMiniProgram: true,
},
// extends: 'eslint:recommended',
rules: {},
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

@ -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
}
})

@ -0,0 +1,13 @@
{
"pages":[
"pages/index/index"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#820",
"navigationBarTitleText": "模 拟 时 钟",
"navigationBarTextStyle":"white"
},
"style": "v2",
"sitemapLocation": "sitemap.json"
}

@ -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;
}

@ -0,0 +1 @@
Subproject commit 349fce417c1e80e2b7605f1dd132b0ac7bfe18db

@ -0,0 +1,84 @@
// pages/clock/clock.js
const util = require("../../utils/util.js");
Page({
/**
* 页面的初始数据
*/
data: {
currentTime: "",
hdeg: 0, //时针旋转角度
mdeg: 0, //分针旋转角度
sdeg: 0, //秒针旋转角度
flag: "none" //获取到时间后再显示页面
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
const that = this;
setInterval(function () {
const _currentTime = util.formatTime(new Date()).split(" ")[1];
const _hdeg = _currentTime.split(":")[0] * 30;
const _mdeg = _currentTime.split(":")[1] * 6;
const _sdeg = _currentTime.split(":")[2] * 6;
that.setData({
currentTime: _currentTime,
hdeg: _hdeg,
mdeg: _mdeg,
sdeg: _sdeg,
flag: "block"
});
}, 1000)
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})

@ -0,0 +1,3 @@
{
"usingComponents": {}
}

@ -0,0 +1,43 @@
<!--pages/clock/clock.wxml-->
<view style="display: {{flag}};">
<view class="warp">
<view class="div1">
<!-- 时 -->
<view class="h" style="transform: rotateZ({{hdeg}}deg);"></view>
<!-- 分 -->
<view class="m" style="transform: rotateZ({{mdeg}}deg);"></view>
<!-- 秒 -->
<view class="s" style="transform: rotateZ({{sdeg}}deg);"></view>
<!-- 中点 -->
<view class=" div1_3"></view>
<!-- 刻度 -->
<view class="div1-4 d0">
<view class="left"></view>
<view class="right"></view>
</view>
<view class="div1-4 d1">
<view class="left"></view>
<view class="right"></view>
</view>
<view class="div1-4 d2">
<view class="left"></view>
<view class="right"></view>
</view>
<view class="div1-4 d3">
<view class="left"></view>
<view class="right"></view>
</view>
<view class="div1-4 d4">
<view class="left"></view>
<view class="right"></view>
</view>
<view class="div1-4 d5">
<view class="left"></view>
<view class="right"></view>
</view>
</view>
</view>
<view class="text1">北京时间</view>
<view class="currentTime">{{currentTime}}</view>
</view>

@ -0,0 +1,147 @@
/**index.wxss**/
.warp {
width: 600rpx;
height: 600rpx;
/*给大的外面设置了一个从中心点的渐变*/
background: radial-gradient(circle, white, rgb(109, 30, 30), rgb(235, 121, 118));
margin: 50rpx auto;
border-radius: 400rpx;
}
/*时钟里面*/
.div1 {
width: 500rpx;
height: 500rpx;
background: lavender;
position: relative;
top: 50rpx;
left: 50rpx;
border-radius: 250rpx;
}
.h {
/*作为时针*/
width: 20rpx;
height: 100rpx;
background: black;
position: absolute;
top: 150rpx;
left: 240rpx;
border-top-left-radius: 10rpx;
border-top-right-radius: 10rpx;
/*指定旋转的中心*/
transform-origin: bottom center;
/* animation: rotate360deg 43200s linear infinite; */
}
.m {
/*作为分针*/
width: 12rpx;
height: 160rpx;
background: black;
position: absolute;
top: 90rpx;
left: 242rpx;
border-top-left-radius: 10rpx;
border-top-right-radius: 10rpx;
/*指定旋转的中心*/
transform-origin: bottom center;
/* animation: rotate360deg 3600s linear infinite; */
}
.s {
/*作为秒针*/
width: 7rpx;
height: 200rpx;
background: red;
position: absolute;
top: 50rpx;
left: 240rpx;
border-top-left-radius: 5rpx;
border-top-right-radius: 5rpx;
/*指定旋转的中心为左边*/
transform-origin: bottom center;
/*时间为60s */
/* animation: rotate360deg 60s steps(60) infinite; */
}
.div1_3 {
position: absolute;
width: 40rpx;
height: 40rpx;
border-radius: 20rpx;
top: 230rpx;
left: 230rpx;
background: rgb(255, 230, 0);
}
.div1-4 {
width: 500rpx;
height: 5rpx;
/*background: red;*/
position: absolute;
top: 250rpx;
/*把它设置成一个弹性盒子,并且让子元素两边对齐*/
display: flex;
justify-content: space-between;
}
/*用旋转把一个圆分成12等分*/
.d1 {
transform: rotateZ(90deg);
}
.d2 {
transform: rotateZ(30deg);
}
.d3 {
transform: rotateZ(60deg);
}
.d4 {
transform: rotateZ(120deg);
}
.d5 {
transform: rotateZ(150deg);
}
.left {
width: 20rpx;
height: 5rpx;
background: black;
}
.right {
width: 20rpx;
height: 5rpx;
background: black;
}
.d0>div,
.d1>div {
height: 10rpx;
width: 35rpx;
}
/* 不采取动画,通过定时调用函数动态显示当前时间 */
/*让时针分针和秒针绕右边旋转360deg*/
/* @keyframes rotate360deg {
from {}
to {
transform: rotateZ(360deg);
}
} */
.text1 {
text-align: center;
font-size: x-large;
margin: 100rpx 0 50rpx;
}
.currentTime {
text-align: center;
font-size: xx-large;
}

@ -0,0 +1 @@
!截图(12345.png)

@ -0,0 +1,52 @@
{
"description": "项目配置文件",
"packOptions": {
"ignore": [],
"include": []
},
"setting": {
"bundle": false,
"userConfirmedBundleSwitch": false,
"urlCheck": true,
"scopeDataCheck": false,
"coverView": true,
"es6": true,
"postcss": true,
"compileHotReLoad": false,
"lazyloadPlaceholderEnable": false,
"preloadBackgroundData": false,
"minified": true,
"autoAudits": false,
"newFeature": false,
"uglifyFileName": false,
"uploadWithSourceMap": true,
"useIsolateContext": true,
"nodeModules": false,
"enhance": true,
"useMultiFrameRuntime": true,
"useApiHook": true,
"useApiHostProcess": true,
"showShadowRootInWxmlPanel": true,
"packNpmManually": false,
"enableEngineNative": false,
"packNpmRelationList": [],
"minifyWXSS": true,
"showES6CompileOption": false,
"minifyWXML": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"condition": false
},
"compileType": "miniprogram",
"libVersion": "2.25.3",
"appid": "touristappid",
"projectname": "miniprogram-92",
"condition": {},
"editorSetting": {
"tabIndent": "insertSpaces",
"tabSize": 2
}
}

@ -0,0 +1,7 @@
{
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"projectname": "SimulationClock",
"setting": {
"compileHotReLoad": true
}
}

@ -0,0 +1,7 @@
{
"desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
"rules": [{
"action": "allow",
"page": "*"
}]
}

@ -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
}
Loading…
Cancel
Save