|
@@ -15,7 +15,7 @@ Page({
|
|
|
form: {
|
|
|
type: ['乒乓球', '足球', '篮球'],
|
|
|
objectType: [{ id: 0, name: '乒乓球' }, { id: 1, name: '足球' }, { id: 2, name: '篮球' },],
|
|
|
- create_time:'2020-02-02',
|
|
|
+ create_time: '2020-02-02',
|
|
|
create_id: '',
|
|
|
create_user: '',
|
|
|
},
|
|
@@ -83,81 +83,22 @@ Page({
|
|
|
members: members,
|
|
|
})
|
|
|
},
|
|
|
- //提交
|
|
|
- formSubmit: function (e) {
|
|
|
- const value = e.detail.value;
|
|
|
- if (!this.WxValidate.checkForm(value)) {
|
|
|
- const error = this.WxValidate.errorList[0];
|
|
|
- wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
|
|
|
- return false
|
|
|
- } else {
|
|
|
- value.logo = this.data.fileList;
|
|
|
- value.members = this.data.members;
|
|
|
- value.create_id = this.data.form.create_id;
|
|
|
- wx.getStorage({
|
|
|
- key: 'token',
|
|
|
- success: function (res) {
|
|
|
- wx.request({
|
|
|
- url: `${app.globalData.publicUrl}/courtAdmin/api/team`, //接口地址
|
|
|
- method: "post",//请求方法
|
|
|
- //请求参数
|
|
|
- data: value,
|
|
|
- header: {},
|
|
|
- success: res => {
|
|
|
- console.log(res);
|
|
|
- if (res.data.errcode == 0) {
|
|
|
- wx.showToast({
|
|
|
- title: '创建团队成功',
|
|
|
- icon: 'success',
|
|
|
- duration: 2000//延迟两秒
|
|
|
- })
|
|
|
- } else {
|
|
|
- wx.showToast({
|
|
|
- title: '创建团队失败',
|
|
|
- icon: 'error',
|
|
|
- duration: 2000
|
|
|
- })
|
|
|
- }
|
|
|
- },
|
|
|
- error: err => {
|
|
|
- console.log(err);
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- console.log(e.detail.value);
|
|
|
- },
|
|
|
- afterRead: function (event) {
|
|
|
+
|
|
|
+ //上传图片
|
|
|
+ imgUpload: function (e) {
|
|
|
const that = this;
|
|
|
- const { file } = event.detail;
|
|
|
- // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式app.globalData.fileUrl:
|
|
|
- console.log(file);
|
|
|
- wx.uploadFile({
|
|
|
- url: `${app.globalData.imageUrl}/files/court/elimg/upload`,
|
|
|
- filePath: file.url,
|
|
|
- name: 'file',
|
|
|
- formData: {},
|
|
|
- success: (res) => {
|
|
|
- console.log(res);
|
|
|
- if (res.statusCode == '200') {
|
|
|
- let data = [{ name: JSON.parse(res.data).name, url: `${app.globalData.imageUrl}` + JSON.parse(res.data).uri }]
|
|
|
- // const { fileList = [] } = this.data;
|
|
|
- // fileList.push({ ...file, url: res.data });
|
|
|
- that.setData({ fileList: data });
|
|
|
- } else {
|
|
|
- wx.showToast({ title: `${res.data.errmsg}`, icon: 'fail', duration: 2000 })
|
|
|
- }
|
|
|
- },
|
|
|
- });
|
|
|
+ let data = that.data.fileList;
|
|
|
+ data.push(e.detail)
|
|
|
+ that.setData({ fileList: data })
|
|
|
},
|
|
|
- //验证必填项
|
|
|
- initValidate() {
|
|
|
- const rules = { name: { required: true }, type: { required: true }, create_user: { required: true }, }
|
|
|
- // 验证字段的提示信息,若不传则调用默认的信息
|
|
|
- const messages = { name: { required: '请输入团队名称' }, type: { required: '请输入团队类型' }, create_user: { required: '请输入团队创建人名称' }, };
|
|
|
- this.WxValidate = new WxValidate(rules, messages)
|
|
|
+ //删除图片
|
|
|
+ imgDel: function (e) {
|
|
|
+ const that = this;
|
|
|
+ let data = that.data.fileList;
|
|
|
+ let arr = data.filter((i, index) => index != e.detail.index)
|
|
|
+ that.setData({ fileList: arr })
|
|
|
},
|
|
|
+
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
@@ -169,6 +110,13 @@ Page({
|
|
|
//验证规则函数
|
|
|
this.initValidate()
|
|
|
},
|
|
|
+ //验证必填项
|
|
|
+ initValidate() {
|
|
|
+ const rules = { name: { required: true }, type: { required: true }, create_user: { required: true }, }
|
|
|
+ // 验证字段的提示信息,若不传则调用默认的信息
|
|
|
+ const messages = { name: { required: '请输入团队名称' }, type: { required: '请输入团队类型' }, create_user: { required: '请输入团队创建人名称' }, };
|
|
|
+ this.WxValidate = new WxValidate(rules, messages)
|
|
|
+ },
|
|
|
// 监听用户是否登录
|
|
|
watchLogin: function () {
|
|
|
const that = this;
|
|
@@ -209,6 +157,51 @@ Page({
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+ //提交
|
|
|
+ formSubmit: function (e) {
|
|
|
+ const value = e.detail.value;
|
|
|
+ if (!this.WxValidate.checkForm(value)) {
|
|
|
+ const error = this.WxValidate.errorList[0];
|
|
|
+ wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
|
|
|
+ return false
|
|
|
+ } else {
|
|
|
+ value.logo = this.data.fileList;
|
|
|
+ value.members = this.data.members;
|
|
|
+ value.create_id = this.data.form.create_id;
|
|
|
+ wx.getStorage({
|
|
|
+ key: 'token',
|
|
|
+ success: function (res) {
|
|
|
+ wx.request({
|
|
|
+ url: `${app.globalData.publicUrl}/courtAdmin/api/team`, //接口地址
|
|
|
+ method: "post",//请求方法
|
|
|
+ //请求参数
|
|
|
+ data: value,
|
|
|
+ header: {},
|
|
|
+ success: res => {
|
|
|
+ console.log(res);
|
|
|
+ if (res.data.errcode == 0) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '创建团队成功',
|
|
|
+ icon: 'success',
|
|
|
+ duration: 2000//延迟两秒
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ wx.showToast({
|
|
|
+ title: '创建团队失败',
|
|
|
+ icon: 'error',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error: err => {
|
|
|
+ console.log(err);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ console.log(e.detail.value);
|
|
|
+ },
|
|
|
// 计算高度
|
|
|
searchHeight: function () {
|
|
|
let frameStyle = this.data.frameStyle;
|