|
@@ -17,29 +17,31 @@ Page({
|
|
|
objectType: [{ id: 0, name: '乒乓球' }, { id: 1, name: '足球' }, { id: 2, name: '篮球' },],
|
|
|
create_time: '2016-09-01',
|
|
|
},
|
|
|
+ members: [],
|
|
|
lists: [],
|
|
|
index: 0,
|
|
|
+ //选择成员列表
|
|
|
item: [],
|
|
|
- menbers: [],
|
|
|
+ check: [],
|
|
|
// 上传图片
|
|
|
fileList: [],
|
|
|
},
|
|
|
- apply: function (e) {
|
|
|
+ determine: function (e) {
|
|
|
this.setData({ showModal: false })
|
|
|
- console.log(this.data.menbers);
|
|
|
+ console.log(this.data.members);
|
|
|
},
|
|
|
//选择队员
|
|
|
checkboxChange: function (e) {
|
|
|
const that = this;
|
|
|
let data = e.detail.value;
|
|
|
let item = that.data.item;
|
|
|
- let menbers = [];
|
|
|
+ let members = [];
|
|
|
for (const val of data) {
|
|
|
let arr = item.find((i) => i._id == val);
|
|
|
console.log(arr);
|
|
|
- if (arr) menbers.push({ id: arr._id, nickname: arr.nickname, icon: arr.icon })
|
|
|
+ if (arr) members.push({ id: arr._id, nickname: arr.nickname, icon: arr.icon })
|
|
|
}
|
|
|
- that.setData({ menbers: menbers })
|
|
|
+ that.setData({ members: members })
|
|
|
},
|
|
|
//显示对话框
|
|
|
clickme: function () {
|
|
@@ -71,60 +73,57 @@ Page({
|
|
|
back: function () {
|
|
|
wx.navigateBack({ url: '/pages/me/index' })
|
|
|
},
|
|
|
-
|
|
|
//点击减号删除
|
|
|
delList: function () {
|
|
|
- var lists = this.data.lists;
|
|
|
- lists.pop(); //实质是删除lists数组内容,使for循环少一次
|
|
|
+ var members = this.data.members;
|
|
|
+ members.pop();//实质是删除lists数组内容,使for循环少一次
|
|
|
this.setData({
|
|
|
- lists: lists,
|
|
|
+ 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.icon = this.data.fileList;
|
|
|
- // 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);
|
|
|
- // }
|
|
|
- // })
|
|
|
- // }
|
|
|
- // })
|
|
|
- // }
|
|
|
- // },
|
|
|
- //上传图片
|
|
|
- formSubmit(e) {
|
|
|
- console.log('form发生了submit事件,携带数据为:', e.detail.value)
|
|
|
+ //提交
|
|
|
+ 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;
|
|
|
+ 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) {
|
|
|
const that = this;
|
|
@@ -149,7 +148,6 @@ Page({
|
|
|
},
|
|
|
});
|
|
|
},
|
|
|
-
|
|
|
//验证必填项
|
|
|
initValidate() {
|
|
|
const rules = { name: { required: true }, type: { required: true }, create_user: { required: true }, }
|