PersonalcenterController.php 4.2 KB
<?php
// +----------------------------------------------------------------------
// | bronet [ 以客户为中心 以奋斗者为本 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
namespace app\portal\controller;

use cmf\controller\WeChatBaseController;
use think\Db;

class PersonalcenterController extends WeChatBaseController{

    /**
     * 显示个人中心页
     */
    public function personal_center(){

        $uid = cmf_get_current_user_id();
        $my_user_status = Db::name('my_user') -> where('uid',$uid) -> find();
        $weixin = Db::name('user') -> where('id',$uid) -> find();
        $this -> assign('weixin',$weixin);
        if($my_user_status['status'] == 0 || $my_user_status['status'] == 1 || $my_user_status['status'] == 3 || $my_user_status['status'] == 4 || $my_user_status['status'] == 5 || $my_user_status['status'] == 6){
            if($my_user_status['status'] == 0){
                $this -> assign('status',0);
            }
            if($my_user_status['status'] == 1 || $my_user_status['status'] == 5 || $my_user_status['status'] == 6){
                $this -> assign('status',1);
            }
            if($my_user_status['status'] == 3){
                $this -> assign('status',3);
            }
            if($my_user_status['status'] == 4){
                $this -> assign('status',4);
            }
            return $this -> fetch();
        }
        //业务员个人中心页
        if($my_user_status['status'] == 2){
            $this -> assign('weixin',$weixin);
            return $this -> fetch('personalcenter/salesman_center');
        }

    }

    /**
     * 完善个人信息页
     */
    public function perfect_information(){

        $uid = cmf_get_current_user_id();
        $my_user_status = Db::name('my_user') -> where('uid',$uid) -> find();
        if($my_user_status['status'] == 2){
            $this -> redirect('Personalcenter/personal_center');
        }else{
            if($my_user_status['status'] == 1){
                $this -> assign('status',1);
            }
            if($my_user_status['status'] == 5){
                $this -> assign('status',5);
            }
            if($my_user_status['status'] == 6){
                $this -> assign('status',6);
            }
            $weixin = Db::name('user') -> where('id',$uid) -> find();
            $this -> assign('weixin',$weixin);
            return $this -> fetch();
        }

    }


    /**
     * 我的收藏页
     */
    public function personal_collect(){

        $uid = cmf_get_current_user_id();
        $data = Db::name('collect') -> where("uid =".$uid) -> select();
        $data_count = count($data);
        if(!empty($data)){
            foreach($data as $key => $val){
                $data_goods[] = Db::name('goods') -> where("id =".$val['goods_id']) -> find();
            }
            foreach ($data_goods as $key => $val){
                $price = explode('.',$val['price']);
                $pricing = explode('.',$val['pricing']);
                $data_goods[$key]['price0'] = $price[0];
                $data_goods[$key]['price1'] = $price[1];
                $data_goods[$key]['pricing0'] = $pricing[0];
                $data_goods[$key]['pricing1'] = $pricing[1];
            }
        }
        $this -> assign('data_count',$data_count);
        $this -> assign('data_goods',$data_goods);
        return $this -> fetch();

    }

    /**
     * 填写个人信息页
     */
    public function add_information(){

        return $this -> fetch();

    }

    /**
     * 浏览记录
     */
    public function browsing_history(){

        $uid = cmf_get_current_user_id();
        $data = Db::name('browsing_history') -> where("uid =".$uid) -> select();
        foreach($data as $key => $val){
            $data_goods[] = Db::name('goods') -> where('id',$val['goods_id']) -> find();
        }
        dump($data_goods);die;
        return $this -> fetch();

    }


















}