match.js 8.4 KB

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