|
@@ -8,25 +8,29 @@ Page({
|
|
|
*/
|
|
|
data: {
|
|
|
frameStyle: { useTop: true, name: '比赛信息', leftArrow: true, useBar: false },
|
|
|
- src: '/image/detail.jpg',
|
|
|
- src1: '/image/head1.png',
|
|
|
- // 上传图片
|
|
|
- fileList: [],
|
|
|
// 主体高度
|
|
|
infoHeight: '',
|
|
|
+ // 数据id
|
|
|
id: '',
|
|
|
- time:'',
|
|
|
- //修改比分
|
|
|
- form: [],
|
|
|
//详情数据
|
|
|
- schedulelist: [],
|
|
|
+ info: {},
|
|
|
+ // 现场图片
|
|
|
+ match_file: [],
|
|
|
showModal: false,
|
|
|
+ //修改比分
|
|
|
+ form: [],
|
|
|
+ //判断用户类别
|
|
|
+ type: '',
|
|
|
+ //用户信息
|
|
|
+ userdata: {},
|
|
|
+ //团队id
|
|
|
+ team_id: '',
|
|
|
},
|
|
|
//验证是否输入
|
|
|
initValidate() {
|
|
|
- const rules = { blue_branch: { required: true }, red_branch: { required: true, } }
|
|
|
+ const rules = { blue_branch: { required: true }, red_branch: { required: true, }, blue_integral: { required: true }, red_integral: { required: true, } }
|
|
|
// 验证字段的提示信息,若不传则调用默认的信息
|
|
|
- const messages = { blue_branch: { required: '请输入蓝方比分', }, red_branch: { required: '请输入红方比分', } };
|
|
|
+ const messages = { blue_branch: { required: '请输入蓝方比分', }, red_branch: { required: '请输入红方比分', }, blue_integral: { required: '请输入蓝方积分', }, red_integral: { required: '请输入红方积分', } };
|
|
|
this.WxValidate = new WxValidate(rules, messages)
|
|
|
},
|
|
|
back: function () {
|
|
@@ -47,57 +51,195 @@ Page({
|
|
|
//上传图片
|
|
|
imgUpload: function (e) {
|
|
|
const that = this;
|
|
|
- let data = that.data.fileList;
|
|
|
- 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({ fileList: data })
|
|
|
- } else {
|
|
|
- wx.showToast({ title: res.data.errmsg, icon: 'error', duration: 2000 })
|
|
|
+ if (that.data.type == '0') {
|
|
|
+ return wx.showToast({
|
|
|
+ title: '不可上传',
|
|
|
+ duration: 2000,
|
|
|
+ icon: 'error',
|
|
|
+ })
|
|
|
+ } else if (that.data.type == '1') {
|
|
|
+ let id = that.data.team_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: '不可上传',
|
|
|
+ duration: 2000,
|
|
|
+ icon: 'error',
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ wx.showToast({
|
|
|
+ title: res.data.errmsg,
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
+ })
|
|
|
+ } else if (that.data.type == '2') {
|
|
|
+ let userid = that.data.userdata.id
|
|
|
+ let red_members = that.data.info.red_members;
|
|
|
+ let blue_members = that.data.info.blue_members;
|
|
|
+ var item = red_members.find(item => item.id == userid)
|
|
|
+ var items = blue_members.find(item => item.id == userid)
|
|
|
+ if (item || items) {
|
|
|
+ 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: '不可上传',
|
|
|
+ duration: 2000,
|
|
|
+ icon: 'error',
|
|
|
+ })
|
|
|
}
|
|
|
- })
|
|
|
+ }
|
|
|
},
|
|
|
//删除图片
|
|
|
imgDel: function (e) {
|
|
|
const that = this;
|
|
|
- let data = that.data.fileList;
|
|
|
- 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({ fileList: arr })
|
|
|
- } else {
|
|
|
- wx.showToast({ title: res.data.errmsg, icon: 'error', duration: 2000 })
|
|
|
+ if (that.data.type == '0') {
|
|
|
+ return wx.showToast({
|
|
|
+ title: '不可删除',
|
|
|
+ duration: 2000,
|
|
|
+ icon: 'error',
|
|
|
+ })
|
|
|
+ } else if (that.data.type == '1') {
|
|
|
+ let id = that.data.team_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: '不可删除',
|
|
|
+ duration: 2000,
|
|
|
+ icon: 'error',
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ wx.showToast({
|
|
|
+ title: res.data.errmsg,
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
+ })
|
|
|
+ } else if (that.data.type == '2') {
|
|
|
+ let userid = that.data.userdata.id
|
|
|
+ let red_members = that.data.info.red_members;
|
|
|
+ let blue_members = that.data.info.blue_members;
|
|
|
+ var item = red_members.find(item => item.id == userid)
|
|
|
+ var items = blue_members.find(item => item.id == userid)
|
|
|
+ if (item || items) {
|
|
|
+ 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: '不可删除',
|
|
|
+ duration: 2000,
|
|
|
+ icon: 'error',
|
|
|
+ })
|
|
|
}
|
|
|
- })
|
|
|
+ }
|
|
|
},
|
|
|
// 提交登录
|
|
|
formSubmit: function (e) {
|
|
|
const that = this;
|
|
|
let id = that.data.id;
|
|
|
const params = e.detail.value;
|
|
|
- params.match_file = that.data.fileList;
|
|
|
+ params.match_file = that.data.match_file;
|
|
|
if (!this.WxValidate.checkForm(params)) {
|
|
|
const error = this.WxValidate.errorList[0];
|
|
|
wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
|
|
@@ -137,28 +279,21 @@ Page({
|
|
|
this.watchLogin();
|
|
|
},
|
|
|
// 监听用户是否登录
|
|
|
- watchLogin: function () {
|
|
|
+ watchLogin: async function () {
|
|
|
const that = this;
|
|
|
let id = that.data.id;
|
|
|
wx.getStorage({
|
|
|
key: 'token',
|
|
|
- success: res => {
|
|
|
- wx.request({
|
|
|
- url: `${app.globalData.publicUrl}/courtAdmin/api/schedule/${id}`, //接口地址
|
|
|
- method: 'get',
|
|
|
- data: {},
|
|
|
- success(res) {
|
|
|
- let fileList = res.data.data.match_file;
|
|
|
- let match_time = res.data.data.match_time;
|
|
|
- let time = match_time.substring(5, 17)
|
|
|
- console.log(res.data.data);
|
|
|
- that.setData({
|
|
|
- schedulelist: res.data.data,
|
|
|
- fileList: fileList,
|
|
|
- time: time,
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
+ success: async res => {
|
|
|
+ that.setData({ type: res.data.type, userdata: res.data })
|
|
|
+ const arr = await app.$get(`/courtAdmin/api/schedule/${id}`);
|
|
|
+ if (arr.errcode === 0) {
|
|
|
+ that.setData({
|
|
|
+ info: arr.data,
|
|
|
+ team_id: arr.data.blue_id
|
|
|
+ })
|
|
|
+ that.setData({ match_file: arr.data.match_file })
|
|
|
+ }
|
|
|
},
|
|
|
fail: res => {
|
|
|
return wx.redirectTo({ url: '/pages/login/index', })
|