Commit 790ce436 authored by 华国豪's avatar 华国豪 🙄

1

parents 4ec2e7be 50177c76
......@@ -50,8 +50,8 @@
"pages/product/SametradeZW/Applicationnotes/Applicationnotes",
"pages/product/SametradeZW/Successview/Successview",
"component/amount/amount",
"pages/activity/activity"
"pages/activity/activity",
"pages/local/TicketOrder/TicketOrder"
],
"window": {
"backgroundTextStyle": "light",
......
......@@ -36,23 +36,28 @@ Component({
let item = e.currentTarget.dataset.item;
let index = e.currentTarget.dataset.index;
if(item.price==0 || item.price==""){
if (item.price == 0 || item.price == "" || !item.color){
return;
}
let msg={
configId: item.configId,
tcid: item.tcid,
selectIndex:index,
ymd: `${item.ym}-${item.day}`
ymd: `${item.ym}-${item.day}`,
};
if (item.couponsId){
msg.couponsId = item.couponsId;
msg.priceId = item.priceId;
msg.ticketId = item.ticketId;
msg.price = item.price;
}
this.triggerEvent('childrenEvent', msg);
},
getYearMonthDay() {
let that = this;
wx.showLoading({
title: '加载中222',
});
// console.log("currentDay", this.data.currentDay)
// console.log("priceData", this.data.priceData)
let currentYear = that.data.currentDay.substring(0, 4); //当前年份
let currentMonth = that.data.currentDay.substring(5, 7); //当前月份
that.setData({
......@@ -89,14 +94,21 @@ Component({
var currentDay = `${currentYear}-${currentMonth}-01`;
var dateObject = new Date(currentDay);
var firstDay = dateObject.getDay(); //得到每个月1号是周几
for (var i in that.data.priceData) {
var price = that.data.priceData[i];
var dayIndex = price.startDate.substring(price.startDate.length - 2, price.startDate.length);
var dayDict = daysData[Number(dayIndex) - 1];
dayDict.price = that.isLogin !== 1 ? price.b2CPrice : price.b2BPrice;
dayDict.configId = price.configIDDes;
dayDict.tcid = price.tcid;
if (price.configIDDes){
dayDict.configId = price.configIDDes;
dayDict.tcid = price.tcid;
}
if (price.couponsId){
dayDict.couponsId = price.couponsId;
dayDict.priceId = price.priceId;
dayDict.ticketId = price.ticketId;
}
if (dayIndex < strDate && strMonth == currentMonth) {
dayDict.price = '';
}
......
......@@ -5,7 +5,7 @@
<view class="dayView">
<view bindtap="selectDate" data-item="{{item}}" data-index="{{index}}" class="{{item.color ?' black':'grey'}} {{selectIndex==index ? 'Active' :''}} {{(item.price==''||item.price==0)?'grey':'black'}}" wx:for="{{daysData}}" wx:key="index">
<view hidden="{{item.day=='0 '}}">{{item.day}}</view>
<view hidden="{{item.price==''||item.price==0}}" class="price">¥{{item.price}}</view>
<view hidden="{{item.price==''||item.price==0 ||!item.price}}" class="price">¥{{item.price}}</view>
</view>
</view>
......
// pages/local/TicketDetails/TicketDetails.js
let app=getApp();
Page({
/**
* 页面的初始数据
*/
data: {
imgUrls: [
'https://images.unsplash.com/photo-1551334787-21e6bd3ab135?w=640',
'https://images.unsplash.com/photo-1551214012-84f95e060dee?w=640',
'https://images.unsplash.com/photo-1551446591-142875a901a1?w=640'
],
indicatorDots: false,
autoplay: false,
interval: 5000,
duration: 1000
duration: 1000,
idDes:'',
data:{},
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let that=this;
console.log(options);
if (options.idDes){
that.setData({
idDes: decodeURIComponent(options.idDes)
})
}
// that.setData({
// idDes: decodeURIComponent("TZxMkiL1iIY%3D%0A")
// })
that.getData();
},
goUrl(e) {
console.log(e)
let item = e.currentTarget.dataset.item;
wx.navigateTo({
url: '/pages/local/TicketOrder/TicketOrder?idDes=' + encodeURIComponent(item.idDes),
})
},
getData(){
app.$apiJavaNew('/api/b2b/scenic/getTicketCouponsInfo', { idDes: this.data.idDes}).then(res => {
this.setData({
data:res
})
}).catch(err => { })
},
goScroll(){
wx.pageScrollTo({
scrollTop: 0
})
},
/**
* 生命周期函数--监听页面初次渲染完成
......
<view class="ticketDes commonF">
<view class="swiper">
<swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}">
<block wx:for="{{imgUrls}}">
<block wx:for="{{data.coverImgs}}" wx:key="index">
<swiper-item>
<image src="{{item}}" class="slide-image" width="355" height="150" />
</swiper-item>
......@@ -11,16 +11,17 @@
<view class="ban_view">
<view class="price" style="margin-top:20rpx">
<text class="cee f22">¥</text>
<text class="cee f46">174~150</text>
<text style="margin-left:20rpx" class="c88 f22">最早可定:7月10号</text>
<text class="cee f46">{{data.minPrice}}</text>
<text class="cee f46" wx:if="{{data.minPrice!=data.maxPrice}}">~{{data.maxPrice}}</text>
<text wx:if="{{data.dieLine}}" style="margin-left:20rpx" class="c88 f22">提前预定天数:{{data.dieLine}}</text>
</view>
<view class="bold f32">
三丽鸥彩虹乐园
{{data.name}}
</view>
<view class="xqView" style="border-bottom:1px solid #E9E9E9">
<view class="left">
<image style="width:20rpx;height:20rpx;margin-right:6rpx" src="/images/group/tuan.png"></image>
<text>开放时间:开放中(日本时间10:00-17:00(周一-周五)</text>
<text>开放时间:{{data.openingHours}}</text>
</view>
<view class="right">
<image style="width:14rpx;height:26rpx" src="/images/group/chakn.png"></image>
......@@ -29,7 +30,7 @@
<view class="xqView">
<view class="left">
<image style="width:16rpx;height:20rpx;margin-right:6rpx" src="/images/group/adress.png"></image>
<text>日本千叶县浦安市舞浜1-1号</text>
<text>{{data.address}}</text>
</view>
<view class="right">
<image style="width:14rpx;height:26rpx" src="/images/group/chakn.png"></image>
......@@ -42,36 +43,22 @@
<image style="width:24rpx;height:26rpx;margin-right:6rpx" src="/images/local/info.png"></image>
<text class="f26">门票信息</text>
</view>
<view class="ticketItem">
<view wx:for="{{data.ticketList}}" wx:key="index" class="ticketItem">
<view class="left">
<view>成人票(18-64岁)</view>
<view style="margin-top:10rpx" class="c66">日本东京迪士尼一日游(海洋乐园)</view>
<view>{{item.ticketName}}<text wx:if="{{item.ticketDesc}}">({{item.ticketDesc}})</text></view>
<view style="margin-top:10rpx" class="c66">{{data.name}}</view>
</view>
<view class="right">
<view class="cee">
<text class="f22">¥</text>
<text class="f36">190</text>
<text class="f36">{{item.b2bPrice}}</text>
</view>
<view>
<text class="Ydbtn">立即预定</text>
</view>
</view>
</view>
<view class="ticketItem">
<view class="left">
<view>成人票(18-64岁)</view>
<view style="margin-top:10rpx" class="c66">日本东京迪士尼一日游(海洋乐园)</view>
</view>
<view class="right">
<view class="cee">
<text class="f22">¥</text>
<text class="f36">190</text>
</view>
<view>
<text class="Ydbtn">立即预定</text>
<text bindtap="goUrl" data-item="{{item}}" class="Ydbtn">立即预定</text>
</view>
</view>
</view>
</view>
<view class="Gray30"></view>
<view class="details">
......@@ -81,11 +68,11 @@
</view>
<view class="deItem">
<view class="f22 cee">预定说明</view>
<view>1、日本国土交通省于平成24年6月(2012年)发布最新规定,每日行车时 间不得超过10小时(以自车库实际发车时间为计算基准),若超时,则 司机有权拒绝,以有效防止巴士司机因过(疲)劳驾驶所衍生之交通状况。 (资料来源:日本国土交通省)。故敬请游客贵宾严格守时。按照导游指 导的集合或游览时间为准。 </view>
<view>{{data.bookingInfo}}</view>
</view>
<view class="deItem">
<view class="f22 cee">温馨提示</view>
<view>1、日本国土交通省于平成24年6月(2012年)发布最新规定,每日行车时 间不得超过10小时(以自车库实际发车时间为计算基准),若超时,则 司机有权拒绝,以有效防止巴士司机因过(疲)劳驾驶所衍生之交通状况。 (资料来源:日本国土交通省)。故敬请游客贵宾严格守时。按照导游指 导的集合或游览时间为准。 </view>
<view>{{data.about}}</view>
</view>
</view>
......@@ -97,21 +84,22 @@
</view>
<view class="deItem">
<view class="f22 cee">园区介绍</view>
<view>1、日本国土交通省于平成24年6月(2012年)发布最新规定,每日行车时 间不得超过10小时(以自车库实际发车时间为计算基准),若超时,则 司机有权拒绝,以有效防止巴士司机因过(疲)劳驾驶所衍生之交通状况。 (资料来源:日本国土交通省)。故敬请游客贵宾严格守时。按照导游指 导的集合或游览时间为准。 </view>
<view>{{data.feature}}</view>
</view>
<view class="deItem">
<view class="f22 cee">交通信息</view>
<view>1、日本国土交通省于平成24年6月(2012年)发布最新规定,每日行车时 间不得超过10小时(以自车库实际发车时间为计算基准),若超时,则 司机有权拒绝,以有效防止巴士司机因过(疲)劳驾驶所衍生之交通状况。 (资料来源:日本国土交通省)。故敬请游客贵宾严格守时。按照导游指 导的集合或游览时间为准。 </view>
<view>{{data.trafficInfo}}</view>
</view>
</view>
<!-- -->
<view class="bottomView">
<view style="margin-top:20rpx" class="bottomView">
<view class="left">
<text class="f22 cee">¥</text>
<text class="f46 bold cee">174~200</text>
<text class="f46 bold cee">{{data.minPrice}}</text>
<text class="f46 bold cee" wx:if="{{data.minPrice!=data.maxPrice}}">~{{data.maxPrice}}</text>
</view>
<view class="right">
<view bindtap="goScroll" class="right">
<image style="width:26rpx;height:26rpx;margin-right:6rpx" src="/images/local/xs.png"></image>
<text style="f30" style="color:#fff ">查看门票</text>
</view>
......
.swiper {
width: 100%;
height: 560rpx;
height: 540rpx;
}
.swiper swiper {
......@@ -62,7 +62,11 @@
.ticketInfo .ticketItem .right {
width: 130rpx;
}
.ticketInfo .ticketItem .right>view{
overflow: hidden;
text-overflow: ellipsis;
white-space:nowrap;
}
.ticketInfo .ticketItem .right .Ydbtn {
display: inline-block;
width: 120rpx;
......@@ -98,7 +102,9 @@
}
.bottomView .left{
width: 410rpx;
white-space: nowrap;
overflow: hidden;
text-overflow:ellipsis;
}
.bottomView .right{
width:341rpx;
......
......@@ -45,6 +45,12 @@ Component({
* 组件的方法列表
*/
methods: {
goUrl(e){
let item = e.currentTarget.dataset.item;
wx.navigateTo({
url: '/pages/local/TicketDetails/TicketDetails?idDes=' + encodeURIComponent(item.idDes),
})
},
zhpx() {
this.data.msg.orderByPrice = 0;
this.data.msg.orderBySales = 0;
......
......@@ -30,14 +30,14 @@
</view>
<!-- 列表数据 -->
<view wx:for="{{dataList}}" wx:key="index" class="ListItem commonF">
<view bindtap="goUrl" data-item="{{item}}" wx:for="{{dataList}}" wx:key="index" class="ListItem commonF">
<view class="imgView">
<image wx:if="{{item.coverImgs[0]}}" src="{{item.coverImgs[0]}}"></image>
</view>
<view class="ItemRight" style="width:460rpx;padding-left:15rpx">
<view class="text2">{{item.name}}
</view>
<view style="color:#888888;font-size:22rpx">
<view style="color:#888888;font-size:22rpx;overflow: hidden;text-overflow: ellipsis;white-space:nowrap;">
<image style="width:18rpx;height:22rpx" src="/images/group/adress.png"></image>
景点地址:{{item.address}}
</view>
......
// pages/GroupTour/ChDateNum/ChDateNum.js
let app = getApp();
var util = require('../../../utils/util.js')
Page({
/**
* 页面的初始数据
*/
data: {
currentDay: util.YYMMDD(new Date()),
priceData: [],
numer: 1,
monthList: [],
activeTab: 0,
isLogin: app.isLogin,
idDes: "",
timeStr: {},
tomonth: util.YYMM(new Date()),
selectIndex: -1,
msg: {
useDate: '',
purchaseQuantity: 1,
contactEmail: '',
discountMoney: 0,
orderSource: 2,
orderForm: 4,
couponAllotIds: "",
customerId: 0,
price: 0,
contactCNName: '',
contactMobile: '',
contactEmail: "",
discountMoney: 0,
couponAllotIds: '',
},
SettlementPrice: 0,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
let that = this;
console.log(options);
if (options.idDes) {
that.setData({
idDes: decodeURIComponent(options.idDes)
})
}
// that.setData({
// idDes: decodeURIComponent("tIVL4K8ZOcU%3D%0A")
// })
that.getInfo();
},
nameInput(e) {
let val = e.detail.value;
this.data.msg.contactCNName = val;
this.setData({
msg: this.data.msg
})
},
phoneInput(e) {
let val = e.detail.value;
this.data.msg.contactMobile = val;
if (val.length > 11) {    
wx.showToast({     
title: '手机号有误',
     icon: 'none',
     duration: 500    
})   
}  
this.setData({
msg: this.data.msg
})
},
emailInput(e) {
let val = e.detail.value;
this.data.msg.contactEmail = val;
this.setData({
msg: this.data.msg
})
},
// 改变月份
changeMonth(e) {
let num = e.currentTarget.dataset.month;
let tomonth = util.changeMonth(this.data.tomonth, num)
this.setData({
tomonth: tomonth
})
this.getCurrentDays()
},
childrenEvent(e) {
let that = this;
let val = e.detail;
that.data.msg.useDate = val.ymd;
that.data.msg.couponsId = val.couponsId;
that.data.msg.ticketId = val.ticketId;
that.data.msg.priceId = val.priceId;
that.data.msg.price = val.price;
that.setData({
selectIndex: val.selectIndex,
msg: that.data.msg
})
this.calcMoney();
},
// 获取当月天数
getCurrentDays() {
let that = this;
let MonthdayList = [];
let tomonth = that.data.tomonth;
let year = tomonth.substr(0, 4)
let month = tomonth.substr(5, 2)
that.data.currentMonthDays = util.getDays(year, month)
for (let i = 1; i <= that.data.currentMonthDays; i++) {
if (i < 10) {
i = `0${i}`;
}
let month = {};
month.dateStr = `${that.data.tomonth}-${i}`;
MonthdayList.push(month)
}
let DayList = [];
let len = that.data.timeStr.length;
MonthdayList.forEach(item => {
if (util.CompareDate(MonthdayList[0].dateStr, that.data.timeStr[len - 1].endDate)) {
let msg = {
dateStr: item.dateStr,
startDate: item.dateStr,
};
DayList.push(msg)
}
this.data.timeStr.forEach(time => {
if (util.CompareDate(item.dateStr, time.startDate) && util.CompareDate(time.endDate, item.dateStr)) {
let msg = {
b2CPrice: time.b2bPrice,
b2BPrice: time.b2bPrice,
couponsId: time.couponsId,
priceId: time.id,
idDes: time.idDes,
ticketId: time.ticketId,
dateStr: item.dateStr,
startDate: item.dateStr,
};
DayList.push(msg)
}
})
if (that.data.timeStr.length < 1) {
let msg = {
dateStr: item.dateStr,
startDate: item.dateStr,
};
DayList.push(msg)
}
})
that.setData({
priceData: DayList,
currentDay: that.data.tomonth
})
this.CreatCalendar();
},
getInfo() {
app.$apiJavaNew('/api/b2b/scenic/getCouponsTicketPriceList', {
idDes: this.data.idDes
}).then(res => {
// console.log(res);
this.setData({
timeStr: res
})
this.getCurrentDays();
}).catch(err => {})
},
StartYd() {
let that = this;
let msg = that.data.msg;
if (msg.useDate == "") {
wx.showToast({
title: "请选择使用日期",
icon: 'none',
duration: 1000
})
return;
}
app.$apiJavaData('/api/b2b/scenic/setTicketOrder', msg).then(res => {
if (res.resultCode == 1) {
wx.navigateTo({
url: '/pages/member/orderCenter/orderCenter?index=3',
})
} else {
wx.showToast({
title: res.message,
icon: 'none',
duration: 1000
})
}
}).catch(err => {})
},
subtract() {
let purchaseQuantity = this.data.msg.purchaseQuantity;
purchaseQuantity > 0 ? purchaseQuantity-- : 0;
this.data.msg.purchaseQuantity = purchaseQuantity
this.setData({
msg: this.data.msg
})
this.calcMoney();
},
add() {
let purchaseQuantity = this.data.msg.purchaseQuantity;
purchaseQuantity = ++purchaseQuantity;
this.data.msg.purchaseQuantity = purchaseQuantity
this.setData({
msg: this.data.msg
})
this.calcMoney();
},
inputPurchase(e) {
let val = e.detail.value;
this.data.msg.purchaseQuantity = val;
this.setData({
msg: this.data.msg
})
this.calcMoney();
},
calcMoney() {
let that = this;
let msg = that.data.msg;
let SettlementPrice = msg.price * Number(msg.purchaseQuantity);
that.setData({
SettlementPrice: SettlementPrice
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
},
CreatCalendar() {
this.calendar = this.selectComponent('#calendar');
this.calendar.getYearMonthDay();
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
}
})
\ No newline at end of file
{
"navigationBarTitleText": "订单填写",
"usingComponents": {
"calendar": "/component/calendar/calendar",
"amount": "/component/amount/amount"
}
}
\ No newline at end of file
<view class="DateNum commonF">
<view style="margin:15rpx;">
<text class="f30 bold">使用日期</text>
</view>
<view style="padding:15rpx 0;text-align:center;border-bottom:1px solid #e5e5e5">
<image bindtap="changeMonth" data-month="{{-1}}" style="width:14rpx;height:27rpx" src="/images/group/before.png"></image>
<text class="f30" style="margin:0 50rpx">{{tomonth}}</text>
<image bindtap="changeMonth" data-month="{{1}}" style="width:14rpx;height:27rpx" src="/images/group/chakn.png"></image>
</view>
<!-- 日历 -->
<view style="padding-bottom:10rpx">
<calendar bind:childrenEvent="childrenEvent" selectIndex="{{selectIndex}}" isLogin="{{isLogin}}" currentDay="{{currentDay}}" priceData="{{priceData}}" id="calendar"></calendar>
</view>
<view class="Gray30"></view>
<view>
<view class="personItem">
<view>购票数量</view>
<view class="num_wrap">
<button class='btn' catchtap='subtract' disabled='{{msg.purchaseQuantity<=0}}'>-</button>
<input class="input" type='number' value='{{msg.purchaseQuantity}}' bindinput='inputPurchase'></input>
<button class='btn' catchtap='add'>+</button>
</view>
</view>
</view>
<view class="Gray30"></view>
<!-- 联系人 -->
<view class="concatView">
<view class="f30">联系人信息</view>
<view class="concatItem">
<view class="left">联系人</view>
<view class="right">
<input bindinput="nameInput" placeholder="请输入联系人姓名"></input>
</view>
</view>
<view class="concatItem">
<view class="left">手机号码</view>
<view class="right">
<input bindinput="phoneInput" type="number" placeholder="请输入联系人手机号码"></input>
</view>
</view>
<view class="concatItem">
<view class="left">电子邮件</view>
<view class="right">
<input bindtap="emailInput" placeholder="用于接收确认单,非必填"></input>
</view>
</view>
</view>
<view class="{{GoodsView?'payFixed PayView':'PayView'}}">
<view style="width:400rpx;">
<text class="f20">总价:¥</text>
<text class="f46 cee">{{SettlementPrice}}</text>
<!-- <text bindtap='OpenGoodsView' style="padding-left:10rpx" class="f22 c55">明细</text> -->
<!-- <image bindtap='OpenGoodsView' style="width:18rpx;height:8rpx" src="/images/group/mx1.png"></image> -->
</view>
<view style="width:100rpx;border-left:1px solid #E9E9E9;">
<image style="width:45rpx;height:45rpx" src="/images/group/pay.png"></image>
</view>
<view bindtap='StartYd' class="startPay">确认订单</view>
</view>
</view>
\ No newline at end of file
.DateNum .scroll-header {
display: flex;
white-space: nowrap;
background: #e5efff;
/* height: 95rpx; */
}
.DateNum .scroll-header .scroll-view-item {
display: inline-flex;
font-size: 24rpx;
color: #111;
width: 166rpx;
height: 82rpx;
align-items: center;
flex-direction: column;
position: relative;
}
.DateNum .scroll-header .ScrollActive {
color: #5597ff;
border-bottom: 1rpx solid #5597ff;
}
.personItem {
width: 100%;
height: 90rpx;
border-top: 1px solid #f4f4f4;
display: flex;
justify-content: space-between;
padding:0 30rpx;
align-items: center;
position: relative;
}
.personItem>view {
display: inline-block;
font-size: 24rpx;
}
.personItem>view text{
position: absolute;
left: 200rpx;
top: 25rpx;
}
.PayView{
width:100%;
height:100rpx;
line-height:100rpx;
border-top:1px solid #E9E9E9;
display: flex;
align-items: center;
background: #fff;
z-index: 100;
}
.PayView>view{
display: inline-flex;
justify-content: center;
height: 100%;
align-items: center;
}
.startPay{
width:250rpx;
background:rgba(238,68,84,1);
color: #fff;
font-size: 30rpx;
}
.GoodsView{
position: fixed;
top: 0;
left: 0;
width: 100%;
height: calc(100% - 100rpx);
background:rgba(0,0,0,0.5);
z-index: 100;
text-align: center;
}
.GoodsView .GoodsDes{
background: #fff;
border-radius:12rpx 12rpx 0px 0px;
position: absolute;
bottom: 0;
width: 100%;
}
.GoodsView .flexbe{
padding:15rpx 30rpx;
display: flex;
justify-content: space-between;
}
.payFixed{
position: fixed;
bottom: 0;
/* width:100%; */
}
.concatView>view{
border-bottom: 1px solid #e9e9e9;
height: 90rpx;
line-height: 90rpx;
padding: 0 30rpx;
}
.concatView>view:last-child{
border: none;
}
.concatView .concatItem .left{
width: 150rpx;
float: left;
font-size: 28rpx;
height: 100%;
}
.concatView .concatItem .right{
width: 500rpx;
float: left;
font-size: 24rpx;
height: 100%;
}
.concatView .concatItem .right input{
height: 100%;
line-height: 90rpx;
}
/* 加减 */
.num_wrap{
width: 220rpx;
vertical-align: middle;
display: inline-flex!important;
flex-direction: row;
align-items: center;
justify-content: flex-end;
}
.num_wrap .btn{
width: 40rpx;
height:40rpx;
line-height: 30rpx;
text-align: center;
border-radius: 50%;
padding: 0;
margin:0;
font-size: 36rpx;
border: 1px solid #EE4454;
color: #EE4454;
}
.btn::after{
border: none;
}
.num_wrap .input{
width: 90rpx;
height: 60rpx;
color: #333;
font-size: 24rpx;
text-align: center;
border: none;
margin: 0 2rpx;
}
\ No newline at end of file
......@@ -18,6 +18,16 @@ const YYMMDD = date => {
return [year, month, day].map(formatNumber).join('-')
}
const YYMM= 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].map(formatNumber).join('-')
}
const CompareDate=(date1, date2)=> {
var oDate1 = new Date(date1);
var oDate2 = new Date(date2);
......@@ -31,10 +41,24 @@ const formatNumber = n => {
n = n.toString()
return n[1] ? n : '0' + n
}
const changeMonth=(date,i)=>{
let data = new Date(date);
data.setMonth(data.getMonth() + i);
let dateString = data.getFullYear() + "-" + ((data.getMonth() + 1) < 10 ? '0' + (data.getMonth() + 1) : (data.getMonth() + 1));
return dateString;
}
// 得到某年某月有多少天
const getDays = (year, month)=>{
month = parseInt(month, 10);
var d = new Date(year, month, 0);
return d.getDate();
}
module.exports = {
formatTime: formatTime,
CompareDate: CompareDate,
YYMMDD: YYMMDD,
changeMonth: changeMonth,
YYMM: YYMM,
getDays: getDays
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment