project/pages/home/index.vue

192 lines
3.6 KiB
Vue

<template>
<view class="home">
<uni-calendar :insert="true" :lunar="true" :start-date="'1950-1-1'" @change="selectCalend" />
<view class="content">
<view class="list">
<view class="item flex">
<view class="num">{{dateOptions.day}}</view>
<view class="text">
<view class="wz1">{{dateOptions.date}}</view>
<view class="wz2">{{dateOptions.nongli}}</view>
</view>
</view>
<view class="item">
<view class="p1 flex">
<view class="ok label"></view>
<view class="text">
<text class="wz" v-for="(item,index) in dateOptions.yi" :key="index">{{item}}</text>
</view>
</view>
<view class="p1 flex">
<view class="label">忌</view>
<view class="text">
<text class="wz" v-for="(item,index) in dateOptions.ji" :key="index">{{item}}</text>
</view>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
import {getHuangLi} from '@/api/home.js';
import lunarFn from '@/utils/lunarFn.js';
export default {
data() {
return {
dateOptions:{}
}
},
onLoad() {
},
onShow(options) {
var _that=this;
let today = _that.$moment().format('YYYY/MM/DD');
_that.getData(today)
},
methods: {
getData(time){
getHuangLi({
day:time
}).then((res)=>{
this.dateOptions = res;
console.log('resresresres',res)
})
},
selectCalend(option) {
//选择日历
var _that=this;
let time = _that.$moment(option.fulldate).format('YYYY/MM/DD')
_that.getData(time)
},
linkTo(){
uni.switchTab({
url: '/pages/customizate/index'
});
}
}
}
</script>
<style lang="scss" scoped>
.home {
background: #f2f2f2;
.flex {
display: flex;
align-items: center;
}
.content {
padding: 10rpx;
box-sizing: border-box;
}
.list {
border-radius: 20rpx;
width: 100%;
background-color: #fff;
padding: 0px 20rpx;
box-sizing: border-box;
.item {
border-bottom: 1px solid #eee;
padding: 0rpx 0px;
padding-bottom: 10rpx;
box-sizing: border-box;
&:last-child {
border-bottom: 0px;
}
.num {
font-size: 90rpx;
color: #d65044;
font-weight: bold;
margin-right: 20rpx;
}
.text {
font-size: 28rpx;
color: #666;
.wz{
margin-right: 10rpx;
}
}
.wz1 {
color: #000;
font-size: 32rpx;
font-weight: 600;
}
.label {
width: 40rpx;
height: 40rpx;
font-size: 28rpx;
text-align: center;
line-height: 40rpx;
border: 1px solid #666;
color: #666;
margin-right: 20rpx;
flex-shrink:0;
&.ok {
color: #d65044;
border: 1px solid #d65044;
}
}
.p1 {
margin: 20rpx 0px;
}
}
.desc {
color: #666;
font-size: 28rpx;
position: relative;
padding: 20rpx 0px;
}
.desc::before {
content: "";
position: absolute;
top: -8rpx;
right: -16rpx;
margin: 20px;
border-right: 1px solid #666;
border-bottom: 1px solid #666;
width: 16rpx;
height: 16rpx;
transform: rotate(-45deg);
}
}
/deep/.uni-calendar__backtoday {
background-color: #d65044;
color: #fff;
}
/deep/.uni-calendar__header-text {
color: #d65044;
font-weight: bold;
}
/deep/.uni-calendar__header-btn {
border-left-color: #d65044;
border-top-color: #d65044;
}
/deep/.uni-calendar-item--isDay,/deep/.uni-calendar-item--checked {
background-color: #d65044;
}
/deep/.uni-calendar-item--isDay .uni-calendar-item--isDay-text{
color: #fff;
}
/deep/.uni-calendar-item--isDay-text{
color: #d65044;
}
}
</style>