123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- "use strict";
- const common_vendor = require("../../../common/vendor.js");
- if (!Array) {
- const _easycom_uni_datetime_picker2 = common_vendor.resolveComponent("uni-datetime-picker");
- const _easycom_uni_file_picker2 = common_vendor.resolveComponent("uni-file-picker");
- (_easycom_uni_datetime_picker2 + _easycom_uni_file_picker2)();
- }
- const _easycom_uni_datetime_picker = () => "../../../uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.js";
- const _easycom_uni_file_picker = () => "../../../uni_modules/uni-file-picker/components/uni-file-picker/uni-file-picker.js";
- if (!Math) {
- (_easycom_uni_datetime_picker + _easycom_uni_file_picker)();
- }
- const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
- __name: "match",
- props: {
- id: { type: String, default: () => "" },
- typeList: { type: Array, default: () => [] },
- numberList: { type: Array, default: () => [] },
- openList: { type: Array, default: () => [] },
- durationList: { type: Array, default: () => [] }
- },
- setup(__props, { expose }) {
- var _a, _b;
- const props = __props;
- const $api = (_a = common_vendor.getCurrentInstance()) == null ? void 0 : _a.appContext.config.globalProperties.$api;
- const $apifile = (_b = common_vendor.getCurrentInstance()) == null ? void 0 : _b.appContext.config.globalProperties.$apifile;
- const form = common_vendor.ref({ file: [], number: "5", type: "0", duration: "2.0", is_open: "Y" });
- const opponent_name = common_vendor.ref("");
- const type_name = common_vendor.ref("足球");
- const number_name = common_vendor.ref("5人制");
- const open_name = common_vendor.ref("");
- const duration_name = common_vendor.ref("2.0小时");
- common_vendor.ref({
- width: 64,
- height: 64,
- border: {
- color: "#ff5a5f",
- width: 2,
- style: "dashed",
- radius: "2px"
- }
- });
- const { id, typeList, durationList, numberList, openList } = common_vendor.toRefs(props);
- common_vendor.onShow(() => {
- common_vendor.index.$on("opponentInfo", function(item) {
- form.value.opponent = item.id;
- opponent_name.value = item.name;
- });
- });
- const typeChange = (e) => {
- const data = typeList.value[e.detail.value];
- if (data) {
- type_name.value = data.dictLabel;
- form.value.type = data.dictValue;
- }
- };
- const numberChange = (e) => {
- const data = numberList.value[e.detail.value];
- if (data) {
- number_name.value = data.dictLabel;
- form.value.number = data.dictValue;
- }
- };
- const dateChange = (e) => {
- form.value.date = e.detail.value;
- };
- const timeChange = (e) => {
- form.value.time = e.detail.value;
- };
- const durationChange = (e) => {
- const data = durationList.value[e.detail.value];
- if (data) {
- duration_name.value = data.dictLabel;
- form.value.duration = data.dictValue;
- }
- };
- const openChange = (e) => {
- const data = openList.value[e.detail.value];
- if (data) {
- open_name.value = data.dictLabel;
- form.value.is_open = data.dictValue;
- }
- };
- const toLocaltion = (e) => {
- common_vendor.index.chooseLocation({
- success: function(res) {
- searchAddress(res);
- }
- });
- };
- const searchAddress = (e) => {
- form.value.address = e.address;
- };
- const toUpload = async (e) => {
- const arr = await $apifile(
- `/common/upload`,
- "file",
- e.tempFilePaths[0],
- "file"
- );
- if (arr.code == 200) {
- form.value.file.push({
- name: arr.originalFilename,
- url: arr.url
- });
- console.log(form.value.file);
- } else {
- common_vendor.index.showToast({
- title: arr.msg,
- icon: "none"
- });
- }
- };
- const toDelete = async (e) => {
- form.value.file = form.value.file.filter((i) => i.name != e.tempFile.name);
- console.log(form.value.file);
- };
- const toOpponent = () => {
- common_vendor.index.navigateTo({
- url: `/pagesHome/create/person`
- });
- };
- const formSubmit = async () => {
- if (!form.value.opponent) {
- common_vendor.index.showToast({ title: "请选择比赛对手", icon: "none" });
- return;
- } else if (!form.value.date) {
- common_vendor.index.showToast({ title: "请选择活动日期", icon: "none" });
- return;
- } else if (!form.value.time) {
- common_vendor.index.showToast({ title: "请选择活动时间", icon: "none" });
- return;
- } else if (!form.value.address) {
- common_vendor.index.showToast({ title: "请选择活动场地", icon: "none" });
- return;
- } else {
- if (form.value.file && form.value.file.length == 0)
- delete form.value.file;
- form.value.teamId = id.value;
- const arr = await $api(`friendship`, "POST", form.value);
- if (arr.code === 200) {
- const data = {
- matchId: arr.id,
- type: "0",
- red: form.value.teamId,
- blue: form.value.opponent,
- startTime: common_vendor.hooks(form.value.date + " " + form.value.time).format("YYYY-MM-DD HH:mm"),
- endTime: common_vendor.hooks(form.value.startTime).add(form.value.duration, "hours").format("YYYY-MM-DD HH:mm")
- };
- const res = await $api(`game`, "POST", data);
- if (res.code === 200) {
- common_vendor.index.navigateTo({
- url: `/pagesHome/activity/info?id=${res.id}`
- });
- }
- } else {
- common_vendor.index.showToast({
- title: arr.msg,
- icon: "error"
- });
- }
- }
- };
- expose({
- formSubmit
- });
- return (_ctx, _cache) => {
- return common_vendor.e({
- a: common_vendor.t(type_name.value || "请选择类型"),
- b: common_vendor.o(typeChange),
- c: _ctx.index,
- d: common_vendor.unref(typeList),
- e: common_vendor.t(number_name.value || "请选择人数"),
- f: common_vendor.o(numberChange),
- g: _ctx.index,
- h: common_vendor.unref(numberList),
- i: form.value.opponent
- }, form.value.opponent ? {
- j: common_vendor.t(opponent_name.value)
- } : {}, {
- k: common_vendor.o(toOpponent),
- l: common_vendor.t(form.value.date || "请选择日期"),
- m: common_vendor.o(dateChange),
- n: _ctx.index,
- o: common_vendor.t(form.value.time || "请选择时间"),
- p: common_vendor.o(timeChange),
- q: _ctx.index,
- r: common_vendor.t(duration_name.value || "请选择时长"),
- s: common_vendor.o(durationChange),
- t: _ctx.index,
- v: common_vendor.unref(durationList),
- w: form.value.address
- }, form.value.address ? {
- x: common_vendor.t(form.value.address)
- } : {}, {
- y: common_vendor.o(toLocaltion),
- z: form.value.money,
- A: form.value.max_person,
- B: common_vendor.t(open_name.value || "请选择"),
- C: common_vendor.o(openChange),
- D: _ctx.index,
- E: common_vendor.unref(openList),
- F: form.value.date && form.value.time
- }, form.value.date && form.value.time ? {
- G: common_vendor.o(($event) => form.value.end_time = $event),
- H: common_vendor.p({
- start: form.value.date,
- border: false,
- modelValue: form.value.end_time
- })
- } : {}, {
- I: form.value.title,
- J: form.value.brief,
- K: common_vendor.o(toUpload),
- L: common_vendor.o(toDelete),
- M: common_vendor.o(($event) => form.value.file = $event),
- N: common_vendor.p({
- fileMediatype: "image",
- ["list-styles"]: _ctx.imageStyles,
- limit: "6",
- title: "最多选择6张图片",
- modelValue: form.value.file
- })
- });
- };
- }
- });
- const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-6bad03e0"], ["__file", "D:/project/足球比赛/match_applet/pagesHome/create/components/match.vue"]]);
- wx.createComponent(Component);
|