activity.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. "use strict";
  2. const common_vendor = require("../../../common/vendor.js");
  3. if (!Array) {
  4. const _easycom_uni_datetime_picker2 = common_vendor.resolveComponent("uni-datetime-picker");
  5. const _easycom_uni_file_picker2 = common_vendor.resolveComponent("uni-file-picker");
  6. (_easycom_uni_datetime_picker2 + _easycom_uni_file_picker2)();
  7. }
  8. const _easycom_uni_datetime_picker = () => "../../../uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.js";
  9. const _easycom_uni_file_picker = () => "../../../uni_modules/uni-file-picker/components/uni-file-picker/uni-file-picker.js";
  10. if (!Math) {
  11. (_easycom_uni_datetime_picker + _easycom_uni_file_picker)();
  12. }
  13. const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  14. __name: "activity",
  15. props: {
  16. id: { type: String, default: () => "" },
  17. type: { type: String, default: () => "0" },
  18. typeList: { type: Array, default: () => [] },
  19. activityList: { type: Array, default: () => [] },
  20. openList: { type: Array, default: () => [] },
  21. durationList: { type: Array, default: () => [] }
  22. },
  23. setup(__props, { expose }) {
  24. var _a, _b;
  25. const props = __props;
  26. (_a = common_vendor.getCurrentInstance()) == null ? void 0 : _a.appContext.config.globalProperties.$api;
  27. const $apifile = (_b = common_vendor.getCurrentInstance()) == null ? void 0 : _b.appContext.config.globalProperties.$apifile;
  28. const form = common_vendor.ref({ file: [] });
  29. common_vendor.ref({
  30. width: 64,
  31. height: 64,
  32. border: {
  33. color: "#ff5a5f",
  34. width: 2,
  35. style: "dashed",
  36. radius: "2px"
  37. }
  38. });
  39. const { id, type, typeList, activityList, durationList, openList } = common_vendor.toRefs(props);
  40. const typeChange = (e) => {
  41. let data;
  42. if (type.value == "1") {
  43. data = typeList.value[e.detail.value];
  44. if (data)
  45. form.value.type = data.dictLabel;
  46. } else {
  47. data = activityList.value[e.detail.value];
  48. if (data)
  49. form.value.type = data.dictLabel;
  50. }
  51. };
  52. const durationChange = (e) => {
  53. const data = durationList.value[e.detail.value];
  54. if (data)
  55. form.value.duration = data.dictLabel;
  56. };
  57. const dateChange = (e) => {
  58. form.value.date = e.detail.value;
  59. };
  60. const timeChange = (e) => {
  61. form.value.time = e.detail.value;
  62. };
  63. const openChange = (e) => {
  64. form.value.is_open = e.detail.value;
  65. };
  66. const toUpload = async (e) => {
  67. const arr = await $apifile(
  68. `/common/upload`,
  69. "file",
  70. e.tempFilePaths[0],
  71. "file"
  72. );
  73. if (arr.code == 200) {
  74. form.value.file.push({
  75. newFileName: arr.newFileName,
  76. originalFilename: arr.originalFilename,
  77. url: arr.url
  78. });
  79. console.log(form.value.file);
  80. } else {
  81. common_vendor.index.showToast({
  82. title: arr.msg,
  83. icon: "none"
  84. });
  85. }
  86. };
  87. const toDelete = async (e) => {
  88. form.value.file = form.value.file.filter((i) => i.originalFilename != e.tempFile.name);
  89. console.log(form.value.file);
  90. };
  91. const formSubmit = () => {
  92. console.log(form.value);
  93. };
  94. expose({
  95. formSubmit
  96. });
  97. return (_ctx, _cache) => {
  98. return common_vendor.e({
  99. a: common_vendor.unref(type) == "1"
  100. }, common_vendor.unref(type) == "1" ? {
  101. b: common_vendor.t(form.value.type || "普通训练"),
  102. c: common_vendor.o(typeChange),
  103. d: _ctx.index,
  104. e: common_vendor.unref(typeList)
  105. } : {
  106. f: common_vendor.t(form.value.type || "请选择"),
  107. g: common_vendor.o(typeChange),
  108. h: _ctx.index,
  109. i: common_vendor.unref(activityList)
  110. }, {
  111. j: common_vendor.t(form.value.date || "请选择"),
  112. k: common_vendor.o(dateChange),
  113. l: _ctx.index,
  114. m: common_vendor.t(form.value.time || "请选择"),
  115. n: common_vendor.o(timeChange),
  116. o: _ctx.index,
  117. p: common_vendor.t(form.value.duration || "请选择时长"),
  118. q: common_vendor.o(durationChange),
  119. r: _ctx.index,
  120. s: common_vendor.unref(durationList),
  121. t: form.value.address,
  122. v: form.value.money,
  123. w: form.value.max_person,
  124. x: common_vendor.t(form.value.is_open || "请选择"),
  125. y: common_vendor.o(openChange),
  126. z: _ctx.index,
  127. A: common_vendor.unref(openList),
  128. B: form.value.date && form.value.time
  129. }, form.value.date && form.value.time ? {
  130. C: common_vendor.o(($event) => form.value.end_time = $event),
  131. D: common_vendor.p({
  132. start: form.value.date,
  133. border: false,
  134. modelValue: form.value.end_time
  135. })
  136. } : {}, {
  137. E: form.value.title,
  138. F: form.value.brief,
  139. G: common_vendor.o(toUpload),
  140. H: common_vendor.o(toDelete),
  141. I: common_vendor.o(($event) => form.value.file = $event),
  142. J: common_vendor.p({
  143. fileMediatype: "image",
  144. ["list-styles"]: _ctx.imageStyles,
  145. limit: "6",
  146. title: "最多选择6张图片",
  147. modelValue: form.value.file
  148. }),
  149. K: common_vendor.o(formSubmit)
  150. });
  151. };
  152. }
  153. });
  154. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-b4c340fa"], ["__file", "D:/project/足球比赛/match_applet/pagesHome/create/components/activity.vue"]]);
  155. wx.createComponent(Component);