From 74df59a8e075caa671a40140f098896622aa7d44 Mon Sep 17 00:00:00 2001 From: liugongyu <290219706@qq.com> Date: Wed, 22 Jun 2022 09:52:08 +0800 Subject: [PATCH] 商户券 有效期 --- common/date.js | 22 ++++++++++++++++++++++ pages/businessCard/printCard.vue | 10 +++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 common/date.js diff --git a/common/date.js b/common/date.js new file mode 100644 index 0000000..7b3f524 --- /dev/null +++ b/common/date.js @@ -0,0 +1,22 @@ +export function formatDate (date, fmt) { + if (/(y+)/.test(fmt)) { + fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length)); + } + let o = { + 'M+': date.getMonth() + 1, + 'd+': date.getDate(), + 'h+': date.getHours(), + 'm+': date.getMinutes(), + 's+': date.getSeconds() + }; + for (let k in o) { + if (new RegExp(`(${k})`).test(fmt)) { + let str = o[k] + ''; + fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? str : padLeftZero(str)); + } + } + return fmt; +}; +function padLeftZero (str) { + return ('00' + str).substr(str.length); +}; \ No newline at end of file diff --git a/pages/businessCard/printCard.vue b/pages/businessCard/printCard.vue index 61c1b60..fdb3145 100644 --- a/pages/businessCard/printCard.vue +++ b/pages/businessCard/printCard.vue @@ -34,6 +34,7 @@