新建产品控制器 /apps/index/controller/Template.php ~~~ namespace app\index\controller; use app\index\model\Order as OrderModel; use app\index\model\User as UserModel; use app\index\model\Template as TplModel; use think\Controller; use think\Request; use think\Db; class Template extends Controller { public function index() { } } ~~~ 编辑产品模型 /apps/index/model/Template.php ~~~ protected function getPnickTextAttr($value,$data) { if($data['pnick']){ return '<em class="hlt">'.$data['pnick'].'</em>'; }else{ return 'None'; } } protected function getPrateTextAttr($value,$data) { if($data['prate']){ return number_format($data['prate']*100,2).'%'; }else{ return ''; } } protected function getDnickTextAttr($value,$data) { if($data['dnick']){ return '<em class="hlt">'.$data['dnick'].'</em>'; }else{ return 'None'; } } protected function getDrateTextAttr($value,$data) { if($data['drate']){ return number_format($data['drate']*100,2).'%'; }else{ return ''; } } protected function getOnick1TextAttr($value,$data) { if($data['onick1']){ return '<em class="hlt">'.$data['onick1'].'</em>'; }else{ return 'None'; } } protected function getOrate1TextAttr($value,$data) { if($data['orate1']){ return number_format($data['orate1']*100,2).'%'; }else{ return ''; } } protected function getOnick2TextAttr($value,$data) { if($data['onick2']){ return '<em class="hlt">'.$data['onick2'].'</em>'; }else{ return 'None'; } } protected function getOrate2TextAttr($value,$data) { if($data['orate2']){ return number_format($data['orate2']*100,2).'%'; }else{ return ''; } } protected function getHighlightColorAttr($value,$data) { $colorgroup = [0 => '#FFFFFF', 1 => '#EE1B2E', 2 => '#EE5023', 3 => '#996600', 4 => '#3C9D40', 5 => '#2897C5', 6 => '#2B65B7', 7 => '#8F2A90', 8 => '#EC1282']; return $colorgroup[$data['highlight']]; } protected function getTtypeTextAttr($value,$data) { $status = [0 => '普通', 1 => '<em class="hlt">焦点</em>', 2 => '待定']; return $status[$data['ttype']]; } // 关联 // public function order() // { // return $this->hasMany('Order','oid','tid'); // } ~~~