<?php
namespace app\index\controller;

use think\Controller;
use think\Db;
/*
个人中心等登陆页面
*/
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2020 http://myucms.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: 梦雨 <50361804@qq.com>
// +----------------------------------------------------------------------
class Home extends Controller
{
    public function _initialize()
    {
        parent::_initialize();
        if (!session('userid')) {
            $this->error('请登录', 'index/index/login');
        }
    }
    //购物车
    public function shopcart()
    {
        return view();
    }
    //支付页面
    public function pay()
    {
        if (fun_sc_p('shopDingdan', array('id' => input('id')), 'uid') != session('userid')) {
            $this->error('参数不全');
        }
        $c = Db::name('shopDingdan')->where(array('id' => input('id')))->find();
        if ($c['open'] != 1) {
            $this->error('参数不全');
        }
        $s = Db::name('shop')->where(array('id' => $c['tid']))->find();
        //查询是否有运费
        if ($s['yunfei'] == 1) {
            //无运费
            if ($s['youhui'] == 1) {
                //有优惠
                $rmb = $s['rmb'] * $c['nu'] - $s['rmbs'] * $c['nu'];
            } else {
                //无优惠
                $rmb = $s['rmb'] * $c['nu'];
            }
        } else {
            //有运费
            if ($s['youhui'] == 1) {
                //有优惠
                $rmb = $s['rmb'] * $c['nu'] - $s['rmbs'] * $c['nu'] + $s['yunfeis'];
            } else {
                //无优惠
                $rmb = $s['rmb'] * $c['nu'] + $s['yunfeis'];
            }
        }
        $this->assign(array('s' => $s, 'c' => $c, 'rmb' => $rmb)); 
        Db::name('shopDingdan')->where(array('id' => input('id')))->setField(array('gouwu' => 0,'time'=>time(),'pay'=>$s['jifen']));
        return view();
    }
    //订单页面
    public function dingdan()
    {
    
        return view();
    }
    //个人中心首页
    public function index()
    {
        return view();
    }
    //我的足迹
    public function foot()
    {
        return view();
    }
    //个人信息
    public function information()
    {
        return view();
    }
    //收货地址
    public function address()
    {
        return view();
    }
    
    //积分充值
    public function point()
    {
        return view();
    }
    //积分记录
    public function point_note()
    {
        return view();
    }
    //我的收藏
    public function shoucang()
    {
        return view();
    }
    //我的评价
    public function comment()
    {
        return view();
    }
}