<?php
namespace app\index\controller;
use think\Controller;
use think\Db;
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2021 http://115cms.com.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: 作者@梦雨 <50361804@qq.com>
// +----------------------------------------------------------------------
class User extends Controller
{
    //个人中心
    public function set()
    {
        hook('phpindexusera');
        if (!session('userid')) {
            $this->error('请登录',url('index/user/login'));
        }
        $html='app/template/'.muban().'/user/set.html';
        if (file_exists($html)) {
            return view($html);
        }else {
            return view('app/index/view/set.html');
        }
    }
    //积分
    public function jifen()
    {
        hook('phpindexuserb');
        if (!session('userid')) {
            $this->error('请登录',url('index/user/login'));
        }
        $html='app/template/'.muban().'/user/jifen.html';
        if (file_exists($html)) {
            return view($html);
        }else {
            return view('app/index/view/jifen.html');
        }
    }
    //文章及收藏
    public function content()
    {
        hook('phpindexuserc');
        if (!session('userid')) {
            $this->error('请登录',url('index/user/login'));
        }
        $html='app/template/'.muban().'/user/content.html';
        if (file_exists($html)) {
            return view($html);
        }else {
            return view('app/index/view/content.html');
        }
    }
    //投稿发布内容
    public function add()
    {
        hook('phpindexuserd');
        if (!session('userid')) {
            $this->error('请登录',url('index/user/login'));
        }
        $c = Db::name(get('model','html'))->where(array('id' => input('id'), 'open' => 1))->find();
        $this->assign('c', $c);
        $html='app/template/'.muban().'/user/add.html';
        if (file_exists($html)) {
            return view($html);
        }else {
            return view('app/index/view/add.html');
        }
    }
    //个人主页
    public function uid()
    {
        hook('phpindexusere');
        $c = Db::name('member')->where(array('userid' => get('id', '1')))->find();
        $this->assign('c', $c);
        if (!$c['userid']) {
            $this->error('你迷路了','/');
        }
        $html='app/template/'.muban().'/user/uid.html';
        if (file_exists($html)) {
            return view($html);
        }else {
            return view('app/index/view/uid.html');
        }
    }
    // 登录
    public function login()
    {
        hook('phpindexuserf');
        if (user('userid')) {
            $this->success('正在跳转','/');
        }
        $html='app/template/'.muban().'/user/login.html';
        if (file_exists($html)) {
            return view($html);
        }else {
            return view('app/index/view/login.html');
        }
    }
    // 注册
    public function reg()
    {
        hook('phpindexuserg');
        if (user('userid')) {
            $this->success('正在跳转','/');
        }
        $html='app/template/'.muban().'/user/reg.html';
        if (file_exists($html)) {
            return view($html);
        }else {
            return view('app/index/view/reg.html');
        }
    }
    //找回密码
    public function forget()
    {
        hook('phpindexuserh');
        $html='app/template/'.muban().'/user/forget.html';
        if (file_exists($html)) {
            return view($html);
        }else {
            return view('app/index/view/forget.html');
        }
    }
}