<?php

/* ========================================================================
 * $Id: setpwd.php 1816 2020-07-05 17:09:48Z onez $
 * 
 * Email: www@onez.cn
 * QQ: 6200103
 * HomePage: http://www.onez.cn
 * ========================================================================
 * Copyright 2016-2017 佳蓝科技.
 * 
 * ======================================================================== */

!defined('IN_ONEZ') && exit('Access Denied');
# edit
#请求数据
if($MODE=='$post'){
  $id=onez()->gp('id');
  $action=onez()->gp('action');
  if($action=='data'){
    $ac=onez()->gp('ac');
    if($ac=='submit'){
      if(!$G['userid']){
        return $this->error('请先登录');
      }
      $password0=onez()->gp('password0');
      $password1=onez()->gp('password1');
      $password2=onez()->gp('password2');
      onez('db')->open('member')->one("userid='$G[userid]'");
      if(md5($password0)!=$T['password']){
        return $this->error('旧密码不正确');
      }elseif(!$password1){
        return $this->error('新密码不能为空');
      }elseif($password1!=$password2){
        return $this->error('两次密码不一致不正确');
      }
      $item=array();
      $item['password']=md5($password2);
      onez('db')->open('member')->update($item,"userid='$G[userid]'");
      return $this->ok('修改成功','reload');
    }
    
    $A['pagedata']['nickname']=$G['user']['nickname'];
  }
  return;
}
?>
<van-form @submit="onSubmit" :show-error-message="false" v-if="$pagedata">
  <van-field
    name="password0"
    type="password"
    label="旧密码"
    placeholder="旧密码"
    :rules="[{ required: true, message: '请填写旧密码' }]"
  />
  <van-field
    name="password1"
    type="password"
    label="新密码"
    placeholder="填写新密码"
    :rules="[{ required: true, message: '请填写新密码' }]"
  />
  <van-field
    name="password2"
    type="password"
    label="确认新密码"
    placeholder="再次填写新密码"
    :rules="[{ required: true, message: '请再次填写新密码' }]"
  />
  <div style="margin: 16px;">
    <van-button round block type="info" native-type="submit">
      确定修改
    </van-button>
  </div>
</van-form>