27 lines
1012 B
JavaScript
27 lines
1012 B
JavaScript
// 复制以下代码到 HBuilderX 的调试控制台 或 浏览器的控制台 中运行
|
|
// 用于检查数据库中是否有优惠券数据
|
|
|
|
const SUPA_URL = 'http://192.168.1.61:18000';
|
|
const SUPA_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlzcyI6InN1cGFiYXNlLTEiLCJpYXQiOjE3Njk2NzY0OTgsImV4cCI6MTkyNzM1NjQ5OH0.ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
|
|
|
|
console.log('正在检查数据库优惠券...');
|
|
|
|
fetch(`${SUPA_URL}/rest/v1/ml_coupon_templates?select=id,name,merchant_id,status`, {
|
|
headers: {
|
|
'apikey': SUPA_KEY,
|
|
'Authorization': `Bearer ${SUPA_KEY}`
|
|
}
|
|
})
|
|
.then(res => res.json())
|
|
.then(data => {
|
|
console.log(`查询结果: 找到 ${data.length || 0} 张优惠券模板`);
|
|
if (Array.isArray(data) && data.length > 0) {
|
|
console.table(data);
|
|
} else {
|
|
console.warn('数据库中没有优惠券!请运行 add_coupons_for_existing_shops.sql 脚本。');
|
|
}
|
|
})
|
|
.catch(err => {
|
|
console.error('连接数据库失败:', err);
|
|
});
|