<?php

/* ========================================================================
 * $Id: login.php 1372 2020-07-05 23:52:01Z onez $
 * 
 * Email: www@onez.cn
 * QQ: 6200103
 * HomePage: http://www.onez.cn
 * ========================================================================
 * Copyright 2016-2017 佳蓝科技.
 * 
 * ======================================================================== */

!defined('IN_ONEZ') && exit('Access Denied');
# 登录
# login
#请求数据
if($MODE=='$post'){
  $action=onez()->gp('action');
  if($action=='data'){
    $ac=onez()->gp('ac');
    if($ac=='submit'){
      $username=onez()->gp('username');
      if(!$username){
        return $this->error('请填写您的登录账号');
      }
      $password=onez()->gp('password');
      if(!$password){
        return $this->error('请填写您的登录密码');
      }
      $or=array();
      $or[]="key2='$username'";
      $or[]="key6='$username'";
      $or[]="key7='$username'";
      $T=$G['this']->userdb()->open('member')->one(implode(' or ',$or));
      if(!$T){
        return $this->error('账号不存在');
      }
      $password_md5=md5($password);
      if($T['key3']!=$password_md5){
        return $this->error('密码不正确');
      }
      onez('cache')->cookie($G['this']->cname,"$T[id]\t$T[username]\tsite",0);
      return $this->ok('登录成功','reload');
    }
  }
  return;
}
?>
<van-form @submit="onSubmit">
  <van-field
    v-model="login.username"
    name="username"
    label=""
    placeholder="登录账号"
  />
  <van-field
    v-model="login.password"
    type="password"
    name="password"
    label=""
    placeholder="登录密码"
  />
  <van-button block type="info" native-type="submit">
    登录
  </van-button>
</van-form>