|
@@ -24,7 +24,8 @@ Page({
|
|
//用户信息
|
|
//用户信息
|
|
userdata: {},
|
|
userdata: {},
|
|
//团队id
|
|
//团队id
|
|
- team_id: '',
|
|
|
|
|
|
+ blue_id: '',
|
|
|
|
+ red_id: '',
|
|
},
|
|
},
|
|
//验证是否输入
|
|
//验证是否输入
|
|
initValidate() {
|
|
initValidate() {
|
|
@@ -49,7 +50,7 @@ Page({
|
|
})
|
|
})
|
|
},
|
|
},
|
|
//上传图片
|
|
//上传图片
|
|
- imgUpload: function (e) {
|
|
|
|
|
|
+ imgUpload: async function (e) {
|
|
const that = this;
|
|
const that = this;
|
|
if (that.data.type == '0') {
|
|
if (that.data.type == '0') {
|
|
return wx.showToast({
|
|
return wx.showToast({
|
|
@@ -58,53 +59,43 @@ Page({
|
|
icon: 'error',
|
|
icon: 'error',
|
|
})
|
|
})
|
|
} else if (that.data.type == '1') {
|
|
} else if (that.data.type == '1') {
|
|
- let id = that.data.team_id
|
|
|
|
|
|
+ let red_id = that.data.red_id
|
|
|
|
+ let blue_id = that.data.blue_id
|
|
let user_id = that.data.userdata.id
|
|
let user_id = that.data.userdata.id
|
|
- //查询数据
|
|
|
|
- wx.request({
|
|
|
|
- url: `${app.globalData.publicUrl}/courtAdmin/api/team/${id}`, //接口地址
|
|
|
|
- method: 'get',
|
|
|
|
- data: '',
|
|
|
|
- success(res) {
|
|
|
|
- if (res.data.errcode == 0) {
|
|
|
|
- let create_id = res.data.data.create_id;
|
|
|
|
- if (create_id == user_id) {
|
|
|
|
- let data = that.data.match_file;
|
|
|
|
- let id = that.data.id;
|
|
|
|
- data.push(e.detail)
|
|
|
|
- wx.request({
|
|
|
|
- url: `${app.globalData.publicUrl}/courtAdmin/api/schedule/${id}`, //接口地址
|
|
|
|
- method: 'post',
|
|
|
|
- data: { match_file: data },
|
|
|
|
- success(res) {
|
|
|
|
- if (res.data.errcode == 0) {
|
|
|
|
- wx.showToast({
|
|
|
|
- title: '添加成功',
|
|
|
|
- duration: 2000,
|
|
|
|
- icon: 'success',
|
|
|
|
- })
|
|
|
|
- that.setData({ match_file: data })
|
|
|
|
- } else {
|
|
|
|
- wx.showToast({ title: res.data.errmsg, icon: 'error', duration: 2000 })
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- } else {
|
|
|
|
- return wx.showToast({
|
|
|
|
- title: '不可上传',
|
|
|
|
|
|
+ let create_id_one = ''
|
|
|
|
+ let create_id_two = ''
|
|
|
|
+ const res = await app.$get('/courtAdmin/api/team', { id: red_id });
|
|
|
|
+ if (res.errcode === 0) create_id_one = res.data[0].create_id;
|
|
|
|
+ const arr = await app.$get('/courtAdmin/api/team', { id: blue_id });
|
|
|
|
+ if (arr.errcode === 0) create_id_two = arr.data[0].create_id;
|
|
|
|
+ if (create_id_one == user_id || create_id_two == user_id) {
|
|
|
|
+ let data = that.data.match_file;
|
|
|
|
+ let id = that.data.id;
|
|
|
|
+ data.push(e.detail)
|
|
|
|
+ wx.request({
|
|
|
|
+ url: `${app.globalData.publicUrl}/courtAdmin/api/schedule/${id}`, //接口地址
|
|
|
|
+ method: 'post',
|
|
|
|
+ data: { match_file: data },
|
|
|
|
+ success(res) {
|
|
|
|
+ if (res.data.errcode == 0) {
|
|
|
|
+ wx.showToast({
|
|
|
|
+ title: '添加成功',
|
|
duration: 2000,
|
|
duration: 2000,
|
|
- icon: 'error',
|
|
|
|
|
|
+ icon: 'success',
|
|
})
|
|
})
|
|
|
|
+ that.setData({ match_file: data })
|
|
|
|
+ } else {
|
|
|
|
+ wx.showToast({ title: res.data.errmsg, icon: 'error', duration: 2000 })
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
- wx.showToast({
|
|
|
|
- title: res.data.errmsg,
|
|
|
|
- icon: 'none',
|
|
|
|
- duration: 2000
|
|
|
|
- })
|
|
|
|
}
|
|
}
|
|
- }
|
|
|
|
- })
|
|
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ return wx.showToast({
|
|
|
|
+ title: '不可上传',
|
|
|
|
+ duration: 2000,
|
|
|
|
+ icon: 'error',
|
|
|
|
+ })
|
|
|
|
+ }
|
|
} else if (that.data.type == '2') {
|
|
} else if (that.data.type == '2') {
|
|
let userid = that.data.userdata.id
|
|
let userid = that.data.userdata.id
|
|
let red_members = that.data.info.red_members;
|
|
let red_members = that.data.info.red_members;
|
|
@@ -134,7 +125,7 @@ Page({
|
|
})
|
|
})
|
|
} else {
|
|
} else {
|
|
return wx.showToast({
|
|
return wx.showToast({
|
|
- title: '不可上传',
|
|
|
|
|
|
+ title: '不可删除',
|
|
duration: 2000,
|
|
duration: 2000,
|
|
icon: 'error',
|
|
icon: 'error',
|
|
})
|
|
})
|
|
@@ -142,7 +133,7 @@ Page({
|
|
}
|
|
}
|
|
},
|
|
},
|
|
//删除图片
|
|
//删除图片
|
|
- imgDel: function (e) {
|
|
|
|
|
|
+ imgDel: async function (e) {
|
|
const that = this;
|
|
const that = this;
|
|
if (that.data.type == '0') {
|
|
if (that.data.type == '0') {
|
|
return wx.showToast({
|
|
return wx.showToast({
|
|
@@ -151,53 +142,44 @@ Page({
|
|
icon: 'error',
|
|
icon: 'error',
|
|
})
|
|
})
|
|
} else if (that.data.type == '1') {
|
|
} else if (that.data.type == '1') {
|
|
- let id = that.data.team_id
|
|
|
|
|
|
+ let red_id = that.data.red_id
|
|
|
|
+ let blue_id = that.data.blue_id
|
|
let user_id = that.data.userdata.id
|
|
let user_id = that.data.userdata.id
|
|
- //查询数据
|
|
|
|
- wx.request({
|
|
|
|
- url: `${app.globalData.publicUrl}/courtAdmin/api/team/${id}`, //接口地址
|
|
|
|
- method: 'get',
|
|
|
|
- data: '',
|
|
|
|
- success(res) {
|
|
|
|
- if (res.data.errcode == 0) {
|
|
|
|
- let create_id = res.data.data.create_id;
|
|
|
|
- if (create_id == user_id) {
|
|
|
|
- let data = that.data.match_file;
|
|
|
|
- let id = that.data.id;
|
|
|
|
- let arr = data.filter((i, index) => index != e.detail.index)
|
|
|
|
- wx.request({
|
|
|
|
- url: `${app.globalData.publicUrl}/courtAdmin/api/schedule/${id}`, //接口地址
|
|
|
|
- method: 'post',
|
|
|
|
- data: { match_file: arr },
|
|
|
|
- success(res) {
|
|
|
|
- if (res.data.errcode == 0) {
|
|
|
|
- wx.showToast({
|
|
|
|
- title: '删除成功',
|
|
|
|
- duration: 2000,
|
|
|
|
- icon: 'success',
|
|
|
|
- })
|
|
|
|
- that.setData({ match_file: arr })
|
|
|
|
- } else {
|
|
|
|
- wx.showToast({ title: res.data.errmsg, icon: 'error', duration: 2000 })
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- } else {
|
|
|
|
- return wx.showToast({
|
|
|
|
- title: '不可删除',
|
|
|
|
|
|
+ let create_id_one = ''
|
|
|
|
+ let create_id_two = ''
|
|
|
|
+ const res = await app.$get('/courtAdmin/api/team', { id: red_id });
|
|
|
|
+ if (res.errcode === 0) create_id_one = res.data[0].create_id;
|
|
|
|
+ const arr = await app.$get('/courtAdmin/api/team', { id: blue_id });
|
|
|
|
+ if (arr.errcode === 0) create_id_two = arr.data[0].create_id;
|
|
|
|
+ if (create_id_one == user_id || create_id_two == user_id) {
|
|
|
|
+ let data = that.data.match_file;
|
|
|
|
+ let id = that.data.id;
|
|
|
|
+ let arr = data.filter((i, index) => index != e.detail.index)
|
|
|
|
+ wx.request({
|
|
|
|
+ url: `${app.globalData.publicUrl}/courtAdmin/api/schedule/${id}`, //接口地址
|
|
|
|
+ method: 'post',
|
|
|
|
+ data: { match_file: arr },
|
|
|
|
+ success(res) {
|
|
|
|
+ if (res.data.errcode == 0) {
|
|
|
|
+ wx.showToast({
|
|
|
|
+ title: '删除成功',
|
|
duration: 2000,
|
|
duration: 2000,
|
|
- icon: 'error',
|
|
|
|
|
|
+ icon: 'success',
|
|
})
|
|
})
|
|
|
|
+ that.setData({ match_file: arr })
|
|
|
|
+ } else {
|
|
|
|
+ wx.showToast({ title: res.data.errmsg, icon: 'error', duration: 2000 })
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
- wx.showToast({
|
|
|
|
- title: res.data.errmsg,
|
|
|
|
- icon: 'none',
|
|
|
|
- duration: 2000
|
|
|
|
- })
|
|
|
|
}
|
|
}
|
|
- }
|
|
|
|
- })
|
|
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ return wx.showToast({
|
|
|
|
+ title: '不可上传',
|
|
|
|
+ duration: 2000,
|
|
|
|
+ icon: 'error',
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
} else if (that.data.type == '2') {
|
|
} else if (that.data.type == '2') {
|
|
let userid = that.data.userdata.id
|
|
let userid = that.data.userdata.id
|
|
let red_members = that.data.info.red_members;
|
|
let red_members = that.data.info.red_members;
|
|
@@ -290,7 +272,8 @@ Page({
|
|
if (arr.errcode === 0) {
|
|
if (arr.errcode === 0) {
|
|
that.setData({
|
|
that.setData({
|
|
info: arr.data,
|
|
info: arr.data,
|
|
- team_id: arr.data.blue_id
|
|
|
|
|
|
+ blue_id: arr.data.blue_id,
|
|
|
|
+ red_id: arr.data.red_id
|
|
})
|
|
})
|
|
that.setData({ match_file: arr.data.match_file })
|
|
that.setData({ match_file: arr.data.match_file })
|
|
}
|
|
}
|