double_choose.js 2.7 KB
define(['jquery', 'bootstrap', 'frontend', 'form', 'template', 'swiper', 'layer'], function($, undefined, Frontend,
			Form, Template, Swiper, Layer) {
			var Controller = {
				index: function() {
                     // console.log(true)
					 var first_swiper = new Swiper ('#first_swiper', {
					    loop: true, // 循环模式选项
					    // 如果需要分页器
						autoplay:true,
					    pagination: {
					      el: '.swiper-pagination',
					    }
					  });
					 $(document).on("click","ul.type li",function(){

						 location.href = '?type='+ $(this).data("type");

					 })
					 $("#create").click(function(){
					 	 layer.open({
					 	   type: 1,
					 		title:['请选择分类','font-size:1rem;'],
					 		area:['50rem','20rem'],
					 	 	scrollbar:false,
					 	    content: $('#modal1'), //这里content是一个DOM,注意:最好该元素要存放在body最外层,否则可能被其它的相对元素所影响
							 success:function(){
								 $.ajax({
									 type:'post',
									 url: 'student_login/getLoginStatus',
									 dataType:'json',
									 success:function(res){
										 console.log(res);
										 if(res.code ==0){
											 Layer.alert(res.msg,{time:3000},function(index){
												 Layer.close(index);
												 if(res.url != ''){
													 location.href = res.url;
												 }
											 });
										 }
									 }
								 });
							 }
					 	 });
					 });
					 $(".apply").click(function(){

						 var double_id =  $(this).data("id");
					 	 layer.open({
							type: 1,
					 		title:['申请加入','font-size:1rem;'],
					 		area:['80%','60%'],
					 	 	scrollbar:false,
							content: $('#modal2'), //这里content是一个DOM,注意:最好该元素要存放在body最外层,否则可能被其它的相对元素所影响
							success:function(){
								$("#modal2").find("#c-double_id").val(double_id);
								$(document).on('submit',"form[name='applyteacher']",function(){
									 var data = $(this).serialize();
									 $.ajax({
										 type:'post',
										 url: $(this).attr('action'),
										 data:data,
										 dataType:'json',
										 success:function(res){
										 	console.log(res);
										 	if(res.code ==0){
										 		Layer.alert(res.msg,{time:3000},function(index){
										 			Layer.close(index);
										 			if(res.url != ''){
										 				location.href = res.url;
													}
												});
											}else{
												Layer.alert(res.msg,{time:3000},function(index){
													Layer.close(index);
													if(res.url != ''){
														location.href = res.url;
													}
												});
											}
										 }
									 });
								});


							}
					 	 });

					 });

				},
				}
				return Controller;
			});