/** * 彩票属性工具 v1.5 * 发布日期:2020-10-31 */ var lhc = { nayin: ["金", "金", "火", "火", "木", "木", "土", "土", "金", "金", "火", "火", "水", "水", "土", "土", "金", "金", "木", "木", "水", "水", "土", "土", "火", "火", "木", "木", "水", "水", "金", "金", "火", "火", "木", "木", "土", "土", "金", "金", "火", "火", "水", "水", "土", "土", "金", "金", "木", "木", "水", "水", "土", "土", "火", "火", "木", "木", "水", "水"], zodiac: ["鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪"], red: { 1: true, 2: true, 7: true, 8: true, 12: true, 13: true, 18: true, 19: true, 23: true, 24: true, 29: true, 30: true, 34: true, 35: true, 40: true, 45: true, 46: true }, blue: { 3: true, 4: true, 9: true, 10: true, 14: true, 15: true, 20: true, 25: true, 26: true, 31: true, 36: true, 37: true, 41: true, 42: true, 47: true, 48: true }, green: { 5: true, 6: true, 11: true, 16: true, 17: true, 21: true, 22: true, 27: true, 28: true, 32: true, 33: true, 38: true, 39: true, 43: true, 44: true, 49: true }, /// /// 常用,获得号码生肖,调用方法:lhc.getZodiac(year,num) /// /// 农历年份 /// 号码 /// getZodiac: function (year, num) { return this.getZodiacList(year)[(Number(num) - 1) % 12]; }, /// /// 获得生肖号码列表,调用方法:lhc.getZodiacNum(year,sx) /// /// 农历年份 /// 生肖 /// getZodiacNum: function (year, sx) { var result = []; var list = this.getZodiacList(year); for (var i = 0; i < list.length; i++) { if (list[i] === sx) { for (x = i + 1; x < 50; x = x + 12) { result.push(x); } } } return result; }, /// /// 获得农历年份12个生肖 /// /// 农历年份 /// getZodiacList: function (year) { var startYear = 1924; var index = (year - startYear) % 12; var a = this.zodiac.slice(0, index + 1).reverse(); var b = this.zodiac.slice(index + 1).reverse(); return a.concat(b); }, /// /// 获得号码五行属性,调用方法:lhc.getFive(year, num) /// /// 农历年份 /// 号码 /// getFive: function (year, num) { return this.getWuhang(year, num); }, /// /// 常用,获得号码五行属性,调用方法:lhc.getWuhang(year, num) /// /// 农历年份 /// 号码 /// getWuhang: function (year, num) { if (this.isLotteryNum(num)) { var list = new Array(); for (var i = 1; i <= 49; i++) { var index = year - 1922 - i - 1; list[i] = this.nayin[index % 60]; } return list[Number(num)]; } return ""; }, /// /// 常用,获得号码波色标志,调用方法:lhc.getBose(num) /// /// 号码 /// getBose: function (num) { num = Number(num); if (this.red[num]) { return "red"; } else if (this.blue[num]) { return "blue"; } else if (this.green[num]) { return "green"; } return ""; }, /// /// 获得号码家禽/野兽属性,调用方法:lhc.getYeshouJiaqin(year, num) /// /// 农历年份 /// 号码 /// getYeshouJiaqin: function (year, num) { var cate = { "鼠,虎,兔,龙,蛇,猴,": "野兽", "牛,马,羊,鸡,狗,猪,": "家禽" }; if (Number(num) === 49) { return ""; } for (var i in cate) { if (i.indexOf(this.getZodiac(year, num)) > -1) { return cate[i] === "野兽" ? this.showTag(cate[i], "color:red") : this.showTag(cate[i], "color:blue"); } } return ""; }, /// /// 获得号码和值 /// /// 号码列表 /// getSum: function (array) { var sum = 0; $.each(array, function (a, b) { sum += Number(b); }); return sum; }, /// /// 获得号码单双,调用方法:lhc.getSumDanShuang(sum) /// /// 和值 /// getSumDanShuang: function (sum) { return sum % 2 === 0 ? this.showTag("总双", "color:red") : this.showTag("总单", "color:blue"); }, /// /// 获得时间星期几 /// /// 时间 /// getWeekday: function (date) { var week = ["日", "一", "二", "三", "四", "五", "六"]; return week[date.getDay()]; }, /// /// 格式化时间 /// 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符, /// 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字) /// 调用方法: /// lhc.dateFormat(date,"yyyy-MM-dd hh:mm:ss.S"); ==> 2020-01-01 08:09:04.423 /// lhc.dateFormat(date,"yyyy-M-d h:m:s.S"); ==> 2020-1-1 8:9:4.18 /// /// 时间 /// 格式化样式 /// dateFormat: function (date, pattern) { var e = ["日", "一", "二", "三", "四", "五", "六"], o = { "M+": date.getMonth() + 1, "d+": date.getDate(), "h+": date.getHours(), "w+": "星期" + e[date.getDay()], "m+": date.getMinutes(), "s+": date.getSeconds(), "q+": Math.floor((date.getMonth() + 3) / 3), S: date.getMilliseconds() }; /(y+)/.test(pattern) && (pattern = pattern.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length))); for (var n in o) new RegExp("(" + n + ")").test(pattern) && (pattern = pattern.replace(RegExp.$1, 1 == RegExp.$1.length ? o[n] : ("00" + o[n]).substr(("" + o[n]).length))); return pattern; }, /// /// 时间格式化 /// /// 时间 /// dateConvert: function (time) { if (time.indexOf("-") > -1) { return new Date(time.replace(/-/g, '/')); } return new Date(time); }, /// 数字位数不够前面位数补零 addZero: function (num) { if (String(num).length > 2) { return num; } return (Array(2).join('0') + num).slice(-2); }, /// /// 判断是否彩票49个号码,调用方法:lhc.isLotteryNum(num) /// /// 号码 /// isLotteryNum: function (num) { num = Number(num); if (this.red[num]) { return true; } else if (this.blue[num]) { return true; } else if (this.green[num]) { return true; } return false; }, /// /// 判断值是否是数字 /// /// 号码 /// isRealNum: function (val) { if (val === "" || val == null) { return false; } return !isNaN(val) ? true : false; }, /// /// span标签的拼接 /// /// 文本 /// undefined--无色 color:blue--蓝色 color:red--红色 color:green--绿色 /// showTag: function (txt, style) { if (style === undefined) { return '' + txt + ''; } else { return "" + txt + ""; } } };