From 11760b9bf4194ac8d3dd4545f344237204303188 Mon Sep 17 00:00:00 2001 From: augushong Date: Wed, 20 Oct 2021 20:31:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=94=A8=E6=88=B7=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B;=E6=8F=90=E4=BE=9B=E6=9B=B4=E5=A4=9Ajs=E6=93=8D?= =?UTF-8?q?=E4=BD=9C;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/model/User.php | 5 +++-- public/static/js/common.js | 29 ++++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/app/model/User.php b/app/model/User.php index 94185fd..8f6f7d5 100644 --- a/app/model/User.php +++ b/app/model/User.php @@ -16,9 +16,10 @@ class User extends Model protected $defaultSoftDelete = 0; - public function getAvatarAttr($value) + public function getAvatarSrcAttr() { - if(empty($value)){ + $value = $this->getAttr('avatar'); + if (empty($value)) { return '/static/images/avatar.png'; } diff --git a/public/static/js/common.js b/public/static/js/common.js index 40b92ed..abd543f 100644 --- a/public/static/js/common.js +++ b/public/static/js/common.js @@ -154,8 +154,27 @@ function isPC() { return flag; } -top.onbeforeunload = function (e) { - setTimeout(() => { - loading.show() - }, 2000); -} \ No newline at end of file +$.upost = function (url, data, callback) { + + if (typeof data == 'function') { + callback = data; + data = {}; + } + loading.show(); + $.post(url, data, function (result) { + + if (result.code == 500) { + + loading.hide(); + + layer.msg(result.msg) + + return false; + } + + callback(result) + + + }) + +}