Parcourir la source

认证手机取消及页面调整

ellisran il y a 1 semaine
Parent
commit
a5dcae4e29

+ 9 - 0
app/controller/profile_controller.js

@@ -414,6 +414,15 @@ module.exports = app => {
                             response.data = JSON.parse(dskAccount.dsk_account);
                         }
                         break;
+                    case 'unbindMobile':
+                        if (!dskAccount.auth_mobile) {
+                            throw '未绑定认证手机';
+                        }
+                        if (dskAccount.dsk_account) {
+                            throw '未解绑大司空账号无法解绑认证手机';
+                        }
+                        response.data = await ctx.service.projectAccount.defaultUpdate({ id: dskAccount.id, auth_mobile: '' });
+                        break;
                     case 'compilation':
                         if (!dskAccount.dsk_account) {
                             throw '未绑定大司空账号';

+ 15 - 0
app/public/js/profile.js

@@ -7,6 +7,7 @@
  */
 $(document).ready(function() {
     autoFlashHeight();
+    $('[data-toggle="popover"]').popover();
     try {
         if (user !== '') {
             $(".sidebar-title").text(user);
@@ -111,6 +112,20 @@ $(document).ready(function() {
             $('#mobile-form').show();
         });
 
+        $('#hide-bind-btn').click(function () {
+            $('#mobile-form').hide();
+            $('#mobile-form').siblings('.form-group').show();
+        });
+
+        $('#del-mobile-btn').click(function () {
+            postData('/profile/dsk/api', { type: 'unbindMobile' }, function (response) {
+                toastr.success('解绑认证手机成功');
+                setTimeout(function () {
+                    location.reload();
+                }, 1000);
+            });
+        })
+
         // 移除签名
         $('#delete-sign').click(function () {
             postData('/profile/sign/delete', {}, function (result) {

+ 17 - 0
app/view/profile/modal.ejs

@@ -15,6 +15,23 @@
     </div>
 </div>
 
+<div class="modal fade" id="remove-auth-mobile" data-backdrop="static">
+    <div class="modal-dialog" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title">解绑认证手机</h5>
+            </div>
+            <div class="modal-body">
+                <h5>确认解绑认证手机?</h5>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">取消</button>
+                <button type="submit" class="btn btn-danger btn-sm" id="del-mobile-btn">确定解绑</button>
+            </div>
+        </div>
+    </div>
+</div>
+
 <div class="modal fade" id="remove-dsk-account" data-backdrop="static">
     <div class="modal-dialog" role="document">
         <div class="modal-content">

+ 12 - 11
app/view/profile/sms.ejs

@@ -14,16 +14,16 @@
                             <div class="card-body pt-3">
                                 <h6 class="card-title">认证手机</h6>
                                 <% if (accountData.auth_mobile !== '') { %>
-                                    <!--已绑定手机-->
-                                    <div class="form-group">
-                                        <label>已认证手机</label>
-                                        <div class="input-group mb-3">
-                                            <input class="form-control form-control-sm" readonly="" value="<%= accountData.auth_mobile %>">
-                                            <div class="input-group-append">
-                                                <button class="btn btn-outline-secondary btn-sm" id="change-mobile">修改手机</button>
-                                            </div>
-                                        </div>
-                                    </div>
+                                <!--已绑定手机-->
+                                <div class="form-group">
+                                    <label><%- accountData.auth_mobile %></label>
+                                    <% if (accountData.dsk_account) { %>
+                                    <a href="javascript:void(0);" class="btn btn-sm btn-outline-secondary" data-container="body" data-toggle="popover" data-placement="bottom" data-content="先解绑大司空账号才能解绑认证手机" data-trigger="focus">解绑</a>
+                                    <% } else { %>
+                                    <a href="#remove-auth-mobile" class="btn btn-sm btn-outline-primary" data-toggle="modal" data-target="#remove-auth-mobile">解绑</a>
+                                    <% } %>
+                                    <a href="javascript:void(0);" class="btn btn-sm btn-outline-warning ml-2" id="change-mobile">修改手机</a>
+                                </div>
                                 <% } %>
                                 <!--绑定手机-->
                                 <% if (accountData.auth_mobile === '') { %><div class="alert alert-warning">认证手机用户找回密码操作,请优先设置。</div><% } %>
@@ -44,6 +44,7 @@
                                         </div>
                                     </div>
                                     <button type="button" class="btn btn-secondary btn-sm disabled" id="bind-btn">确认绑定</button>
+                                    <% if (accountData.auth_mobile !== '') { %><button type="button" class="btn btn-outline-secondary btn-sm" id="hide-bind-btn">取消</button><% } %>
                                 </form>
                                 <% if (accountData.auth_mobile !== '' && false) { %>
                                     <!--短信通知开关(已有认证手机后显示)-->
@@ -243,6 +244,6 @@
                     location.reload();
                 }, 1000);
             });
-        })
+        });
     });
 </script>