diff --git a/src/main/java/xuan/controller/ToolController.java b/src/main/java/xuan/controller/ToolController.java new file mode 100644 index 0000000..c03ebd8 --- /dev/null +++ b/src/main/java/xuan/controller/ToolController.java @@ -0,0 +1,402 @@ +package xuan.controller; + +import com.nlf.calendar.Lunar; +import com.nlf.calendar.Solar; +import com.nlf.calendar.LunarYear; +import com.nlf.calendar.LunarMonth; +import org.springframework.web.bind.annotation.*; +import xuan.core.bazi.BaZi; +import xuan.core.bazi.settings.BaZiJiChuSetting; + +import java.util.*; + +@RestController +@RequestMapping("/api/tools") +public class ToolController { + + @PostMapping("/lunar") + public Map lunarQuery(@RequestBody Map params) { + Map result = new HashMap<>(); + try { + String date = params.get("date").toString(); + int type = params.containsKey("type") ? Integer.parseInt(params.get("type").toString()) : 0; + + Map data = new HashMap<>(); + + if (type == 0) { + Solar solar = Solar.fromYmdHms( + Integer.parseInt(date.substring(0, 4)), + Integer.parseInt(date.substring(5, 7)), + Integer.parseInt(date.substring(8, 10)), + params.containsKey("hour") ? Integer.parseInt(params.get("hour").toString()) : 0, + params.containsKey("minute") ? Integer.parseInt(params.get("minute").toString()) : 0, + 0 + ); + Lunar lunar = solar.getLunar(); + + data.put("solar", solar.toString()); + data.put("lunar", lunar.toString()); + data.put("lunarYear", lunar.getYearInGanZhi()); + data.put("lunarMonth", lunar.getMonthInGanZhi()); + data.put("lunarDay", lunar.getDayInGanZhi()); + data.put("lunarYearName", lunar.getYearShengXiao() + "年"); + data.put("lunarMonthName", lunar.getMonthName()); + data.put("lunarDayName", lunar.getDayName()); + data.put("festival", lunar.getFestivals()); + data.put("jieQi", lunar.getJieQi()); + data.put("week", solar.getWeekInChinese()); + data.put("constellation", solar.getXingZuo()); + } else { + int year = Integer.parseInt(params.get("lunarYear").toString()); + int month = Integer.parseInt(params.get("lunarMonth").toString()); + int day = Integer.parseInt(params.get("lunarDay").toString()); + boolean isLeap = params.containsKey("isLeap") && Boolean.parseBoolean(params.get("isLeap").toString()); + + Lunar lunar = Lunar.fromYmd(year, month, day, isLeap ? 1 : 0); + Solar solar = lunar.getSolar(); + + data.put("lunar", lunar.toString()); + data.put("solar", solar.toString()); + data.put("solarYear", solar.getYear()); + data.put("solarMonth", solar.getMonth()); + data.put("solarDay", solar.getDay()); + } + + result.put("success", true); + result.put("data", data); + } catch (Exception e) { + result.put("success", false); + result.put("error", e.getMessage()); + } + return result; + } + + @PostMapping("/ganzhi") + public Map ganZhiQuery(@RequestBody Map params) { + Map result = new HashMap<>(); + try { + String date = params.get("date").toString(); + int hour = params.containsKey("hour") ? Integer.parseInt(params.get("hour").toString()) : 0; + + Solar solar = Solar.fromYmdHms( + Integer.parseInt(date.substring(0, 4)), + Integer.parseInt(date.substring(5, 7)), + Integer.parseInt(date.substring(8, 10)), + hour, 0, 0 + ); + Lunar lunar = solar.getLunar(); + + Map data = new HashMap<>(); + data.put("yearGanZhi", lunar.getYearInGanZhi()); + data.put("monthGanZhi", lunar.getMonthInGanZhi()); + data.put("dayGanZhi", lunar.getDayInGanZhi()); + data.put("hourGanZhi", lunar.getTimeInGanZhi()); + data.put("yearGan", lunar.getYearGan()); + data.put("yearZhi", lunar.getYearZhi()); + data.put("monthGan", lunar.getMonthGan()); + data.put("monthZhi", lunar.getMonthZhi()); + data.put("dayGan", lunar.getDayGan()); + data.put("dayZhi", lunar.getDayZhi()); + data.put("hourGan", lunar.getTimeGan()); + data.put("hourZhi", lunar.getTimeZhi()); + + result.put("success", true); + result.put("data", data); + } catch (Exception e) { + result.put("success", false); + result.put("error", e.getMessage()); + } + return result; + } + + @PostMapping("/shengxiao") + public Map shengXiaoQuery(@RequestBody Map params) { + Map result = new HashMap<>(); + try { + int year = Integer.parseInt(params.get("year").toString()); + + Solar solar = Solar.fromYmd(year, 1, 1); + Lunar lunar = solar.getLunar(); + String shengXiao = lunar.getYearShengXiao(); + + Map data = new HashMap<>(); + data.put("year", year); + data.put("shengXiao", shengXiao); + + String[] shengXiaoOrder = {"鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪"}; + Map shengXiaoInfo = new HashMap<>(); + shengXiaoInfo.put("鼠", "子鼠,五行属水,聪明机智,适应力强"); + shengXiaoInfo.put("牛", "丑牛,五行属土,勤劳踏实,责任心强"); + shengXiaoInfo.put("虎", "寅虎,五行属木,勇敢自信,领导力强"); + shengXiaoInfo.put("兔", "卯兔,五行属木,温柔善良,心思细腻"); + shengXiaoInfo.put("龙", "辰龙,五行属土,气宇轩昂,有远大理想"); + shengXiaoInfo.put("蛇", "巳蛇,五行属火,智慧深沉,洞察力强"); + shengXiaoInfo.put("马", "午马,五行属火,热情奔放,行动力强"); + shengXiaoInfo.put("羊", "未羊,五行属土,温文尔雅,富有同情心"); + shengXiaoInfo.put("猴", "申猴,五行属金,聪明伶俐,多才多艺"); + shengXiaoInfo.put("鸡", "酉鸡,五行属金,精明能干,善于表达"); + shengXiaoInfo.put("狗", "戌狗,五行属土,忠诚可靠,正义感强"); + shengXiaoInfo.put("猪", "亥猪,五行属水,善良宽厚,乐观豁达"); + + data.put("info", shengXiaoInfo.getOrDefault(shengXiao, "未知生肖")); + + String ganZhi = lunar.getYearInGanZhi(); + data.put("ganZhi", ganZhi); + + result.put("success", true); + result.put("data", data); + } catch (Exception e) { + result.put("success", false); + result.put("error", e.getMessage()); + } + return result; + } + + @PostMapping("/xingzuo") + public Map xingZuoQuery(@RequestBody Map params) { + Map result = new HashMap<>(); + try { + int month = Integer.parseInt(params.get("month").toString()); + int day = Integer.parseInt(params.get("day").toString()); + + Solar solar = Solar.fromYmd(2000, month, day); + String xingZuo = solar.getXingZuo(); + + Map data = new HashMap<>(); + data.put("month", month); + data.put("day", day); + data.put("xingZuo", xingZuo); + + Map> xingZuoInfo = new HashMap<>(); + xingZuoInfo.put("白羊座", Map.of( + "dateRange", "3月21日-4月19日", + "element", "火象星座", + "character", "热情、冲动、自信", + "desc", "白羊座是黄道十二宫的第一宫,代表着新的开始和生命力。白羊座的人充满活力,勇于冒险,具有领导才能。" + )); + xingZuoInfo.put("金牛座", Map.of( + "dateRange", "4月20日-5月20日", + "element", "土象星座", + "character", "稳重、务实、固执", + "desc", "金牛座是黄道十二宫的第二宫,代表着物质和财富。金牛座的人踏实可靠,追求稳定,有很强的耐心。" + )); + xingZuoInfo.put("双子座", Map.of( + "dateRange", "5月21日-6月21日", + "element", "风象星座", + "character", "聪明、善变、好奇", + "desc", "双子座是黄道十二宫的第三宫,代表着沟通和交流。双子座的人思维敏捷,善于表达,兴趣广泛。" + )); + xingZuoInfo.put("巨蟹座", Map.of( + "dateRange", "6月22日-7月22日", + "element", "水象星座", + "character", "敏感、顾家、情绪化", + "desc", "巨蟹座是黄道十二宫的第四宫,代表着家庭和情感。巨蟹座的人重视家庭,情感丰富,有很强的保护欲。" + )); + xingZuoInfo.put("狮子座", Map.of( + "dateRange", "7月23日-8月22日", + "element", "火象星座", + "character", "自信、慷慨、霸道", + "desc", "狮子座是黄道十二宫的第五宫,代表着创造力和自我表达。狮子座的人自信大方,有领导才能,喜欢成为焦点。" + )); + xingZuoInfo.put("处女座", Map.of( + "dateRange", "8月23日-9月22日", + "element", "土象星座", + "character", "细心、完美主义、挑剔", + "desc", "处女座是黄道十二宫的第六宫,代表着分析和服务。处女座的人注重细节,追求完美,有很强的分析能力。" + )); + xingZuoInfo.put("天秤座", Map.of( + "dateRange", "9月23日-10月23日", + "element", "风象星座", + "character", "优雅、公正、犹豫", + "desc", "天秤座是黄道十二宫的第七宫,代表着平衡和和谐。天秤座的人追求公正,善于社交,有很强的审美能力。" + )); + xingZuoInfo.put("天蝎座", Map.of( + "dateRange", "10月24日-11月22日", + "element", "水象星座", + "character", "神秘、执着、多疑", + "desc", "天蝎座是黄道十二宫的第八宫,代表着转化和重生。天蝎座的人意志坚定,洞察力强,有很强的直觉。" + )); + xingZuoInfo.put("射手座", Map.of( + "dateRange", "11月23日-12月21日", + "element", "火象星座", + "character", "乐观、自由、粗心", + "desc", "射手座是黄道十二宫的第九宫,代表着探索和哲学。射手座的人热爱自由,乐观开朗,有很强的冒险精神。" + )); + xingZuoInfo.put("摩羯座", Map.of( + "dateRange", "12月22日-1月19日", + "element", "土象星座", + "character", "务实、有责任感、悲观", + "desc", "摩羯座是黄道十二宫的第十宫,代表着成就和责任。摩羯座的人有很强的责任感,追求成功,脚踏实地。" + )); + xingZuoInfo.put("水瓶座", Map.of( + "dateRange", "1月20日-2月18日", + "element", "风象星座", + "character", "独立、创新、叛逆", + "desc", "水瓶座是黄道十二宫的第十一宫,代表着创新和人道主义。水瓶座的人思想前卫,独立自主,有很强的创造力。" + )); + xingZuoInfo.put("双鱼座", Map.of( + "dateRange", "2月19日-3月20日", + "element", "水象星座", + "character", "浪漫、敏感、优柔寡断", + "desc", "双鱼座是黄道十二宫的最后一宫,代表着灵性和直觉。双鱼座的人富有想象力,感情丰富,有很强的同理心。" + )); + + Map info = xingZuoInfo.getOrDefault(xingZuo, Map.of("desc", "未知星座")); + data.put("dateRange", info.get("dateRange")); + data.put("element", info.get("element")); + data.put("character", info.get("character")); + data.put("desc", info.get("desc")); + + result.put("success", true); + result.put("data", data); + } catch (Exception e) { + result.put("success", false); + result.put("error", e.getMessage()); + } + return result; + } + + @PostMapping("/wuxing") + public Map wuXingQuery(@RequestBody Map params) { + Map result = new HashMap<>(); + try { + String date = params.get("date").toString(); + int hour = params.containsKey("hour") ? Integer.parseInt(params.get("hour").toString()) : 0; + + Solar solar = Solar.fromYmdHms( + Integer.parseInt(date.substring(0, 4)), + Integer.parseInt(date.substring(5, 7)), + Integer.parseInt(date.substring(8, 10)), + hour, 0, 0 + ); + Lunar lunar = solar.getLunar(); + + String yearGan = lunar.getYearGan(); + String monthGan = lunar.getMonthGan(); + String dayGan = lunar.getDayGan(); + String hourGan = lunar.getTimeGan(); + + Map ganWuXing = new HashMap<>(); + ganWuXing.put("甲", "木"); ganWuXing.put("乙", "木"); + ganWuXing.put("丙", "火"); ganWuXing.put("丁", "火"); + ganWuXing.put("戊", "土"); ganWuXing.put("己", "土"); + ganWuXing.put("庚", "金"); ganWuXing.put("辛", "金"); + ganWuXing.put("壬", "水"); ganWuXing.put("癸", "水"); + + Map data = new HashMap<>(); + data.put("yearGan", yearGan); + data.put("yearWuXing", ganWuXing.get(yearGan)); + data.put("monthGan", monthGan); + data.put("monthWuXing", ganWuXing.get(monthGan)); + data.put("dayGan", dayGan); + data.put("dayWuXing", ganWuXing.get(dayGan)); + data.put("hourGan", hourGan); + data.put("hourWuXing", ganWuXing.get(hourGan)); + + Map wuXingCount = new HashMap<>(); + wuXingCount.put("金", 0); + wuXingCount.put("木", 0); + wuXingCount.put("水", 0); + wuXingCount.put("火", 0); + wuXingCount.put("土", 0); + + for (String gan : Arrays.asList(yearGan, monthGan, dayGan, hourGan)) { + String wx = ganWuXing.get(gan); + wuXingCount.put(wx, wuXingCount.get(wx) + 1); + } + + String[] zhiList = {lunar.getYearZhi(), lunar.getMonthZhi(), lunar.getDayZhi(), lunar.getTimeZhi()}; + Map zhiWuXing = new HashMap<>(); + zhiWuXing.put("子", "水"); zhiWuXing.put("丑", "土"); + zhiWuXing.put("寅", "木"); zhiWuXing.put("卯", "木"); + zhiWuXing.put("辰", "土"); zhiWuXing.put("巳", "火"); + zhiWuXing.put("午", "火"); zhiWuXing.put("未", "土"); + zhiWuXing.put("申", "金"); zhiWuXing.put("酉", "金"); + zhiWuXing.put("戌", "土"); zhiWuXing.put("亥", "水"); + + for (String zhi : zhiList) { + String wx = zhiWuXing.get(zhi); + wuXingCount.put(wx, wuXingCount.get(wx) + 1); + } + + data.put("wuXingCount", wuXingCount); + + List missing = new ArrayList<>(); + for (Map.Entry entry : wuXingCount.entrySet()) { + if (entry.getValue() == 0) { + missing.add(entry.getKey()); + } + } + data.put("missing", missing); + + Map wuXingInfo = new HashMap<>(); + wuXingInfo.put("金", "金主义,其性刚,其情烈。金盛之人骨肉相称,面方白净,眉高眼深。"); + wuXingInfo.put("木", "木主仁,其性直,其情和。木盛之人丰姿秀丽,骨骼修长,手足细腻。"); + wuXingInfo.put("水", "水主智,其性聪,其情善。水盛之人面黑有采,语言清和,为人深思熟虑。"); + wuXingInfo.put("火", "火主礼,其性急,其情恭。火盛之人头小脚长,上尖下阔,浓眉小耳。"); + wuXingInfo.put("土", "土主信,其性重,其情厚。土盛之人圆腰廓鼻,眉清目秀,口才声重。"); + + data.put("wuXingInfo", wuXingInfo); + + result.put("success", true); + result.put("data", data); + } catch (Exception e) { + result.put("success", false); + result.put("error", e.getMessage()); + } + return result; + } + + @PostMapping("/jiri") + public Map jiRiQuery(@RequestBody Map params) { + Map result = new HashMap<>(); + try { + String date = params.get("date").toString(); + + Solar solar = Solar.fromYmd( + Integer.parseInt(date.substring(0, 4)), + Integer.parseInt(date.substring(5, 7)), + Integer.parseInt(date.substring(8, 10)) + ); + Lunar lunar = solar.getLunar(); + + Map data = new HashMap<>(); + data.put("solar", solar.toString()); + data.put("lunar", lunar.toString()); + data.put("ganZhi", lunar.getDayInGanZhi()); + data.put("xingZuo", solar.getXingZuo()); + data.put("week", solar.getWeekInChinese()); + + List yi = lunar.getDayYi(); + List ji = lunar.getDayJi(); + data.put("yi", yi); + data.put("ji", ji); + + String[] chong = lunar.getDayChong().split(" "); + data.put("chong", chong.length > 0 ? chong[0] : ""); + data.put("chongGan", lunar.getDayChongGan()); + data.put("chongZhi", lunar.getDayChongZhi()); + data.put("sha", lunar.getDaySha()); + + String jieQi = lunar.getJieQi(); + data.put("jieQi", jieQi != null ? jieQi : "无"); + + List festivals = lunar.getFestivals(); + data.put("festivals", festivals); + + List solarFestivals = solar.getFestivals(); + data.put("solarFestivals", solarFestivals); + + boolean isGoodDay = yi.size() > ji.size(); + data.put("isGoodDay", isGoodDay); + data.put("suggestion", isGoodDay ? "今日宜多行善事,适合办理重要事务" : "今日宜静不宜动,适合修身养性"); + + result.put("success", true); + result.put("data", data); + } catch (Exception e) { + result.put("success", false); + result.put("error", e.getMessage()); + } + return result; + } +} diff --git a/xuan-deduct-uniapp/src/pages.json b/xuan-deduct-uniapp/src/pages.json index 760935c..6be20a4 100644 --- a/xuan-deduct-uniapp/src/pages.json +++ b/xuan-deduct-uniapp/src/pages.json @@ -160,6 +160,54 @@ "navigationBarBackgroundColor": "#8B5CF6", "navigationBarTextStyle": "white" } + }, + { + "path": "pages/tool-lunar/tool-lunar", + "style": { + "navigationBarTitleText": "农历查询", + "navigationBarBackgroundColor": "#3B82F6", + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/tool-ganzhi/tool-ganzhi", + "style": { + "navigationBarTitleText": "干支查询", + "navigationBarBackgroundColor": "#10B981", + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/tool-shengxiao/tool-shengxiao", + "style": { + "navigationBarTitleText": "生肖查询", + "navigationBarBackgroundColor": "#F59E0B", + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/tool-xingzuo/tool-xingzuo", + "style": { + "navigationBarTitleText": "星座查询", + "navigationBarBackgroundColor": "#8B5CF6", + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/tool-wuxing/tool-wuxing", + "style": { + "navigationBarTitleText": "五行查询", + "navigationBarBackgroundColor": "#EF4444", + "navigationBarTextStyle": "white" + } + }, + { + "path": "pages/tool-jiri/tool-jiri", + "style": { + "navigationBarTitleText": "吉日查询", + "navigationBarBackgroundColor": "#EC4899", + "navigationBarTextStyle": "white" + } } ], "globalStyle": { diff --git a/xuan-deduct-uniapp/src/pages/tool-ganzhi/tool-ganzhi.vue b/xuan-deduct-uniapp/src/pages/tool-ganzhi/tool-ganzhi.vue new file mode 100644 index 0000000..e79c071 --- /dev/null +++ b/xuan-deduct-uniapp/src/pages/tool-ganzhi/tool-ganzhi.vue @@ -0,0 +1,284 @@ + + + + + diff --git a/xuan-deduct-uniapp/src/pages/tool-jiri/tool-jiri.vue b/xuan-deduct-uniapp/src/pages/tool-jiri/tool-jiri.vue new file mode 100644 index 0000000..bdb6784 --- /dev/null +++ b/xuan-deduct-uniapp/src/pages/tool-jiri/tool-jiri.vue @@ -0,0 +1,370 @@ + + + + + diff --git a/xuan-deduct-uniapp/src/pages/tool-lunar/tool-lunar.vue b/xuan-deduct-uniapp/src/pages/tool-lunar/tool-lunar.vue new file mode 100644 index 0000000..e2bd005 --- /dev/null +++ b/xuan-deduct-uniapp/src/pages/tool-lunar/tool-lunar.vue @@ -0,0 +1,338 @@ + + + + + diff --git a/xuan-deduct-uniapp/src/pages/tool-shengxiao/tool-shengxiao.vue b/xuan-deduct-uniapp/src/pages/tool-shengxiao/tool-shengxiao.vue new file mode 100644 index 0000000..4ee3e36 --- /dev/null +++ b/xuan-deduct-uniapp/src/pages/tool-shengxiao/tool-shengxiao.vue @@ -0,0 +1,219 @@ + + + + + diff --git a/xuan-deduct-uniapp/src/pages/tool-wuxing/tool-wuxing.vue b/xuan-deduct-uniapp/src/pages/tool-wuxing/tool-wuxing.vue new file mode 100644 index 0000000..d301b94 --- /dev/null +++ b/xuan-deduct-uniapp/src/pages/tool-wuxing/tool-wuxing.vue @@ -0,0 +1,312 @@ + + + + + diff --git a/xuan-deduct-uniapp/src/pages/tool-xingzuo/tool-xingzuo.vue b/xuan-deduct-uniapp/src/pages/tool-xingzuo/tool-xingzuo.vue new file mode 100644 index 0000000..7bdb5f0 --- /dev/null +++ b/xuan-deduct-uniapp/src/pages/tool-xingzuo/tool-xingzuo.vue @@ -0,0 +1,263 @@ + + + + + diff --git a/xuan-deduct-uniapp/src/pages/tools/tools.vue b/xuan-deduct-uniapp/src/pages/tools/tools.vue index d379bdb..605dc61 100644 --- a/xuan-deduct-uniapp/src/pages/tools/tools.vue +++ b/xuan-deduct-uniapp/src/pages/tools/tools.vue @@ -37,20 +37,19 @@ export default { data() { return { tools: [ - { name: '农历查询', desc: '公历农历互转', icon: '📅', color: 'linear-gradient(135deg, #3B82F6 0%, #1D4ED8 100%)' }, - { name: '干支查询', desc: '年月日时干支', icon: '🕐', color: 'linear-gradient(135deg, #10B981 0%, #059669 100%)' }, - { name: '生肖查询', desc: '十二生肖属性', icon: '🐉', color: 'linear-gradient(135deg, #F59E0B 0%, #D97706 100%)' }, - { name: '星座查询', desc: '十二星座运势', icon: '⭐', color: 'linear-gradient(135deg, #8B5CF6 0%, #7C3AED 100%)' }, - { name: '五行查询', desc: '五行属性分析', icon: '🔥', color: 'linear-gradient(135deg, #EF4444 0%, #DC2626 100%)' }, - { name: '吉日查询', desc: '黄道吉日查询', icon: '📆', color: 'linear-gradient(135deg, #EC4899 0%, #DB2777 100%)' } + { name: '农历查询', desc: '公历农历互转', icon: '📅', color: 'linear-gradient(135deg, #3B82F6 0%, #1D4ED8 100%)', path: '/pages/tool-lunar/tool-lunar' }, + { name: '干支查询', desc: '年月日时干支', icon: '🕐', color: 'linear-gradient(135deg, #10B981 0%, #059669 100%)', path: '/pages/tool-ganzhi/tool-ganzhi' }, + { name: '生肖查询', desc: '十二生肖属性', icon: '🐉', color: 'linear-gradient(135deg, #F59E0B 0%, #D97706 100%)', path: '/pages/tool-shengxiao/tool-shengxiao' }, + { name: '星座查询', desc: '十二星座运势', icon: '⭐', color: 'linear-gradient(135deg, #8B5CF6 0%, #7C3AED 100%)', path: '/pages/tool-xingzuo/tool-xingzuo' }, + { name: '五行查询', desc: '五行属性分析', icon: '🔥', color: 'linear-gradient(135deg, #EF4444 0%, #DC2626 100%)', path: '/pages/tool-wuxing/tool-wuxing' }, + { name: '吉日查询', desc: '黄道吉日查询', icon: '📆', color: 'linear-gradient(135deg, #EC4899 0%, #DB2777 100%)', path: '/pages/tool-jiri/tool-jiri' } ] } }, methods: { openTool(item) { - uni.showToast({ - title: `${item.name}功能开发中`, - icon: 'none' + uni.navigateTo({ + url: item.path }) } } diff --git a/xuan-deduct-uniapp/src/utils/api.js b/xuan-deduct-uniapp/src/utils/api.js index ba0d945..982c911 100644 --- a/xuan-deduct-uniapp/src/utils/api.js +++ b/xuan-deduct-uniapp/src/utils/api.js @@ -13,11 +13,7 @@ const request = (options) => { timeout: 30000, success: (res) => { if (res.statusCode === 200) { - if (res.data.success) { - resolve(res.data.data) - } else { - reject(new Error(res.data.error || '请求失败')) - } + resolve(res.data) } else { reject(new Error('网络请求失败: ' + res.statusCode)) } @@ -35,6 +31,7 @@ const baziApi = { url: '/bazi/paipan', method: 'POST', data: { + userId: data.userId || 'default_user', name: data.name || '某人', sex: data.sex || 1, date: data.date, @@ -224,6 +221,51 @@ const recordApi = { } } +const toolApi = { + lunar: (data) => { + return request({ + url: '/tools/lunar', + method: 'POST', + data: data + }) + }, + ganzhi: (data) => { + return request({ + url: '/tools/ganzhi', + method: 'POST', + data: data + }) + }, + shengxiao: (data) => { + return request({ + url: '/tools/shengxiao', + method: 'POST', + data: data + }) + }, + xingzuo: (data) => { + return request({ + url: '/tools/xingzuo', + method: 'POST', + data: data + }) + }, + wuxing: (data) => { + return request({ + url: '/tools/wuxing', + method: 'POST', + data: data + }) + }, + jiri: (data) => { + return request({ + url: '/tools/jiri', + method: 'POST', + data: data + }) + } +} + export default { baziApi, liuyaoApi, @@ -233,5 +275,6 @@ export default { zhanxingApi, taLuoApi, recordApi, + toolApi, request }