|
@@ -6,6 +6,14 @@ Page({
|
|
|
*/
|
|
|
data: {
|
|
|
frameStyle: { useTop: true, name: '淘汰赛管理', leftArrow: true, useBar: false },
|
|
|
+ dialog: { title: '赛程信息', show: false, type: '1' },
|
|
|
+ form: {},
|
|
|
+ // 赛事信息
|
|
|
+ matchList: [],
|
|
|
+ // 组别
|
|
|
+ groupingList: [],
|
|
|
+ //组内项目
|
|
|
+ projectList: [],
|
|
|
},
|
|
|
// 跳转菜单
|
|
|
back(e) {
|
|
@@ -15,7 +23,64 @@ Page({
|
|
|
},
|
|
|
// 添加
|
|
|
toAdd: function () {
|
|
|
- wx.navigateTo({ url: '/pages/eliminate/add' })
|
|
|
+ const that = this;
|
|
|
+ that.setData({ dialog: { title: '赛程信息', show: true, type: '1' } })
|
|
|
+ },
|
|
|
+ // 关闭弹框
|
|
|
+ toClose: function () {
|
|
|
+ const that = this;
|
|
|
+ that.setData({ form: {} })
|
|
|
+ that.setData({ dialog: { title: '赛程信息', show: true, type: '1' } })
|
|
|
+
|
|
|
+ },
|
|
|
+ // 选择赛事
|
|
|
+ matchChange: function (e) {
|
|
|
+ const that = this;
|
|
|
+ let data = that.data.matchList[e.detail.value];
|
|
|
+ if (data) {
|
|
|
+ that.setData({ 'form.match_id': data._id });
|
|
|
+ that.setData({ 'form.match_name': data.name });
|
|
|
+ if (data.grouping && data.grouping.length > 0) {
|
|
|
+ that.setData({ groupingList: data.grouping })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 选择赛事组别
|
|
|
+ grpupChange: async function (e) {
|
|
|
+ const that = this;
|
|
|
+ let data = that.data.groupingList[e.detail.value];
|
|
|
+ if (data) {
|
|
|
+ that.setData({ 'form.grouping_id': data._id });
|
|
|
+ that.setData({ 'form.grouping_name': data.name });
|
|
|
+ if (data.project && data.project.length > 0) {
|
|
|
+ let projectList = [];
|
|
|
+ for (const val of data.project) {
|
|
|
+ const arr = await app.$get(`/newCourt/api/matchProject/${val}`)
|
|
|
+ if (arr.errcode == '0') projectList.push(arr.data);
|
|
|
+ that.setData({ projectList: projectList })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 选择组内项目
|
|
|
+ projectChange: function (e) {
|
|
|
+ const that = this;
|
|
|
+ let data = that.data.projectList[e.detail.value];
|
|
|
+ if (data) {
|
|
|
+ that.setData({ 'form.project_id': data._id });
|
|
|
+ that.setData({ 'form.project_name': data.name });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 赛程信息
|
|
|
+ onSubmit: function (e) {
|
|
|
+ const that = this;
|
|
|
+ const params = e.detail.value;
|
|
|
+ if (params.match_id && params.grouping_id && params.project_id) {
|
|
|
+ wx.navigateTo({ url: `/pages/eliminate/add?match_id=${params.match_id}&grouping_id=${params.grouping_id}&project_id=${params.project_id}` })
|
|
|
+ } else {
|
|
|
+ wx.showToast({ title: `缺少必要信息`, icon: 'error', duration: 2000 })
|
|
|
+ }
|
|
|
+
|
|
|
},
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
@@ -35,7 +100,25 @@ Page({
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
onShow: function () {
|
|
|
+ const that = this;
|
|
|
+ that.watchLogin();
|
|
|
+ },
|
|
|
+ // 监听用户是否登录
|
|
|
+ watchLogin: async function () {
|
|
|
+ const that = this;
|
|
|
+ wx.getStorage({
|
|
|
+ key: 'user',
|
|
|
+ success: async res => {
|
|
|
+ let arr;
|
|
|
+ // 比赛信息
|
|
|
+ arr = await app.$get(`/newCourt/api/match`, { status: '0' });//2
|
|
|
+ if (arr.errcode == '0') { that.setData({ matchList: arr.data }) }
|
|
|
|
|
|
+ },
|
|
|
+ fail: res => {
|
|
|
+ wx.redirectTo({ url: '/pages/index/index', })
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
/**
|