|
@@ -1,79 +1,111 @@
|
|
|
<?php
|
|
|
+
|
|
|
namespace app\agent\controller;
|
|
|
|
|
|
use app\agent\BaseController;
|
|
|
-use app\common\model\Worker as WorkerModel;
|
|
|
use app\common\model\Agent as AgentModel;
|
|
|
+use app\common\model\AgentMarket as AgentMarketModel;
|
|
|
|
|
|
class Agent extends BaseController
|
|
|
{
|
|
|
-
|
|
|
- public function agentForm()
|
|
|
- {
|
|
|
- $agentid = $this->access_agent['id'];
|
|
|
- $agent = AgentModel::with('worker')->findOrEmpty($agentid);
|
|
|
- return view('agent/agentform',[
|
|
|
- 'agent' => $agent
|
|
|
- ]);
|
|
|
- }
|
|
|
-
|
|
|
- public function editAgent()
|
|
|
- {
|
|
|
- $agentid = $this->access_agent['id'];
|
|
|
- $data = [
|
|
|
- 'tilpic' => input('tilpic/s'),
|
|
|
- 'realname' => input('realname/s'),
|
|
|
- 'mobile' => input('mobile/s'),
|
|
|
- 'priority' => input('priority/d'),
|
|
|
- 'picall' => input('picall/a', array()),
|
|
|
- 'telephone' => input('telephone/s'),
|
|
|
- 'latitude' => input('latitude/f'),
|
|
|
- 'longitude' => input('longitude/f'),
|
|
|
- 'province' => input('province/s'),
|
|
|
- 'city' => input('city/s'),
|
|
|
- 'district' => input('district/s'),
|
|
|
- 'address' => input('address/s'),
|
|
|
- 'details' => input('details/s'),
|
|
|
- ];
|
|
|
- $agent = AgentModel::find($agentid);
|
|
|
- $agent->save($data);
|
|
|
-
|
|
|
- exit(json_encode(array(
|
|
|
- 'code' => 0
|
|
|
- )));
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- public function myPassword()
|
|
|
- {
|
|
|
- return view('agent/mypassword');
|
|
|
- }
|
|
|
-
|
|
|
- public function editMyPassword()
|
|
|
- {
|
|
|
- $agent = $this->access_agent;
|
|
|
- $oldpassword = input('oldpassword');
|
|
|
- if ( $agent['password']!==md5($oldpassword) ){
|
|
|
- exit(json_encode(array(
|
|
|
- 'code' => 1,
|
|
|
- 'msg' => "当前密码不正确。"
|
|
|
- )));
|
|
|
- }
|
|
|
- $password = input('password');
|
|
|
- $repassword = input('repassword');
|
|
|
- if ( $password!==$repassword ){
|
|
|
- exit(json_encode(array(
|
|
|
- 'code' => 1,
|
|
|
- 'msg' => "两次输入的新密码不一致。"
|
|
|
- )));
|
|
|
- }
|
|
|
- AgentModel::update(['password'=>md5($password)], ['id'=>$agent['id']]);
|
|
|
- session('access_agent', null);
|
|
|
- echo json_encode(array(
|
|
|
- 'code' => 0
|
|
|
- ));
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
|
|
|
+ public function agentForm()
|
|
|
+ {
|
|
|
+ $agentid = $this->access_agent['id'];
|
|
|
+ $agent = AgentModel::with('worker')->findOrEmpty($agentid);
|
|
|
+ return view('agent/agentform', [
|
|
|
+ 'agent' => $agent,
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function editAgent()
|
|
|
+ {
|
|
|
+ $agentid = $this->access_agent['id'];
|
|
|
+ $data = [
|
|
|
+ 'tilpic' => input('tilpic/s'),
|
|
|
+ 'realname' => input('realname/s'),
|
|
|
+ 'mobile' => input('mobile/s'),
|
|
|
+ 'priority' => input('priority/d'),
|
|
|
+ 'picall' => input('picall/a', []),
|
|
|
+ 'telephone' => input('telephone/s'),
|
|
|
+ 'latitude' => input('latitude/f'),
|
|
|
+ 'longitude' => input('longitude/f'),
|
|
|
+ 'province' => input('province/s'),
|
|
|
+ 'city' => input('city/s'),
|
|
|
+ 'district' => input('district/s'),
|
|
|
+ 'address' => input('address/s'),
|
|
|
+ 'details' => input('details/s'),
|
|
|
+ ];
|
|
|
+ $agent = AgentModel::find($agentid);
|
|
|
+ $agent->save($data);
|
|
|
+
|
|
|
+ exit(json_encode([
|
|
|
+ 'code' => 0,
|
|
|
+ ]));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function myPassword()
|
|
|
+ {
|
|
|
+ return view('agent/mypassword');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function editMyPassword()
|
|
|
+ {
|
|
|
+ $agent = $this->access_agent;
|
|
|
+ $oldpassword = input('oldpassword');
|
|
|
+ if ($agent['password'] !== md5($oldpassword)) {
|
|
|
+ exit(json_encode([
|
|
|
+ 'code' => 1,
|
|
|
+ 'msg' => "当前密码不正确。",
|
|
|
+ ]));
|
|
|
+ }
|
|
|
+ $password = input('password');
|
|
|
+ $repassword = input('repassword');
|
|
|
+ if ($password !== $repassword) {
|
|
|
+ exit(json_encode([
|
|
|
+ 'code' => 1,
|
|
|
+ 'msg' => "两次输入的新密码不一致。",
|
|
|
+ ]));
|
|
|
+ }
|
|
|
+ AgentModel::update(['password' => md5($password)], ['id' => $agent['id']]);
|
|
|
+ session('access_agent', null);
|
|
|
+ echo json_encode([
|
|
|
+ 'code' => 0,
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function market()
|
|
|
+ {
|
|
|
+ $agentid = $this->access_agent['id'];
|
|
|
+ $market = AgentMarketModel::findOrEmpty($agentid);
|
|
|
+ return view('agent/market', [
|
|
|
+ 'market' => $market,
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function editMarket()
|
|
|
+ {
|
|
|
+ $agentid = $this->access_agent['id'];
|
|
|
+ $data = [
|
|
|
+ 'name' => input('name/s'),
|
|
|
+ 'mobile' => input('mobile/s'),
|
|
|
+ 'content' => input('content/s'),
|
|
|
+ 'is_bargain' => input('is_bargain/d'),
|
|
|
+ ];
|
|
|
+ $market = AgentMarketModel::where('agent_id',$agentid)->find();
|
|
|
+ if (empty($market)) {
|
|
|
+ $data['agent_id'] = $agentid;
|
|
|
+ AgentMarketModel::create($data);
|
|
|
+ } else {
|
|
|
+ foreach ($data as $k => $v) {
|
|
|
+ $market->$k = $v;
|
|
|
+ }
|
|
|
+ $market->save();
|
|
|
+ }
|
|
|
+
|
|
|
+ exit(json_encode([
|
|
|
+ 'code' => 0,
|
|
|
+ ]));
|
|
|
+ }
|
|
|
}
|