|
@@ -27,53 +27,114 @@ Page({
|
|
|
classList:[],
|
|
|
class_:-1,
|
|
|
class_id:0,
|
|
|
- data:{}
|
|
|
+ data:{},
|
|
|
+ type:0
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
- if(options.id){
|
|
|
+ this.setData({
|
|
|
+ type: options.type
|
|
|
+ })
|
|
|
+ var sub_list=[]
|
|
|
+ wx.request({
|
|
|
+ url: host + '/api/wx/sujectitem',
|
|
|
+ success: res => {
|
|
|
+ sub_list = res.data.data
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // options:s_name 分类名称 s_id 分类id class_id 班级id
|
|
|
+ //新增报名
|
|
|
+ if (options.type == 1){
|
|
|
+ //班级列表
|
|
|
+ wx.request({
|
|
|
+ url: host + '/api/wx/class/list?subject_item0=' + options.s_id,
|
|
|
+ method: 'GET',
|
|
|
+ success: res => {
|
|
|
+ // 过滤分类
|
|
|
+ let list = sub_list.filter(item => item.id == options.s_id)
|
|
|
+ this.setData({
|
|
|
+ categoryArray: list[0].children,
|
|
|
+ z_type: list[0].name, //提交时拼接subject_item
|
|
|
+ classList: res.data.data[0].classes
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ //修改报名
|
|
|
+ if(options.type == 2){
|
|
|
wx.request({
|
|
|
url: host+'/api/wx/signup',
|
|
|
method:'GET',
|
|
|
data:{id:options.id},
|
|
|
success:res=>{
|
|
|
+ let data = res.data.data, subject_item = data.subject_item.split('|')
|
|
|
+ let list = sub_list.filter(item => item.name == subject_item[0])
|
|
|
+ let categoryArray = list[0].children, subject = 0,
|
|
|
+ subjectArray = [], category = 0, train=0
|
|
|
+ //定位分类下拉选项
|
|
|
+ for(let i=0;i<categoryArray.length;i++){
|
|
|
+ if (categoryArray[i].name == subject_item[1]){
|
|
|
+ category=i
|
|
|
+ subjectArray = categoryArray[i].children
|
|
|
+ for(let j=0;j<subjectArray.length;j++){
|
|
|
+ if (subjectArray[j].name == subject_item[2]){
|
|
|
+ subject=j
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for(let i=0;i<this.data.trainArray.length;i++){
|
|
|
+ if (this.data.trainArray[i].name == data.train_type){
|
|
|
+ train=i
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //获取班级列表
|
|
|
+ wx.request({
|
|
|
+ url: host + '/api/wx/class/list?subject_item0=' + list[0].id,
|
|
|
+ method: 'GET',
|
|
|
+ success: res => {
|
|
|
+ let classes = res.data.data[0].classes, class_=0
|
|
|
+ for(let i=0;i<classes.length;i++){
|
|
|
+ if (classes[i].cid == data.class_id){
|
|
|
+ class_=i
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.setData({
|
|
|
+ classList: classes,
|
|
|
+ class_: class_
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ z_type: subject_item[0],
|
|
|
+ sex:data.sex=='男' ? 0 :1,
|
|
|
+ record: this.data.recordArray.indexOf(data.education),
|
|
|
+ receive: data.receive_card == '自取' ? 0 : 1,
|
|
|
+ categoryArray: categoryArray,
|
|
|
+ subjectArray: subjectArray,
|
|
|
+ category: category,
|
|
|
+ subject: subject,
|
|
|
+ train: train,
|
|
|
+ area:data.area.split(' ')
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
this.setData({
|
|
|
data: res.data.data
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
- if(options.class_id){
|
|
|
+ //班级报名
|
|
|
+ if(options.type == 3){
|
|
|
this.setData({
|
|
|
- class_id: options.class_id,
|
|
|
- price: options.price
|
|
|
+ parice_list: options.price.split('_'),
|
|
|
+ class_id: options.class_id
|
|
|
})
|
|
|
- }else{
|
|
|
- wx.request({
|
|
|
- url: host + '/api/wx/sujectitem',
|
|
|
- success: res => {
|
|
|
- let list = res.data.data.filter(item => item.name == options.name)
|
|
|
- this.setData({
|
|
|
- categoryArray: list[0].children,
|
|
|
- z_type: options.name
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- wx.request({
|
|
|
- url: host + '/api/wx/class/list?subject_item0=' + options.s_id,
|
|
|
- method: 'GET',
|
|
|
- success: res => {
|
|
|
- // let list = res.data.data.filter(item => item.type == options.name)
|
|
|
- this.setData({
|
|
|
- classList: res.data.data[0].classes
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
|
|
|
},
|
|
|
pickerChange:function(e){
|
|
@@ -109,7 +170,9 @@ Page({
|
|
|
};
|
|
|
if (e.target.dataset.name == 'train') {
|
|
|
var price=this.data.price
|
|
|
- if(!this.data.class_id && this.data.category>=0 && this.data.subject>=0){
|
|
|
+ if(this.data.type == 3){
|
|
|
+ price = this.data.parice_list[e.detail.value]
|
|
|
+ }else if(this.data.category>=0 && this.data.subject>=0){
|
|
|
if (e.detail.value == 0){
|
|
|
price = this.data.categoryArray[this.data.category].price_new
|
|
|
}
|
|
@@ -168,7 +231,7 @@ Page({
|
|
|
})
|
|
|
return false
|
|
|
}
|
|
|
- if(!this.data.class_id){
|
|
|
+ if(data.type != 3){
|
|
|
if (this.data.category == -1) {
|
|
|
wx.showToast({
|
|
|
title: '请选择作业类别',
|
|
@@ -185,14 +248,6 @@ Page({
|
|
|
})
|
|
|
return false
|
|
|
}
|
|
|
- if (this.data.train == -1) {
|
|
|
- wx.showToast({
|
|
|
- title: '请选择培训类型',
|
|
|
- icon: 'none',
|
|
|
- duration: 2000
|
|
|
- })
|
|
|
- return false
|
|
|
- }
|
|
|
if (this.data.class_ == -1) {
|
|
|
wx.showToast({
|
|
|
title: '请选择班级',
|
|
@@ -201,35 +256,62 @@ Page({
|
|
|
})
|
|
|
return false
|
|
|
}
|
|
|
- }
|
|
|
- if (!this.data.class_id) {
|
|
|
- formData.subject_item = data.z_type+"|"+data.categoryArray[data.category].name+"|"+data.subjectArray[data.subject].name
|
|
|
- formData.subject_id = data.subjectArray[data.subject].id
|
|
|
- formData.sex=data.sexArray[data.sex]
|
|
|
- formData.education = data.recordArray[data.record]
|
|
|
- formData.receive_card = data.receiveArray[data.receive]
|
|
|
- formData.class_id = data.classList[data.class_].id
|
|
|
+ formData.subject_item = data.z_type + "|" + data.categoryArray[data.category].name + "|" + data.subjectArray[data.subject].name
|
|
|
+ formData.subject_id = data.subjectArray[data.subject].id
|
|
|
+ formData.class_id = data.classList[data.class_].cid
|
|
|
}else{
|
|
|
- formData.class_id = this.data.class_id
|
|
|
+ formData.class_id = data.class_id
|
|
|
}
|
|
|
+ if (this.data.train == -1) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '请选择培训类型',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ formData.sex=data.sexArray[data.sex]
|
|
|
+ formData.education = data.recordArray[data.record]
|
|
|
+ formData.receive_card = data.receiveArray[data.receive]
|
|
|
formData.train_type = data.trainArray[data.train].name
|
|
|
formData.price=this.data.price
|
|
|
- formData.area=this.data.area.join('')
|
|
|
+ formData.area=this.data.area.join(' ')
|
|
|
+ var method = 'POST', post_data = formData
|
|
|
+ if (this.data.type == 2) {
|
|
|
+ method = 'PUT'
|
|
|
+ var new_data=this.data.data
|
|
|
+ for(let key in formData){
|
|
|
+ new_data[key]=formData[key]
|
|
|
+ }
|
|
|
+ post_data = new_data
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
wx.showLoading({
|
|
|
title: '',
|
|
|
})
|
|
|
+
|
|
|
wx.request({
|
|
|
url: host + '/api/wx/signup',
|
|
|
- method: 'POST',
|
|
|
+ method: method,
|
|
|
header: {
|
|
|
openid: this.data.openid
|
|
|
},
|
|
|
- data: formData,
|
|
|
+ data: post_data,
|
|
|
success: res => {
|
|
|
wx.hideLoading()
|
|
|
- wx.navigateTo({
|
|
|
- url: '../upload/upload?id='+res.data.data.id,
|
|
|
- })
|
|
|
+ if(res.data.status == 'suc'){
|
|
|
+ let id = (data.type == 2) ? new_data.id : res.data.data.id
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '../upload/upload?id='+id,
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ wx.showToast({
|
|
|
+ title: res.data.message,
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
|