根据您提供的接口文档,这是一个功能非常全面的专业八字排盘API!
https://api.jisuapi.com/bazi/paipan在 config/api-config.js 中找到以下代码:
JISU_API: {
BASE_URL: 'https://api.jisuapi.com',
API_KEY: 'YOUR_JISU_API_KEY', // ⚠️ 替换为您的真实API Key
ENDPOINTS: {
bazi: '/bazi/paipan'
},
// ... 其他配置
}
将 YOUR_JISU_API_KEY 替换为您在极速数据获取的真实API Key
在微信小程序后台添加合法域名:
https://api.jisuapi.com
重新运行您的八字测算功能,控制台应该显示:
🔍 尝试调用专业八字API
📡 选中API: JISU_API 专业八字排盘,功能最全面
✅ JISU_API 调用成功
✅ 极速数据返回完整八字排盘信息
| 参数 | 类型 | 说明 | 示例 |
|---|---|---|---|
| appkey | string | 您的API Key | - |
| name | string | 姓名 | "张三" |
| city | string | 城市 | "北京" (可空) |
| year | int | 年份 | 1990 |
| month | int | 月份 | 5 |
| day | int | 日期 | 15 |
| hour | int | 小时 | 14 |
| minute | int | 分钟 | 30 |
| sex | int | 性别 | 1男 0女 |
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| islunar | int | 0 | 是否农历 (0阳历 1农历) |
| istaiyang | int | 0 | 是否太阳时 (0否 1是) |
| islunarmonth | int | 2 | 是否闰月 (1是 2否) |
{
"bazi": ["己丑", "甲戌", "丙申", "己丑"], // 八字四柱
"nayin": ["霹雳火", "山头火", "山下火", "霹雳火"], // 纳音
"animal": "牛", // 生肖
"yearganzhi": "己丑" // 年干支
}
{
"taiyuan": "乙丑", // 胎元
"minggong": "庚午", // 命宫
"xunkong": ["午未", "申酉", "辰巳", "午未"], // 旬空
"qiyun": { // 起运时间
"year": "3",
"month": "2",
"day": "12"
},
"shensha": [ // 神煞
["太极贵人", "华盖", "国印贵人"],
["太极贵人", "寡宿", "吊客"]
]
}
{
"dayun": { // 大运
"ganzhi": ["甲戌", "癸酉", "壬申"],
"sui": ["1-2岁", "3岁", "13岁", "23岁"]
},
"liunian": [ // 流年
["己丑", "壬辰", "壬寅"]
]
}
// 在您的八字测算页面中
async calculateBazi() {
try {
const birthDateObj = new Date(this.birthDate + ' 12:00:00')
// 使用增强版API调用
const baziData = await baziUtil.calculateEnhancedBaZi(
birthDateObj,
this.selectedHour
)
console.log('八字结果:', baziData)
if (baziData.apiProvider === 'jisuapi') {
console.log('🎉 使用极速数据专业API结果')
console.log('生肖:', baziData.animal)
console.log('胎元:', baziData.taiyuan)
console.log('命宫:', baziData.minggong)
// ... 更多专业信息
}
} catch (error) {
console.error('测算失败:', error)
}
}
<!-- 在八字结果页面显示更多专业信息 -->
<view class="professional-info" v-if="baziAnalysis.apiProvider === 'jisuapi'">
<view class="section-title">🏆 专业版信息</view>
<!-- 生肖信息 -->
<view class="info-item">
<text class="info-label">生肖:</text>
<text class="info-value">{{ baziAnalysis.animal }}</text>
</view>
<!-- 胎元命宫 -->
<view class="info-item">
<text class="info-label">胎元:</text>
<text class="info-value">{{ baziAnalysis.taiyuan }}</text>
</view>
<view class="info-item">
<text class="info-label">命宫:</text>
<text class="info-value">{{ baziAnalysis.minggong }}</text>
</view>
<!-- 农历信息 -->
<view class="info-item" v-if="baziAnalysis.lunar">
<text class="info-label">农历:</text>
<text class="info-value">
{{ baziAnalysis.lunar.year }}.{{ baziAnalysis.lunar.month }}.{{ baziAnalysis.lunar.day }}
</text>
</view>
</view>
| 套餐类型 | 次数 | 价格 | 单价 | 适用场景 |
|---|---|---|---|---|
| 免费套餐 | 10次 | 0元 | 0元/次 | 功能测试 |
| Level1 | 10000次 | 980元 | 0.098元/次 | 个人项目 |
| Level2 | 20000次 | 1940元 | 0.097元/次 | 小型企业 |
| Level1特惠 | 1000次/天 | 2320元/月 | 0.077元/次 | 高频使用 |
// ❌ 错误:直接暴露在前端
const API_KEY = 'your_real_api_key'
// ✅ 正确:配置文件中管理
JISU_API: {
API_KEY: process.env.JISU_API_KEY || 'YOUR_JISU_API_KEY'
}
// 完善的错误处理
try {
const result = await getBaziFromAPI(birthDate, hour)
if (!result) {
console.log('⚠️ API调用失败,使用本地算法')
// 自动降级到本地算法
}
} catch (error) {
if (error.status === 104) {
console.log('❌ API次数用完,请充值')
// 提醒用户充值或升级套餐
}
}
建议添加调用次数统计:
// 简单的次数统计
function logAPIUsage(provider, cost) {
const today = new Date().toDateString()
const usage = uni.getStorageSync('apiUsage') || {}
if (!usage[today]) usage[today] = { calls: 0, cost: 0 }
usage[today].calls++
usage[today].cost += cost
uni.setStorageSync('apiUsage', usage)
}
配置完成后,您的八字测算将获得:
🎉 恭喜您获得了专业级的八字测算能力!
这套系统将让您的产品在同类应用中脱颖而出,为用户提供真正可信的专业测算服务。
需要进一步的技术支持或功能定制,随时联系我!