index.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  4. __name: "index",
  5. setup(__props) {
  6. var _a, _b, _c;
  7. const $api = (_a = common_vendor.getCurrentInstance()) == null ? void 0 : _a.appContext.config.globalProperties.$api;
  8. (_b = common_vendor.getCurrentInstance()) == null ? void 0 : _b.appContext.config.globalProperties.$config;
  9. const $apifile = (_c = common_vendor.getCurrentInstance()) == null ? void 0 : _c.appContext.config.globalProperties.$apifile;
  10. common_vendor.computed(() => {
  11. return common_vendor.index.getStorageSync("openid");
  12. });
  13. const id = common_vendor.ref("");
  14. const user = common_vendor.ref({ icon: "" });
  15. const form = common_vendor.ref({});
  16. const typeList = common_vendor.ref([]);
  17. common_vendor.onLoad(async (options) => {
  18. id.value = options && options.id;
  19. await searchUser();
  20. await searchOther();
  21. await search();
  22. });
  23. common_vendor.onShow(() => {
  24. common_vendor.index.$on("setCity", function(city) {
  25. form.value.city = city;
  26. });
  27. });
  28. const searchUser = async () => {
  29. user.value = common_vendor.index.getStorageSync("user");
  30. };
  31. const searchOther = async () => {
  32. let res;
  33. res = await $api(`dict/data/list`, "GET", { dictType: "sys_user_type" });
  34. if (res.code === 200 && res.total > 0)
  35. typeList.value = res.rows;
  36. };
  37. const search = async () => {
  38. };
  39. const typeChange = (e) => {
  40. const data = typeList.value[e.detail.value];
  41. if (data)
  42. form.value.type = data.dictLabel;
  43. };
  44. const dateChange = (e) => {
  45. form.value.date = e.detail.value;
  46. };
  47. const toCity = () => {
  48. if (form.value.city) {
  49. common_vendor.index.navigateTo({
  50. url: `/pagesHome/city/index?city=${form.value.city}`
  51. });
  52. } else {
  53. common_vendor.index.navigateTo({
  54. url: `/pagesHome/city/index`
  55. });
  56. }
  57. };
  58. const Preview = () => {
  59. common_vendor.index.chooseImage({
  60. count: 1,
  61. sizeType: ["original", "compressed"],
  62. sourceType: ["album", "camera"],
  63. success: async function(res) {
  64. let tempFile = JSON.parse(JSON.stringify(res.tempFilePaths));
  65. const arr = await $apifile(
  66. `/common/upload`,
  67. "file",
  68. tempFile[0],
  69. "file"
  70. );
  71. if (arr.code == 200) {
  72. form.value.logo = arr.url;
  73. } else {
  74. common_vendor.index.showToast({
  75. title: arr.msg,
  76. icon: "none"
  77. });
  78. }
  79. }
  80. });
  81. };
  82. const formSubmit = (e) => {
  83. if (user.value.id) {
  84. console.log(e.deatil.value);
  85. } else {
  86. common_vendor.index.showToast({
  87. title: `无用户信息 无法创建球队`,
  88. icon: "none"
  89. });
  90. }
  91. };
  92. return (_ctx, _cache) => {
  93. return common_vendor.e({
  94. a: form.value.logo || "/static/qiudui.png",
  95. b: common_vendor.o(Preview),
  96. c: form.value.name,
  97. d: common_vendor.t(form.value.type || "请选择类型"),
  98. e: common_vendor.o(typeChange),
  99. f: _ctx.index,
  100. g: typeList.value,
  101. h: form.value.city
  102. }, form.value.city ? {
  103. i: common_vendor.t(form.value.city)
  104. } : {}, {
  105. j: common_vendor.o(toCity),
  106. k: common_vendor.t(form.value.date || "请选择成立时间"),
  107. l: common_vendor.o(dateChange),
  108. m: _ctx.index,
  109. n: form.value.color,
  110. o: form.value.brief,
  111. p: common_vendor.o(formSubmit)
  112. });
  113. };
  114. }
  115. });
  116. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-01c8185c"], ["__file", "D:/project/足球比赛/match_applet/pagesHome/team/index.vue"]]);
  117. wx.createPage(MiniProgramPage);