tiefen_space_h5/api/space.js

66 lines
1.4 KiB
JavaScript
Raw Normal View History

2024-07-06 11:05:19 +08:00
import require from "@/utils/require";
export const getStreamerInfo = async (mid) => {
try {
const data = await require("POST", "/api/zone/list_by_mid", {
body: {
mid,
},
});
if (data.ret === -1) {
Toast.show({
icon: "fail",
content: data.msg,
position: "top",
});
return;
}
return {
...data.data.list[0],
refund_enable: data.data.refund_enable,
refund_status: data.data.refund_status,
};
} catch (error) {
console.error(error);
}
};
//获取空间数据并将该空间标为已读
export const getSpaceData = async (mid) => {
try {
const data = await require("POST", `/api/zone/list_by_mid`, {
body: {
mid,
},
});
if (data.ret === -1) {
Toast.show({
type: "error",
text1: data.msg,
topOffset: 60,
});
return;
}
//将空间标为已读
const data2 = await require("POST", `/api/zone_session/upsert`, {
body: {
2024-07-06 16:03:15 +08:00
zid: data.data.list[0]?.id,
2024-07-06 11:05:19 +08:00
},
});
if (data2.ret === -1) {
Toast.show({
type: "error",
text1: data2.msg,
topOffset: 60,
});
return;
}
return {
isRefunding: data.data.refund_status === 1,
noRole: data.data.list[0].visitor_role === 4,
};
} catch (error) {
console.error(error);
}
};