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.
375 lines
9.1 KiB
375 lines
9.1 KiB
// pages/club/manage/manage.js |
|
var Api = require('../../../utils/common.js'); |
|
var re = require('../../../utils/request.js'); |
|
Page({ |
|
|
|
/** |
|
* 页面的初始数据 |
|
*/ |
|
data: { |
|
array: [ |
|
{id:'0',name:'允许任何人加入'},{id:'1',name:'需验证加入'} |
|
], |
|
accts:[ |
|
{id:'1',name:'会长账户'}, |
|
// {id:'2',name:'管理员账户'} |
|
], |
|
acctindex:0, |
|
joinWay:'0', |
|
index: 0, |
|
company:{}, |
|
uploaderList: [], |
|
showList: [], |
|
uploaderNum: 0, |
|
showUpload:true, |
|
payType:'0', |
|
uploaderListcom:[],//logo |
|
showListcom: [], |
|
uploaderNumcom: 0, |
|
showUploadcom:true, |
|
old:true, |
|
jurisdiction:5 |
|
}, |
|
bindPickerChange: function(e) { |
|
var that = this; |
|
that.setData({ |
|
index: e.detail.value, |
|
joinWay:that.data.array[e.detail.value].id |
|
}) |
|
}, |
|
textDetailChange(e){ |
|
this.setData({ |
|
company: {...this.data.company, clubIntroduction: e.detail.value} |
|
}) |
|
}, |
|
accountChange: function(e) { |
|
var that = this; |
|
that.setData({ |
|
acctindex: e.detail.value, |
|
payType:that.data.array[e.detail.value].id |
|
}) |
|
}, |
|
togroups:function(){ |
|
wx.navigateTo({ |
|
url: '../clubgroups/clubgroups?id='+this.data.company.clubId+'' |
|
}) |
|
}, |
|
topopname:function(){ |
|
wx.navigateTo({ |
|
url: '../popname/popname?id='+this.data.company.clubId |
|
}) |
|
}, |
|
removesb:function(){ |
|
wx.navigateTo({ |
|
url: '../removesb/removesb?id='+this.data.company.clubId+'' |
|
}) |
|
}, |
|
setDeputy:function(){ |
|
wx.navigateTo({ |
|
url: '../setadmin/setadmin?type=2' |
|
}) |
|
}, |
|
toacct:function(){ |
|
wx.navigateTo({ |
|
url: '../account/account' |
|
}) |
|
}, |
|
tosetadmin:function(){ |
|
wx.navigateTo({ |
|
url: '../setadmin/setadmin?type=3' |
|
}) |
|
}, |
|
/** |
|
* 生命周期函数--监听页面加载 |
|
*/ |
|
onLoad: function (options) { |
|
let queryval = JSON.parse(options.val) |
|
console.log('options:', options); |
|
if(this.uploaderList === undefined) { |
|
this.uploaderList = [] |
|
} |
|
if(queryval.clubBgimg){ |
|
this.uploaderList.push(queryval.clubBgimg); |
|
this.setData({ |
|
showUpload:false, |
|
uploaderList: this.uploaderList, |
|
}) |
|
} |
|
|
|
console.log( this.uploaderList,'tupian',this.showUpload ) |
|
this.setData({ |
|
company:queryval, |
|
}) |
|
var header = { |
|
token:wx.getStorageSync('token'), |
|
"Content-Type": "application/x-www-form-urlencoded" |
|
}; |
|
re.request(Api.selectgrade(),{clubId:this.data.company.clubId},header).then(res=>{ |
|
console.log(res,'查询权限等级'); |
|
this.setData({ |
|
// jurisdiction:1 |
|
jurisdiction:res.data.data |
|
}) |
|
}) |
|
}, |
|
// 删除图片 |
|
clearImg: function (e) { |
|
var nowList = []; //新数据 |
|
var nowListshow = []; //新数据 |
|
var uploaderList = this.data.uploaderList; //原数据 |
|
var showList = this.data.showList; //原数据 |
|
|
|
for (let i = 0; i < uploaderList.length; i++) { |
|
if (i == e.currentTarget.dataset.index) { |
|
continue; |
|
} else { |
|
nowList.push(uploaderList[i]); |
|
nowListshow.push(showList[i]); |
|
} |
|
} |
|
this.setData({ |
|
uploaderNum: this.data.uploaderNum - 1, |
|
uploaderList: nowList, |
|
showUpload: true, |
|
showList:nowListshow |
|
}) |
|
}, |
|
//展示图片 |
|
showImg: function (e) { |
|
var that = this; |
|
wx.previewImage({ |
|
urls: that.data.uploaderList, |
|
current: that.data.uploaderList[e.currentTarget.dataset.index] |
|
}) |
|
}, |
|
//上传图片 |
|
upload: function (e) { |
|
var that = this; |
|
wx.chooseImage({ |
|
count: 1 - that.data.uploaderNum, // 默认3 |
|
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有 |
|
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有 |
|
success: function (res) { |
|
// 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片 |
|
let tempFilePaths = res.tempFilePaths; |
|
let uploaderList = that.data.uploaderList.concat(tempFilePaths); |
|
if (uploaderList.length == 1) { |
|
that.setData({ |
|
showUpload: false |
|
}) |
|
} |
|
that.setData({ |
|
uploaderList: uploaderList, |
|
uploaderNum: uploaderList.length, |
|
}) |
|
|
|
for(var i=0;i<tempFilePaths.length;i++){ |
|
wx.uploadFile({ |
|
url: Api.uploadImg(), |
|
filePath: res.tempFilePaths[i], |
|
name: 'file', |
|
formData: { |
|
}, |
|
success: function (res) { |
|
var sss = JSON.parse(res.data); |
|
let showList = that.data.showList.concat(sss.msg); |
|
that.setData({ |
|
showList:showList |
|
}) |
|
} |
|
}) |
|
} |
|
} |
|
}) |
|
}, |
|
removeold:function(){ |
|
this.setData({ |
|
old:false |
|
}) |
|
}, |
|
// 删除com图片 |
|
clearImgcom: function (e) { |
|
var nowList = []; //新数据 |
|
var nowListshowcom = []; //新数据 |
|
var uploaderListcom = this.data.uploaderListcom; //原数据 |
|
var showListcom = this.data.showListcom; //原数据 |
|
|
|
for (let i = 0; i < uploaderListcom.length; i++) { |
|
if (i == e.currentTarget.dataset.index) { |
|
continue; |
|
} else { |
|
nowList.push(uploaderListcom[i]); |
|
nowListshowcom.push(showListcom[i]); |
|
} |
|
} |
|
this.setData({ |
|
uploaderNum: this.data.uploaderNum - 1, |
|
uploaderListcom: nowList, |
|
showUploadcom: true, |
|
showListcom:nowListshowcom |
|
}) |
|
}, |
|
//展示图片 |
|
showImgcom: function (e) { |
|
var that = this; |
|
wx.previewImage({ |
|
urls: that.data.uploaderListcom, |
|
current: that.data.uploaderListcom[e.currentTarget.dataset.index] |
|
}) |
|
}, |
|
//上传图片 |
|
uploadcom: function (e) { |
|
var that = this; |
|
wx.chooseImage({ |
|
count: 1 - that.data.uploaderNum, // 默认3 |
|
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有 |
|
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有 |
|
success: function (res) { |
|
// 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片 |
|
let tempFilePaths = res.tempFilePaths; |
|
let uploaderListcom = that.data.uploaderListcom.concat(tempFilePaths); |
|
if (uploaderListcom.length == 1) { |
|
that.setData({ |
|
showUploadcom: false |
|
}) |
|
} |
|
that.setData({ |
|
uploaderListcom: uploaderListcom, |
|
uploaderNum: uploaderListcom.length, |
|
}) |
|
|
|
for(var i=0;i<tempFilePaths.length;i++){ |
|
wx.uploadFile({ |
|
url: Api.uploadImg(), |
|
filePath: res.tempFilePaths[i], |
|
name: 'file', |
|
formData: { |
|
}, |
|
success: function (res) { |
|
var sss = JSON.parse(res.data); |
|
console.log(sss) |
|
let showListcom = that.data.showListcom.concat(sss.msg); |
|
that.setData({ |
|
showListcom:showListcom |
|
}) |
|
} |
|
}) |
|
} |
|
} |
|
}) |
|
}, |
|
tosave:function(){ |
|
var that = this; |
|
var header = { |
|
token:wx.getStorageSync('token'), |
|
"Content-Type": "application/x-www-form-urlencoded" |
|
}; |
|
var postData={ |
|
clubId:that.data.company.clubId, |
|
clubBgimg:that.data.showList[0], |
|
clubIntroduction:that.data.company.clubIntroduction, |
|
clubLogo:that.data.old?that.data.company.clubLogo:that.data.showListcom[0], |
|
clubName:that.data.company.clubName, |
|
joinWay:0, |
|
payType:that.data.payType |
|
}; |
|
|
|
re.request(Api.changeClub(), postData, header).then((res) => { |
|
let datas = res.data.data; |
|
console.log(datas); |
|
wx.showToast({ |
|
title: '提交成功,等待审核', |
|
icon: 'none', |
|
duration: 1000 |
|
}) |
|
wx.navigateBack({ |
|
delta: 1 |
|
}) |
|
}) |
|
}, |
|
todelete:function(){ |
|
var that = this; |
|
wx.showModal({ |
|
title: '提示', |
|
content: '确定要解散该俱乐部吗?', |
|
success: function (sm) { |
|
if (sm.confirm) { |
|
that.subRemove(); |
|
} else if (sm.cancel) { |
|
console.log('用户点击取消') |
|
} |
|
} |
|
}) |
|
|
|
}, |
|
subRemove:function(){ |
|
var that = this; |
|
var header = { |
|
token:wx.getStorageSync('token'), |
|
"Content-Type": "application/x-www-form-urlencoded" |
|
}; |
|
var postData={ |
|
clubId:that.data.company.clubId, |
|
}; |
|
re.request(Api.removeClub(), postData, header).then((res) => { |
|
let datas = res.data.data; |
|
console.log(datas); |
|
wx.showToast({ |
|
title: '提交成功,等待审核', |
|
icon: 'none', |
|
duration: 1000 |
|
}) |
|
wx.navigateBack({ |
|
delta: 2 |
|
}) |
|
}) |
|
}, |
|
/** |
|
* 生命周期函数--监听页面初次渲染完成 |
|
*/ |
|
onReady: function () { |
|
|
|
}, |
|
|
|
/** |
|
* 生命周期函数--监听页面显示 |
|
*/ |
|
onShow: function () { |
|
|
|
}, |
|
|
|
/** |
|
* 生命周期函数--监听页面隐藏 |
|
*/ |
|
onHide: function () { |
|
|
|
}, |
|
|
|
/** |
|
* 生命周期函数--监听页面卸载 |
|
*/ |
|
onUnload: function () { |
|
|
|
}, |
|
|
|
/** |
|
* 页面相关事件处理函数--监听用户下拉动作 |
|
*/ |
|
onPullDownRefresh: function () { |
|
|
|
}, |
|
|
|
/** |
|
* 页面上拉触底事件的处理函数 |
|
*/ |
|
onReachBottom: function () { |
|
|
|
}, |
|
|
|
/** |
|
* 用户点击右上角分享 |
|
*/ |
|
onShareAppMessage: function () { |
|
|
|
} |
|
}) |