UNPKG

movm

Version:

一个基于antdsegin的ui组件

74 lines (66 loc) 2.65 kB
/* 中国标准时间/毫秒值 转 正常时间 带时分秒 */ export var TFM = function TFM(msec) { var datetime = new Date(msec); // console.log(' 自定义时间转换 ', datetime) var year = datetime.getFullYear(); var month = datetime.getMonth(); var date = datetime.getDate(); var hour = datetime.getHours(); var minute = datetime.getMinutes(); var second = datetime.getSeconds(); var result1 = year + '-' + (month + 1 >= 10 ? month + 1 : '0' + (month + 1)) + '-' + (date + 1 < 10 ? '0' + date : date) + ' ' + (hour + 1 < 10 ? '0' + hour : hour) + ':' + (minute + 1 < 10 ? '0' + minute : minute) + ':' + (second + 1 < 10 ? '0' + second : second); return msec ? result1 : '-'; }; /* 中国标准时间/毫秒值 转 正常时间 不带时分秒 */ export var TFD = function TFD(msec) { var datetime = new Date(msec); // console.log(' 自定义时间转换 ', datetime) var year = datetime.getFullYear(); var month = datetime.getMonth(); var date = datetime.getDate(); var result2 = year + '-' + (month + 1 >= 10 ? month + 1 : '0' + (month + 1)) + '-' + (date + 1 < 10 ? '0' + date : date); return msec ? result2 : '-'; }; /* 正常时间 转 毫秒 */ export var DTS = function DTS(msec) { var result3 = new Date(msec).getTime(); return msec ? result3 : '-'; }; /* 无数据时渲染 */ export var ND = function ND(val) { return (val !== null && val !== void 0 ? val : '') !== '' ? val : '-'; }; /* input输入节流 */ var timer; export var THROT = function THROT(atChange, time) { if (timer) clearTimeout(timer); timer = setTimeout(function () { atChange(); }, time ? time : 1000); }; /* 高德地图 - 地址解析坐标 */ export var ATC = function ATC(key, value, send) { if (key && value && send) { fetch("https://restapi.amap.com/v3/geocode/geo?address=".concat(value, "&key=").concat(key, "&output=JOSN"), { method: 'get' }).then(function (response) { return response.json(); }).then(function (data) { send(data.geocodes[0].location); }); } else { console.warn('请检查所传参数是否完整'); } }; /* 高德地图 - 坐标解析地址 */ export var CTA = function CTA(key, location, send, radius) { if (key && location && send) { fetch("https://restapi.amap.com/v3/geocode/regeo?output=JOSN&location=".concat(location, "&key=").concat(key, "&radius=").concat(radius ? radius : 1000, "&extensions=all"), { method: 'get' }).then(function (response) { return response.json(); }).then(function (data) { send(data.regeocode); }); } else { console.warn('请检查所传参数是否完整'); } };