重构js
This commit is contained in:
+14
-22
@@ -48,7 +48,7 @@
|
|||||||
data: {'xx': 'xx'},
|
data: {'xx': 'xx'},
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
common_alert_(data.msg)
|
common_alert(data.msg)
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
location.reload();
|
location.reload();
|
||||||
}, 1000)
|
}, 1000)
|
||||||
@@ -123,10 +123,10 @@
|
|||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
if (data.code === 0) {
|
if (data.code === 0) {
|
||||||
primary_alert_(data.msg)
|
primary_alert(data.msg)
|
||||||
$('#' + card_id).remove()
|
$('#' + card_id).remove()
|
||||||
} else {
|
} else {
|
||||||
common_alert_(data.msg)
|
common_alert(data.msg)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async: false
|
async: false
|
||||||
@@ -141,19 +141,12 @@
|
|||||||
/**校验密码是否输入一致*/
|
/**校验密码是否输入一致*/
|
||||||
validate_pw_eq: function (obj, inputPassword, inputPassword_) {
|
validate_pw_eq: function (obj, inputPassword, inputPassword_) {
|
||||||
if (inputPassword !== inputPassword_) {
|
if (inputPassword !== inputPassword_) {
|
||||||
reg_alert('两次密码输入不一样,请确认!')
|
common_alert('两次密码输入不一样,请确认!')
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
/** 注册提示 */
|
|
||||||
reg_alert: function (text, class_str) {
|
|
||||||
common_alert_(text, class_str)
|
|
||||||
},
|
|
||||||
/** 登录提示 */
|
|
||||||
login_alert: function (text, class_str) {
|
|
||||||
common_alert_(text, class_str)
|
|
||||||
},
|
|
||||||
/** 设置窗口名称 */
|
/** 设置窗口名称 */
|
||||||
set_modal_title: function (title) {
|
set_modal_title: function (title) {
|
||||||
$('#exampleModal .modal-title').html(title);
|
$('#exampleModal .modal-title').html(title);
|
||||||
@@ -197,7 +190,6 @@
|
|||||||
me.set_modal_title('登录');
|
me.set_modal_title('登录');
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
/** 注册按钮 */
|
/** 注册按钮 */
|
||||||
$('#register_button').click(function () {
|
$('#register_button').click(function () {
|
||||||
const userName = $('#userName').val();
|
const userName = $('#userName').val();
|
||||||
@@ -205,12 +197,12 @@
|
|||||||
const inputPassword_ = $('#inputPassword_').val();
|
const inputPassword_ = $('#inputPassword_').val();
|
||||||
|
|
||||||
if (!userName) {
|
if (!userName) {
|
||||||
me.reg_alert('请输入用户名')
|
common_alert('请输入用户名')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!inputPassword) {
|
if (!inputPassword) {
|
||||||
me.reg_alert('请输入密码')
|
common_alert('请输入密码')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,13 +218,13 @@
|
|||||||
// 注册成功
|
// 注册成功
|
||||||
if (data.code === 0) {
|
if (data.code === 0) {
|
||||||
me.clear_reg_info()
|
me.clear_reg_info()
|
||||||
me.reg_alert(data.msg, 'alert-primary')
|
common_alert(data.msg, 'alert-primary')
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
$('#p_login_a').click()
|
$('#p_login_a').click()
|
||||||
}, 1500)
|
}, 1500)
|
||||||
} else {
|
} else {
|
||||||
// 注册失败
|
// 注册失败
|
||||||
me.reg_alert(data.msg)
|
common_alert(data.msg)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async: false
|
async: false
|
||||||
@@ -246,7 +238,7 @@
|
|||||||
const userName_login = $('#userName_login').val();
|
const userName_login = $('#userName_login').val();
|
||||||
const inputPassword_login = $('#inputPassword_login').val();
|
const inputPassword_login = $('#inputPassword_login').val();
|
||||||
if (!userName_login || !inputPassword_login) {
|
if (!userName_login || !inputPassword_login) {
|
||||||
me.login_alert('请输入用户名和密码')
|
common_alert('请输入用户名和密码')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@@ -258,14 +250,14 @@
|
|||||||
success: function (data) {
|
success: function (data) {
|
||||||
// 登录成功
|
// 登录成功
|
||||||
if (data.code === 0) {
|
if (data.code === 0) {
|
||||||
me.login_alert(data.msg, 'alert-primary')
|
common_alert(data.msg, 'alert-primary')
|
||||||
$('#exampleModal').modal('hide')
|
$('#exampleModal').modal('hide')
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
location.reload();
|
location.reload();
|
||||||
}, 500)
|
}, 500)
|
||||||
} else {
|
} else {
|
||||||
// 登录失败
|
// 登录失败
|
||||||
me.login_alert(data.msg)
|
common_alert(data.msg)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async: false
|
async: false
|
||||||
@@ -277,7 +269,7 @@
|
|||||||
debugger
|
debugger
|
||||||
const mind_name = $('#mindName').val()
|
const mind_name = $('#mindName').val()
|
||||||
if (!mind_name) {
|
if (!mind_name) {
|
||||||
common_alert_('请输入导图名称')
|
common_alert('请输入导图名称')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,7 +290,7 @@
|
|||||||
window.open('detail?id=' + id)
|
window.open('detail?id=' + id)
|
||||||
}, 500)
|
}, 500)
|
||||||
} else {
|
} else {
|
||||||
common_alert_(resp.msg)
|
common_alert(resp.msg)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async: false
|
async: false
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
function common_alert_(text, class_str) {
|
function common_alert(text, class_str) {
|
||||||
if (!class_str) {
|
if (!class_str) {
|
||||||
class_str = 'alert-warning'
|
class_str = 'alert-warning'
|
||||||
}
|
}
|
||||||
@@ -17,6 +17,6 @@ function common_alert_(text, class_str) {
|
|||||||
}, 1500)
|
}, 1500)
|
||||||
}
|
}
|
||||||
|
|
||||||
function primary_alert_(text) {
|
function primary_alert(text) {
|
||||||
common_alert_(text, 'alert-primary')
|
common_alert(text, 'alert-primary')
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user