Browse Source

修复短信发送bug及限时开放测试

ellisran 1 year ago
parent
commit
84d936f602

+ 1 - 1
app/public/js/change_information_show.js

@@ -230,7 +230,7 @@ $(document).ready(() => {
                 if (response.err === 0) {
                     codeSuccess(btn);
                     $("input[name='code']").removeAttr('readonly');
-                    // $("#re-shenpi-btn").removeAttr('disabled');
+                    $("#re-shenpi-btn").removeAttr('disabled');
                     $("#re-shenpi-btn2").removeAttr('disabled');
                 } else {
                     toast(response.msg, 'error');

File diff suppressed because it is too large
+ 948 - 948
app/service/project_account.js


+ 193 - 129
app/view/change/apply_information_modal.ejs

@@ -919,152 +919,216 @@
 <script>
     const cur_uid = parseInt('<%- ctx.session.sessionUser.accountId %>');
     const csrf = '<%= ctx.csrf %>';
+    const authMobile = '<%= authMobile %>';
 </script>
 <script>
-    $('.sp-location-list').on('shown.bs.modal', function () {
-        const scrollBox = $(this).find('div[class="col-8 modal-height-500"]');
-        const bdiv = (scrollBox.offset() && scrollBox.offset().top) || 0;
-        scrollBox.scrollTop(0);
-        const hdiv = divSearch($(this).find('textarea')) ? $(this).find('textarea') : null;
-        const hdheight = hdiv ? hdiv.parents('.timeline-item-content').offset().top : null;
-        if (hdiv && scrollBox.length && scrollBox[0].scrollHeight > 200 && hdheight - bdiv > 200) {
-            scrollBox.scrollTop(hdheight - bdiv);
-        }
-    });
-    function divSearch(div) {
-        if (div.length > 0) {
-            return true;
+    $(function () {
+        $('.sp-location-list').on('shown.bs.modal', function () {
+            const scrollBox = $(this).find('div[class="col-8 modal-height-500"]');
+            const bdiv = (scrollBox.offset() && scrollBox.offset().top) || 0;
+            scrollBox.scrollTop(0);
+            const hdiv = divSearch($(this).find('textarea')) ? $(this).find('textarea') : null;
+            const hdheight = hdiv ? hdiv.parents('.timeline-item-content').offset().top : null;
+            if (hdiv && scrollBox.length && scrollBox[0].scrollHeight > 200 && hdheight - bdiv > 200) {
+                scrollBox.scrollTop(hdheight - bdiv);
+            }
+        });
+        function divSearch(div) {
+            if (div.length > 0) {
+                return true;
+            }
+            return false;
         }
-        return false;
-    }
 
-    // 展开历史审核记录
-    $('.modal-body #fold-btn').click(function () {
-        const type = $(this).data('target')
-        const auditCard = $(this).parent().parent()
-        if (type === 'show') {
-            $(this).data('target', 'hide')
-            auditCard.find('.fold-card').slideDown('swing', () => {
-                auditCard.find('#fold-btn').text('收起历史审核记录')
-            })
-        } else {
-            $(this).data('target', 'show')
-            auditCard.find('.fold-card').slideUp('swing', () => {
-                auditCard.find('#fold-btn').text('展开历史审核记录')
-            })
-        }
-    });
+        // 展开历史审核记录
+        $('.modal-body #fold-btn').click(function () {
+            const type = $(this).data('target')
+            const auditCard = $(this).parent().parent()
+            if (type === 'show') {
+                $(this).data('target', 'hide')
+                auditCard.find('.fold-card').slideDown('swing', () => {
+                    auditCard.find('#fold-btn').text('收起历史审核记录')
+                })
+            } else {
+                $(this).data('target', 'show')
+                auditCard.find('.fold-card').slideUp('swing', () => {
+                    auditCard.find('#fold-btn').text('展开历史审核记录')
+                })
+            }
+        });
 
-    $('.sp-list-btn').click(function () {
-        const type = $(this).data('type')
-        if (type === 'hide') {
-            $('.sp-list-item').hide()
-            $('.modal-title').text('审批流程')
-        } else {
-            $('.sp-list-item').show()
-            $('.modal-title').text('重新上报')
-        }
-    });
+        $('.sp-list-btn').click(function () {
+            const type = $(this).data('type')
+            if (type === 'hide') {
+                $('.sp-list-item').hide()
+                $('.modal-title').text('审批流程')
+            } else {
+                $('.sp-list-item').show()
+                $('.modal-title').text('重新上报')
+            }
+        });
 
-    $('#re-shenpi-btn').click(function () {
-        const data = {
-            caid: parseInt('<%- ctx.change.id %>'),
-        };
-        <% if (ctx.session.sessionUser.loginStatus === 0) { %>
-        const code = $("#againForm input[name='code']").val();
-        if ($(this).hasClass('disabled')) {
-            return false;
-        }
-        if (code.length < 6) {
-            // alert('请填写正确的验证码');
-            toastr.error('请填写正确的验证码');
-            return false;
-        }
-        data.code = code;
-        <% } %>
-        $.ajax({
-            url: '/tender/<%- tender.id %>/change/apply/check/again?_csrf_j=' + csrf,
-            type: 'post',
-            data: data,
-            dataTye: 'json',
-            success: function(response) {
-                if (response.err === 0) {
-                    window.location.href = response.url;
-                } else {
-                    toastr.error(response.msg);
+        $('#re-shenpi-btn').click(function () {
+            const data = {
+                caid: parseInt('<%- ctx.change.id %>'),
+            };
+            <% if (ctx.session.sessionUser.loginStatus === 0) { %>
+            const code = $("#againForm input[name='code']").val();
+            if ($(this).hasClass('disabled')) {
+                return false;
+            }
+            if (code.length < 6) {
+                // alert('请填写正确的验证码');
+                toastr.error('请填写正确的验证码');
+                return false;
+            }
+            data.code = code;
+            <% } %>
+            $.ajax({
+                url: '/tender/<%- tender.id %>/change/apply/check/again?_csrf_j=' + csrf,
+                type: 'post',
+                data: data,
+                dataTye: 'json',
+                success: function(response) {
+                    if (response.err === 0) {
+                        window.location.href = response.url;
+                    } else {
+                        toastr.error(response.msg);
+                    }
                 }
+            });
+        })
+
+        $('#re-shenpi-btn2').click(function () {
+            const data = {
+                caid: parseInt('<%- ctx.change.id %>'),
+            };
+            <% if (ctx.session.sessionUser.loginStatus === 0) { %>
+            const code = $("#reviseForm input[name='code']").val();
+            if ($(this).hasClass('disabled')) {
+                return false;
             }
+            if (code.length < 6) {
+                // alert('请填写正确的验证码');
+                toast('请填写正确的验证码', 'error');
+                return false;
+            }
+            data.code = code;
+            <% } %>
+            $.ajax({
+                url: '/tender/<%- tender.id %>/change/apply/check/revise?_csrf_j=' + csrf,
+                type: 'post',
+                data: data,
+                dataTye: 'json',
+                success: function(response) {
+                    if (response.err === 0) {
+                        window.location.href = response.url;
+                    } else {
+                        toastr.error(response.msg);
+                    }
+                }
+            });
         });
-    })
 
-    $('#re-shenpi-btn2').click(function () {
-        const data = {
-            caid: parseInt('<%- ctx.change.id %>'),
-        };
         <% if (ctx.session.sessionUser.loginStatus === 0) { %>
-        const code = $("#reviseForm input[name='code']").val();
-        if ($(this).hasClass('disabled')) {
-            return false;
-        }
-        if (code.length < 6) {
-            // alert('请填写正确的验证码');
-            toast('请填写正确的验证码', 'error');
-            return false;
-        }
-        data.code = code;
-        <% } %>
-        $.ajax({
-            url: '/tender/<%- tender.id %>/change/apply/check/revise?_csrf_j=' + csrf,
-            type: 'post',
-            data: data,
-            dataTye: 'json',
-            success: function(response) {
-                if (response.err === 0) {
-                    window.location.href = response.url;
-                } else {
-                    toastr.error(response.msg);
-                }
+        // 重新审批获取手机验证码
+        // 获取验证码
+        let isPosting = false;
+        $("#get-code").click(function() {
+            if (isPosting) {
+                return false;
             }
+            const btn = $(this);
+
+            $.ajax({
+                url: '/profile/code?_csrf_j=' + csrf,
+                type: 'post',
+                data: { mobile: authMobile, type: 'shenpi' },
+                dataTye: 'json',
+                error: function() {
+                    isPosting = false;
+                },
+                beforeSend: function() {
+                    isPosting = true;
+                },
+                success: function(response) {
+                    isPosting = false;
+                    if (response.err === 0) {
+                        codeSuccess(btn);
+                        $("input[name='code']").removeAttr('readonly');
+                        $("#re-shenpi-btn").removeAttr('disabled');
+                        $("#re-shenpi-btn2").removeAttr('disabled');
+                    } else {
+                        toastr.error(response.msg);
+                    }
+                }
+            });
         });
-    })
+        <% } %>
 
-    $('#cancel-revise-btn').click(function () {
-        const data = {
-            caid: parseInt('<%- ctx.change.id %>'),
-        };
-        $.ajax({
-            url: '/tender/<%- tender.id %>/change/apply/cancel/revise?_csrf_j=' + csrf,
-            type: 'post',
-            data: data,
-            dataTye: 'json',
-            success: function(response) {
-                if (response.err === 0) {
-                    window.location.href = response.url;
-                } else {
-                    toastr.error(response.msg);
+        $('#cancel-revise-btn').click(function () {
+            const data = {
+                caid: parseInt('<%- ctx.change.id %>'),
+            };
+            $.ajax({
+                url: '/tender/<%- tender.id %>/change/apply/cancel/revise?_csrf_j=' + csrf,
+                type: 'post',
+                data: data,
+                dataTye: 'json',
+                success: function(response) {
+                    if (response.err === 0) {
+                        window.location.href = response.url;
+                    } else {
+                        toastr.error(response.msg);
+                    }
                 }
-            }
+            });
+        })
+
+        <% if (ctx.change && ctx.change.cancancel) { %>
+        $("#cancel-shenpi-btn").click(function () {
+            const data = {
+                caid: parseInt('<%- ctx.change.id %>'),
+            };
+            $.ajax({
+                url: '/tender/<%- tender.id %>/change/apply/cancel/audit?_csrf_j=' + csrf,
+                type: 'post',
+                data: data,
+                dataTye: 'json',
+                success: function (response) {
+                    if (response.err === 0) {
+                        window.location.href = response.url;
+                    } else {
+                        toastr.error(response.msg);
+                    }
+                }
+            });
         });
+        <% } %>
     })
+    /**
+     * 获取成功后的操作
+     *
+     * @param {Object} btn - 点击的按钮
+     * @return {void}
+     */
+    function codeSuccess(btn) {
+        let counter = 60;
+        btn.addClass('disabled').text('重新获取 ' + counter + 'S');
+        btn.parent().siblings('input').removeAttr('readonly').attr('placeholder', '输入短信中的6位验证码');
+        const bindBtn = $("#bind-btn");
+        bindBtn.removeClass('btn-secondary disabled').addClass('btn-primary');
 
-    <% if (ctx.change && ctx.change.cancancel) { %>
-    $("#cancel-shenpi-btn").click(function () {
-        const data = {
-            caid: parseInt('<%- ctx.change.id %>'),
-        };
-        $.ajax({
-            url: '/tender/<%- tender.id %>/change/apply/cancel/audit?_csrf_j=' + csrf,
-            type: 'post',
-            data: data,
-            dataTye: 'json',
-            success: function (response) {
-                if (response.err === 0) {
-                    window.location.href = response.url;
-                } else {
-                    toastr.error(response.msg);
-                }
+        const countDown = setInterval(function() {
+            const countString = counter - 1 <= 0 ? '' : ' ' + (counter - 1) + 'S';
+            // 倒数结束后
+            if (countString === '') {
+                clearInterval(countDown);
+                btn.removeClass('disabled');
             }
-        });
-    });
-    <% } %>
+            const text = '重新获取' + countString;
+            btn.text(text);
+            counter -= 1;
+        }, 1000);
+    }
 </script>

+ 193 - 129
app/view/change/plan_information_modal.ejs

@@ -895,152 +895,216 @@
 <script>
     const cur_uid = parseInt('<%- ctx.session.sessionUser.accountId %>');
     const csrf = '<%= ctx.csrf %>';
+    const authMobile = '<%= authMobile %>';
 </script>
 <script>
-    $('.sp-location-list').on('shown.bs.modal', function () {
-        const scrollBox = $(this).find('div[class="col-8 modal-height-500"]');
-        const bdiv = (scrollBox.offset() && scrollBox.offset().top) || 0;
-        scrollBox.scrollTop(0);
-        const hdiv = divSearch($(this).find('textarea')) ? $(this).find('textarea') : null;
-        const hdheight = hdiv ? hdiv.parents('.timeline-item-content').offset().top : null;
-        if (hdiv && scrollBox.length && scrollBox[0].scrollHeight > 200 && hdheight - bdiv > 200) {
-            scrollBox.scrollTop(hdheight - bdiv);
-        }
-    });
-    function divSearch(div) {
-        if (div.length > 0) {
-            return true;
+    $(function () {
+        $('.sp-location-list').on('shown.bs.modal', function () {
+            const scrollBox = $(this).find('div[class="col-8 modal-height-500"]');
+            const bdiv = (scrollBox.offset() && scrollBox.offset().top) || 0;
+            scrollBox.scrollTop(0);
+            const hdiv = divSearch($(this).find('textarea')) ? $(this).find('textarea') : null;
+            const hdheight = hdiv ? hdiv.parents('.timeline-item-content').offset().top : null;
+            if (hdiv && scrollBox.length && scrollBox[0].scrollHeight > 200 && hdheight - bdiv > 200) {
+                scrollBox.scrollTop(hdheight - bdiv);
+            }
+        });
+        function divSearch(div) {
+            if (div.length > 0) {
+                return true;
+            }
+            return false;
         }
-        return false;
-    }
 
-    // 展开历史审核记录
-    $('.modal-body #fold-btn').click(function () {
-        const type = $(this).data('target')
-        const auditCard = $(this).parent().parent()
-        if (type === 'show') {
-            $(this).data('target', 'hide')
-            auditCard.find('.fold-card').slideDown('swing', () => {
-                auditCard.find('#fold-btn').text('收起历史审核记录')
-            })
-        } else {
-            $(this).data('target', 'show')
-            auditCard.find('.fold-card').slideUp('swing', () => {
-                auditCard.find('#fold-btn').text('展开历史审核记录')
-            })
-        }
-    });
+        // 展开历史审核记录
+        $('.modal-body #fold-btn').click(function () {
+            const type = $(this).data('target')
+            const auditCard = $(this).parent().parent()
+            if (type === 'show') {
+                $(this).data('target', 'hide')
+                auditCard.find('.fold-card').slideDown('swing', () => {
+                    auditCard.find('#fold-btn').text('收起历史审核记录')
+                })
+            } else {
+                $(this).data('target', 'show')
+                auditCard.find('.fold-card').slideUp('swing', () => {
+                    auditCard.find('#fold-btn').text('展开历史审核记录')
+                })
+            }
+        });
 
-    $('.sp-list-btn').click(function () {
-        const type = $(this).data('type')
-        if (type === 'hide') {
-            $('.sp-list-item').hide()
-            $('.modal-title').text('审批流程')
-        } else {
-            $('.sp-list-item').show()
-            $('.modal-title').text('重新上报')
-        }
-    });
+        $('.sp-list-btn').click(function () {
+            const type = $(this).data('type')
+            if (type === 'hide') {
+                $('.sp-list-item').hide()
+                $('.modal-title').text('审批流程')
+            } else {
+                $('.sp-list-item').show()
+                $('.modal-title').text('重新上报')
+            }
+        });
 
-    $('#re-shenpi-btn').click(function () {
-        const data = {
-            cpid: parseInt('<%- ctx.change.id %>'),
-        };
-        <% if (ctx.session.sessionUser.loginStatus === 0) { %>
-        const code = $("#againForm input[name='code']").val();
-        if ($(this).hasClass('disabled')) {
-            return false;
-        }
-        if (code.length < 6) {
-            // alert('请填写正确的验证码');
-            toastr.error('请填写正确的验证码');
-            return false;
-        }
-        data.code = code;
-        <% } %>
-        $.ajax({
-            url: '/tender/<%- tender.id %>/change/plan/check/again?_csrf_j=' + csrf,
-            type: 'post',
-            data: data,
-            dataTye: 'json',
-            success: function(response) {
-                if (response.err === 0) {
-                    window.location.href = response.url;
-                } else {
-                    toastr.error(response.msg);
+        $('#re-shenpi-btn').click(function () {
+            const data = {
+                cpid: parseInt('<%- ctx.change.id %>'),
+            };
+            <% if (ctx.session.sessionUser.loginStatus === 0) { %>
+            const code = $("#againForm input[name='code']").val();
+            if ($(this).hasClass('disabled')) {
+                return false;
+            }
+            if (code.length < 6) {
+                // alert('请填写正确的验证码');
+                toastr.error('请填写正确的验证码');
+                return false;
+            }
+            data.code = code;
+            <% } %>
+            $.ajax({
+                url: '/tender/<%- tender.id %>/change/plan/check/again?_csrf_j=' + csrf,
+                type: 'post',
+                data: data,
+                dataTye: 'json',
+                success: function(response) {
+                    if (response.err === 0) {
+                        window.location.href = response.url;
+                    } else {
+                        toastr.error(response.msg);
+                    }
                 }
+            });
+        })
+
+        $('#re-shenpi-btn2').click(function () {
+            const data = {
+                cpid: parseInt('<%- ctx.change.id %>'),
+            };
+            <% if (ctx.session.sessionUser.loginStatus === 0) { %>
+            const code = $("#reviseForm input[name='code']").val();
+            if ($(this).hasClass('disabled')) {
+                return false;
             }
+            if (code.length < 6) {
+                // alert('请填写正确的验证码');
+                toast('请填写正确的验证码', 'error');
+                return false;
+            }
+            data.code = code;
+            <% } %>
+            $.ajax({
+                url: '/tender/<%- tender.id %>/change/plan/check/revise?_csrf_j=' + csrf,
+                type: 'post',
+                data: data,
+                dataTye: 'json',
+                success: function(response) {
+                    if (response.err === 0) {
+                        window.location.href = response.url;
+                    } else {
+                        toastr.error(response.msg);
+                    }
+                }
+            });
         });
-    })
 
-    $('#re-shenpi-btn2').click(function () {
-        const data = {
-            cpid: parseInt('<%- ctx.change.id %>'),
-        };
         <% if (ctx.session.sessionUser.loginStatus === 0) { %>
-        const code = $("#reviseForm input[name='code']").val();
-        if ($(this).hasClass('disabled')) {
-            return false;
-        }
-        if (code.length < 6) {
-            // alert('请填写正确的验证码');
-            toast('请填写正确的验证码', 'error');
-            return false;
-        }
-        data.code = code;
-        <% } %>
-        $.ajax({
-            url: '/tender/<%- tender.id %>/change/plan/check/revise?_csrf_j=' + csrf,
-            type: 'post',
-            data: data,
-            dataTye: 'json',
-            success: function(response) {
-                if (response.err === 0) {
-                    window.location.href = response.url;
-                } else {
-                    toastr.error(response.msg);
-                }
+        // 重新审批获取手机验证码
+        // 获取验证码
+        let isPosting = false;
+        $("#get-code").click(function() {
+            if (isPosting) {
+                return false;
             }
+            const btn = $(this);
+
+            $.ajax({
+                url: '/profile/code?_csrf_j=' + csrf,
+                type: 'post',
+                data: { mobile: authMobile, type: 'shenpi' },
+                dataTye: 'json',
+                error: function() {
+                    isPosting = false;
+                },
+                beforeSend: function() {
+                    isPosting = true;
+                },
+                success: function(response) {
+                    isPosting = false;
+                    if (response.err === 0) {
+                        codeSuccess(btn);
+                        $("input[name='code']").removeAttr('readonly');
+                        $("#re-shenpi-btn").removeAttr('disabled');
+                        $("#re-shenpi-btn2").removeAttr('disabled');
+                    } else {
+                        toastr.error(response.msg);
+                    }
+                }
+            });
         });
-    })
+        <% } %>
 
-    $('#cancel-revise-btn').click(function () {
-        const data = {
-            cpid: parseInt('<%- ctx.change.id %>'),
-        };
-        $.ajax({
-            url: '/tender/<%- tender.id %>/change/plan/cancel/revise?_csrf_j=' + csrf,
-            type: 'post',
-            data: data,
-            dataTye: 'json',
-            success: function(response) {
-                if (response.err === 0) {
-                    window.location.href = response.url;
-                } else {
-                    toastr.error(response.msg);
+        $('#cancel-revise-btn').click(function () {
+            const data = {
+                cpid: parseInt('<%- ctx.change.id %>'),
+            };
+            $.ajax({
+                url: '/tender/<%- tender.id %>/change/plan/cancel/revise?_csrf_j=' + csrf,
+                type: 'post',
+                data: data,
+                dataTye: 'json',
+                success: function(response) {
+                    if (response.err === 0) {
+                        window.location.href = response.url;
+                    } else {
+                        toastr.error(response.msg);
+                    }
                 }
-            }
+            });
+        })
+
+        <% if (ctx.change && ctx.change.cancancel) { %>
+        $("#cancel-shenpi-btn").click(function () {
+            const data = {
+                cpid: parseInt('<%- ctx.change.id %>'),
+            };
+            $.ajax({
+                url: '/tender/<%- tender.id %>/change/plan/cancel/audit?_csrf_j=' + csrf,
+                type: 'post',
+                data: data,
+                dataTye: 'json',
+                success: function (response) {
+                    if (response.err === 0) {
+                        window.location.href = response.url;
+                    } else {
+                        toastr.error(response.msg);
+                    }
+                }
+            });
         });
+        <% } %>
     })
+    /**
+     * 获取成功后的操作
+     *
+     * @param {Object} btn - 点击的按钮
+     * @return {void}
+     */
+    function codeSuccess(btn) {
+        let counter = 60;
+        btn.addClass('disabled').text('重新获取 ' + counter + 'S');
+        btn.parent().siblings('input').removeAttr('readonly').attr('placeholder', '输入短信中的6位验证码');
+        const bindBtn = $("#bind-btn");
+        bindBtn.removeClass('btn-secondary disabled').addClass('btn-primary');
 
-    <% if (ctx.change && ctx.change.cancancel) { %>
-    $("#cancel-shenpi-btn").click(function () {
-        const data = {
-            cpid: parseInt('<%- ctx.change.id %>'),
-        };
-        $.ajax({
-            url: '/tender/<%- tender.id %>/change/plan/cancel/audit?_csrf_j=' + csrf,
-            type: 'post',
-            data: data,
-            dataTye: 'json',
-            success: function (response) {
-                if (response.err === 0) {
-                    window.location.href = response.url;
-                } else {
-                    toastr.error(response.msg);
-                }
+        const countDown = setInterval(function() {
+            const countString = counter - 1 <= 0 ? '' : ' ' + (counter - 1) + 'S';
+            // 倒数结束后
+            if (countString === '') {
+                clearInterval(countDown);
+                btn.removeClass('disabled');
             }
-        });
-    });
-    <% } %>
+            const text = '重新获取' + countString;
+            btn.text(text);
+            counter -= 1;
+        }, 1000);
+    }
 </script>

+ 192 - 129
app/view/change/project_information_modal.ejs

@@ -956,150 +956,213 @@
     const accountList = JSON.parse(unescape('<%- escape(JSON.stringify(accountList)) %>'));
     const cur_uid = parseInt('<%- ctx.session.sessionUser.accountId %>');
     const csrf = '<%= ctx.csrf %>';
-    $('.sp-location-list').on('shown.bs.modal', function () {
-        const scrollBox = $(this).find('div[class="col-8 modal-height-500"]');
-        const bdiv = (scrollBox.offset() && scrollBox.offset().top) || 0;
-        scrollBox.scrollTop(0);
-        const hdiv = divSearch($(this).find('textarea')) ? $(this).find('textarea') : null;
-        const hdheight = hdiv ? hdiv.parents('.timeline-item-content').offset().top : null;
-        if (hdiv && scrollBox.length && scrollBox[0].scrollHeight > 200 && hdheight - bdiv > 200) {
-            scrollBox.scrollTop(hdheight - bdiv);
-        }
-    });
-    function divSearch(div) {
-        if (div.length > 0) {
-            return true;
+    const authMobile = '<%= authMobile %>';
+    $(function () {
+        $('.sp-location-list').on('shown.bs.modal', function () {
+            const scrollBox = $(this).find('div[class="col-8 modal-height-500"]');
+            const bdiv = (scrollBox.offset() && scrollBox.offset().top) || 0;
+            scrollBox.scrollTop(0);
+            const hdiv = divSearch($(this).find('textarea')) ? $(this).find('textarea') : null;
+            const hdheight = hdiv ? hdiv.parents('.timeline-item-content').offset().top : null;
+            if (hdiv && scrollBox.length && scrollBox[0].scrollHeight > 200 && hdheight - bdiv > 200) {
+                scrollBox.scrollTop(hdheight - bdiv);
+            }
+        });
+        function divSearch(div) {
+            if (div.length > 0) {
+                return true;
+            }
+            return false;
         }
-        return false;
-    }
 
-    // 展开历史审核记录
-    $('.modal-body #fold-btn').click(function () {
-        const type = $(this).data('target')
-        const auditCard = $(this).parent().parent()
-        if (type === 'show') {
-            $(this).data('target', 'hide')
-            auditCard.find('.fold-card').slideDown('swing', () => {
-                auditCard.find('#fold-btn').text('收起历史审核记录')
-            })
-        } else {
-            $(this).data('target', 'show')
-            auditCard.find('.fold-card').slideUp('swing', () => {
-                auditCard.find('#fold-btn').text('展开历史审核记录')
-            })
-        }
-    });
+        // 展开历史审核记录
+        $('.modal-body #fold-btn').click(function () {
+            const type = $(this).data('target')
+            const auditCard = $(this).parent().parent()
+            if (type === 'show') {
+                $(this).data('target', 'hide')
+                auditCard.find('.fold-card').slideDown('swing', () => {
+                    auditCard.find('#fold-btn').text('收起历史审核记录')
+                })
+            } else {
+                $(this).data('target', 'show')
+                auditCard.find('.fold-card').slideUp('swing', () => {
+                    auditCard.find('#fold-btn').text('展开历史审核记录')
+                })
+            }
+        });
 
-    $('.sp-list-btn').click(function () {
-        const type = $(this).data('type')
-        if (type === 'hide') {
-            $('.sp-list-item').hide()
-            $('.modal-title').text('审批流程')
-        } else {
-            $('.sp-list-item').show()
-            $('.modal-title').text('重新上报')
-        }
-    });
+        $('.sp-list-btn').click(function () {
+            const type = $(this).data('type')
+            if (type === 'hide') {
+                $('.sp-list-item').hide()
+                $('.modal-title').text('审批流程')
+            } else {
+                $('.sp-list-item').show()
+                $('.modal-title').text('重新上报')
+            }
+        });
 
-    $('#re-shenpi-btn').click(function () {
-        const data = {
-            cpid: parseInt('<%- ctx.change.id %>'),
-        };
+        $('#re-shenpi-btn').click(function () {
+            const data = {
+                cpid: parseInt('<%- ctx.change.id %>'),
+            };
+            <% if (ctx.session.sessionUser.loginStatus === 0) { %>
+            const code = $("#againForm input[name='code']").val();
+            if ($(this).hasClass('disabled')) {
+                return false;
+            }
+            if (code.length < 6) {
+                // alert('请填写正确的验证码');
+                toastr.error('请填写正确的验证码');
+                return false;
+            }
+            data.code = code;
+            <% } %>
+            $.ajax({
+                url: '/tender/<%- tender.id %>/change/project/check/again?_csrf_j=' + csrf,
+                type: 'post',
+                data: data,
+                dataTye: 'json',
+                success: function(response) {
+                    if (response.err === 0) {
+                        window.location.href = response.url;
+                    } else {
+                        toastr.error(response.msg);
+                    }
+                }
+            });
+        });
         <% if (ctx.session.sessionUser.loginStatus === 0) { %>
-        const code = $("#againForm input[name='code']").val();
-        if ($(this).hasClass('disabled')) {
-            return false;
-        }
-        if (code.length < 6) {
-            // alert('请填写正确的验证码');
-            toastr.error('请填写正确的验证码');
-            return false;
-        }
-        data.code = code;
-        <% } %>
-        $.ajax({
-            url: '/tender/<%- tender.id %>/change/project/check/again?_csrf_j=' + csrf,
-            type: 'post',
-            data: data,
-            dataTye: 'json',
-            success: function(response) {
-                if (response.err === 0) {
-                    window.location.href = response.url;
-                } else {
-                    toastr.error(response.msg);
+        // 重新审批获取手机验证码
+        // 获取验证码
+        let isPosting = false;
+        $("#get-code").click(function() {
+            if (isPosting) {
+                return false;
+            }
+            const btn = $(this);
+
+            $.ajax({
+                url: '/profile/code?_csrf_j=' + csrf,
+                type: 'post',
+                data: { mobile: authMobile, type: 'shenpi' },
+                dataTye: 'json',
+                error: function() {
+                    isPosting = false;
+                },
+                beforeSend: function() {
+                    isPosting = true;
+                },
+                success: function(response) {
+                    isPosting = false;
+                    if (response.err === 0) {
+                        codeSuccess(btn);
+                        $("input[name='code']").removeAttr('readonly');
+                        $("#re-shenpi-btn").removeAttr('disabled');
+                        $("#re-shenpi-btn2").removeAttr('disabled');
+                    } else {
+                        toastr.error(response.msg);
+                    }
                 }
+            });
+        });
+        <% } %>
+
+        $('#re-shenpi-btn2').click(function () {
+            const data = {
+                cpid: parseInt('<%- ctx.change.id %>'),
+            };
+            <% if (ctx.session.sessionUser.loginStatus === 0) { %>
+            const code = $("#reviseForm input[name='code']").val();
+            if ($(this).hasClass('disabled')) {
+                return false;
+            }
+            if (code.length < 6) {
+                // alert('请填写正确的验证码');
+                toastr.error('请填写正确的验证码');
+                return false;
             }
+            data.code = code;
+            <% } %>
+            $.ajax({
+                url: '/tender/<%- tender.id %>/change/project/check/revise?_csrf_j=' + csrf,
+                type: 'post',
+                data: data,
+                dataTye: 'json',
+                success: function(response) {
+                    if (response.err === 0) {
+                        window.location.href = response.url;
+                    } else {
+                        toastr.error(response.msg);
+                    }
+                }
+            });
         });
-    })
 
-    $('#re-shenpi-btn2').click(function () {
-        const data = {
-            cpid: parseInt('<%- ctx.change.id %>'),
-        };
-        <% if (ctx.session.sessionUser.loginStatus === 0) { %>
-        const code = $("#reviseForm input[name='code']").val();
-        if ($(this).hasClass('disabled')) {
-            return false;
-        }
-        if (code.length < 6) {
-            // alert('请填写正确的验证码');
-            toastr.error('请填写正确的验证码');
-            return false;
-        }
-        data.code = code;
-        <% } %>
-        $.ajax({
-            url: '/tender/<%- tender.id %>/change/project/check/revise?_csrf_j=' + csrf,
-            type: 'post',
-            data: data,
-            dataTye: 'json',
-            success: function(response) {
-                if (response.err === 0) {
-                    window.location.href = response.url;
-                } else {
-                    toastr.error(response.msg);
+        $('#cancel-revise-btn').click(function () {
+            const data = {
+                cpid: parseInt('<%- ctx.change.id %>'),
+            };
+            $.ajax({
+                url: '/tender/<%- tender.id %>/change/project/cancel/revise?_csrf_j=' + csrf,
+                type: 'post',
+                data: data,
+                dataTye: 'json',
+                success: function(response) {
+                    if (response.err === 0) {
+                        window.location.href = response.url;
+                    } else {
+                        toastr.error(response.msg);
+                    }
                 }
-            }
+            });
         });
-    })
 
-    $('#cancel-revise-btn').click(function () {
-        const data = {
-            cpid: parseInt('<%- ctx.change.id %>'),
-        };
-        $.ajax({
-            url: '/tender/<%- tender.id %>/change/project/cancel/revise?_csrf_j=' + csrf,
-            type: 'post',
-            data: data,
-            dataTye: 'json',
-            success: function(response) {
-                if (response.err === 0) {
-                    window.location.href = response.url;
-                } else {
-                    toastr.error(response.msg);
+        <% if (ctx.change && ctx.change.cancancel) { %>
+        $("#cancel-shenpi-btn").click(function () {
+            const data = {
+                cpid: parseInt('<%- ctx.change.id %>'),
+            };
+            $.ajax({
+                url: '/tender/<%- tender.id %>/change/project/cancel/audit?_csrf_j=' + csrf,
+                type: 'post',
+                data: data,
+                dataTye: 'json',
+                success: function (response) {
+                    if (response.err === 0) {
+                        window.location.href = response.url;
+                    } else {
+                        toastr.error(response.msg);
+                    }
                 }
-            }
+            });
         });
+        <% } %>
     })
+    /**
+     * 获取成功后的操作
+     *
+     * @param {Object} btn - 点击的按钮
+     * @return {void}
+     */
+    function codeSuccess(btn) {
+        let counter = 60;
+        btn.addClass('disabled').text('重新获取 ' + counter + 'S');
+        btn.parent().siblings('input').removeAttr('readonly').attr('placeholder', '输入短信中的6位验证码');
+        const bindBtn = $("#bind-btn");
+        bindBtn.removeClass('btn-secondary disabled').addClass('btn-primary');
 
-    <% if (ctx.change && ctx.change.cancancel) { %>
-    $("#cancel-shenpi-btn").click(function () {
-        const data = {
-            cpid: parseInt('<%- ctx.change.id %>'),
-        };
-        $.ajax({
-            url: '/tender/<%- tender.id %>/change/project/cancel/audit?_csrf_j=' + csrf,
-            type: 'post',
-            data: data,
-            dataTye: 'json',
-            success: function (response) {
-                if (response.err === 0) {
-                    window.location.href = response.url;
-                } else {
-                    toastr.error(response.msg);
-                }
+        const countDown = setInterval(function() {
+            const countString = counter - 1 <= 0 ? '' : ' ' + (counter - 1) + 'S';
+            // 倒数结束后
+            if (countString === '') {
+                clearInterval(countDown);
+                btn.removeClass('disabled');
             }
-        });
-    });
-    <% } %>
+            const text = '重新获取' + countString;
+            btn.text(text);
+            counter -= 1;
+        }, 1000);
+    }
 </script>