You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
250 lines
4.9 KiB
250 lines
4.9 KiB
// pages/club/popname/popname.js |
|
var Api = require('../../../utils/common.js'); |
|
var re = require('../../../utils/request.js'); |
|
Page({ |
|
|
|
/** |
|
* 页面的初始数据 |
|
*/ |
|
data: { |
|
text1:'', |
|
text2:'', |
|
text3:'', |
|
text4:'', |
|
text5:'', |
|
text6:'', |
|
text7:'', |
|
text8:'', |
|
clubId:'', |
|
isxiugai:false |
|
}, |
|
zhengjia(){ |
|
let {text1,text2,text3,text4,text5,text6,text7,text8,clubId}=this.data |
|
if(text1==''||text2==''||text3==''||text4==''||text5==''||text6==''||text7==''||text8==''){ |
|
wx.showToast({ |
|
title: '内容不能为空', |
|
icon:'none' |
|
}) |
|
return |
|
} |
|
var header = { |
|
token:wx.getStorageSync('token'), |
|
"Content-Type": "application/x-www-form-urlencoded" |
|
}; |
|
|
|
if(!this.data.isxiugai){ |
|
for(let i=1;i<=8;i++){ |
|
let text |
|
switch (i) { |
|
case 1: |
|
text=text1 |
|
break; |
|
case 2: |
|
text=text2 |
|
break; |
|
case 3: |
|
text=text3 |
|
break; |
|
case 4: |
|
text=text4 |
|
break; |
|
case 5: |
|
text=text5 |
|
break; |
|
case 6: |
|
text=text6 |
|
break; |
|
case 7: |
|
text=text7 |
|
break; |
|
case 8: |
|
text=text8 |
|
break; |
|
} |
|
let data={ |
|
clubId, |
|
// 'nicknameList[0].clubId':'', |
|
'nicknameList[0].nameType':i, |
|
"nicknameList[0].nickname":text, |
|
} |
|
re.request(Api.nicknameadd(),data,header).then(res=>{ |
|
console.log(res); |
|
}) |
|
|
|
} |
|
}else{ |
|
for(let i=1;i<=8;i++){ |
|
let text |
|
switch (i) { |
|
case 1: |
|
text=text1 |
|
break; |
|
case 2: |
|
text=text2 |
|
break; |
|
case 3: |
|
text=text3 |
|
break; |
|
case 4: |
|
text=text4 |
|
break; |
|
case 5: |
|
text=text5 |
|
break; |
|
case 6: |
|
text=text6 |
|
break; |
|
case 7: |
|
text=text7 |
|
break; |
|
case 8: |
|
text=text8 |
|
break; |
|
} |
|
let data={ |
|
clubId, |
|
'nicknameList[0].clubId':clubId, |
|
'nicknameList[0].nameType':i, |
|
"nicknameList[0].nickname":text, |
|
} |
|
re.request(Api.nicknameedit(),data,header).then(res=>{ |
|
console.log(res); |
|
}) |
|
} |
|
|
|
} |
|
wx.showToast({ |
|
title: '保存成功', |
|
}) |
|
wx.navigateBack({ |
|
delta: 1, |
|
}) |
|
}, |
|
removeall(){ |
|
this.setData({ |
|
text1:'', |
|
text2:'', |
|
text3:'', |
|
text4:'', |
|
text5:'', |
|
text6:'', |
|
text7:'', |
|
text8:'' |
|
}) |
|
}, |
|
/** |
|
* 生命周期函数--监听页面加载 |
|
*/ |
|
onLoad: function (options) { |
|
console.log(options.id); |
|
this.setData({ |
|
clubId:options.id |
|
}) |
|
var header = { |
|
token:wx.getStorageSync('token'), |
|
"Content-Type": "application/x-www-form-urlencoded" |
|
}; |
|
//初始化查询 |
|
re.request(Api.nicknamedetail(), {clubId:options.id}, header).then(res=>{ |
|
console.log(res,'初始化'); |
|
if(res.data.data.length!=0){ |
|
res.data.data.map((item)=>{ |
|
switch (Number(item.nameType)) { |
|
case 1: |
|
this.setData({ |
|
text1:item.nickname |
|
}) |
|
break; |
|
case 2: |
|
this.setData({ |
|
text2:item.nickname |
|
}) |
|
break; |
|
case 3: |
|
this.setData({ |
|
text3:item.nickname |
|
}) |
|
break; |
|
case 4: |
|
this.setData({ |
|
text4:item.nickname |
|
}) |
|
break; |
|
case 5: |
|
this.setData({ |
|
text5:item.nickname |
|
}) |
|
break; |
|
case 6: |
|
this.setData({ |
|
text6:item.nickname |
|
}) |
|
break; |
|
case 7: |
|
this.setData({ |
|
text7:item.nickname |
|
}) |
|
break; |
|
case 8: |
|
this.setData({ |
|
text8:item.nickname |
|
}) |
|
break; |
|
} |
|
}) |
|
this.setData({ |
|
isxiugai:true |
|
}) |
|
} |
|
}) |
|
}, |
|
|
|
/** |
|
* 生命周期函数--监听页面初次渲染完成 |
|
*/ |
|
onReady: function () { |
|
|
|
}, |
|
|
|
/** |
|
* 生命周期函数--监听页面显示 |
|
*/ |
|
onShow: function () { |
|
|
|
}, |
|
|
|
/** |
|
* 生命周期函数--监听页面隐藏 |
|
*/ |
|
onHide: function () { |
|
|
|
}, |
|
|
|
/** |
|
* 生命周期函数--监听页面卸载 |
|
*/ |
|
onUnload: function () { |
|
|
|
}, |
|
|
|
/** |
|
* 页面相关事件处理函数--监听用户下拉动作 |
|
*/ |
|
onPullDownRefresh: function () { |
|
|
|
}, |
|
|
|
/** |
|
* 页面上拉触底事件的处理函数 |
|
*/ |
|
onReachBottom: function () { |
|
|
|
}, |
|
|
|
/** |
|
* 用户点击右上角分享 |
|
*/ |
|
onShareAppMessage: function () { |
|
|
|
} |
|
}) |