choose_project.js 13.7 KB
"use strict";
const common_vendor = require("../../common/vendor.js");
const common_match = require("../../common/match.js");
require("../../common/request.js");
require("../../config.js");
require("../../common/login.js");
require("../../common/api.js");
if (!Array) {
  const _easycom_uni_swipe_action_item2 = common_vendor.resolveComponent("uni-swipe-action-item");
  const _easycom_uni_swipe_action2 = common_vendor.resolveComponent("uni-swipe-action");
  const _easycom_uni_list_item2 = common_vendor.resolveComponent("uni-list-item");
  const _easycom_uni_list2 = common_vendor.resolveComponent("uni-list");
  const _easycom_uni_collapse_item2 = common_vendor.resolveComponent("uni-collapse-item");
  const _easycom_uni_collapse2 = common_vendor.resolveComponent("uni-collapse");
  const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup");
  const _easycom_uni_data_checkbox2 = common_vendor.resolveComponent("uni-data-checkbox");
  const _easycom_uni_section2 = common_vendor.resolveComponent("uni-section");
  (_easycom_uni_swipe_action_item2 + _easycom_uni_swipe_action2 + _easycom_uni_list_item2 + _easycom_uni_list2 + _easycom_uni_collapse_item2 + _easycom_uni_collapse2 + _easycom_uni_popup2 + _easycom_uni_data_checkbox2 + _easycom_uni_section2)();
}
const _easycom_uni_swipe_action_item = () => "../../uni_modules/uni-swipe-action/components/uni-swipe-action-item/uni-swipe-action-item.js";
const _easycom_uni_swipe_action = () => "../../uni_modules/uni-swipe-action/components/uni-swipe-action/uni-swipe-action.js";
const _easycom_uni_list_item = () => "../../uni_modules/uni-list/components/uni-list-item/uni-list-item.js";
const _easycom_uni_list = () => "../../uni_modules/uni-list/components/uni-list/uni-list.js";
const _easycom_uni_collapse_item = () => "../../uni_modules/uni-collapse/components/uni-collapse-item/uni-collapse-item.js";
const _easycom_uni_collapse = () => "../../uni_modules/uni-collapse/components/uni-collapse/uni-collapse.js";
const _easycom_uni_popup = () => "../../uni_modules/uni-popup/components/uni-popup/uni-popup.js";
const _easycom_uni_data_checkbox = () => "../../uni_modules/uni-data-checkbox/components/uni-data-checkbox/uni-data-checkbox.js";
const _easycom_uni_section = () => "../../uni_modules/uni-section/components/uni-section/uni-section.js";
if (!Math) {
  (_easycom_uni_swipe_action_item + _easycom_uni_swipe_action + _easycom_uni_list_item + _easycom_uni_list + _easycom_uni_collapse_item + _easycom_uni_collapse + _easycom_uni_popup + _easycom_uni_data_checkbox + _easycom_uni_section)();
}
const _sfc_main = {
  __name: "choose_project",
  setup(__props) {
    const data = common_vendor.reactive({
      baseFormData: {},
      projectList: [],
      matchId: "",
      chooseList: [],
      signGroupList: [],
      signlevel0: [],
      signlevel1: [],
      signlevel2: [],
      signlevelListPopup: null,
      signlevelList: [],
      signlevelListGirl: [],
      signlevelListBoy: [],
      popup: null
    });
    const {
      baseFormData,
      projectList,
      matchId,
      chooseList,
      popup,
      signGroupList,
      signlevelList,
      signlevelListGirl,
      signlevelListBoy,
      signlevelListPopup,
      signlevel0,
      signlevel1,
      signlevel2
    } = common_vendor.toRefs(data);
    let personId = "";
    let chargeFlag = "";
    common_vendor.onLoad((option) => {
      if (option.matchId) {
        matchId.value = option.matchId;
      }
      getMyself();
      common_match.getMatchById({
        id: matchId.value
      }).then((res) => {
        chargeFlag = res.data.chargeFlag;
      });
    });
    common_vendor.onShow(() => {
      if (matchId.value) {
        getMySignInfo();
      }
    });
    function getMyself() {
      common_match.getMyPersonInfo().then((res) => {
        personId = res.data.id;
      });
    }
    function addProject() {
      if (signInfoType == "2") {
        common_match.recoverMySign({ cptId: matchId.value }).then((res) => {
          if (res.msg.indexOf("Exception:") > -1) {
            let msg = res.msg.slice(10);
            common_vendor.index.showModal({
              title: "提示",
              content: msg,
              success: function(res2) {
                if (res2.confirm) {
                  console.log("用户点击确定");
                }
              }
            });
            return;
          }
          getMySignInfo();
        });
      }
      common_vendor.index.navigateTo({
        url: `/pages_match/match/projectList?personId=${personId}&matchId=${matchId.value}&groupId=0`
      });
    }
    function chooseThisProject(p) {
      signGroupList.value = [];
      common_match.getCanSignGroupListFromSelectPerson(p.id, personId).then((res) => {
        for (var g of res.data) {
          if (g.canSign == "1") {
            signGroupList.value.push(g);
          }
        }
      });
    }
    function removeThis(p, index) {
      common_match.deleteSign(p.id).then((res) => {
        chooseList.value = [];
        getMySignInfo();
      });
    }
    let nowLevel = "";
    function findLevels(groupId) {
      signlevelList.value = [];
      signlevelListGirl.value = [];
      signlevelListBoy.value = [];
      common_match.getCanSignlevelListFromSelectPerson(groupId, personId).then((res) => {
        for (let l of res.data) {
          l.text = l.name;
          l.value = l.id;
          if (l.levelType == "1") {
            signlevelListBoy.value.push(l);
          } else if (l.levelType == "2") {
            signlevelListGirl.value.push(l);
          } else {
            signlevelList.value.push(l);
          }
        }
        signlevelListPopup.value.open();
      });
    }
    function levelMaskClick() {
      signlevelList.value = [];
      signlevelListGirl.value = [];
      signlevelListBoy.value = [];
      signlevel0.value = "";
      signlevel1.value = "";
      signlevel2.value = "";
      nowLevel = "";
    }
    function levelDone() {
      console.log(signlevel0.value, signlevel1.value, signlevel2.value);
      nowLevel = signlevel0.value + signlevel1.value + signlevel2.value;
      if (!nowLevel) {
        common_vendor.index.showToast({
          title: "请选择级别",
          icon: "none",
          duration: 2e3
        });
        return;
      }
      let obj = {
        levelId: nowLevel,
        athleteIds: personId,
        groupId: "",
        teamId: ""
      };
      saveOne(obj);
    }
    function saveOne(obj) {
      common_match.sportsmanDone(obj).then((res) => {
        if (res.msg.indexOf("Exception:") > -1) {
          let msg = res.msg.slice(10);
          common_vendor.index.showModal({
            title: "提示",
            content: msg,
            success: function(res2) {
              if (res2.confirm)
                ;
            }
          });
          return;
        }
        signlevel0.value = [];
        signlevel1.value = [];
        signlevel2.value = [];
        nowLevel = "";
        res.data;
        signlevelListPopup.value.close();
        popup.value.close();
        getMySignInfo();
      });
    }
    let signInfoType = null;
    function getMySignInfo() {
      common_match.getMySignInfo({
        cptId: matchId.value,
        groupId: ""
      }).then((res) => {
        console.log(res.data);
        signInfoType = res.data.type;
        if (!res.data.signInfo) {
          return;
        }
        chooseList.value = res.data.signInfo;
        if (signInfoType == "2") {
          console.log("ff");
        }
      });
    }
    function goPrev() {
      common_vendor.index.navigateBack();
    }
    function goNext() {
      if (signInfoType == "1") {
        common_vendor.index.showModal({
          title: "提示",
          content: "已报项,前往我的报项",
          showCancel: false,
          success: function(res) {
            if (res.confirm) {
              let path = `/pages/usercenter/match`;
              common_vendor.index.reLaunch({
                url: path
              });
            } else if (res.cancel) {
              console.log("用户点击取消");
            }
          }
        });
        return;
      }
      if (signInfoType == "2") {
        common_match.recoverMySign({ cptId: matchId.value }).then((res) => {
          if (res.msg.indexOf("Exception:") > -1) {
            let msg = res.msg.slice(10);
            common_vendor.index.showModal({
              title: "提示",
              content: msg,
              success: function(res2) {
                if (res2.confirm) {
                  console.log("用户点击确定");
                }
              }
            });
            return;
          } else {
            afterRecover();
          }
        });
      } else {
        afterRecover();
      }
    }
    function afterRecover() {
      if (chooseList.length == 0) {
        common_vendor.index.showToast({
          title: "请至少选择一个项目",
          icon: "none",
          duration: 2e3
        });
        return;
      }
      if (chargeFlag == "0") {
        var obj = {
          cptId: matchId.value,
          groupId: ""
        };
        common_match.commitSign(obj).then((res) => {
          console.log(res.data);
          let path = `/pages_match/match/matchPayDone?cptId=${matchId.value}&groupId=0&chargeFlag=${chargeFlag}&orderId=${res.data}`;
          common_vendor.index.navigateTo({
            url: path
          });
        });
      } else {
        common_vendor.index.navigateTo({
          url: `/pages_match/match/matchBill?cptId=${matchId.value}&personId=${personId}`
        });
      }
    }
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: common_vendor.o(addProject),
        b: common_vendor.f(common_vendor.unref(chooseList), (p, index, i0) => {
          return {
            a: common_vendor.t(p.name),
            b: common_vendor.t(p.cptProjectName),
            c: common_vendor.t(p.cptGroupName),
            d: common_vendor.t(p.cptLevelName),
            e: common_vendor.o(($event) => removeThis(p), p.id),
            f: "6169f0b4-1-" + i0 + "," + ("6169f0b4-0-" + i0),
            g: "6169f0b4-0-" + i0,
            h: p.id
          };
        }),
        c: common_vendor.unref(chooseList).length == 0
      }, common_vendor.unref(chooseList).length == 0 ? {} : {}, {
        d: common_vendor.o(goPrev),
        e: common_vendor.o(goNext),
        f: common_vendor.f(common_vendor.unref(projectList), (p, index, i0) => {
          return common_vendor.e({
            a: common_vendor.t(p.name),
            b: common_vendor.o(($event) => chooseThisProject(p), index),
            c: common_vendor.f(common_vendor.unref(signGroupList), (group, index2, i1) => {
              return {
                a: index2,
                b: common_vendor.o(($event) => findLevels(group.id), index2),
                c: "6169f0b4-6-" + i0 + "-" + i1 + "," + ("6169f0b4-5-" + i0),
                d: common_vendor.p({
                  title: group.name,
                  clickable: true
                })
              };
            }),
            d: "6169f0b4-5-" + i0 + "," + ("6169f0b4-4-" + i0)
          }, common_vendor.unref(signGroupList).length == 0 ? {} : {}, {
            e: index,
            f: "6169f0b4-4-" + i0 + ",6169f0b4-3"
          });
        }),
        g: common_vendor.p({
          border: false
        }),
        h: common_vendor.unref(signGroupList).length == 0,
        i: common_vendor.p({
          ["show-arrow"]: false,
          border: false,
          ["title-border"]: "none"
        }),
        j: common_vendor.p({
          accordion: true
        }),
        k: common_vendor.sr(popup, "6169f0b4-2", {
          "k": "popup"
        }),
        l: common_vendor.p({
          type: "bottom",
          ["background-color"]: "#fff"
        }),
        m: common_vendor.unref(signlevelList).length && common_vendor.unref(signlevelList).length > 0
      }, common_vendor.unref(signlevelList).length && common_vendor.unref(signlevelList).length > 0 ? {
        n: common_vendor.o(_ctx.changeSignlevel0),
        o: common_vendor.o(($event) => common_vendor.isRef(signlevel0) ? signlevel0.value = $event : null),
        p: common_vendor.p({
          mode: "button",
          localdata: common_vendor.unref(signlevelList),
          modelValue: common_vendor.unref(signlevel0)
        })
      } : {}, {
        q: common_vendor.unref(signlevelListBoy).length > 0
      }, common_vendor.unref(signlevelListBoy).length > 0 ? {
        r: common_vendor.o(_ctx.changeSignlevel1),
        s: common_vendor.o(($event) => common_vendor.isRef(signlevel1) ? signlevel1.value = $event : null),
        t: common_vendor.p({
          mode: "button",
          localdata: common_vendor.unref(signlevelListBoy),
          modelValue: common_vendor.unref(signlevel1)
        }),
        v: common_vendor.p({
          title: "男子组",
          type: "line"
        })
      } : {}, {
        w: common_vendor.unref(signlevelListGirl).length > 0
      }, common_vendor.unref(signlevelListGirl).length > 0 ? {
        x: common_vendor.o(_ctx.changeSignlevel2),
        y: common_vendor.o(($event) => common_vendor.isRef(signlevel2) ? signlevel2.value = $event : null),
        z: common_vendor.p({
          mode: "button",
          localdata: common_vendor.unref(signlevelListGirl),
          modelValue: common_vendor.unref(signlevel2)
        }),
        A: common_vendor.p({
          title: "女子组",
          type: "line"
        })
      } : {}, {
        B: common_vendor.o(levelDone),
        C: common_vendor.sr(signlevelListPopup, "6169f0b4-7", {
          "k": "signlevelListPopup"
        }),
        D: common_vendor.o(levelMaskClick)
      });
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-6169f0b4"], ["__file", "/Users/yangyang/project/j-mini/Venue/pages_match/match/choose_project.vue"]]);
wx.createPage(MiniProgramPage);