免费生辰八字测姓名打分测试 (免费生辰八字 *** )

anleey2024-11-12 06:28:32193
javascript const form = document.getElementById('form'); const result = document.getElementById('result');form.addEventListener('submit',(event) => {event.preventDefault();const birth = document.getElementById('birth').value;const name = document.getElementById('name').value;// 计算生辰八字const [year, month, day, hour] = birth.split('-');const baZi = getBaZi(year, month, day, hour);// 计算姓名评分const score = getNameScore(name);// 显示结果result.innerHTML = `

生辰八字: ${baZi.join('、')}

免费生辰八字测姓名打分测试 (免费生辰八字算命)

姓名评分: ${score}

`; });// 计算生辰八字 function getBaZi(year, month, day, hour) {// 计算生肖const animals = ['鼠', '牛', '虎', '兔', '龙', '蛇', '马', '羊', '猴', '鸡', '狗', '猪'];const animalIndex = (parseInt(year) - 4) % 12;const animal = animals[animalIndex];// 计算天干和地支 const stems = ['甲', '乙', '丙', '丁', '戊', '己', '庚', '辛', '壬', '癸'];const branches = ['子', '丑', '寅', '卯', '辰', '巳', '午', '未', '申', '酉', '戌', '亥'];const stemIndex = (parseInt(year) - 4) % 10;const branchIndex = (parseInt(month) - 1) % 12;const dayStemIndex = (parseInt(day) - 1) % 10;const dayBranchIndex = (parseInt(hour) - 1) % 12;const yearStem = stems[stemIndex];const yearBranch = branches[branchIndex];const monthStem = stems[stemIndex];const monthBranch = branches[(branchIndex + 1) % 12];const dayStem = stems[dayStemIndex];const dayBranch = branches[dayBranchIndex];const hourStem = stems[dayStemIndex];const hourBranch = branches[(dayBranchIndex + 1) % 12];return [`${yearStem}${yearBranch}`,`${monthStem}${monthBranch}`,`${dayStem}${dayBranch}`,`${hourStem}${hourBranch}`,]; }// 计算姓名评分 function getNameScore(name) {let score = 0;// 计算笔划数for (let i = 0; i < name.length; i++) {const char = name[i];const strokes = getStrokes(char);score += strokes;}// 计算五格数理const wuge = getWuGe(name);score += wuge.total;return score; }// 计算笔划数 function getStrokes(char) {const strokes = [1, 1, 2, 3, 3, 4, 4, 4, 4, 5,5, 5, 5, 5, 5, 5, 5, 6, 6, 6,6, 6,6, 6, 6, 6, 6, 6, 6, 7,7, 7, 7, 7, 7, 7, 7, 7, 7, 7,7, 8, 8, 8, 8, 8, 8, 8, 8, 8,8, 8, 8, 8, 8, 8, 8, 8, 9, 9,9, 9, 9, 9, 9, 9, 9, 9, 9, 10,10, 10, 10, 10, 10, 10, 10, 10, 10, 10,10, 10, 10, 10, 10, 10, 10, 10, 10, 11,11, 11, 11, 11, 11, 11, 11, 11, 11, 11,11, 11, 11, 11, 11, 12, 12, 12, 12, 12,12, 12, 12, 12, 12, 12, 12, 12, 12, 12,12, 12, 12, 12, 12, 13, 13, 13, 13, 13,13, 13, 13, 13, 13, 13, 13, 13, 13, 13,13, 13, 13, 13, 13, 14, 14, 14, 14, 14,14, 14, 14, 14, 14, 14, 14, 14, 1