乡村相册

This commit is contained in:
yanran200730
2022-05-17 16:13:03 +08:00
parent 8e3113f00d
commit c38c92f19a
9 changed files with 600 additions and 114 deletions

View File

@@ -1,11 +1,10 @@
<template> <template>
<div class="photo" ref="waterMarker" :class="[isHide ? 'home-active' : '']" :style="{height: height + 'px'}"> <div class="photo" ref="waterMarker" :class="[isHide ? 'home-active' : '']" :style="{height: height + 'px'}">
<div class="photo-top" data-html2canvas-ignore> <div class="photo-top" data-html2canvas-ignore>
<!-- <image src="./images/gengduo1.png" @click="back" /> --> <image src="./images/close.png" @click="back" />
<u-icon name="close" color="#fff" size="28" @click="back"></u-icon>
<div class="photo-top__middle"> <div class="photo-top__middle">
<span>保存至默认相册</span> <span>保存至默认相册</span>
<image src="./images/gengduo1.png" /> <image src="./images/to-right.png" />
</div> </div>
<span @click="save">保存</span> <span @click="save">保存</span>
</div> </div>
@@ -15,7 +14,7 @@
</div> </div>
<div class="photo-bottom" v-if="!isHide"> <div class="photo-bottom" v-if="!isHide">
<div class="photo-bottom__top"> <div class="photo-bottom__top">
<image src="./images/gengduo1.png" @click="isHide = true, currIndex = -1" /> <image src="./images/clear.png" @click="isHide = true, currIndex = -1" />
<h2>水印</h2> <h2>水印</h2>
<span>确定</span> <span>确定</span>
</div> </div>
@@ -246,6 +245,7 @@
justify-content: center; justify-content: center;
width: 336px; width: 336px;
height: 72px; height: 72px;
line-height: 1;
background: #0B111F; background: #0B111F;
border-radius: 40px; border-radius: 40px;
font-size: 28px; font-size: 28px;

View File

@@ -1,72 +1,171 @@
<template> <template>
<div class="Watermark1"> <div class="Watermark7" @click="linkTo('./WatermarkConfig')">
<image src="../../images/hjws.png" />
<h2>整好环境卫生</h2>
<div class="middle">
<div class="top"> <div class="top">
<h2>打卡记录7</h2> <h2>{{ time }}</h2>
<p>09:45</p> <span>多云 7</span>
</div> </div>
<div class="info"> <div class="bottom">{{ date }} {{ weekCn }}</div>
<p>2022.02.25 星期五</p>
<p>武汉市·绿地蓝海国际A座</p>
<p> 7</p>
</div> </div>
<div class="text">#这是一条备注信息</div> <div class="bottom">武汉市·绿地蓝海A座</div>
</div> </div>
</template> </template>
<script> <script>
import {mapActions} from 'vuex'
export default { export default {
data () {
return {
date: '',
time: '',
week: '',
timer: null
}
},
computed: {
weekCn() {
if (this.week === 1) {
return '星期一'
}
if (this.week === 2) {
return '星期二'
}
if (this.week === 3) {
return '星期三'
}
if (this.week === 4) {
return '星期四'
}
if (this.week === 5) {
return '星期五'
}
if (this.week === 6) {
return '星期六'
}
return '星期天'
}
},
created () {
this.date = this.$dayjs(new Date).format('YYYY-MM-DD')
this.time = this.$dayjs().format('HH:mm')
this.timer = setInterval(() => {
this.date = this.$dayjs().format('YYYY-MM-DD')
this.time = this.$dayjs().format('HH:mm')
this.week = new Date().getDay()
}, 1000)
this.injectJWeixin(['getLocation']).then(res => {
console.log(res)
wx.getLocation({
type: 'wgs84',
success: function (res) {
var latitude = res.latitude
var longitude = res.longitude
var speed = res.speed
var accuracy = res.accuracy
}
});
})
},
destroyed () {
clearInterval(this.timer)
},
methods: {
...mapActions(['injectJWeixin']),
getLocation () {
uni.getLocation({
type: 'wgs84',
success: res => {
console.log(res)
this.$http.get('https://apis.map.qq.com/ws/geocoder/v1/?location=39.984154,116.307490&key=3RZBZ-LZUCF-CT6J5-NWKZH-FCWOQ-UUFKY&get_poi=1').then(res => {
console.log(res)
})
},
fail: error => {
console.log(error)
}
})
},
linkTo (url) {
uni.navigateTo({
url
})
}
}
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.Watermark1 { .Watermark7 {
width: 400px;
font-size: 0;
box-sizing: border-box;
h2 {
font-weight: normal;
}
* { * {
box-sizing: border-box; box-sizing: border-box;
} }
.text { & > image {
min-width: 274px; width: 100%;
height: 48px; height: 64px;
line-height: 48px;
padding: 0 16px;
font-size: 28px;
background: linear-gradient(270deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.2) 100%);
} }
& > .bottom {
line-height: 1.3;
padding: 10px 16px;
font-size: 26px;
text-align: justify;
background: rgba(27, 120, 65, 0.8);
}
.middle {
line-height: 1;
padding: 16px;
background: rgba(0, 0, 0, 0.5);
.top { .top {
width: 184px; display: flex;
background: #FEFFFE; align-items: center;
border-radius: 16px; margin-bottom: 6px;
text-align: center;
overflow: hidden;
h2 { h2 {
height: 64px; margin-right: 16px;
line-height: 64px; color: #FFFFFF;
background: #1ABDA6;
font-size: 34px;
font-weight: normal;
}
p {
height: 72px;
line-height: 72px;
font-weight: 600;
color: #333333;
font-size: 48px; font-size: 48px;
} }
span {
color: #62CD8B;
font-size: 26px;
}
} }
.info { .bottom {
line-height: 40px; font-size: 26px;
margin: 32px 0;
padding-left: 22px;
border-left: 6px solid #F8BC58;
p:nth-of-type(2) {
margin: 8px 0;
} }
} }
& > h2 {
height: 64px;
line-height: 64px;
text-align: center;
color: #fff;
font-size: 32px;
background: #1B7841;
}
} }
</style> </style>

View File

@@ -1,72 +1,132 @@
<template> <template>
<div class="Watermark1"> <div class="Watermark8" @click="linkTo('./WatermarkConfig')">
<div class="top"> <h2>{{ date }}</h2>
<h2>打卡记录8</h2> <div>{{ day }}</div>
<p>09:45</p> <p>{{ lunar }} {{ weekCn }}</p>
</div>
<div class="info">
<p>2022.02.25 星期五</p>
<p>武汉市·绿地蓝海国际A座</p>
<p> 7</p>
</div>
<div class="text">#这是一条备注信息</div>
</div> </div>
</template> </template>
<script> <script>
import {mapActions} from 'vuex'
import lunar from '../../config/calendar'
export default { export default {
data () {
return {
date: '',
week: '',
day: '',
lunar: '',
timer: null
}
},
computed: {
weekCn() {
if (this.week === 1) {
return '星期一'
}
if (this.week === 2) {
return '星期二'
}
if (this.week === 3) {
return '星期三'
}
if (this.week === 4) {
return '星期四'
}
if (this.week === 5) {
return '星期五'
}
if (this.week === 6) {
return '星期六'
}
return '星期天'
}
},
created () {
const date = this.$dayjs(new Date)
const result = lunar.solarToLunar(date.format('YYYY'), date.format('MM'), date.format('DD'))
this.date = date.format('YYYY年MM月')
this.day = date.format('DD')
this.lunar = `${result.monthStr}${result.dayStr}`
this.week = new Date().getDay()
this.injectJWeixin(['getLocation']).then(res => {
console.log(res)
wx.getLocation({
type: 'wgs84',
success: function (res) {
var latitude = res.latitude
var longitude = res.longitude
var speed = res.speed
var accuracy = res.accuracy
}
});
})
},
destroyed () {
clearInterval(this.timer)
},
methods: {
...mapActions(['injectJWeixin']),
getLocation () {
uni.getLocation({
type: 'wgs84',
success: res => {
console.log(res)
this.$http.get('https://apis.map.qq.com/ws/geocoder/v1/?location=39.984154,116.307490&key=3RZBZ-LZUCF-CT6J5-NWKZH-FCWOQ-UUFKY&get_poi=1').then(res => {
console.log(res)
})
},
fail: error => {
console.log(error)
}
})
},
linkTo (url) {
uni.navigateTo({
url
})
}
}
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.Watermark1 { .Watermark8 {
* { width: 292px;
height: 376px;
color: #FF5643;
box-sizing: border-box; box-sizing: border-box;
}
.text {
min-width: 274px;
height: 48px;
line-height: 48px;
padding: 0 16px;
font-size: 28px;
background: linear-gradient(270deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.2) 100%);
}
.top {
width: 184px;
background: #FEFFFE;
border-radius: 16px;
text-align: center; text-align: center;
overflow: hidden; background-image: url(../../images/rili.png);
background-size: 100% 100%;
h2 { h2 {
height: 64px; height: 68px;
line-height: 64px; padding-top: 106px;
background: #1ABDA6; text-align: center;
font-size: 34px; font-size: 32px;
color: #fff;
font-weight: normal; font-weight: normal;
} }
p { div {
height: 72px; line-height: 1;
line-height: 72px; margin: 10px 0 8px;
font-size: 100px;
font-weight: 600; font-weight: 600;
color: #333333;
font-size: 48px;
}
} }
.info { p {
line-height: 40px; font-size: 26px;
margin: 32px 0;
padding-left: 22px;
border-left: 6px solid #F8BC58;
p:nth-of-type(2) {
margin: 8px 0;
}
} }
} }
</style> </style>

View File

@@ -0,0 +1,327 @@
/*
* 农历数据表
*
* 农历分大小月大月30天小月29天但一年中哪个月为大月哪个月为小月是无规律的。
* 农历每十年有4个闰年但哪一年为闰年也是不确定的。
* 而闰月中,哪个闰月为大月,哪个为小月也是不确定的。
*
* 下面共20行每行10个数据。每个数据代表一年从阳历1900.1.31日起为第一个数据年的开始即阳历1900.1.31农历0.1.1。
* 200个数据可推200年的农历因此目前最大只能推算到2100年
*
* 对于每一个数据项5个十六进制数 = 20个二进制位
* 前4位即0在这一年是闰年时才有意义它代表这年闰月的大小月为1则闰大月为0则闰小月。
* 中间12位即4bd每位代表一个月为1则为大月为0则为小月。
* 最后4位即8代表这一年的闰月月份为0则不闰。首4位要与末4位搭配使用。
*/
const lunarInfo = new Array(
0x04bd8, 0x04ae0, 0x0a570, 0x054d5, 0x0d260, 0x0d950, 0x16554, 0x056a0, 0x09ad0, 0x055d2, // 1900年~1909年
0x04ae0, 0x0a5b6, 0x0a4d0, 0x0d250, 0x1d255, 0x0b540, 0x0d6a0, 0x0ada2, 0x095b0, 0x14977, // 1910年~1919年
0x04970, 0x0a4b0, 0x0b4b5, 0x06a50, 0x06d40, 0x1ab54, 0x02b60, 0x09570, 0x052f2, 0x04970, // 1920年~1929年
0x06566, 0x0d4a0, 0x0ea50, 0x06e95, 0x05ad0, 0x02b60, 0x186e3, 0x092e0, 0x1c8d7, 0x0c950, // 1930年~1939年
0x0d4a0, 0x1d8a6, 0x0b550, 0x056a0, 0x1a5b4, 0x025d0, 0x092d0, 0x0d2b2, 0x0a950, 0x0b557, // 1940年~1949年
0x06ca0, 0x0b550, 0x15355, 0x04da0, 0x0a5d0, 0x14573, 0x052d0, 0x0a9a8, 0x0e950, 0x06aa0, // 1950年~1959年
0x0aea6, 0x0ab50, 0x04b60, 0x0aae4, 0x0a570, 0x05260, 0x0f263, 0x0d950, 0x05b57, 0x056a0, // 1960年~1969年
0x096d0, 0x04dd5, 0x04ad0, 0x0a4d0, 0x0d4d4, 0x0d250, 0x0d558, 0x0b540, 0x0b5a0, 0x195a6, // 1970年~1979年
0x095b0, 0x049b0, 0x0a974, 0x0a4b0, 0x0b27a, 0x06a50, 0x06d40, 0x0af46, 0x0ab60, 0x09570, // 1980年~1989年
0x04af5, 0x04970, 0x064b0, 0x074a3, 0x0ea50, 0x06b58, 0x055c0, 0x0ab60, 0x096d5, 0x092e0, // 1990年~1999年
0x0c960, 0x0d954, 0x0d4a0, 0x0da50, 0x07552, 0x056a0, 0x0abb7, 0x025d0, 0x092d0, 0x0cab5, // 2000年~2009年
0x0a950, 0x0b4a0, 0x0baa4, 0x0ad50, 0x055d9, 0x04ba0, 0x0a5b0, 0x15176, 0x052b0, 0x0a930, // 2010年~2019年
0x07954, 0x06aa0, 0x0ad50, 0x05b52, 0x04b60, 0x0a6e6, 0x0a4e0, 0x0d260, 0x0ea65, 0x0d530, // 2020年~2029年
0x05aa0, 0x076a3, 0x096d0, 0x04bd7, 0x04ad0, 0x0a4d0, 0x1d0b6, 0x0d250, 0x0d520, 0x0dd45, // 2030年~2039年
0x0b5a0, 0x056d0, 0x055b2, 0x049b0, 0x0a577, 0x0a4b0, 0x0aa50, 0x1b255, 0x06d20, 0x0ada0, // 2040年~2049年
0x14b63, 0x09370, 0x049f8, 0x04970, 0x064b0, 0x168a6, 0x0ea50, 0x06b20, 0x1a6c4, 0x0aae0, // 2050年~2059年
0x0a2e0, 0x0d2e3, 0x0c960, 0x0d557, 0x0d4a0, 0x0da50, 0x05d55, 0x056a0, 0x0a6d0, 0x055d4, // 2060年~2069年
0x052d0, 0x0a9b8, 0x0a950, 0x0b4a0, 0x0b6a6, 0x0ad50, 0x055a0, 0x0aba4, 0x0a5b0, 0x052b0, // 2070年~2079年
0x0b273, 0x06930, 0x07337, 0x06aa0, 0x0ad50, 0x14b55, 0x04b60, 0x0a570, 0x054e4, 0x0d160, // 2080年~2089年
0x0e968, 0x0d520, 0x0daa0, 0x16aa6, 0x056d0, 0x04ae0, 0x0a9d4, 0x0a2d0, 0x0d150, 0x0f252, // 2090年~2099年
0x0d520 // 2100年
);
const minYear = 1900; // 能计算的最小年份
const maxYear = 2100; // 能计算的最大年份
// 阳历每月天数遇到闰年2月需加1天
const solarMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
// 农历月份别称
const monthName = new Array('正月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '冬月', '腊月');
// 二十四节气
const solarTerm = new Array(
'小寒', '大寒', '立春', '雨水', '惊蛰', '春分',
'清明', '谷雨', '立夏', '小满', '芒种', '夏至',
'小暑', '大暑', '立秋', '处暑', '白露', '秋分',
'寒露', '霜降', '立冬', '小雪', '大雪', '冬至'
);
// 二十节气相关系数
const termInfo = new Array(
0, 21208, 42467, 63836, 85337, 107014,
128867, 150921, 173149, 195551, 218072, 240693,
263343, 285989, 308563, 331033, 353350, 375494,
397447, 419210, 440795, 462224, 483532, 504758);
/**
* 检查年份是否输入正确
* @param year int 年份
*/
function _checkYear(year) {
if (year < minYear) {
throw new RangeError('年份不能小于' + minYear + '年');
} else if (year > maxYear) {
throw new RangeError('年份不能大于' + maxYear + '年');
}
return true;
}
/**
* 检查月份是否输入正确
* @param month int 月份
*/
function _checkMonth(month) {
if (month < 1) {
throw new RangeError('月份不能小于1');
} else if (month > 12) {
throw new RangeError('月份不能大于12');
}
return true;
}
/**
* 检查日期是否输入正确
* @param day int 日期
*/
function _checkDay(day) {
if (day < 1) {
throw new RangeError('日期不能小于1');
} else if (day > 31) {
throw new RangeError('日期不能大于31');
}
return true;
}
/**
* 返回农历year年中哪个月是闰月没有闰月返回0
* @param year int 年份
*/
function getLunarLeapMonth(year) {
if (_checkYear(year)) {
return lunarInfo[year - minYear] & 0xf; // 最后4位代表这一年的闰月月份为0则今年没有闰月
}
}
/**
* 返回农历year年闰月的天数如果没有闰月则返回0
* @param year int 年份
*/
function getLeapMonthDaysCount(year) {
if (getLunarLeapMonth(year)) {
return lunarInfo[year - minYear] & 0x10000 ? 30 : 29; // 前4位即0在这一年是闰年时才有意义它代表这年闰月的大小月
}
return 0;
}
/**
* 返回农历year年的总天数
* @param year int 年份
*/
function getLunarYearDaysCount(year) {
if (_checkYear(year)) {
let sum = 348; // 29天 * 12个月 = 348日
for (let i = 0x8000; i > 0x8; i >>= 1) {
sum += (lunarInfo[year - minYear] & i ? 1 : 0);
}
return sum + getLeapMonthDaysCount(year);
}
}
/**
* 返回农历year年month月的天数
* @param year int 年份
* @param month int 月份 1~12
*/
function getLunarYearMonthDaysCount(year, month) {
if (_checkYear(year) && _checkMonth(month)) {
return lunarInfo[year - minYear] & (0x10000 >> month) ? 30 : 29;
}
}
/**
* 农历日期的中文字符串
* @param day int 日期
*/
function getLunarDayString(day) {
if (_checkDay(day)) {
const nStr1 = new Array('日', '一', '二', '三', '四', '五', '六', '七', '八', '九', '十');
const nStr2 = new Array('初', '十', '廿', '卅');
let str = '';
switch (day) {
case 10:
str = '初十';
break;
case 20:
str = '二十';
break;
case 30:
str = '三十';
break;
default:
str = nStr2[Math.floor(day / 10)];
str += nStr1[day % 10];
break;
}
return str;
}
}
/**
* 返回某年的第n个节气为几日(从0小寒起算)
* @param year int 年份
* @param n 节气编号 0~23
*/
function getLunarTermDay(year, n) {
if (_checkYear(year) && n <= 23 && n >= 0) {
const sTermInfo = new Array(0, 21208, 42467, 63836, 85337, 107014, 128867, 150921, 173149, 195551, 218072, 240693, 263343, 285989, 308563, 331033, 353350, 375494, 397447, 419210, 440795, 462224, 483532, 504758);
const offDate = new Date((31556925974.7 * (year - minYear) + sTermInfo[n] * 60000) + Date.UTC(minYear, 0, 6, 2, 5));
return offDate.getUTCDate();
}
}
/**
* 阳历日期转农历日期
* @param year int 年份
* @param month int 月份 1~12
* @param day int 日期 1~31
*/
function solarToLunar(year, month, day) {
if (_checkYear(year) && _checkMonth(month) && _checkDay(day)) {
const baseDate = new Date(minYear, 0, 31); // 基础日期1900年1月31日
const objDate = new Date(year, month - 1, day); // 目标日期
let offset = parseInt((objDate - baseDate) / 86400000); // 偏移天数 60 * 60 * 24 * 1000 = 864000001天的毫秒数
let temp = 0;
let i = 0;
for (i = minYear; i < maxYear && offset > 0; i++) {
temp = getLunarYearDaysCount(i); // 农历year年的总天数
if (offset < temp) {
break;
} else {
offset -= temp;
}
}
const lunarYear = i; // 农历年份
const leap = getLunarLeapMonth(lunarYear); // 当年闰月是哪个月
let isLeapMonth = false; // 当前农历月份是否是闰月
for (i = 1; i <= 12 && offset > 0; i++) {
if (leap > 0 && i == (leap + 1) && !isLeapMonth) {
--i;
isLeapMonth = true;
temp = getLeapMonthDaysCount(lunarYear);
} else {
isLeapMonth = false;
temp = getLunarYearMonthDaysCount(lunarYear, i);
}
if (offset < temp) {
break;
} else {
offset -= temp;
}
}
const lunarMonth = i; // 农历月份
const lunarDay = offset + 1; // 农历日期
let monthStr = '';
if (isLeapMonth) {
monthStr = '闰' + monthName[lunarMonth - 1];
} else {
monthStr = monthName[lunarMonth - 1];
}
return {
year: lunarYear, // 农历年份
month: lunarMonth, // 农历月份
day: lunarDay, // 农历日期
isLeap: isLeapMonth, // 是否闰月
monthStr: monthStr, // 月份字符串
dayStr: getLunarDayString(lunarDay) // 日期字符串
};
}
}
/**
* 阳历某个月份天数
* @param year int 年份
* @param month int 月份 1~12
*/
function getSolarMonthDaysCount(year, month) {
if (_checkYear(year) && _checkMonth(month)) {
if (month == 2) {
return (((year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0)) ? 29 : 28);
} else {
return solarMonth[month - 1];
}
}
}
/**
* 获取指定日期是阳历年中的第几天
* @param year int 年份
* @param month int 月份 1-12
* @param day int 日期
*/
function getSolarDayNumber(year, month, day) {
if (_checkYear(year) && _checkMonth(month) && _checkDay(day)) {
const date = new Date(year, month - 1, day);
const d = date.getDate(); // 本月第几天
const m = month - 1;
let sum = d;
for (let i = 0; i < m; i++) {
sum += solarMonth[i];
}
if (m > 1 && (year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
sum += 1;
}
return sum;
}
}
/**
* 计算指定日期是否属于24节气
* @param year int 年份
* @param month int 月份 1~12
* @param day int 日期 1~31
*/
function getLunar24Days(year, month, day) {
if (_checkYear(year) && _checkMonth(month) && _checkDay(day)) {
const baseDate = new Date(1900, 0, 6, 2, 5, 0);
let str = false;
for (let i = 1; i <= 24; i++) {
const num = 525948.76 * (year - 1900) + termInfo[i];
const timestamp = baseDate.getTime() + num * 60 * 1000;
const newDate = new Date(timestamp);
if (getSolarDayNumber(newDate.getFullYear(), newDate.getMonth() + 1, newDate.getDate()) ==
getSolarDayNumber(year, month, day)) {
str = solarTerm[i];
break;
}
}
return str;
}
}
module.exports = {
getLunarLeapMonth, // 返回农历year年中哪个月是闰月没有闰月返回0
getLeapMonthDaysCount, // 返回农历year年闰月的天数如果没有闰月则返回0
getLunarYearDaysCount, // 返回农历year年的总天数
getLunarYearMonthDaysCount, // 返回农历year年month月的天数
getLunarDayString, // 农历日期的中文字符串
getLunarTermDay, // 返回某年的第n个节气为第几日
getSolarMonthDaysCount, // 获取阳历某个月份有多少天
getSolarDayNumber, // 获取指定日期是阳历年中的第几天
getLunar24Days, // 计算指定日期是否属于24节气
solarToLunar, // 阳历日期转农历日期
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 699 B