1
0
Files
helper/application/common/model/MemberInfo.php
2020-08-06 14:58:51 +08:00

97 lines
2.6 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +------------------------------------------------+
// |http://www.cjango.com |
// +------------------------------------------------+
// | 修复BUG不是一朝一夕的事情等我喝醉了再说吧 |
// +------------------------------------------------+
// | Author: 小陈叔叔 <Jason.Chen> |
// +------------------------------------------------+
namespace app\common\model;
class MemberInfo extends _Init
{
protected $createTime = false;
protected $readonly = ['image'];
/**
* 获取头像地址
* @param [type] $value [description]
* @param [type] $data [description]
* @return [type] [description]
*/
protected function getAvatarAttr($value, $data)
{
$avatar = $data['headimgurl'];
if (!empty($avatar) && strpos($avatar, 'wx.qlogo.cn')) {
return rtrim($avatar, '0') . '132';
} elseif (empty($avatar)) {
return '/static/system/images/avatar.jpg';
} else {
return $avatar;
}
}
/**
* 获取头像地址
* @param [type] $value [description]
* @param [type] $data [description]
* @return [type] [description]
*/
protected function getQrcodeAttr($value, $data)
{
$path = Storage::where('id', $data['qrcode'])->value('path');
return $path ?? '';
}
/**
* 判断用户是否为 未过期的VIP会员
* @param [type] $value [description]
* @param [type] $data [description]
* @return [type] [description]
*/
protected function getIsVipAttr($value, $data)
{
if ($data['vip_time'] > time() && $data["is_vip"] == 1) {
return 1;
} else {
return 0;
}
}
protected function getVipTextAttr($value, $data)
{
if ($data['vip_time'] > time() && $data["is_vip"] == 1) {
return 'VIP会员';
} else {
return '普通会员';
}
}
protected function getVipTimeAttr($value, $data)
{
if ($value < time()) {
return '永久';
} else {
return date('Y-m-d', $value);
}
}
protected function getVipEndTimeAttr($value, $data)
{
return $data['vip_time'];
}
protected function getIndexTplAttr($value, $data)
{
if ($this->is_vip) {
return $value;
} else {
return 1;
}
}
protected function getMessageCountAttr($value, $data)
{
return Message::where('to_uid', $data['uid'])->count();
}
}