match.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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: "match",
  15. props: {
  16. id: { type: String, default: () => "" },
  17. typeList: { type: Array, default: () => [] },
  18. numberList: { type: Array, default: () => [] },
  19. openList: { type: Array, default: () => [] },
  20. durationList: { type: Array, default: () => [] }
  21. },
  22. setup(__props, { expose }) {
  23. var _a, _b;
  24. const props = __props;
  25. const $api = (_a = common_vendor.getCurrentInstance()) == null ? void 0 : _a.appContext.config.globalProperties.$api;
  26. const $apifile = (_b = common_vendor.getCurrentInstance()) == null ? void 0 : _b.appContext.config.globalProperties.$apifile;
  27. const form = common_vendor.ref({ file: [], number: "5", type: "0", duration: "2.0", is_open: "Y" });
  28. const opponent_name = common_vendor.ref("");
  29. const type_name = common_vendor.ref("足球");
  30. const number_name = common_vendor.ref("5人制");
  31. const open_name = common_vendor.ref("");
  32. const duration_name = common_vendor.ref("2.0小时");
  33. common_vendor.ref({
  34. width: 64,
  35. height: 64,
  36. border: {
  37. color: "#ff5a5f",
  38. width: 2,
  39. style: "dashed",
  40. radius: "2px"
  41. }
  42. });
  43. const { id, typeList, durationList, numberList, openList } = common_vendor.toRefs(props);
  44. common_vendor.onShow(() => {
  45. common_vendor.index.$on("opponentInfo", function(item) {
  46. form.value.opponent = item.id;
  47. opponent_name.value = item.name;
  48. });
  49. });
  50. const typeChange = (e) => {
  51. const data = typeList.value[e.detail.value];
  52. if (data) {
  53. type_name.value = data.dictLabel;
  54. form.value.type = data.dictValue;
  55. }
  56. };
  57. const numberChange = (e) => {
  58. const data = numberList.value[e.detail.value];
  59. if (data) {
  60. number_name.value = data.dictLabel;
  61. form.value.number = data.dictValue;
  62. }
  63. };
  64. const dateChange = (e) => {
  65. form.value.date = e.detail.value;
  66. };
  67. const timeChange = (e) => {
  68. form.value.time = e.detail.value;
  69. };
  70. const durationChange = (e) => {
  71. const data = durationList.value[e.detail.value];
  72. if (data) {
  73. duration_name.value = data.dictLabel;
  74. form.value.duration = data.dictValue;
  75. }
  76. };
  77. const openChange = (e) => {
  78. const data = openList.value[e.detail.value];
  79. if (data) {
  80. open_name.value = data.dictLabel;
  81. form.value.is_open = data.dictValue;
  82. }
  83. };
  84. const toLocaltion = (e) => {
  85. common_vendor.index.chooseLocation({
  86. success: function(res) {
  87. searchAddress(res);
  88. }
  89. });
  90. };
  91. const searchAddress = (e) => {
  92. form.value.address = e.address;
  93. };
  94. const toUpload = async (e) => {
  95. const arr = await $apifile(
  96. `/common/upload`,
  97. "file",
  98. e.tempFilePaths[0],
  99. "file"
  100. );
  101. if (arr.code == 200) {
  102. form.value.file.push({
  103. name: arr.originalFilename,
  104. url: arr.url
  105. });
  106. console.log(form.value.file);
  107. } else {
  108. common_vendor.index.showToast({
  109. title: arr.msg,
  110. icon: "none"
  111. });
  112. }
  113. };
  114. const toDelete = async (e) => {
  115. form.value.file = form.value.file.filter((i) => i.name != e.tempFile.name);
  116. console.log(form.value.file);
  117. };
  118. const toOpponent = () => {
  119. common_vendor.index.navigateTo({
  120. url: `/pagesHome/create/person`
  121. });
  122. };
  123. const formSubmit = async () => {
  124. if (!form.value.opponent) {
  125. common_vendor.index.showToast({ title: "请选择比赛对手", icon: "none" });
  126. return;
  127. } else if (!form.value.date) {
  128. common_vendor.index.showToast({ title: "请选择活动日期", icon: "none" });
  129. return;
  130. } else if (!form.value.time) {
  131. common_vendor.index.showToast({ title: "请选择活动时间", icon: "none" });
  132. return;
  133. } else if (!form.value.address) {
  134. common_vendor.index.showToast({ title: "请选择活动场地", icon: "none" });
  135. return;
  136. } else {
  137. if (form.value.file && form.value.file.length == 0)
  138. delete form.value.file;
  139. form.value.teamId = id.value;
  140. const arr = await $api(`friendship`, "POST", form.value);
  141. if (arr.code === 200) {
  142. const data = {
  143. matchId: arr.id,
  144. type: "0",
  145. red: form.value.teamId,
  146. blue: form.value.opponent,
  147. startTime: common_vendor.hooks(form.value.date + " " + form.value.time).format("YYYY-MM-DD HH:mm"),
  148. endTime: common_vendor.hooks(form.value.startTime).add(form.value.duration, "hours").format("YYYY-MM-DD HH:mm")
  149. };
  150. const res = await $api(`game`, "POST", data);
  151. if (res.code === 200) {
  152. common_vendor.index.navigateTo({
  153. url: `/pagesHome/activity/info?id=${res.id}`
  154. });
  155. }
  156. } else {
  157. common_vendor.index.showToast({
  158. title: arr.msg,
  159. icon: "error"
  160. });
  161. }
  162. }
  163. };
  164. expose({
  165. formSubmit
  166. });
  167. return (_ctx, _cache) => {
  168. return common_vendor.e({
  169. a: common_vendor.t(type_name.value || "请选择类型"),
  170. b: common_vendor.o(typeChange),
  171. c: _ctx.index,
  172. d: common_vendor.unref(typeList),
  173. e: common_vendor.t(number_name.value || "请选择人数"),
  174. f: common_vendor.o(numberChange),
  175. g: _ctx.index,
  176. h: common_vendor.unref(numberList),
  177. i: form.value.opponent
  178. }, form.value.opponent ? {
  179. j: common_vendor.t(opponent_name.value)
  180. } : {}, {
  181. k: common_vendor.o(toOpponent),
  182. l: common_vendor.t(form.value.date || "请选择日期"),
  183. m: common_vendor.o(dateChange),
  184. n: _ctx.index,
  185. o: common_vendor.t(form.value.time || "请选择时间"),
  186. p: common_vendor.o(timeChange),
  187. q: _ctx.index,
  188. r: common_vendor.t(duration_name.value || "请选择时长"),
  189. s: common_vendor.o(durationChange),
  190. t: _ctx.index,
  191. v: common_vendor.unref(durationList),
  192. w: form.value.address
  193. }, form.value.address ? {
  194. x: common_vendor.t(form.value.address)
  195. } : {}, {
  196. y: common_vendor.o(toLocaltion),
  197. z: form.value.money,
  198. A: form.value.max_person,
  199. B: common_vendor.t(open_name.value || "请选择"),
  200. C: common_vendor.o(openChange),
  201. D: _ctx.index,
  202. E: common_vendor.unref(openList),
  203. F: form.value.date && form.value.time
  204. }, form.value.date && form.value.time ? {
  205. G: common_vendor.o(($event) => form.value.end_time = $event),
  206. H: common_vendor.p({
  207. start: form.value.date,
  208. border: false,
  209. modelValue: form.value.end_time
  210. })
  211. } : {}, {
  212. I: form.value.title,
  213. J: form.value.brief,
  214. K: common_vendor.o(toUpload),
  215. L: common_vendor.o(toDelete),
  216. M: common_vendor.o(($event) => form.value.file = $event),
  217. N: common_vendor.p({
  218. fileMediatype: "image",
  219. ["list-styles"]: _ctx.imageStyles,
  220. limit: "6",
  221. title: "最多选择6张图片",
  222. modelValue: form.value.file
  223. })
  224. });
  225. };
  226. }
  227. });
  228. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-6bad03e0"], ["__file", "D:/project/足球比赛/match_applet/pagesHome/create/components/match.vue"]]);
  229. wx.createComponent(Component);