customer_id <= 0) { abort(redirect(url('/login'))); } } public function index() { $row = Loader::model('Customer')->getRow(['id' => $this->customer_id]); if (empty($row)) { return exception('数据有误,请检查后再操作'); } $value['hangye'] = (array) Config::get('website_hangye'); $value['zhiye'] = (array) Config::get('website_zhiye'); $value['customer'] = $row; $this->assign($value); return $this->fetch(); } public function update() { if ($this->request->isPost()) { $data = $this->request->post(); if (empty($data) || !is_array($data)) { return $this->error(Lang::get('incorrect operation')); } // //验证规则 // $validaterule = ['birthday' => 'require|date',]; // //验证提示信息 // $validatemsg = ['birthday.date' => '生日不是日期格式',]; // $valid_result = $this->validate($data, $validaterule, $validatemsg); // if (true !== $valid_result) { // // 验证失败 输出错误信息 // return $this->error($valid_result); // } $data['id'] = $this->customer_id; $model = Loader::model('Customer')->updateRow($data); if ($model && $model->getData('id')) { return $this->success(Lang::get('operation successed')); } else { return $this->error(Lang::get('operation failed')); } } return $this->error(Lang::get('incorrect operation')); } public function resetpwd() { if ($this->request->isPost()) { $data = $this->request->post(); if (empty($data) || !is_array($data)) { return $this->error(Lang::get('incorrect operation')); } //验证规则 $validaterule = [ 'password' => 'require|min:6|max:32', 'repassword' => 'require|confirm:password', ]; //验证提示信息 $validatemsg = [ 'password.require' => '密码不能为空', 'password.min' => '密码不少于6个字符', 'password.max' => '密码不多于32个字符', 'repassword.require' => '确认密码不能为空', 'repassword.confirm' => '两次密码不相符', ]; $valid_result = $this->validate($data, $validaterule, $validatemsg); if (true !== $valid_result) { // 验证失败 输出错误信息 return $this->error($valid_result); } $row = Loader::model('Customer')->getRow(['id' => $this->customer_id]); if (empty($row)) { return $this->error('数据有误,请检查后再操作'); } $data['id'] = $this->customer_id; $model = Loader::model('Customer')->updatePassword($data); if ($model && $model->getData('id')) { return $this->success('修改密码成功'); } } return $this->error(Lang::get('incorrect operation')); } public function resetemail() { if ($this->request->isPost()) { $data = $this->request->post(); if (empty($data) || !is_array($data)) { return $this->error(Lang::get('incorrect operation')); } //验证规则 $validaterule = ['email' => 'email|unique:customer,email',]; //验证提示信息 $validatemsg = [ 'email.email' => '邮箱格式错误', 'email.unique' => '邮箱已经被使用', ]; $valid_result = $this->validate($data, $validaterule, $validatemsg); if (true !== $valid_result) { // 验证失败 输出错误信息 return $this->error($valid_result); } $row = Loader::model('Customer')->getRow(['id' => $this->customer_id]); if (empty($row)) { return $this->error('数据有误,请检查后再操作'); } $model = Loader::model('Customer')->update(['email' => $data['email'], 'id' => $this->customer_id]); if ($model && $model->getData('id')) { return $this->success('修改邮箱成功'); } } return $this->error(Lang::get('incorrect operation')); } public function resettx() { if ($this->request->isPost()) { $data = $this->request->post(); $txarr = range(0, 5); shuffle($txarr); $data['picture'] = '/uploads/user/ns' . $txarr[0] . '.jpg'; $data['id'] = $this->customer_id; $model = Loader::model('Customer')->updateRow($data); if ($model && $model->getData('id')) { return $this->success(Lang::get('operation successed'), null, ['picture' => $data['picture']]); } else { return $this->error(Lang::get('operation failed')); } } return $this->error(Lang::get('incorrect operation')); } }