Files
nuttyreading-html/pages/luck/luck.vue
2024-01-17 17:15:05 +08:00

428 lines
11 KiB
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<view class="container">
<!-- 公共组件-每个页面必须引入 -->
<public-module></public-module> -->
<z-nav-bar title="五运六气"></z-nav-bar>
<view>
<!-- {{date}}---{{timestamp}} -->
<!-- <uni-section :title="'date 对象用法:' + datetimesingle" type="line"></uni-section> -->
<view class="datetimeBox">
<uni-datetime-picker type="datetime" v-model="date" @change="changeLog" :clear-icon="false" />
</view>
<view class="flexbox box1 grayBg">
<view class="yunqi">
<view class="">
<text>五运{{wy.zhuyun[wy.now]}}(主运) &nbsp; {{wy.keyun[wy.now]}}(客运) &nbsp;
{{wy.nianyun}}(年运)</text>
</view>
<view class="">
<text>六气{{lq.zhuqi[lq.now]}}(主气) &nbsp; {{lq.keqi[lq.now]}}(客气)</text>
</view>
</view>
<!-- <view class="yinli">
<text>{{yinli.year}}</text>
<text>{{yinli.month}}</text>
<text>{{yinli.day}}</text>
<text>{{yinli.hour}}</text>
</view> -->
</view>
</view>
<view class="centerBox"> 五运图 </view>
<!-- <scroll-view class="scroll-view_H flexbox" scroll-x="true" @scroll="scroll" > -->
<view class="flexbox scroll-view_H wuYunBox">
<view class="leftone row" id="text">
<view class="line line1">开始时间<br /><span>运数</span></view>
<!-- <view class="">*</view> -->
<view class="line zhuyun">主运</view>
<view class="line keyun">客运</view>
</view>
<view :class="['row', wy.now == 0 ? 'cur' : '']" id="text0">
<view class="line line1">{{wy.fiveTimes[0]}}<br /><span>初之运</span></view>
<view class="line zhuyun">{{wy.zhuyun[0]}}</view>
<view class="line keyun">{{wy.keyun[0]}}</view>
</view>
<view :class="['row', wy.now == 1 ? 'cur' : '']" id="text1">
<view class="line line1">{{wy.fiveTimes[1]}}<br /><span>二之运</span></view>
<view class="line zhuyun">{{wy.zhuyun[1]}}</view>
<view class="line keyun">{{wy.keyun[1]}}</view>
</view>
<view :class="['row', wy.now == 2 ? 'cur' : '']" id="text2">
<view class="line line1">{{wy.fiveTimes[2]}}<br /><span>三之运</span></view>
<view class="line zhuyun">{{wy.zhuyun[2]}}</view>
<view class="line keyun">{{wy.keyun[2]}}</view>
</view>
<view :class="['row', wy.now == 3 ? 'cur' : '']" id="text3">
<view class="line line1">{{wy.fiveTimes[3]}}<br /><span>四之运</span></view>
<view class="line zhuyun">{{wy.zhuyun[3]}}</view>
<view class="line keyun">{{wy.keyun[3]}}</view>
</view>
<view :class="['row',wy.now == 4 ? 'cur' : '']" id="text4">
<view class="line line1">{{wy.fiveTimes[4]}}<br /><span>终之运</span></view>
<view class="line zhuyun">{{wy.zhuyun[4]}}</view>
<view class="line keyun">{{wy.keyun[4]}}</view>
</view>
</view>
<!-- </scroll-view> -->
<view class="centerBox"> 六气图左滑查看全年气数 </view>
<scroll-view class="scroll-view_H flexbox liuqiBox" scroll-x="true" @scroll="scroll" :scroll-left="200">
<!-- <view class="flexbox scroll-view_H"> -->
<view class="leftone row">
<view class="line line1">开始时间<br /><span>气数</span></view>
<!-- <view class="">*</view> -->
<view class="line zhuyun">主气</view>
<view class="line keyun">客气</view>
</view>
<view :class="['row', lq.now == 0 ? 'cur' : '']">
<view class="line line1">{{lq.time[0]}}<br /><span>初之气</span></view>
<view class="line zhuyun">{{lq.zhuqi[0]}}</view>
<view class="line keyun">{{lq.keqi[0]}}</view>
</view>
<view :class="['row', lq.now == 1 ? 'cur' : '']">
<view class="line line1">{{lq.time[1]}}<br /><span>二之气</span></view>
<view class="line zhuyun">{{lq.zhuqi[1]}}</view>
<view class="line keyun">{{lq.keqi[1]}}</view>
</view>
<view :class="['row', 'sizai', 'sizai1', lq.now == 2 ? 'cur' : '']">
<view class="line line1">{{lq.time[2]}}<br /><span>三之气</span></view>
<view class="line zhuyun">{{lq.zhuqi[2]}}</view>
<view class="line keyun">{{lq.keqi[2]}}</view>
</view>
<view :class="['row', lq.now == 3 ? 'cur' : '']">
<view class="line line1">{{lq.time[3]}}<br /><span>四之气</span></view>
<view class="line zhuyun">{{lq.zhuqi[3]}}</view>
<view class="line keyun">{{lq.keqi[3]}}</view>
</view>
<view :class="['row', lq.now == 4 ? 'cur' : '']">
<view class="line line1">{{lq.time[4]}}<br /><span>五之气</span></view>
<view class="line zhuyun">{{lq.zhuqi[4]}}</view>
<view class="line keyun">{{lq.keqi[4]}}</view>
</view>
<view :class="['row', 'sizai', 'sizai2', lq.now == 5 ? 'cur' : '']">
<view class="line line1">{{lq.time[5]}}<br /><span>终之气</span></view>
<view class="line zhuyun">{{lq.zhuqi[5]}}</view>
<view class="line keyun">{{lq.keqi[5]}}</view>
</view>
<!-- </view> -->
</scroll-view>
<!-- <image src="../../static/icon/leftFrag.gif" mode="scaleToFill"></image> -->
<music-play :playData="playData"></music-play>
<z-navigation></z-navigation>
</view>
</template>
<script>
import musicPlay from '@/components/music.vue'
import $http from '@/config/requestConfig.js';
function formatDateTime(time) {
var date = new Date(time);
var y = date.getFullYear();
var m = date.getMonth() + 1;
m = m < 10 ? ('0' + m) : m;
var d = date.getDate();
d = d < 10 ? ('0' + d) : d;
var h = date.getHours();
h = h < 10 ? ('0' + h) : h;
var minute = date.getMinutes();
var second = date.getSeconds();
minute = minute < 10 ? ('0' + minute) : minute;
second = second < 10 ? ('0' + second) : second;
return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + second;
};
export default {
data() {
return {
playData: {},
pageWidth: uni.getSystemInfoSync().windowWidth,
pageHeight: uni.getSystemInfoSync().windowHeight - 200,
fiveYunNum: 5,
// date: new Date().toISOString().slice(0, 10), // 只返回年月日
// date: Date.now() -2* 24 * 3600 * 1000, // 返回年月日带时间
date: Date.now(), // 返回年月日带时间
dateToString: formatDateTime(new Date()), // 字符串格式的日期
// timestamp: Date.now() -2* 24 * 3600 * 1000, // 时间戳
timestamp: Date.now(), // 时间戳
wy: {
curTime: 0,
zhuyun: [],
keyun: [],
nianyun: '',
fiveTimes: []
},
showCalendar: false,
info: {
lunar: true,
range: true,
insert: false,
selected: []
},
lq: {
curTime: 0,
zhuqi: [],
keqi: [],
time: []
},
yinli: {
year: '',
month: '',
day: '',
hour: ''
},
wYScrollLeft: 0,
lQScrollLeft: 0,
wytext: '',
}
},
onLoad() {
let da = new Date().toISOString().slice(0, 10)
this.timestamp = new Date(da).getTime()
this.getYun(this.dateToString)
},
onHide() {
},
methods: {
scroll: function(e) {},
// 获取五运六气
getYun(date) {
let that = this
$http.request({
url: "book/point/WYLQForYear",
method: "POST", // POST、GET、PUT、DELETE具体说明查看官方文档
data: {
"date": date
},
header: { //默认 无 说明:请求头
'Content-Type': 'application/json'
},
})
.then(res => {
if (res.code == 0 && res.wylq) {
console.log('获取成功', res.wylq)
this.wy.zhuyun = res.wylq.wy.zhuYun
this.wy.keyun = res.wylq.wy.keYun
this.wy.nianyun = res.wylq.wy.nianYun
this.wy.fiveTimes = res.wylq.wy.time
this.wy.now = res.wylq.wy.now
this.wytext = 'text' + this.wy.now
// this.wy.timestampList = res.wylq.wy.time.map( item => {
// return new Date(item).getTime()
// })
// this.wy.curTime = this.wy.timestampList.find(function(elem){
// return elem > that.timestamp
// });
// console.log(this.wy,'this.wy.curTime',this.timestamp)
// this.yinli.month = res.wylq.month
// this.yinli.day = res.wylq.day
// this.yinli.hour = res.wylq.hour
// this.yinli.year = res.wylq.year
this.lq = res.wylq.lq
// this.wy.now >= 2 ? this.wYScrollLeft = 1800 : 0
// this.lq.now >= 2 ?this.lQScrollLeft = 1800 : 0
// this.lq.timestampList = res.wylq.lq.time.map( item => {
// return new Date(item).getTime()
// })
// console.log(this.wYScrollLeft,this.lQScrollLeft,'this.lq.timestampList')
}
}).catch(e => {
console.log(e, 'e')
});
},
changeLog(e) {
console.log('change事件:', e);
let ss = e.slice(0, 10)
this.timestamp = new Date(ss).getTime()
this.getYun(e)
},
formatDateTime(time) {
var date = new Date(time);
var y = date.getFullYear();
var m = date.getMonth() + 1;
m = m < 10 ? ('0' + m) : m;
var d = date.getDate();
d = d < 10 ? ('0' + d) : d;
var h = date.getHours();
h = h < 10 ? ('0' + h) : h;
var minute = date.getMinutes();
var second = date.getSeconds();
minute = minute < 10 ? ('0' + minute) : minute;
second = second < 10 ? ('0' + second) : second;
return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + second;
},
},
components: {
musicPlay
},
}
</script>
<style lang="scss" scoped>
* {
font-size: 28rpx;
}
.centerBox {
text-align: center;
padding: 20px;
color: #888;
}
.yinli {
line-height: 50rpx;
text {
writing-mode: vertical-rl;
letter-spacing: 20rpx;
color: #c06346;
}
}
.box1 {
padding: 20rpx;
margin-bottom: 20rpx;
justify-content: space-between;
.yunqi {
color: #c06346;
line-height: 50rpx;
}
}
.grayBg {
background-color: #eee;
}
.scroll-view_H {
white-space: nowrap;
width: 100%;
.leftone {
border-left: 1px solid #ddd;
}
.row {
display: inline-block;
text-align: center;
background-color: #fef9e4;
border-right: 1px solid #ddd;
border-bottom: 1px solid #ddd;
}
.row.cur {
background-color: #8d3d16;
color: #fff;
position: relative;
border-right: 0;
z-index: 5;
box-shadow: 0 0 10px #8d3d16;
}
.line {
padding: 20rpx;
border-top: 1px solid #ddd;
span {
font-size: 36rpx;
}
}
.line1 {
font-size: 24rpx;
height: 200rpx;
writing-mode: vertical-rl;
;
}
.zhuyun {
color: #8d3d16;
background-color: #faede7;
font-size: 30rpx;
}
.keyun {
color: #c06346;
background-color: #fceeed;
font-size: 30rpx;
}
}
.container {
padding: 10rpx;
background-color: #fff;
padding-bottom: 70rpx;
}
.datetimeBox {
width: 80%;
margin: 0 auto;
margin-bottom: 30rpx;
}
.liuqiBox {
.line.keyun {
padding: 60rpx 10rpx
}
}
.wuYunBox {
.row {
width: 20%;
box-sizing: border-box;
}
}
/deep/ .uni-calendar__content-mobile {
bottom: 100rpx !important;
}
.sizai {
.keyun {
position: relative;
}
.keyun::after {
position: absolute;
content: '';
top: 24rpx;
left: 0;
font-size: 24rpx;
display: block;
width: 100%;
color: #888;
text-align: center;
}
}
.sizai1 {
.keyun::after {
content: '(司天)';
}
}
.sizai2 {
.keyun::after {
content: '(在泉)';
}
}
.flexbox {
display: flex;
}
</style>