|
@@ -1,11 +1,116 @@
|
|
|
const app = getApp();
|
|
|
Page({
|
|
|
data: {
|
|
|
- frameStyle: { useTop: true, name: '基本页面', leftArrow: true, useBar: false },
|
|
|
+ frameStyle: { useTop: true, name: '自动建组', leftArrow: true, useBar: false },
|
|
|
+ list: [],
|
|
|
+ total: 0,
|
|
|
+ page: 0,
|
|
|
+ skip: 0,
|
|
|
+ limit: 5,
|
|
|
+ dialog: { title: '审核申请', show: false, type: '1' },
|
|
|
+ form: {},
|
|
|
+ //比赛列表
|
|
|
+ matchList: [],
|
|
|
+ // 赛事组别
|
|
|
+ groupList: [],
|
|
|
+ // 组内项目
|
|
|
+ projectList: [],
|
|
|
+ // 成员
|
|
|
+ memberList: []
|
|
|
},
|
|
|
// 返回
|
|
|
back: function () { wx.navigateBack({ delta: 1 }) },
|
|
|
-
|
|
|
+ // 设置条件
|
|
|
+ toSet: async function (e) {
|
|
|
+ const that = this;
|
|
|
+ that.setData({ dialog: { title: '设置条件', show: true, type: '1' } })
|
|
|
+ },
|
|
|
+ // 修改
|
|
|
+ toEdit: async function (e) {
|
|
|
+ const that = this;
|
|
|
+ const { item } = e.currentTarget.dataset;
|
|
|
+ that.setData({ form: item })
|
|
|
+ that.setData({ 'form.member': that.data.memberList })
|
|
|
+ that.setData({ dialog: { title: '修改信息', show: true, type: '2' } })
|
|
|
+ },
|
|
|
+ // 删除成员
|
|
|
+ toDel: async function (e) {
|
|
|
+ const that = this;
|
|
|
+ const { name, tag } = e.currentTarget.dataset;
|
|
|
+ that.data.memberList.push(tag)
|
|
|
+ let list = that.data.list;
|
|
|
+ for (const val of list) {
|
|
|
+ if (val.name == name) {
|
|
|
+ val.person = val.person.filter(i => i._id != tag._id)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ that.setData({ list })
|
|
|
+ },
|
|
|
+ checkboxChange(e) {
|
|
|
+ const member = this.data.form.person
|
|
|
+ const values = e.detail.value
|
|
|
+ for (let i = 0, lenI = member.length; i < lenI; ++i) {
|
|
|
+ member[i].checked = false
|
|
|
+ for (let j = 0, lenJ = values.length; j < lenJ; ++j) {
|
|
|
+ if (member[i].value === values[j]) {
|
|
|
+ member[i].checked = true
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.setData({
|
|
|
+ 'form.person': member
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 赛事
|
|
|
+ matchChange: async function (e) {
|
|
|
+ const that = this;
|
|
|
+ let data = that.data.matchList[e.detail.value];
|
|
|
+ if (data) {
|
|
|
+ that.setData({ 'form.match_id': data._id, 'form.match_name': data.name });
|
|
|
+ const arr = await app.$get(`/matchGroup`, { match_id: data._id }, 'race');
|
|
|
+ if (arr.errcode == '0') { that.setData({ groupList: arr.data }) }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 组别
|
|
|
+ groupChange: async function (e) {
|
|
|
+ const that = this;
|
|
|
+ let data = that.data.groupList[e.detail.value];
|
|
|
+ if (data) {
|
|
|
+ that.setData({ 'form.group_id': data._id, 'form.group_name': data.name });
|
|
|
+ const arr = await app.$get(`/matchProject`, { match_id: data.match_id, group_id: data._id }, 'race');
|
|
|
+ if (arr.errcode == '0') { that.setData({ projectList: arr.data }) }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 项目
|
|
|
+ projectChange: async function (e) {
|
|
|
+ const that = this;
|
|
|
+ let data = that.data.projectList[e.detail.value];
|
|
|
+ if (data) {
|
|
|
+ that.setData({ 'form.project_id': data._id, 'form.project_name': data.name });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ personSubmit: async function (e) {
|
|
|
+ const that = this;
|
|
|
+ const params = e.detail.value;
|
|
|
+ console.log(params);
|
|
|
+ },
|
|
|
+ onSubmit: async function (e) {
|
|
|
+ const that = this;
|
|
|
+ const params = e.detail.value;
|
|
|
+ const arr = await app.$post(`/matchTeamGroup/auto`, params, 'race');
|
|
|
+ if (arr.errcode == '0') {
|
|
|
+ wx.showToast({ title: `维护信息完成`, icon: 'success', duration: 2000 });
|
|
|
+ that.toClose();
|
|
|
+ that.watchLogin(arr.data);
|
|
|
+ }
|
|
|
+ else wx.showToast({ title: `${arr.errmsg}`, icon: 'none', duration: 2000 })
|
|
|
+ },
|
|
|
+ // 关闭弹框
|
|
|
+ toClose: function () {
|
|
|
+ const that = this;
|
|
|
+ that.setData({ dialog: { title: '设置条件', show: false, type: '1' } })
|
|
|
+ },
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
@@ -23,11 +128,16 @@ Page({
|
|
|
that.watchLogin();
|
|
|
},
|
|
|
// 监听用户是否登录
|
|
|
- watchLogin: async function () {
|
|
|
+ watchLogin: async function (e) {
|
|
|
const that = this;
|
|
|
wx.getStorage({
|
|
|
key: 'raceuser',
|
|
|
- success: async res => { },
|
|
|
+ success: async res => {
|
|
|
+ let arr;
|
|
|
+ arr = await app.$get(`/match`, { belong_id: '630ec0480a92b0a015ccfbe1' }, 'race');
|
|
|
+ if (arr.errcode == '0') that.setData({ matchList: arr.data });
|
|
|
+ that.setData({ list: e });
|
|
|
+ },
|
|
|
fail: async res => {
|
|
|
wx.redirectTo({ url: '/pages/index/index' })
|
|
|
}
|