info.js 4.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. if (!Array) {
  4. const _easycom_uni_segmented_control2 = common_vendor.resolveComponent("uni-segmented-control");
  5. _easycom_uni_segmented_control2();
  6. }
  7. const _easycom_uni_segmented_control = () => "../../uni_modules/uni-segmented-control/components/uni-segmented-control/uni-segmented-control.js";
  8. if (!Math) {
  9. _easycom_uni_segmented_control();
  10. }
  11. const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  12. __name: "info",
  13. setup(__props) {
  14. var _a;
  15. const $api = (_a = common_vendor.getCurrentInstance()) == null ? void 0 : _a.appContext.config.globalProperties.$api;
  16. const config = common_vendor.ref({ logoUrl: "" });
  17. const info = common_vendor.ref({});
  18. const list = common_vendor.ref(["出勤报名", "数据统计"]);
  19. const current = common_vendor.ref(0);
  20. const id = common_vendor.ref("");
  21. common_vendor.onLoad(async (options) => {
  22. id.value = options && options.id;
  23. common_vendor.index.setNavigationBarTitle({
  24. title: options && options.name || "活动详情"
  25. });
  26. await searchConfig();
  27. await search();
  28. });
  29. const searchConfig = async () => {
  30. config.value = common_vendor.index.getStorageSync("config");
  31. };
  32. const search = async () => {
  33. if (id.value) {
  34. const res = await $api(`game/${id.value}`, "GET", {});
  35. if (res.code === 200) {
  36. if (res.data) {
  37. const date1 = common_vendor.hooks(res.data.startTime).format("YYYY-MM-DD");
  38. const date2 = common_vendor.hooks(res.data.endTime).format("YYYY-MM-DD");
  39. if (common_vendor.hooks(date1).isSame(date2))
  40. res.data.time = common_vendor.hooks(res.data.startTime).format("MM-DD") + " " + common_vendor.hooks(res.data.startTime).format("HH:mm") + "-" + common_vendor.hooks(res.data.endTime).format("HH:mm");
  41. else
  42. res.data.time = common_vendor.hooks(res.data.startTime).format("MM-DD") + "/" + common_vendor.hooks(res.data.endTime).format("MM-DD");
  43. info.value = res.data;
  44. }
  45. } else {
  46. common_vendor.index.showToast({
  47. title: res.msg || "",
  48. icon: "error"
  49. });
  50. }
  51. }
  52. };
  53. const onClickItem = (e) => {
  54. if (current.value !== e.currentIndex)
  55. current.value = e.currentIndex;
  56. };
  57. const getDayOfWeek = (dateString) => {
  58. if (dateString) {
  59. const date = new Date(dateString);
  60. const dayOfWeek = date.getDay();
  61. const weekdays = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
  62. return weekdays[dayOfWeek];
  63. } else
  64. return "暂无日期";
  65. };
  66. return (_ctx, _cache) => {
  67. var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
  68. return {
  69. a: common_vendor.t(info.value.number || 0),
  70. b: common_vendor.t(info.value.wheel || 0),
  71. c: ((_b = (_a2 = info.value) == null ? void 0 : _a2.redInfo) == null ? void 0 : _b.logo) || config.value.logoUrl,
  72. d: common_vendor.t(((_d = (_c = info.value) == null ? void 0 : _c.redInfo) == null ? void 0 : _d.name) || "暂无红方名称"),
  73. e: common_vendor.t(info.value.redScore || 0),
  74. f: common_vendor.t(info.value.blueScore || 0),
  75. g: ((_f = (_e = info.value) == null ? void 0 : _e.blueInfo) == null ? void 0 : _f.logo) || config.value.logoUrl,
  76. h: common_vendor.t(((_h = (_g = info.value) == null ? void 0 : _g.blueInfo) == null ? void 0 : _h.name) || "暂无蓝方名称"),
  77. i: common_vendor.t(getDayOfWeek(info.value.startTime)),
  78. j: common_vendor.t(info.value.time || "暂无时间"),
  79. k: common_vendor.t(((_j = (_i = info.value) == null ? void 0 : _i.matchInfo) == null ? void 0 : _j.address) || "暂无地点"),
  80. l: common_vendor.o(onClickItem),
  81. m: common_vendor.p({
  82. current: current.value,
  83. values: list.value,
  84. styleType: "text",
  85. activeColor: "#dd524d"
  86. }),
  87. n: current.value === 0,
  88. o: current.value === 1
  89. };
  90. };
  91. }
  92. });
  93. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-24c37ea1"], ["__file", "D:/project/足球比赛/match_applet/pagesHome/activity/info.vue"]]);
  94. wx.createPage(MiniProgramPage);