编辑index方法:
~~~
public function index($ap=0){
}
~~~
添加代码如下:
~~~
if($this->request->method()=='POST'){
$postdata = $this->request->only(['moderate','operation']);
if($postdata['operation']=='delete'){
if(!empty($postdata['moderate'])){
OrderModel::destroy($postdata['moderate']);
return $this->success('删除成功');
}
}else if($postdata['operation']=='changetemplate'){
// 选择模板
$post = $this->request->only(['templateid']);
foreach($postdata['moderate'] as $oid)
{
$order = OrderModel::get(['uid'=> $activeuser['uid'],'oid'=> $oid]);
$order->tid = $post['templateid'];
$order->save();
}
return $this->success('模板选择成功');
}else{
echo 'none';
}
}
~~~