diff --git a/assets/images/appointment.png b/assets/images/appointment.png
new file mode 100644
index 0000000..0556456
Binary files /dev/null and b/assets/images/appointment.png differ
diff --git a/config/config.js b/config/config.js
index 2667193..c0c5c24 100644
--- a/config/config.js
+++ b/config/config.js
@@ -160,6 +160,22 @@ var config = {
* 订单退款状态
*/
getRefundStatus: "/order/getRefundStatus",
+ /**
+ * 查询预约状态
+ */
+ getUserReservation: "/wxCouponOrderReservation/getUserReservation",
+ /**
+ * 保存/更改预约信息
+ */
+ saveOrderReservation: "/wxCouponOrderReservation/saveOrUpdate",
+ /**
+ * 查询预约详情
+ */
+ getOrderReservationDetail: "/wxCouponOrderReservation/detail",
+ /**
+ * 取消预约
+ */
+ cancelReservation: "/wxCouponOrderReservation/cancelReservation",
/**
* 获取im客服id
*/
diff --git a/package2/pages/appointment/appointment.js b/package2/pages/appointment/appointment.js
index c0895be..60f1891 100644
--- a/package2/pages/appointment/appointment.js
+++ b/package2/pages/appointment/appointment.js
@@ -1,9 +1,244 @@
// c:\Users\Holy-Knight-IX\Desktop\Working Space\4.TikTok-MiniPro\ttc\package2\pages\appointment\appointment.js
+let config = require("../../../config/config.js");
+let util = require("../../../utils/util");
+let Http = require("../../../utils/HttpBasics");
+let app = getApp();
+const imgurl = require("../../../utils/imgurl");
Page({
data: {
+ appointmentText: "确认预约",
+ id: "",
+ orderId: "",
+ startTime: "",
+ endTime: "",
+ mallTenantId: "",
+ pickedAddress: "请选择地址",
+ pickedDate: "请选择日期",
+ pickedStartTime: "请选择",
+ pickedEndTime: "请选择",
+ describeStr: "",
+ status: ""
+ },
+ onLoad(options) {
+ console.log(options, 'options');
+ this.setData({
+ id: options.id || '',
+ orderId: options.orderId || '',
+ startTime: options.startTime || '',
+ endTime: options.endTime || ''
+ })
+
+ const mallTenantId = tt.getStorageSync('mallTenantId');
+ if (mallTenantId) {
+ this.setData({
+ mallTenantId
+ })
+ }
+
+ if (this.data.id) {
+ this.getDetail(this.data.id)
+ }
+ },
+
+ chooseAddress() {
+ let that = this;
+ tt.chooseLocation({
+ success: function (res) {
+ that.setData({
+ pickedAddress: res.address,
+ })
+ },
+ fail: function (error) {
+ console.log(error)
+ },
+ complete: function (data) {}
+ })
+ },
+
+ chooseDate(e) {
+ console.log(e.detail.value, 'e');
+ this.setData({
+ pickedDate: e.detail.value
+ })
+ },
+
+ chooseStartTime(e) {
+ console.log(e.detail.value, 'e');
+ this.setData({
+ pickedStartTime: e.detail.value
+ })
+ },
+
+ chooseEndTime(e) {
+ console.log(e.detail.value, 'e');
+ this.setData({
+ pickedEndTime: e.detail.value
+ })
+ },
+
+ describing(e) {
+ this.setData({
+ describeStr: e.detail.value
+ })
+ },
+
+ confirm() {
+ const tempData = this.data
+
+ if (tempData.pickedAddress == '请选择地址') {
+ tt.showToast({
+ title: '请选择地址!',
+ icon: 'fail'
+ });
+ return
+ }
+
+ if (tempData.pickedDate == '请选择日期') {
+ tt.showToast({
+ title: '请请选择日期!',
+ icon: 'fail'
+ });
+ return
+ }
+
+ if (tempData.pickedStartTime == '请选择') {
+ tt.showToast({
+ title: '请起始时间!',
+ icon: 'fail'
+ });
+ return
+ }
+
+ if (tempData.pickedEndTime == '请选择') {
+ tt.showToast({
+ title: '请结束时间!',
+ icon: 'fail'
+ });
+ return
+ }
+
+ const data = {
+ couponOrderId: tempData.orderId,
+ userAddress: tempData.pickedAddress,
+ startDate: tempData.pickedDate + " " + tempData.pickedStartTime + ":00",
+ endDate: tempData.pickedDate + " " + tempData.pickedEndTime + ":00",
+ describeStr: tempData.describeStr,
+ mallTenantId: tempData.mallTenantId || ''
+ }
+
+ if (this.data.id) {
+ data.id = this.data.id
+ }
+
+ if (this.data.status == 1) {
+ data.status = 0
+ }
+
+ console.log(data, 'data');
+ this.saveOrderReservation(data)
+ },
+
+ cancel() {
+ tt.showModal({
+ title: "取消预约",
+ content: "确定要取消预约吗?",
+ showCancel: true,
+ success: (res) => {
+ if (res.confirm) {
+ this.cancelReservation(this.data.id)
+ }
+ if (res.cancel) {
+ return
+ }
+ },
+ fail: (res) => {
+
+ },
+ });
+
+ },
+
+ cancelReservation(id) {
+ const that = this
+ Http.post({
+ url: config.api.cancelReservation,
+ data: {
+ id,
+ mallTenantId: this.data.mallTenantId || ''
+ }
+ }).then(res => {
+ console.log(res, 'cancelReservation');
+ tt.showToast({
+ title: '取消成功!',
+ icon: 'success',
+ duration: 2000,
+ success: (res) => {
+ setTimeout(() => {
+ tt.navigateBack();
+ }, 1500);
+ },
+ fail: (res) => {
+
+ },
+ });
+ }).catch(err => {
+ console.log(err, 'cancelReservation');
+ tt.showToast({
+ title: err.message,
+ icon: 'none'
+ });
+ })
+ },
+
+ saveOrderReservation(data) {
+ Http.post({
+ url: config.api.saveOrderReservation,
+ data
+ }).then(res => {
+ console.log(res, 'saveOrderReservation');
+ tt.showToast({
+ title: '预约成功!',
+ icon: 'success',
+ duration: 2000,
+ success: (res) => {
+ setTimeout(() => {
+ tt.navigateBack();
+ }, 1500);
+ },
+ fail: (res) => {
+ },
+ });
+ }).catch(err => {
+ console.log(err, 'saveOrderReservation');
+ tt.showToast({
+ title: err.message,
+ icon: 'none'
+ });
+ })
},
- onLoad: function (options) {
+ getDetail(id) {
+ const that = this
+ Http.get({
+ url: config.api.getOrderReservationDetail,
+ data: {
+ id,
+ mallTenantId: this.data.mallTenantId || ''
+ }
+ }).then(res => {
+ console.log(res, 'getOrderReservationDetail');
+ that.setData({
+ pickedAddress: res.data.userAddress || '请选择地址',
+ pickedDate: util.timestampToTime(res.data.startDate, 'YYYY-MM-DD'),
+ pickedStartTime: util.timestampToTime(res.data.startDate, 'hh:mm'),
+ pickedEndTime: util.timestampToTime(res.data.endDate, 'hh:mm'),
+ describeStr: res.data.describeStr,
+ status: res.data.status,
+ appointmentText: res.data.status == 1 ? "重新预约" : "修改预约"
+ })
+ }).catch(err => {
+ console.log(err, 'getOrderReservationDetail');
+ })
}
})
\ No newline at end of file
diff --git a/package2/pages/appointment/appointment.json b/package2/pages/appointment/appointment.json
index 3928faa..e608899 100644
--- a/package2/pages/appointment/appointment.json
+++ b/package2/pages/appointment/appointment.json
@@ -1,3 +1,6 @@
{
+ "navigationBarTitleText": "订单预约",
+ "navigationBarBackgroundColor": "#fff",
+ "navigationBarTextStyle": "black",
"usingComponents": {}
}
\ No newline at end of file
diff --git a/package2/pages/appointment/appointment.ttml b/package2/pages/appointment/appointment.ttml
index f14869b..678a22a 100644
--- a/package2/pages/appointment/appointment.ttml
+++ b/package2/pages/appointment/appointment.ttml
@@ -1,2 +1,36 @@
-c:\Users\Holy-Knight-IX\Desktop\Working Space\4.TikTok-MiniPro\ttc\package2\pages\appointment\appointment.ttml
\ No newline at end of file
+
+
+ 选择服务地点:
+
+ {{ pickedAddress }}
+
+
+
+
+ 选择服务地点:
+
+ {{ pickedAddress }}
+
+
+
+
+ 选择服务日期:
+
+ {{ pickedDate }}
+
+
+
+ 预计上门时间:
+ {{ pickedStartTime }}
+ -
+ {{ pickedEndTime }}
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/package2/pages/appointment/appointment.ttss b/package2/pages/appointment/appointment.ttss
index bf74286..57f4f57 100644
--- a/package2/pages/appointment/appointment.ttss
+++ b/package2/pages/appointment/appointment.ttss
@@ -1 +1,65 @@
-/* c:\Users\Holy-Knight-IX\Desktop\Working Space\4.TikTok-MiniPro\ttc\package2\pages\appointment\appointment.ttss */
\ No newline at end of file
+/* c:\Users\Holy-Knight-IX\Desktop\Working Space\4.TikTok-MiniPro\ttc\package2\pages\appointment\appointment.ttss */
+page {
+ font-size: 30rpx;
+ box-sizing: border-box !important;
+}
+
+.continer {
+ width: 90%;
+ height: 100%;
+ margin: auto;
+}
+
+.addressPicker {
+ background-color: #fff;
+ border-radius: 20rpx;
+ padding: 30rpx;
+ margin: 35rpx auto;
+}
+
+.address {
+ color: #8a8a8a;
+}
+
+.addressPickerFlex {
+ display: flex;
+ justify-content: space-between;
+ background-color: #fff;
+ border-radius: 20rpx;
+ padding: 30rpx;
+ margin: 35rpx auto;
+}
+
+
+.datePicker {
+ background-color: #fff;
+ border-radius: 20rpx;
+ padding: 30rpx;
+ margin: 35rpx auto;
+}
+
+.datePickerFlex {
+ display: flex;
+ justify-content: space-between;
+ background-color: #fff;
+ border-radius: 20rpx;
+ padding: 30rpx;
+ margin: 35rpx auto;
+}
+
+.textarea {
+ margin: 35rpx auto;
+ overflow: hidden;
+ border-radius: 20rpx;
+}
+
+.describe {
+ width: 100%;
+ background-color: #fff;
+ padding: 25rpx;
+}
+
+.confirm {
+ background-color: #3c89ff;
+ margin-bottom: 20rpx;
+}
\ No newline at end of file
diff --git a/pages/coupon/detail/index.js b/pages/coupon/detail/index.js
index 287393f..e62a7c6 100644
--- a/pages/coupon/detail/index.js
+++ b/pages/coupon/detail/index.js
@@ -306,7 +306,7 @@ Page({
let param = {
id: this.data.cardData.couponOrderId,
cUserId: this.data.cardData.cuserId,
- updateDate: util.formatTime(Number(that.data.cardData.updateDate), "yyyy-MM-dd hh:mm:ss")
+ updateDate: util.timestampToTime(Number(that.data.cardData.updateDate), "YYYY-MM-DD hh:mm:ss")
}
Http.get({
url: config.api.queryCardStatus,
@@ -327,7 +327,7 @@ Page({
let param = {
id: this.data.cardData.couponOrderId,
cUserId: this.data.cardData.cuserId,
- updateDate: util.formatTime(Number(this.data.cardData.updateDate), "yyyy-MM-dd hh:mm:ss")
+ updateDate: util.timestampToTime(Number(this.data.cardData.updateDate), "YYYY-MM-DD hh:mm:ss")
}
this.setData({
@@ -788,7 +788,7 @@ Page({
clearInterval(that.data.setInterval)
}
if (res.data.actStatus == 0) {
- var beginTime = util.formatTime(res.data.beginTime, "yyyy-MM-dd hh:mm:ss");
+ var beginTime = util.timestampToTime(res.data.beginTime, "YYYY-MM-DD hh:mm:ss");
if (util.timechuo(beginTime).indexOf('-') == 0) {
that.setData({
beginTime: "活动已结束",
@@ -799,7 +799,7 @@ Page({
});
}
} else {
- var endTime = util.formatTime(res.data.endTime, "yyyy-MM-dd hh:mm:ss");
+ var endTime = util.timestampToTime(res.data.endTime, "YYYY-MM-DD hh:mm:ss");
if (util.timechuo(endTime).indexOf('-') == 0) {
that.setData({
endtime: "活动已结束",
@@ -818,8 +818,8 @@ Page({
if (res.data.type == 10) {
that.setData({
salePriceStr: res.data.salePriceStr,
- pickEndDate: util.formatTime(res.data.pickEndDate, "yyyy-MM-dd"),
- pickStartDate: util.formatTime(res.data.pickStartDate, "yyyy-MM-dd"),
+ pickEndDate: util.timestampToTime(res.data.pickEndDate, "YYYY-MM-DD"),
+ pickStartDate: util.timestampToTime(res.data.pickStartDate, "YYYY-MM-DD"),
priceStr: res.data.priceStr,
tailPriceStr: res.data.tailPriceStr,
origPriceStr: res.data.origPriceStr
@@ -827,12 +827,12 @@ Page({
}
if (res.data.validType == 1) {
that.setData({
- soldStartTime: util.formatTime(res.data.soldStartTime, "yyyy-MM-dd") || null,
- soldEndTime: util.formatTime(res.data.soldEndTime, "yyyy-MM-dd") || null,
- validStartDate: util.formatTime(res.data.validStartDate, "yyyy-MM-dd"),
- validEndDate: util.formatTime(res.data.validEndDate, "yyyy-MM-dd"),
- pickStartDate: util.formatTime(res.data.pickStartDate, "yyyy-MM-dd"),
- pickEndDate: util.formatTime(res.data.pickEndDate, "yyyy-MM-dd"),
+ soldStartTime: util.timestampToTime(res.data.soldStartTime, "YYYY-MM-DD") || null,
+ soldEndTime: util.timestampToTime(res.data.soldEndTime, "YYYY-MM-DD") || null,
+ validStartDate: util.timestampToTime(res.data.validStartDate, "YYYY-MM-DD"),
+ validEndDate: util.timestampToTime(res.data.validEndDate, "YYYY-MM-DD"),
+ pickStartDate: util.timestampToTime(res.data.pickStartDate, "YYYY-MM-DD"),
+ pickEndDate: util.timestampToTime(res.data.pickEndDate, "YYYY-MM-DD"),
});
} else {
if (res.data.validDays) {
diff --git a/pages/coupon/detail/index.ttml b/pages/coupon/detail/index.ttml
index c69efbe..4a33e9d 100644
--- a/pages/coupon/detail/index.ttml
+++ b/pages/coupon/detail/index.ttml
@@ -138,6 +138,8 @@
+
+
购买须知
使用期
diff --git a/pages/coupon/detail/index.ttss b/pages/coupon/detail/index.ttss
index 74db8ad..0ba3111 100644
--- a/pages/coupon/detail/index.ttss
+++ b/pages/coupon/detail/index.ttss
@@ -377,6 +377,10 @@ button::after {
padding-bottom: 30rpx;
}
+.alerting {
+ width: 100%;
+}
+
.nodesD {
height: 87rpx;
line-height: 87rpx;
diff --git a/pages/order/detail/index.js b/pages/order/detail/index.js
index b35be1c..9cd8fda 100644
--- a/pages/order/detail/index.js
+++ b/pages/order/detail/index.js
@@ -60,7 +60,12 @@ Page({
IMorderId: "",
outOrderId: "",
outRefundOrderId: "",
- canIUseRefund: false
+ canIUseRefund: false,
+ isAppointment: false,
+ appointStart: "",
+ appointEnd: "",
+ appointmentId: "",
+ appointmentStatus: ""
},
imCallback(e) {
@@ -175,6 +180,48 @@ Page({
})
},
+ goAppointment(e) {
+ const that = this
+ const orderId = e.currentTarget.dataset.id
+ const id = this.data.appointmentId
+ const startTime = that.data.order.validStartDate
+ const endTime = that.data.order.validEndDate
+
+ console.log(startTime, endTime);
+
+ tt.navigateTo({
+ url: `/package2/pages/appointment/appointment?id=${id}&orderId=${orderId}&startTime=${startTime}&endTime=${endTime}`,
+ });
+ },
+
+ getUserReservation(couponOrderId) {
+ const that = this
+ Http.get({
+ url: config.api.getUserReservation,
+ data: {
+ couponOrderId,
+ mallTenantId: this.data.mallTenantId || ''
+ }
+ }).then(res => {
+ console.log(res, 'getUserReservation');
+ if (res.data) {
+ const appointStart = util.timestampToTime(res.data.startDate, 'YYYY-MM-DD hh:mm:ss')
+ const appointEnd = util.timestampToTime(res.data.endDate, 'hh:mm:ss')
+ const appointmentId = res.data.id
+ const appointmentStatus = res.data.status
+ that.setData({
+ appointStart,
+ appointEnd,
+ appointmentId,
+ appointmentStatus,
+ isAppointment: true
+ })
+ }
+ }).catch(err => {
+ console.log(err, 'getUserReservation');
+ })
+ },
+
getOrderStatus(orderId) {
const that = this
Http.get({
@@ -222,13 +269,6 @@ Page({
})
},
- goAppointment(e) {
- const id = e.currentTarget.dataset.id
- tt.navigateTo({
- url: `/package2/pages/appointment/appointment?id=${id}`,
- });
- },
-
getIm() { //获取im客服id
const that = this
Http.get({
@@ -259,8 +299,10 @@ Page({
const couponChannelId = res.data.orders[0].couponChannelId
const orderID = res.data.orders[0].id
+ const cOrderID = res.data.orders[0].couponOrderId
that.getOrderStatus(orderID)
+ that.getUserReservation(cOrderID)
that.getIm()
const extParam = res.data.extParam || null
if (extParam) {
@@ -394,16 +436,16 @@ Page({
tenantId: res.data.tenantId
})
}
- var createDate = util.formatTime(res.data.orders[0].createDate, "yyyy-MM-dd");
+ var createDate = util.timestampToTime(res.data.orders[0].createDate, "YYYY-MM-DD");
let tempData = res.data.orders[0]
tempData.deliveryInfo = tempData.deliveryInfo ? JSON.parse(tempData.deliveryInfo) : ""
tempData.itemGroup = tempData.itemGroup ? JSON.parse(tempData.itemGroup) : ""
- tempData.soldStartTime = util.formatTime(tempData.soldStartTime, "yyyy-MM-dd") || null,
- tempData.soldEndTime = util.formatTime(tempData.soldEndTime, "yyyy-MM-dd") || null,
+ tempData.soldStartTime = util.timestampToTime(tempData.soldStartTime, "YYYY-MM-DD") || null,
+ tempData.soldEndTime = util.timestampToTime(tempData.soldEndTime, "YYYY-MM-DD") || null,
- tempData.validStartDate = util.formatTime(tempData.validStartDate, "yyyy-MM-dd")
- tempData.validEndDate = util.formatTime(tempData.validEndDate, "yyyy-MM-dd")
+ tempData.validStartDate = util.timestampToTime(tempData.validStartDate, "YYYY-MM-DD")
+ tempData.validEndDate = util.timestampToTime(tempData.validEndDate, "YYYY-MM-DD")
tempData.couponOrderIdS = tempData.couponOrderId ? tempData.couponOrderId.slice(0, 4) + `******` + tempData.couponOrderId.slice(14) : ''
diff --git a/pages/order/detail/index.ttml b/pages/order/detail/index.ttml
index 0b85cca..a1272ee 100644
--- a/pages/order/detail/index.ttml
+++ b/pages/order/detail/index.ttml
@@ -116,14 +116,18 @@
-->
-
+
预约时间:
- 点击预约
-
-
-
+
+ 点击预约
+ {{appointStart}}-{{appointEnd}}
+ 预约已取消
+
@@ -210,6 +214,8 @@
+
+
diff --git a/pages/order/detail/index.ttss b/pages/order/detail/index.ttss
index 61e8d61..8a597b5 100644
--- a/pages/order/detail/index.ttss
+++ b/pages/order/detail/index.ttss
@@ -19,6 +19,17 @@ page {
z-index: 99999;
}
+.alerting {
+ width: 100%;
+}
+
+.cancelAppoint {
+ color: #ffffff;
+ background-color: #ff0000;
+ border-radius: 5rpx;
+ padding: 5rpx 3rpx;
+}
+
.serviceBox2 {
width: 50rpx;
height: 50rpx;
diff --git a/project.private.config.json b/project.private.config.json
index 0ead833..4a6bb79 100644
--- a/project.private.config.json
+++ b/project.private.config.json
@@ -56,8 +56,20 @@
"scene": "011007",
"launchFrom": "scan",
"location": "audit"
+ },
+ {
+ "id": 1686207127735,
+ "name": "预约功能调试",
+ "pathName": "package2/pages/appointment/appointment",
+ "query": "id=826355515227168768&startTime=2023-05-29&endTime=2023-06-28",
+ "scene": "990001",
+ "launchFrom": "scan",
+ "location": "qr_code"
}
]
}
+ },
+ "setting": {
+ "mockLogin": false
}
}
diff --git a/utils/util.js b/utils/util.js
index c1c0049..596e6a0 100644
--- a/utils/util.js
+++ b/utils/util.js
@@ -8,10 +8,11 @@ function convertUTCTimeToLocalTime(UTCDateString) {
if (!UTCDateString) {
return '-';
}
- function formatFunc(str) { //格式化显示
+
+ function formatFunc(str) { //格式化显示
return str > 9 ? str : '0' + str
}
- var date2 = new Date(UTCDateString); //这步是关键
+ var date2 = new Date(UTCDateString); //这步是关键
var year = date2.getFullYear();
var mon = formatFunc(date2.getMonth() + 1);
var day = formatFunc(date2.getDate());
@@ -20,7 +21,7 @@ function convertUTCTimeToLocalTime(UTCDateString) {
hour = hour >= 24 ? hour - 24 : hour;
hour = formatFunc(hour);
var min = formatFunc(date2.getMinutes());
- var dateStr = ' ' + hour + ':' + min ;
+ var dateStr = ' ' + hour + ':' + min;
return dateStr;
}
@@ -29,15 +30,15 @@ function convertUTCTimeToLocalTime(UTCDateString) {
// return new Date(+new Date(dateee) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '');
// }
-function moodsText(Num){//人气值处理 Num人气值 返回字符串 处理到万位
+function moodsText(Num) { //人气值处理 Num人气值 返回字符串 处理到万位
let sing = ""
- if(Num>10000){
- sing = (Num/10000).toFixed(2)+"w"
-
- }else{
- sing =Num
- }
- return sing
+ if (Num > 10000) {
+ sing = (Num / 10000).toFixed(2) + "w"
+
+ } else {
+ sing = Num
+ }
+ return sing
}
const formatTime = (date, fmt) => {
@@ -69,9 +70,9 @@ const formatTime = (date, fmt) => {
if (new RegExp("(" + k + ")").test(fmt))
fmt = fmt.replace(
RegExp.$1,
- RegExp.$1.length == 1
- ? o[k]
- : ("00" + o[k]).substr(("" + o[k]).length)
+ RegExp.$1.length == 1 ?
+ o[k] :
+ ("00" + o[k]).substr(("" + o[k]).length)
);
return fmt;
} catch (error) {
@@ -104,6 +105,7 @@ function qrc(id, code, width, height) {
height: convert_length(height)
});
}
+
function fmtDate(obj) {
if (typeof obj === 'string' && obj.length === 13) {
obj = Number(obj);
@@ -121,6 +123,57 @@ function fmtDate(obj) {
);
}
+/**
+ * @description 根据时间戳获取时间
+ * @param {*} timestamp 必传,number类型,时间戳数据(10位及以下,10位至13位);若不传,则返回:“无时间戳”
+ * @param {*} format 选传,string类型,提供以下时间格式:YYYY-MM-DD hh:mm:ss、YYYY/MM/DD hh:mm:ss、YYYY.MM.DD hh:mm:ss、YYYY MM DD hh:mm:ss、YYYY年MM月DD日 hh:mm:ss、YYYY-MM-DD、YYYY/MM/DD、YYYY.MM.DD、YYYY MM DD、YYYY年MM月DD日、hh:mm:ss、hh:mm;若不传,则默认为:YYYY-MM-DD
+ * @returns 根据要求的时间格式
+ * @version V 1.0, Created by YWQ, 2022.10.20
+ */
+function timestampToTime(timestamp, format) {
+ //时间戳为10位需*1000,时间戳为13位不需乘1000
+ const length = timestamp ? timestamp.length : ''
+ if (length <= 10) {
+ var date = new Date(timestamp * 1000)
+ } else {
+ var date = new Date(timestamp)
+ }
+ let Y = String(date.getFullYear())
+ let M = String(date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1)
+ let D = String(date.getDate() + 1 < 10 ? '0' + (date.getDate()) : date.getDate())
+ let h = String(date.getHours() + 1 < 10 ? '0' + (date.getHours()) : date.getHours())
+ let m = String(date.getMinutes() + 1 < 10 ? '0' + (date.getMinutes()) : date.getMinutes())
+ let s = String(date.getSeconds() + 1 < 10 ? '0' + (date.getSeconds()) : date.getSeconds())
+ // return Y + M + D + h + m + s
+ if (format == "YYYY-MM-DD hh:mm:ss") {
+ return Y + "-" + M + "-" + D + " " + h + ":" + m + ":" + s
+ } else if (format == "YYYY/MM/DD hh:mm:ss") {
+ return Y + "/" + M + "/" + D + " " + h + ":" + m + ":" + s
+ } else if (format == "YYYY.MM.DD hh:mm:ss") {
+ return Y + "." + M + "." + D + " " + h + ":" + m + ":" + s
+ } else if (format == "YYYY MM DD hh:mm:ss") {
+ return Y + " " + M + " " + D + " " + h + ":" + m + ":" + s
+ } else if (format == "YYYY年MM月DD日 hh:mm:ss") {
+ return Y + "年" + M + "月" + D + "日" + " " + h + ":" + m + ":" + s
+ } else if (format == "YYYY-MM-DD") {
+ return Y + "-" + M + "-" + D
+ } else if (format == "YYYY/MM/DD") {
+ return Y + "/" + M + "/" + D
+ } else if (format == "YYYY.MM.DD") {
+ return Y + "." + M + "." + D
+ } else if (format == "YYYY MM DD") {
+ return Y + " " + M + " " + D
+ } else if (format == "YYYY年MM月DD日") {
+ return Y + "年" + M + "月" + D + "日"
+ } else if (format == "hh:mm:ss") {
+ return h + ":" + m + ":" + s
+ } else if (format == "hh:mm") {
+ return h + ":" + m
+ } else {
+ return Y + "-" + M + "-" + D
+ }
+}
+
//计算下单的时间与现在的时间的
function timechuo(startTime) {
var s1 = new Date(startTime.replace(/-/g, "/"));
@@ -137,20 +190,20 @@ function timechuo(startTime) {
var minute = Math.floor(runTime / 60);
var runTime = runTime % 60;
var second = runTime;
- if (day && !year && !month){
+ if (day && !year && !month) {
return (day + '天' + hour + "小时" + minute + "分钟")
- } else if (month && !year){
- return ((month*30+day) +'天' + hour + "小时" + minute + "分钟")
+ } else if (month && !year) {
+ return ((month * 30 + day) + '天' + hour + "小时" + minute + "分钟")
} else if (year) {
- return ((year*365 + month*30+ day) + '天' + hour + "小时" + minute + "分钟")
- }else{
+ return ((year * 365 + month * 30 + day) + '天' + hour + "小时" + minute + "分钟")
+ } else {
return (hour + "小时" + minute + "分钟")
}
}
//计算时间差
-function timecha(endTime,startTime) {
+function timecha(endTime, startTime) {
var s1 = new Date(endTime.replace(/-/g, "/"));
var s2 = new Date(startTime.replace(/-/g, "/"));
var runTime = parseInt((s1.getTime() - s2.getTime()) / 1000);
@@ -165,8 +218,9 @@ function timecha(endTime,startTime) {
var minute = Math.floor(runTime / 60);
var runTime = runTime % 60;
var second = runTime;
- return (month+"月"+day+"天"+hour+"小时"+minute+"分钟")
+ return (month + "月" + day + "天" + hour + "小时" + minute + "分钟")
}
+
function isJSON(str) {
if (typeof str == 'string') {
console.log("string")
@@ -202,6 +256,7 @@ module.exports = {
fmtDate: fmtDate,
timechuo: timechuo,
timecha: timecha,
- moodsText:moodsText,
- convertUTCTimeToLocalTime: convertUTCTimeToLocalTime
-};
+ moodsText: moodsText,
+ convertUTCTimeToLocalTime: convertUTCTimeToLocalTime,
+ timestampToTime: timestampToTime
+};
\ No newline at end of file