|
@@ -2,10 +2,6 @@ const app = getApp();
|
|
Page({
|
|
Page({
|
|
data: {
|
|
data: {
|
|
frameStyle: { useTop: true, name: '赛事信息', leftArrow: true, useBar: false },
|
|
frameStyle: { useTop: true, name: '赛事信息', leftArrow: true, useBar: false },
|
|
- fileUrl: app.globalData.fileUrl,
|
|
|
|
- id: '',
|
|
|
|
- info: {},
|
|
|
|
- user: {},
|
|
|
|
// 选项卡
|
|
// 选项卡
|
|
tabs: {
|
|
tabs: {
|
|
active: 'a',
|
|
active: 'a',
|
|
@@ -17,37 +13,142 @@ Page({
|
|
{ title: '成绩册', active: 'e' },
|
|
{ title: '成绩册', active: 'e' },
|
|
],
|
|
],
|
|
},
|
|
},
|
|
- // 状态
|
|
|
|
- statusList: []
|
|
|
|
|
|
+ // 用户信息
|
|
|
|
+ user: {},
|
|
|
|
+ // 赛事id
|
|
|
|
+ id: '',
|
|
|
|
+ // 赛事信息
|
|
|
|
+ info: {},
|
|
|
|
+ // 赛事选手
|
|
|
|
+ playerList: [],
|
|
|
|
+ // 第一层手风琴
|
|
|
|
+ playerIndex: 99999,
|
|
|
|
+ // 第二层手风琴
|
|
|
|
+ playerIndexs: 99999,
|
|
|
|
+ // 秩序册
|
|
|
|
+ cType: '0',
|
|
|
|
+ cList: [],
|
|
|
|
+ cSearchname: '',
|
|
|
|
+ raceteamList: [],
|
|
|
|
+ raceList: [],
|
|
|
|
+ // 赛况
|
|
|
|
+ dTabs: { active: '0', menu: [] },
|
|
|
|
+ dList: [],
|
|
|
|
+ // 成绩册
|
|
|
|
+ achieveList: [],
|
|
|
|
+ //赛事状态
|
|
|
|
+ statusList: [],
|
|
|
|
+ //赛事类别
|
|
|
|
+ typeList: [],
|
|
|
|
+ //赛制列表
|
|
|
|
+ formatList: [],
|
|
|
|
+ //性别列表
|
|
|
|
+ genderList: [],
|
|
},
|
|
},
|
|
// 返回
|
|
// 返回
|
|
back: function () { wx.navigateBack({ delta: 1 }) },
|
|
back: function () { wx.navigateBack({ delta: 1 }) },
|
|
|
|
+ //比赛报名
|
|
|
|
+ toSign: function (e) {
|
|
|
|
+ const { item } = e.currentTarget.dataset;
|
|
|
|
+ wx.getStorage({
|
|
|
|
+ key: 'user',
|
|
|
|
+ success: async res => {
|
|
|
|
+ if (res.data.type == '10') {
|
|
|
|
+ wx.showModal({ title: '提示', content: '游客不能进入比赛系统,请注册成为正式用户' })
|
|
|
|
+ } else {
|
|
|
|
+ const arr = await app.$post(`/user/login`, { openid: res.data.openid }, 'race');
|
|
|
|
+ if (arr.errcode == '0') {
|
|
|
|
+ wx.setStorageSync('raceuser', arr.data);
|
|
|
|
+ wx.navigateTo({ url: `/pagesMatch/match/sign?id=${item._id}` })
|
|
|
|
+ } else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }); }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ fail: async res => {
|
|
|
|
+ wx.redirectTo({ url: '/pages/index/index' })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ // 赛事项目详细信息
|
|
|
|
+ toAchieve: function (e) {
|
|
|
|
+ const { match_id, group_id } = e.detail;
|
|
|
|
+ let project_id = e.detail.project_id || e.detail._id;
|
|
|
|
+ wx.navigateTo({ url: `/pagesMatch/match/achieve?match_id=${match_id}&group_id=${group_id}&project_id=${project_id}` })
|
|
|
|
+ },
|
|
// 选项卡
|
|
// 选项卡
|
|
tabsChange: function (e) {
|
|
tabsChange: function (e) {
|
|
const that = this;
|
|
const that = this;
|
|
- that.setData({ 'tabs.active': e.detail.active });
|
|
|
|
|
|
+ let { active } = e.detail;
|
|
|
|
+ let info = that.data.info;
|
|
|
|
+ if (info.status == '0') {
|
|
|
|
+ if (active == 'a') {
|
|
|
|
+ that.setData({ 'tabs.active': active });
|
|
|
|
+ } else {
|
|
|
|
+ wx.showToast({ title: `暂无开放`, icon: 'error', duration: 2000 });
|
|
|
|
+ }
|
|
|
|
+ } else if (info.status == '1') {
|
|
|
|
+ if (active == 'a' || active == 'b') {
|
|
|
|
+ that.setData({ 'tabs.active': active });
|
|
|
|
+ } else {
|
|
|
|
+ wx.showToast({ title: `暂无开放`, icon: 'error', duration: 2000 });
|
|
|
|
+ }
|
|
|
|
+ } else if (info.status == '2' || info.status == '3') {
|
|
|
|
+ if (active == 'a' || active == 'b') {
|
|
|
|
+ that.setData({ 'tabs.active': active });
|
|
|
|
+ } else {
|
|
|
|
+ wx.showToast({ title: `暂无开放`, icon: 'error', duration: 2000 });
|
|
|
|
+ }
|
|
|
|
+ } else if (info.status == '4') {
|
|
|
|
+ if (active == 'a' || active == 'b' || active == 'c') {
|
|
|
|
+ that.setData({ 'tabs.active': active });
|
|
|
|
+ } else {
|
|
|
|
+ wx.showToast({ title: `暂无开放`, icon: 'error', duration: 2000 });
|
|
|
|
+ }
|
|
|
|
+ } else if (info.status == '5' || info.status == '6') {
|
|
|
|
+ that.setData({ 'tabs.active': active });
|
|
|
|
+ }
|
|
},
|
|
},
|
|
- //比赛报名
|
|
|
|
- toSign: function (e) {
|
|
|
|
- const { item } = e.currentTarget.dataset;
|
|
|
|
- wx.navigateTo({ url: `/pagesMatch/match/sign?id=${item._id}` })
|
|
|
|
|
|
+ // 第一层手风琴
|
|
|
|
+ onePayer: function (e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ if (e.detail != that.data.playerIndex) that.setData({ playerIndex: e.detail })
|
|
|
|
+ else that.setData({ playerIndex: 99999 })
|
|
},
|
|
},
|
|
- /**
|
|
|
|
- * 生命周期函数--监听页面加载
|
|
|
|
- */
|
|
|
|
- onLoad: function (options) {
|
|
|
|
|
|
+ // 第二层手风琴
|
|
|
|
+ twoPayer: function (e) {
|
|
const that = this;
|
|
const that = this;
|
|
- that.setData({ id: options.id || '' });
|
|
|
|
|
|
+ if (e.detail != that.data.playerIndexs) that.setData({ playerIndexs: e.detail })
|
|
|
|
+ else that.setData({ playerIndexs: 99999 })
|
|
|
|
+ },
|
|
|
|
+ // 秩序册选择
|
|
|
|
+ cChange: function (e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ const ctype = e.detail;
|
|
|
|
+ that.setData({ cType: ctype })
|
|
|
|
+ that.setData({ cList: that.data.cType == '0' ? that.data.raceList : that.data.raceteamList })
|
|
|
|
+ },
|
|
|
|
+ // 秩序册查询
|
|
|
|
+ cinputSearch: function (e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ that.setData({ 'cSearchname': e.detail });
|
|
|
|
+ that.searchOrderBook();
|
|
|
|
+ },
|
|
|
|
+ // 赛况场地选择
|
|
|
|
+ dtabsChange: function (e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ let raceList = that.data.raceList;
|
|
|
|
+ let data = that.data.dTabs.menu[e.detail];
|
|
|
|
+ let list = []
|
|
|
|
+ if (data._id) list = raceList.filter(i => i.address_id == data._id);
|
|
|
|
+ else list = raceList;
|
|
|
|
+ that.setData({ dList: list })
|
|
|
|
+ that.setData({ 'dTabs.active': e.detail })
|
|
},
|
|
},
|
|
/**
|
|
/**
|
|
- * 生命周期函数--监听页面初次渲染完成
|
|
|
|
- */
|
|
|
|
- onReady: function () { },
|
|
|
|
- /**
|
|
|
|
- * 生命周期函数--监听页面显示
|
|
|
|
|
|
+ * 生命周期函数--监听页面加载
|
|
*/
|
|
*/
|
|
- onShow: async function () {
|
|
|
|
|
|
+ onLoad: async function (options) {
|
|
const that = this;
|
|
const that = this;
|
|
|
|
+ that.setData({ id: options && options.id || '630ec4700a92b0a015ccfd14' });
|
|
// 查询其他信息
|
|
// 查询其他信息
|
|
await that.searchOther();
|
|
await that.searchOther();
|
|
// 监听用户是否登录
|
|
// 监听用户是否登录
|
|
@@ -56,37 +157,128 @@ Page({
|
|
searchOther: async function () {
|
|
searchOther: async function () {
|
|
const that = this;
|
|
const that = this;
|
|
let arr;
|
|
let arr;
|
|
- // 状态
|
|
|
|
|
|
+ // 赛事状态
|
|
arr = await app.$get(`/dict`, { code: "match_status" });
|
|
arr = await app.$get(`/dict`, { code: "match_status" });
|
|
- if (arr.errcode == '0' && arr.total > 0) { that.setData({ statusList: arr.data[0].list }); }
|
|
|
|
|
|
+ if (arr.errcode == '0' && arr.total > 0) that.setData({ statusList: arr.data[0].list });
|
|
|
|
+ // 赛事类别
|
|
|
|
+ arr = await app.$get(`/dict`, { code: "match_type" });
|
|
|
|
+ if (arr.errcode == '0' && arr.total > 0) that.setData({ typeList: arr.data[0].list });
|
|
|
|
+ // 赛制列表
|
|
|
|
+ arr = await app.$get(`/dict`, { code: "match_format" });
|
|
|
|
+ if (arr.errcode == '0' && arr.total > 0) that.setData({ formatList: arr.data[0].list });
|
|
|
|
+ // 性别列表
|
|
|
|
+ arr = await app.$get(`/dict`, { code: "gender" });
|
|
|
|
+ if (arr.errcode == '0' && arr.total > 0) that.setData({ genderList: arr.data[0].list });
|
|
},
|
|
},
|
|
|
|
+ /**
|
|
|
|
+ * 生命周期函数--监听页面初次渲染完成
|
|
|
|
+ */
|
|
|
|
+ onReady: function () { },
|
|
|
|
+ /**
|
|
|
|
+ * 生命周期函数--监听页面显示
|
|
|
|
+ */
|
|
|
|
+ onShow: async function () { },
|
|
// 监听用户是否登录
|
|
// 监听用户是否登录
|
|
watchLogin: async function () {
|
|
watchLogin: async function () {
|
|
const that = this;
|
|
const that = this;
|
|
const statusList = that.data.statusList;
|
|
const statusList = that.data.statusList;
|
|
|
|
+ const typeList = that.data.typeList;
|
|
|
|
+ const formatList = that.data.formatList;
|
|
wx.getStorage({
|
|
wx.getStorage({
|
|
- key: 'raceuser',
|
|
|
|
|
|
+ key: 'user',
|
|
success: async res => {
|
|
success: async res => {
|
|
that.setData({ user: res.data })
|
|
that.setData({ user: res.data })
|
|
let arr;
|
|
let arr;
|
|
- // 比赛信息
|
|
|
|
|
|
+ // 赛事信息
|
|
arr = await app.$get(`/match/${that.data.id}`, {}, 'race');
|
|
arr = await app.$get(`/match/${that.data.id}`, {}, 'race');
|
|
if (arr.errcode == '0') {
|
|
if (arr.errcode == '0') {
|
|
- let status = statusList.find(i => i.value == arr.data.status)
|
|
|
|
- if (status) arr.data.zhStatus = status.label;
|
|
|
|
|
|
+ let info = arr.data;
|
|
|
|
+ // 赛事状态
|
|
|
|
+ let status = statusList.find(i => i.value == info.status)
|
|
|
|
+ if (status) info.zhStatus = status.label;
|
|
|
|
+ // 赛事类别
|
|
|
|
+ let type = typeList.find(i => i.value == info.type)
|
|
|
|
+ if (type) info.zhtype = type.label;
|
|
|
|
+ // 赛事赛制
|
|
|
|
+ let format = formatList.find(i => i.value == info.format)
|
|
|
|
+ if (format) info.zhFormat = format.label;
|
|
let regular = arr.data.regular.replace(/\<img/gi, '<img style="width:100%;height:auto;margin: 5px 0"');
|
|
let regular = arr.data.regular.replace(/\<img/gi, '<img style="width:100%;height:auto;margin: 5px 0"');
|
|
- if (regular) arr.data.zhRegular = regular;
|
|
|
|
- that.setData({ info: arr.data })
|
|
|
|
- } else { wx.showToast({ title: `${res.errmsg}`, icon: 'fail', duration: 2000 }); }
|
|
|
|
|
|
+ if (regular) info.zhRegular = regular;
|
|
|
|
+ that.setData({ info })
|
|
|
|
+ } else { wx.showToast({ title: `${arr.errmsg}`, icon: 'fail', duration: 2000 }); }
|
|
|
|
+ // 赛事选手
|
|
|
|
+ arr = await app.$get(`/match/getAll/${arr.data._id}`, {}, 'race');
|
|
|
|
+ if (arr.errcode == '0') that.setData({ playerList: arr.data })
|
|
|
|
+ // 秩序册
|
|
|
|
+ that.searchOrderBook();
|
|
|
|
+ // 场地
|
|
|
|
+ arr = await app.$get(`/matchAddress`, { is_use: '0', belong_id: that.data.info.belong_id }, 'race');
|
|
|
|
+ if (arr.errcode == '0') {
|
|
|
|
+ let addressList = []
|
|
|
|
+ arr.data.unshift({ _id: '', title: '全部场地', active: 0 });
|
|
|
|
+ for (const [index, val] of arr.data.entries()) {
|
|
|
|
+ addressList.push({ _id: val._id, title: val.title || val.name, active: index })
|
|
|
|
+ }
|
|
|
|
+ that.setData({ 'dTabs.menu': addressList })
|
|
|
|
+ }
|
|
|
|
+ // 成绩册列表
|
|
|
|
+ arr = await app.$get(`/matchProject`, { match_id: that.data.info._id }, 'race');
|
|
|
|
+ if (arr.errcode == '0') { that.setData({ achieveList: arr.data }) }
|
|
|
|
+
|
|
},
|
|
},
|
|
fail: async res => {
|
|
fail: async res => {
|
|
wx.redirectTo({ url: '/pages/index/index' })
|
|
wx.redirectTo({ url: '/pages/index/index' })
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
- /**
|
|
|
|
- * 页面上拉触底事件的处理函数
|
|
|
|
- */
|
|
|
|
|
|
+ // 查询秩序册
|
|
|
|
+ searchOrderBook: async function (e) {
|
|
|
|
+ const that = this;
|
|
|
|
+ let genderList = that.data.genderList;
|
|
|
|
+ let type = that.data.cType;
|
|
|
|
+ let match = that.data.info;
|
|
|
|
+ let cSearch = that.data.cSearchname;
|
|
|
|
+ let info = { match_id: match._id };
|
|
|
|
+ if (type == '0') { if (cSearch) info.user_name = cSearch; }
|
|
|
|
+ else { if (cSearch) info.project_name = cSearch; }
|
|
|
|
+ let arr;
|
|
|
|
+ //小组赛组--场次表
|
|
|
|
+ arr = await app.$get(`/matchTeamGroup`, { ...info }, 'race');
|
|
|
|
+ if (arr.errcode == '0') {
|
|
|
|
+ let list = arr.data;
|
|
|
|
+ for (const val of list) {
|
|
|
|
+ // 查询组
|
|
|
|
+ const group = await app.$get(`/matchGroup/${val.group_id}`, {}, 'race');
|
|
|
|
+ if (group.errcode == '0') { val.age = group.data.age; }
|
|
|
|
+ // 查询项目
|
|
|
|
+ const project = await app.$get(`/matchProject/${val.project_id}`, {}, 'race');
|
|
|
|
+ if (project.errcode == '0') {
|
|
|
|
+ val.projectAge = project.data.age;
|
|
|
|
+ let gender = genderList.find(i => i.value == project.data.gender)
|
|
|
|
+ if (gender) val.pojectGender = gender.label;
|
|
|
|
+ }
|
|
|
|
+ // 名字分割
|
|
|
|
+ for (const p1 of val.person) { p1.one = p1.name.split("-")[0]; p1.two = p1.name.split("-")[1]; }
|
|
|
|
+ }
|
|
|
|
+ that.setData({ raceteamList: list })
|
|
|
|
+ }
|
|
|
|
+ //小组赛赛程--对阵表
|
|
|
|
+ arr = await app.$get(`/msgs`, { ...info }, 'race');
|
|
|
|
+ if (arr.errcode == '0') {
|
|
|
|
+ for (const val of arr.data) {
|
|
|
|
+ if (val.player_type == 'Race.TeamApply') {
|
|
|
|
+ val.one_one = val.player_one_name.split("-")[0];
|
|
|
|
+ val.one_two = val.player_one_name.split("-")[1];
|
|
|
|
+ val.two_one = val.player_two_name.split("-")[0];
|
|
|
|
+ val.two_two = val.player_two_name.split("-")[1];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ that.setData({ raceList: arr.data });
|
|
|
|
+ that.setData({ dList: that.data.raceList })
|
|
|
|
+ }
|
|
|
|
+ that.setData({ cList: that.data.cType == '0' ? that.data.raceList : that.data.raceteamList })
|
|
|
|
+ },
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
*/
|