public function actionPwd()
 {
     $request = Yii::$app->request->post();
     //修改用户密码
     if ($request['type'] == 'pwd') {
         if (!empty($request['oldpassword']) && !empty($request['password']) && !empty($request['ispassword'])) {
             $User = new User();
             $re = $User->password($request['mer_id'], md5($request['oldpassword']));
             if ($re) {
                 preg_match('/\\w{5,17}/', $request['password'], $str);
                 preg_match('/\\w{5,17}/', $request['ispassword'], $strs);
                 //验证是否合法
                 if ($str && $strs) {
                     //验证密码密码是否一致
                     if ($request['password'] == $request['ispassword']) {
                         //修改支付密码
                         $user = User::findOne($request['mer_id']);
                         $user->user_password = md5($request['ispassword']);
                         $res = $user->save();
                         if ($res) {
                             $this->success('修改成功!', ['consumption/security']);
                         } else {
                             $this->error('修改失败!', ['consumption/merchantsave']);
                         }
                     } else {
                         $this->error('密码与确认密码不一致请重新输入!', ['consumption/merchantsave']);
                     }
                 } else {
                     $this->error('密码必须6-18位!', ['consumption/merchantsave']);
                 }
             } else {
                 $this->error('旧密码错误!', ['consumption/merchantsave']);
             }
         } else {
             $this->error('数据不能为空!', ['consumption/merchantsave']);
         }
         //修改支付密码
     } else {
         if ($request['type'] == 'pay') {
             if (!empty($request['paypassword']) && !empty($request['ispaypassword']) && !empty($request['code']) && !empty($request['mer_id'])) {
                 preg_match('/\\w{5,17}/', $request['paypassword'], $str);
                 preg_match('/\\w{5,17}/', $request['ispaypassword'], $strs);
                 //验证是否合法
                 if ($str && $strs) {
                     //验证密码密码是否一致
                     if ($request['paypassword'] == $request['ispaypassword']) {
                         //验证验证码是否合法
                         $code = new Code();
                         $code = $code->getUsercode($request['str_phone']);
                         if ($code == $request['code']) {
                             //修改支付密码
                             $merchant = Merchant::findOne($request['mer_id']);
                             $merchant->mer_paypassword = md5($request['ispaypassword']);
                             print_R($nerchant);
                             die;
                             $res = $merchant->save();
                             if ($res) {
                                 $this->success('修改成功!', ['consumption/security']);
                             } else {
                                 $this->error('修改失败!', ['consumption/merchantsave']);
                             }
                         } else {
                             $this->error('验证码错误!', ['consumption/merchantsave']);
                         }
                     } else {
                         $this->error('密码与确认密码不一致请重新输入!', ['consumption/merchantsave']);
                     }
                 } else {
                     $this->error('密码必须6-18位!', ['consumption/merchantsave']);
                 }
             } else {
                 $this->error('数据不能为空!', ['consumption/merchantsave']);
             }
             //手机验证
         } else {
             if ($request['type'] == 'phone') {
                 if (!empty($request['phone']) && !empty($request['code'])) {
                     $User = new User();
                     $re = $User->phone($request['phone']);
                     if (!$re) {
                         preg_match('/(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}/', $request['phone'], $str);
                         //验证是否合法
                         if ($str) {
                             //修改支付密码
                             $user = User::findOne($request['mer_id']);
                             $user->user_phone = $request['phone'];
                             $res1 = $user->save();
                             $user = Merchant::findOne($request['mer_id']);
                             $user->mer_phone = $request['phone'];
                             $res2 = $user->save();
                             if ($res1 && $res2) {
                                 $this->success('修改成功!', ['consumption/security']);
                             } else {
                                 $this->error('修改失败!', ['consumption/merchantsave']);
                             }
                         } else {
                             $this->error('手机号码格式不正确!', ['consumption/merchantsave']);
                         }
                     } else {
                         $this->error('手机号码已存在!', ['consumption/merchantsave']);
                     }
                 } else {
                     $this->error('数据不能为空!', ['consumption/merchantsave']);
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
<?php

use yii\helpers\Url;
use frontend\models\consumption\Merchant;
$user_id = 1;
$merchant = new Merchant();
$base = $merchant->getMerchant($user_id);
?>
<div class="t_min t_tit">当前位置:<a href="<?php 
echo Url::to(['site/index']);
?>
">首页</a> > 我的门店</div>
<!--我的趣淘学-->
<div class="t_min">
<div class="mt_le t_le">
<h1>我的门店</h1>
<ul>
<li><a href="<?php 
echo Url::to(['consumption/order']);
?>
" class="co">我的订单</a></li>
<li><a href="<?php 
echo Url::to(['consumption/comment']);
?>
">订单评论</a></li>
<li><a href="<?php 
echo Url::to(['consumption/preferential']);
?>
">优惠活动</a></li>
<h2>个人设置</h2>
<li><a href="<?php