浏览代码

移除签名功能

laiguoran 6 年之前
父节点
当前提交
05ac0a1686
共有 5 个文件被更改,包括 2826 次插入2785 次删除
  1. 33 0
      app/controller/profile_controller.js
  2. 9 1
      app/public/js/profile.js
  3. 1 0
      app/router.js
  4. 5 6
      app/view/profile/sign.ejs
  5. 2778 2778
      package-lock.json

+ 33 - 0
app/controller/profile_controller.js

@@ -204,6 +204,39 @@ module.exports = app => {
         }
 
         /**
+         * 电子签名删除
+         *
+         * @param {object} ctx - egg全局变量
+         * @return {void}
+         */
+        async signDelete(ctx) {
+            const response = {
+                err: 0,
+                msg: '',
+            };
+            try {
+                const sessionUser = ctx.session.sessionUser;
+
+                // 获取账号数据
+                const accountData = await ctx.service.projectAccount.getDataByCondition({ id: sessionUser.accountId });
+
+                if (accountData.sign_path === '') {
+                    throw '不存在签名';
+                }
+
+                const result = await ctx.service.projectAccount.update({ sign_path: '' }, { id: sessionUser.accountId });
+                if (!result) {
+                    throw '移除签名失败';
+                }
+            } catch (error) {
+                response.err = 1;
+                response.msg = error.toString();
+            }
+
+            ctx.body = response;
+        }
+
+        /**
          * 生成二维码
          *
          * @param {object} ctx - egg全局变量

+ 9 - 1
app/public/js/profile.js

@@ -88,11 +88,19 @@ $(document).ready(function() {
                 return false;
             }
         });
-
+        // 修改手机
         $('#change-mobile').click(function () {
             $(this).parents('.form-group').hide();
             $('#mobile-form').show();
         });
+
+        // 移除签名
+        $('#delete-sign').click(function () {
+            postData('/profile/sign/delete', {}, function (result) {
+                $('#sign-show').remove();
+                toast('移除成功', 'success');
+            })
+        })
     } catch (error) {
         console.log(error);
     }

+ 1 - 0
app/router.js

@@ -203,6 +203,7 @@ module.exports = app => {
     app.get('/profile/info', sessionAuth, 'profileController.info');
     app.get('/profile/sms', sessionAuth, 'profileController.sms');
     app.get('/profile/sign', sessionAuth, 'profileController.sign');
+    app.post('/profile/sign/delete', sessionAuth, 'profileController.signDelete');
     app.get('/profile/safe', sessionAuth, 'profileController.safe');
     app.post('/profile/save', sessionAuth, 'profileController.saveBase');
     app.post('/profile/password', sessionAuth, 'profileController.modifyPassword');

+ 5 - 6
app/view/profile/sign.ejs

@@ -31,15 +31,17 @@
                             <div><img src="/profile/qrCode" width="150"></div>
                             <small class="form-text text-danger">微信扫码使用在线手写程序</small>
                         </div>
-                        <button type="submit" class="btn btn-danger">移除签名</button>
+                        <button type="button" class="btn btn-danger" id="delete-sign">移除签名</button>
                         <div class="form-group">
                             <label>签名图预览</label>
                             <div>
                                 <div class="position-relative">
                                     <img src="/public/images/baobiao3.png">
-                                    <div class="position-absolute fixed-top" style="left:290px;top:320px">
-                                        <img src="/public/images/user-sign.png" width="90">
+                                    <% if (accountData.sign_path !== '') { %>
+                                    <div class="position-absolute fixed-top" id="sign-show" style="left:290px;top:320px">
+                                        <img src="/public/upload/sign/<%= accountData.sign_path %>" width="90">
                                     </div>
+                                    <% } %>
                                 </div>
                             </div>
                         </div>
@@ -50,9 +52,6 @@
     </div>
 </div>
 <script type="text/javascript">
-    new Vue({
-        el: '#app',
-    });
     const csrf = '<%= ctx.csrf %>';
 </script>
 <script type="text/javascript" src="/public/js/profile.js"></script>

文件差异内容过多而无法显示
+ 2778 - 2778
package-lock.json