|
@@ -4,6 +4,7 @@ namespace app\common\model;
|
|
|
|
|
|
use app\admin\model\Admin;
|
|
|
use app\common\service\MobileComputer;
|
|
|
+use think\Cache;
|
|
|
use think\Model;
|
|
|
use traits\model\SoftDelete;
|
|
|
|
|
@@ -172,4 +173,15 @@ class Mobile extends Model
|
|
|
throw_user('该号码已售或不存在');
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public function viewCountCacheName(){
|
|
|
+ return __CLASS__."view_count_{$this['id']}_".date('ymdh');
|
|
|
+ }
|
|
|
+ public function getViewCountAttr(){
|
|
|
+ return Cache::get($this->viewCountCacheName(),0);
|
|
|
+ }
|
|
|
+ public function addViewCount(){
|
|
|
+ $num=Cache::get($this->viewCountCacheName(),0);
|
|
|
+ Cache::set($this->viewCountCacheName(),$num+1);
|
|
|
+ }
|
|
|
}
|