// pages/live/wxroom/index.ts
Page({
  onLoad(options: Record<string, string | undefined>) {
    const query = Object.entries(options || {})
      .filter(([, value]) => value !== undefined && value !== "")
      .map(
        ([key, value]) =>
          `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`,
      )
      .join("&");

    const target = query
      ? `/package-live/wxroom/index?${query}`
      : "/package-live/wxroom/index";

    wx.redirectTo({
      url: target,
      fail: () => {
        wx.showToast({
          title: "进入直播间失败",
          icon: "none",
        });
      },
    });
  },
});
