瀏覽代碼

Merge branch 'master' of http://59.57.98.130:3000/jjhc/report

sugangqiang 2 年之前
父節點
當前提交
526af030bb

+ 55 - 0
app/common/controller/Api.php

@@ -3,7 +3,11 @@
 namespace app\common\controller;
 namespace app\common\controller;
 
 
 use app\BaseController;
 use app\BaseController;
+use app\common\api\EnterpriseApi;
 use app\common\middleware\Auth;
 use app\common\middleware\Auth;
+use app\common\model\TalentChecklog;
+use app\common\validate\Enterprise;
+use think\exception\ValidateException;
 use think\facade\Db;
 use think\facade\Db;
 use app\enterprise\api\TalentApi;
 use app\enterprise\api\TalentApi;
 use app\common\api\TalentLogApi;
 use app\common\api\TalentLogApi;
@@ -490,4 +494,55 @@ class Api extends BaseController {
         }
         }
     }
     }
 
 
+    public function changePwd(){
+        $password = \StrUtil::getRequestDecodeParam($this->request,'password');
+        $newPassword = \StrUtil::getRequestDecodeParam($this->request,'newPassword');
+        //数据校验(原密码与新密码不能为空)
+        if (\StrUtil::isEmpOrNull($password)) {
+            return json(['code' => 500, 'msg' => "请填写原密码!"]);
+        }
+        if (\StrUtil::isEmpOrNull($newPassword)) {
+            return json(['code' => 500, 'msg' => "请填写新密码!"]);
+        }
+
+        try {
+            validate(Enterprise::class)->batch(true)->scene('changePwd')->check(['password' => $password, 'password' => $newPassword]);
+            $ep = EnterpriseApi::getOne(session("user")['uid']);
+            if(!$ep){
+                return json(['code' => 500, 'msg' => "请刷新页面后重试!"]);
+            }
+            if($ep->password != hash('md5',$password)){
+                return json(['code' => 500, 'msg' => "旧密码不正确!"]);
+            }
+            $ep->password = hash('md5',$newPassword);
+            $ep->updateUser = session("user")['uid'];
+            $ep->updateTime = date("Y-m-d H:i:s");
+            $ep->save();
+
+            TalentChecklog::create([
+                'id' => getStringId(),
+                'category' => 'enterprise_change',
+                'mainId' => $ep->id,
+                'type' => 10,
+                'typeField' => null,
+                'active' => 1,
+                'state' => 1,
+                'step' => 100,
+                'stateChange' => null,
+                'description' => '用户修改密码',
+                'createTime' => date("Y-m-d H:i:s",time()),
+                'createUser' => '用户'
+            ]);
+
+            return json(['code' => 200, 'msg' => "修改成功!"]);
+
+
+        } catch (ValidateException $e){
+            $error = $e->getError();
+            return json(['code' => 500, 'msg' => array_pop($error)]);
+        }
+
+
+    }
+
 }
 }

+ 2 - 1
app/common/validate/Enterprise.php

@@ -69,6 +69,7 @@ class Enterprise extends Validate{
 
 
     protected $scene = [
     protected $scene = [
         'add'  =>  ['username','password','re_password','name','idCard','type','industryFieldNew','enterpriseTag','enterpriseType','agentName','agentPhone','verificationCode','legal','street','address','ephone','agentEmail','bankCard','bank','bankNetwork'],
         'add'  =>  ['username','password','re_password','name','idCard','type','industryFieldNew','enterpriseTag','enterpriseType','agentName','agentPhone','verificationCode','legal','street','address','ephone','agentEmail','bankCard','bank','bankNetwork'],
-        'change' => ['name','idCard','industryFieldNew','enterpriseTag','enterpriseType','agentName','agentPhone','legal','street','address','ephone','agentEmail','bankCard','bank','bankNetwork']
+        'change' => ['name','idCard','industryFieldNew','enterpriseTag','enterpriseType','agentName','agentPhone','legal','street','address','ephone','agentEmail','bankCard','bank','bankNetwork'],
+        'changePwd' => ['password']
     ];
     ];
 }
 }

+ 2 - 1
public/static/modular/gate/enterprise/enterprise_center.js

@@ -22,11 +22,12 @@ EnterpriseCenter.changePwd = function() {
 		return;
 		return;
 	}
 	}
 	if (newPassword != newRePassword) {
 	if (newPassword != newRePassword) {
+		console.log(newPassword,newRePassword)
 		Feng.info("两次新密码填写不一致!");
 		Feng.info("两次新密码填写不一致!");
 		return;
 		return;
 	}
 	}
 	var da = {"password":password, "newPassword":newPassword};
 	var da = {"password":password, "newPassword":newPassword};
-	var ajax = new $ax(Feng.ctxPath + "/api/enterpriseUser/changePwd", function(data){
+	var ajax = new $ax(Feng.ctxPath + "/common/api/changePwd", function(data){
         Feng.info(data.msg);
         Feng.info(data.msg);
         if (data.code == 200) {
         if (data.code == 200) {
         	$("#tab-3").find("input[name='password']").val('');
         	$("#tab-3").find("input[name='password']").val('');