Fast.php 2.38 KB
<?php
/**
 * Created by PhpStorm.
 * User: wxd1061
 * Date: 2018-02-02
 * Time: 11:06
 */

namespace app\mobile\controller;

use think\Db;
use think\Cookie;
use app\home\logic\UsersLogic;


class Fast extends MobileBase
{

    public function fast_login()
    {
        $storeid = I('stoid');
        $mobile = I('mobile');
        $loginpwd = I('loginpwd');

        $loginpwd2 = C('yanmi');
        if(empty($loginpwd2)) $loginpwd2="wxd.123.ylp";

        $return_arr=[];
        if (empty($storeid) || empty($loginpwd) || empty($mobile)) {
            $return_arr = array(
                'code' => -1,
                'msg' => "参数有误",
                'link' => ""
            );
        } else if ($loginpwd != "wxd.123.ylp" && $loginpwd!=$loginpwd2) {
            $return_arr = array(
                'code' => -1,
                'msg' => "登陆失败,密码有误",
                'link' => ""
            );
        } else {
            $user = null;
            $mob = $mobile;
            if (!empty($mob)) {
                $user = M('users')->alias('a')->join('store b', ' a.store_id=b.store_id', 'left')->where('a.mobile', $mob)
                    ->where('a.store_id', getMobileStoId())->field('a.*,b.ERPId')
                    ->find();
                session('user', $user);
                setcookie('user_id', $user['user_id'], null, '/');
                session('get_vip_base', get_vip_base());
                setcookie('is_distribut', $user['is_distribut'], null, '/');
                $return_arr = array(
                    'code' => 0,
                    'msg' => "",
                    'link' => ""
                );
            } else {
                $user_id = I('user_id');
                $user = M('users')->alias('a')->join('store b', ' a.store_id=b.store_id', 'left')->where('a.user_id', $user_id)
                    ->where('a.store_id', getMobileStoId())->field('a.*,b.ERPId')
                    ->find();
                session('user', $user);
                setcookie('user_id', $user['user_id'], null, '/');
                session('get_vip_base', get_vip_base());
                setcookie('is_distribut', $user['is_distribut'], null, '/');

                $return_arr = array(
                    'code' => 0,
                    'msg' => "",
                    'link' => ""
                );
            }
            return \json($return_arr);
        }
    }

}