:coding:完成totp适配

This commit is contained in:
sunxiaolong
2023-11-22 02:18:29 +08:00
parent 4c35fbd41a
commit afb2486cad
3 changed files with 96 additions and 17 deletions

View File

@@ -164,6 +164,21 @@ func (c *UpdateController) OperatorAccount() {
accountUid := strings.TrimSpace(c.GetString("accountUid"))
accountOperator := strings.TrimSpace(c.GetString("accountOperator"))
amount := strings.TrimSpace(c.GetString("amount"))
totpCode := strings.TrimSpace(c.GetString("totpCode"))
c.GetSession("")
userID := c.GetSession("userID").(string)
userInfo := user.GetUserInfoByUserID(userID)
if userInfo.OtpSecret != "" && !mfa.ValidCode(totpCode, userInfo.OtpSecret) {
dataJSON := new(datas.BaseDataJSON)
dataJSON.Code = -1
dataJSON.Msg = "二次验证失败"
c.GenerateJSON(dataJSON)
return
}
se := new(service.UpdateService)
accountDataJSON := se.OperatorAccount(accountOperator, amount, accountUid)

View File

@@ -82,7 +82,6 @@
<option value="100">100</option>
</select>
</li>
<li class="current_total_page">
<span class="current_page">
@@ -101,6 +100,49 @@
</li>
</div>
</div>
<div class="modal fade" id="account-solve" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">订单处理</h4>
</div>
<div class="modal-body modal-body-order-solve">
<input type="text" id="account-uid-edit" hidden>
<div style="display: flex">
<div>
<label>
操作:
<select value="" id="account-edit-operator">
<option value="plus_amount">加款</option>
<option value="sub_amount">减款</option>
</select>
</label>
</div>
<div>
<label>
<input type="text" value="" id="account-edit-operator-amount"
placeholder="请输入增加(减少)金额">
</label>
</div>
</div>
<div>
<label>
二次验证:
<input type="text" value="" id="order-info-totp">
</label>
</div>
<div>
<p class="error-msg"></p>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default account-edit-save">确定</button>
<button type="button" class="btn btn-default cancel-order-solve" data-dismiss="modal">取消</button>
</div>
</div>
</div>
</div>
</body>
<script>
function getAccountCutPageValues() {
let displayCount = $("#display_count").val();
@@ -147,10 +189,20 @@
"<th>" + v.SettleAmount + "</th>" + "<th>" + v.WaitAmount + "</th>" + "<th>" + v.LoanAmount + "</th>" +
"<th>" + v.FreezeAmount + "</th>" + "<th>" + v.PayforAmount + "</th>" + "<th>" + v.Status + "</th>";
tmp = tmp.replace("unactive", "冻结").replace("active", "激活");
tmp = tmp + "<th>" + '<div class="btn-group" role="group" aria-label="...">' +
'<button type="button" value="' + v.AccountUid + '" class="btn btn-default" onclick="updateAccountStatus(this.value);">' + "激活|冻结" + '</button>' +
'<button type="button" value="' + v.AccountUid + '" class="btn btn-default" onclick="deleteAccount(this.value);"><span class="glyphicon glyphicon-trash"></span></button>' +
'</div>' + "</th>" + "</tr>";
tmp = tmp + "<th>" +
'<div class="btn-group" role="group" aria-label="...">' +
'<button type="button" value="' +
v.AccountUid +
'" class="btn btn-default" onclick="updateAccountStatus(this.value);">' +
"激活|冻结" +
'</button>' +
`<button type="button" value="${v.AccountUid}" class="btn btn-default" onclick="showTotpModal(this.value)">变更钱包余额</button>` +
'<button type="button" value="' +
v.AccountUid +
'" class="btn btn-default" onclick="deleteAccount(this.value);"><span class="glyphicon glyphicon-trash"></span></button>' +
'</div>' +
"</th>" +
"</tr>";
if (v.Status === "unactive") {
tmp = tmp.replace("<tr>", "<tr style='color: red;'>");
}
@@ -226,24 +278,32 @@
});
}
// 改变账户余额
$(".account-edit-save").click(function () {
let accountUid = $("#account-uid-edit").html();
let accountOperator = $("#account-edit-opertor").val();
let amount = $("#account-edit-opertor-amount").val();
const accountUid = $("#account-uid-edit").val();
const accountOperator = $("#account-edit-operator").val();
const amount = $("#account-edit-operator-amount").val();
const totpCode = $("#order-info-totp").val();
if (accountUid === "" || accountOperator === "" || amount === "" || totpCode === "") {
$(".error-msg").val("信息填写不完全,请重新填写");
return
}
$.ajax({
url: "/account/operator",
data: {
"accountUid": accountUid,
"accountOperator": accountOperator,
"amount": amount
accountUid: accountUid,
accountOperator: accountOperator,
amount: amount,
totpCode: totpCode,
},
success: function (res) {
if (res.Code === 404) {
window.parent.location = "/login.html";
} else {
$("#account-edit-opertor-result").html(res.Msg);
randerAccountEdit(accountUid);
alert(res.Msg);
ajaxAccountList({});
}
}
});
@@ -258,7 +318,7 @@
$(".pre_page").click(function () {
let dataJSON = getAccountCutPageValues();
if (dataJSON["currentPage"] == 1) {
if (dataJSON["currentPage"] === 1) {
return;
}
dataJSON["currentPage"] = parseInt(dataJSON["currentPage"]) - 1;
@@ -267,7 +327,7 @@
//点击下一页的按钮时
$(".next_page").click(function () {
let dataJSON = getAccountCutPageValues();
if (dataJSON["currentPage"] == dataJSON["totalPage"]) {
if (dataJSON["currentPage"] === dataJSON["totalPage"]) {
return;
}
dataJSON["currentPage"] = parseInt(dataJSON["currentPage"]) + 1;
@@ -293,6 +353,11 @@
clearAccountSearchValues();
ajaxAccountList({});
});
function showTotpModal(merchantUid) {
console.log(merchantUid)
$("#account-solve").modal("show");
$("#account-uid-edit").val(merchantUid);
}
</script>
</body>
</html>

View File

@@ -256,7 +256,6 @@
<input type="text" value="" id="order-info-totp">
</label>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default save-order-solve">确定</button>