<?php
namespace app\admin\controller;

use app\admin\BaseController;
use app\common\model\Sinpage as SinpageModel;

class Sinpage extends BaseController
{
	
	public function index()
	{
		$sinpage = SinpageModel::where(1)->find();
		return view('set/sinpage',[
			'sinpage' => $sinpage 
		]);
	}
	
	public function editSinpage()
	{
		$sinpage = SinpageModel::where(1)->find();
		if ($sinpage==null){
			SinpageModel::create([
				'aboutus'		=> input('aboutus/s'),
				'privacy'		=> input('privacy/s'),
				'service'		=> input('service/s'),
				'contact'		=> input('contact/s'),
                'wxmp'		    => input('wxmp/s'),
				'apptreaty'		=> input('apptreaty/s')
			]);
		}else{
			SinpageModel::update([
				'id'			=> $sinpage['id'],
				'aboutus'		=> input('aboutus/s'),
				'privacy'		=> input('privacy/s'),
				'service'		=> input('service/s'),
				'contact'		=> input('contact/s'),
                'wxmp'		    => input('wxmp/s'),
				'apptreaty'		=> input('apptreaty/s')
			]);
		}
		exit(json_encode(array(
			'code' 	=> 0,
			'data'  => ""
		)));
	}
	
}
	