where(['is_delete' => 0])->order(['create_time' => 'desc'])->select(); } /** * 新增页面 * @param $data * @return bool */ public function add($data) { // 删除wxapp缓存 Wxapp::deleteCache(); return $this->save([ 'page_type' => 20, 'page_name' => $data['page']['params']['name'], 'page_data' => $data, 'wxapp_id' => self::$wxapp_id ]); } /** * 更新页面 * @param $data * @return bool */ public function edit($data) { // 删除wxapp缓存 Wxapp::deleteCache(); // 保存数据 return $this->save([ 'page_name' => $data['page']['params']['name'], 'page_data' => $data ]) !== false; } /** * 删除记录 * @return int */ public function setDelete() { if ($this['page_type'] == 10) { $this->error = '默认首页不可以删除'; return false; } // 删除wxapp缓存 Wxapp::deleteCache(); return $this->save(['is_delete' => 1]); } /** * 设为默认首页 * @return int */ public function setHome() { // 取消原默认首页 $this->where(['page_type' => 10])->update(['page_type' => 20]); // 删除wxapp缓存 Wxapp::deleteCache(); return $this->save(['page_type' => 10]); } }