feat: 完善见素起名小程序功能
- 添加收藏锦囊功能,支持查看和删除收藏 - 实现积分系统,每日赠送5次灵感次数 - 添加静心阅读功能,阅读15秒可获得额外次数 - 实现灵感广场,展示用户分享的名字 - 添加字源溯源组件,长按汉字查看详情 - 优化空状态和结语卡片样式统一 - 添加音频控制(静音/风铃/雨落/古琴/白噪音/森林/溪流) - 优化名字生成逻辑,确保每次返回5个不重复名字 - 修复卡片翻转样式问题 - 移除首页动态提醒气泡
This commit is contained in:
@@ -8,32 +8,72 @@ App({
|
||||
swipe: wx.createInnerAudioContext() // 滑动切换
|
||||
};
|
||||
|
||||
// 预设音效资源
|
||||
// 预设音效资源(本地文件)
|
||||
// 翻页声 - 纸张摩擦
|
||||
this.globalData.audioContexts.flip.src = 'https://assets.mixkit.co/active_storage/sfx/2571/2571-preview.mp3';
|
||||
this.globalData.audioContexts.flip.src = '/assets/audio/flip.mp3';
|
||||
// 收藏成功 - 清脆铃声
|
||||
this.globalData.audioContexts.success.src = 'https://assets.mixkit.co/active_storage/sfx/2000/2000-preview.mp3';
|
||||
this.globalData.audioContexts.success.src = '/assets/audio/success.mp3';
|
||||
// 水滴声 - 水墨滴落
|
||||
this.globalData.audioContexts.inkDrop.src = 'https://assets.mixkit.co/active_storage/sfx/2578/2578-preview.mp3';
|
||||
this.globalData.audioContexts.inkDrop.src = '/assets/audio/inkDrop.mp3';
|
||||
// 滑动声
|
||||
this.globalData.audioContexts.swipe.src = 'https://assets.mixkit.co/active_storage/sfx/2571/2571-preview.mp3';
|
||||
this.globalData.audioContexts.swipe.src = '/assets/audio/swipe.mp3';
|
||||
|
||||
// 微信登录获取 openid
|
||||
this.wxLogin();
|
||||
},
|
||||
|
||||
// 微信登录
|
||||
wxLogin() {
|
||||
wx.login({
|
||||
success: (res) => {
|
||||
if (res.code) {
|
||||
// 发送 code 到后端换取 openid
|
||||
wx.request({
|
||||
url: `${this.globalData.apiBaseUrl}/api/auth/login`,
|
||||
method: 'POST',
|
||||
data: { code: res.code },
|
||||
success: (response) => {
|
||||
if (response.data && response.data.success) {
|
||||
this.globalData.openid = response.data.openid;
|
||||
console.log('登录成功,openid:', response.data.openid);
|
||||
} else {
|
||||
console.error('登录失败:', response.data);
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('登录请求失败:', err);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
console.error('登录失败:', res.errMsg);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 获取 openid(如果还未获取到则返回 null)
|
||||
getOpenid() {
|
||||
return this.globalData.openid;
|
||||
},
|
||||
|
||||
playAudio(type) {
|
||||
const ctx = this.globalData.audioContexts[type];
|
||||
if (ctx) {
|
||||
ctx.stop();
|
||||
ctx.play().catch(err => {
|
||||
try {
|
||||
ctx.play();
|
||||
} catch (err) {
|
||||
console.log('音效播放失败:', err);
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
globalData: {
|
||||
audioContexts: {},
|
||||
openid: null,
|
||||
// API 基础地址 - 修改这里即可切换环境
|
||||
// apiBaseUrl: 'http://localhost:8080'
|
||||
apiBaseUrl: 'https://feast.yidaima.cn/jsu'
|
||||
apiBaseUrl: 'http://localhost:8080'
|
||||
// apiBaseUrl: 'https://feast.yidaima.cn/jsu'
|
||||
// 生产环境:'https://api.yourdomain.com'
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user