因为要兼容IE7,没有用到route功能,在index.html页面include了菜单和登陆注册页面(header.html),在header页面中点击登陆时,后台接收到2次请求,一次无数据,第二次成功接收数据了。我检查页面了没有引用2次controller,但是不知为啥就是触发了2次请求。还请各位大神指点
html
- 手机号码:
请输入11位手机号码
请输入正确的手机号码
- 验证码:
请输入正确验证码
2-20个字符,可由中文、字母和数字组成
- 密码:
请输入密码
2-20个字符,可由中文、字母和数字组成
- 确认密码:
两次输入的密码必须一致
两次输入的密码必须一致
阅读并同意入网服务协议服务条款、隐私政策
请先同意协议
js代码:
function LoginCtrl($scope,$http,$rootScope) {
// console.log("请求进入")
// 二级导航显示
$(".telWatch").on("mouseenter",function(){
$(".secNav").slideDown(function(){
$(".secNav").stop(true);
})//.stop(true,true);
return;
})
$(".telWatch").on("mouseleave",function(){
$(".secNav").slideUp(function(){
$(".secNav").stop(true,true);
});
return;
})
//登陆事件
$scope.showLogin = function(){
//页面层
layer.open({
type: 1,
title:"登录",
shadeClose: true,
skin: 'layui-layer-rim', //加上边框
area: ['500px', '500px'], //宽高
content: $('.login')
})
}
//注册事件
$scope.showRegin = function(){
//页面层
layer.open({
type: 1,
title:"注册",
shadeClose: true,
skin: 'layui-layer-rim', //加上边框
area: ['500px', '500px'], //宽高
content:$('.reg')
})
}
//注册
$scope.addUsers = function (item) {
//表单正常提交
if($scope.userForm.$valid){
if($scope.user.pwd != $scope.user.pwd2){
$(".pwd2").show();
return false
}else{
$(".pwd2").hide();
}
var url = "http://10.12.12.74:30030/gateway.do";
//正常提交表单
$http({
method : 'POST',
url : url,
data: {phone:phone,password:pwd},
header:headers
}).success(function(data, status) {
console.log(data.msg);
// alert(item.pwd,item.pwd2)
// $(".layui-layer-close1").click();
// $('.user').show();
// $(".loginItem").hide();
}).error(function(data, status) {
});
}
else{
$scope.submitted = true;
}
};
$scope.rebpwd = true;
//登陆
$scope.userlogin = function (phone,pwd) {
console.log(phone);
//表单正常提交
if($scope.loginForm.$valid){
//正常提交表单
var url = "http://10.12.12.74:30030/gateway.do";
var headers= {'Content-Type':'application/json'};
$http({
method : 'POST',
url : url,
data: {phone:phone,password:pwd},
header:headers
}).success(function(data, status) {
console.log(data.msg);
}).error(function(data, status) {
console.log(data.msg);
});
}
else{
$scope.submitted = true;
}
};
$scope.logout = function(){
alert("退出按钮")
}
}