mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-uniapp.git
synced 2026-08-06 10:57:25 +08:00
feat: 添加直播房间页面及相关样式和功能
- 新增直播房间页面,支持竖屏直播模式 - 实现直播播放器和消息展示功能 - 增加购物车按钮和商品推荐展示 - 更新样式以适应新页面布局 - 移除不再使用的 MQTT 相关文件和 API 调用
This commit is contained in:
27
pages/promotion/live/utils/liveRecommend.js
Normal file
27
pages/promotion/live/utils/liveRecommend.js
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* 直播 MQTT 推荐消息解析(商品 / 优惠券)
|
||||
*/
|
||||
|
||||
export function toBoolean(value) {
|
||||
if (typeof value === "boolean") return value;
|
||||
if (typeof value === "number") return value === 1;
|
||||
if (typeof value === "string") {
|
||||
const normalized = value.trim().toLowerCase();
|
||||
return normalized === "true" || normalized === "1";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function parseRecommendMessageArray(message) {
|
||||
try {
|
||||
const parsed = JSON.parse(message);
|
||||
return Array.isArray(parsed) ? parsed : [];
|
||||
} catch (error) {
|
||||
console.warn("MQTT 消息解析失败:", error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
export function findRecommendPayload(list) {
|
||||
return list.find((item) => toBoolean(item.recommend) && !toBoolean(item.hideFlag));
|
||||
}
|
||||
Reference in New Issue
Block a user