优化用户模型;提供更多js操作;

This commit is contained in:
augushong
2021-10-20 20:31:02 +08:00
parent 1998d07a21
commit 11760b9bf4
2 changed files with 27 additions and 7 deletions

View File

@@ -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';
}

View File

@@ -154,8 +154,27 @@ function isPC() {
return flag;
}
top.onbeforeunload = function (e) {
setTimeout(() => {
loading.show()
}, 2000);
}
$.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)
})
}