Commit 3a892ee0206991fdf7aabad974c1c993866abfa1

Authored by xu
1 parent 166cb0a2
Exists in master

app-wx(v0.1.0 build 7)

F 订单详情,登录界面,注册完善
F 图片上传接口调整
Showing 46 changed files with 1675 additions and 740 deletions   Show diff stats
app-wx/config/main.php
... ... @@ -12,7 +12,7 @@ return [
12 12 'runtimePath' => Yii::getAlias('@rootRuntime').'/app-wx/',
13 13 'bootstrap' => ['log'],
14 14 'controllerNamespace' => 'app\wx\controllers',
15   - 'defaultRoute' => 'user',
  15 + 'defaultRoute' => 'order',
16 16 'modules' => [
17 17 'order' => [
18 18 'class' => 'app\wx\modules\order\Module',
... ... @@ -23,9 +23,8 @@ return [
23 23 ],
24 24 'components' => [
25 25 'user' => [
26   - 'class'=> 'app\wx\exts\User',
27 26 'identityClass' => 'app\wx\models\User',
28   - 'enableAutoLogin' => false,//是否启用自动登录
  27 + 'enableAutoLogin' => true,//是否启用自动登录
29 28 ],
30 29 'errorHandler' => [
31 30 'errorAction' => 'site/error',
... ...
app-wx/config/params.php
1 1 <?php
2 2 return [
3 3 'adminEmail' => 'admin@example.com',
4   - 'VERSION' => 'v0.1.0 build 6', // 当前发布版本号: v0.1.0 是版本号 | build 1 是编译次数
  4 + 'VERSION' => 'v0.1.0 build 7', // 当前发布版本号: v0.1.0 是版本号 | build 1 是编译次数
5 5 ];
... ...
app-wx/controllers/BaseController.php
... ... @@ -120,9 +120,13 @@ class BaseController extends AppController
120 120 * 获取 ID
121 121 * @return int|string
122 122 */
123   - public function getEngineerId()
  123 + public function getUserId()
124 124 {
125   - return 0;
  125 + if (isset(Yii::$app->user)) {
  126 + return Yii::$app->user->id;
  127 + } else {
  128 + return 0;
  129 + }
126 130 }
127 131  
128 132 /**
... ... @@ -171,17 +175,22 @@ class BaseController extends AppController
171 175 */
172 176 protected function handleMallAccessCtrl()
173 177 {
174   - //AppLog::DEBUG("BaseController: handleMallAccessCtrl()" );
175 178 $appUser = Yii::$app->getUser();
  179 +
  180 + if (YII_ENV_DEV) {
  181 + $baseURL = Yii::$app->request->getHostInfo() . Yii::$app->request->baseUrl;
  182 + } else {
  183 + $baseURL = Yii::$app->request->getHostInfo();
  184 + }
  185 +
176 186 if(YII_ENV_DEV && $appUser->isGuest){
177   - $uid = Yii::$app->params['testUID']; // 请在各自的config/params-local.php里配置
178   - header("Location: " . Yii::$app->params["baseUrl"] . "/user#login" );exit;
179   - return ;
  187 + //header("Location: " .$baseURL . "/user#login" );
  188 + //exit;
180 189 }
181   - //test和 prod 环境,进行微信登陆
  190 + //test和 prod 环境
182 191 if ($appUser->isGuest){
183   - header("Location: " . Yii::$app->params["baseUrl"] . "/user#login" );exit;
184   - return ;
  192 + header("Location: " . $baseURL . "/user#login" );
  193 + exit;
185 194 }
186 195  
187 196 }
... ... @@ -220,41 +229,6 @@ class BaseController extends AppController
220 229 return true;
221 230 }
222 231  
223   - //
224   - public function setPhoneCode($phone, $code)
225   - {
226   - Yii::$app->session['v_'.$phone] = array('create_time' => time(),'vCode' => md5($phone.'_'.$code));
227   - }
228   -
229   - public function getPhoneCode($phone)
230   - {
231   - return Yii::$app->session['v_'.$phone];
232   - }
233   -
234   - // 默认是300秒
235   - public function validatePhoneCode($phone, $code, $vaTime = 300)
236   - {
237   - $pCode = $this->getPhoneCode($phone);
238   - $cTime = time();
239   - if (empty($pCode)) {
240   - return -3;
241   - }
242   - if ($cTime > ($pCode['create_time'] + $vaTime)) {
243   - $this->unsetPhoneCode($phone);
244   - return -1;
245   - }
246   - if($pCode['vCode'] == md5($phone.'_'.$code)){
247   - return 0;
248   - }else{
249   - return -2;
250   - }
251   - }
252   -
253   - public function unsetPhoneCode($phone)
254   - {
255   - unset(Yii::$app->session['v_'.$phone]);
256   - }
257   -
258 232 /**
259 233 * 初始化web目录文件夹, 完成自动创建
260 234 */
... ...
app-wx/exts/User.php
... ... @@ -1,112 +0,0 @@
1   -<?php
2   -namespace app\wx\exts;
3   -
4   -use Yii;
5   -use yii\web\Cookie;
6   -use yii\web\User as AppUser;
7   -
8   -/**
9   - * Class User
10   - * @package app\wx\exts
11   - */
12   -class User extends AppUser
13   -{
14   -
15   - /** @var 工程师用户ID **/
16   - private $_id = null;
17   -
18   -
19   -
20   - /**
21   - * @var string the class name of the [[identity]] object.
22   - */
23   - public $identityClassForMall;
24   -
25   - /**
26   - * @inheritdoc
27   - */
28   - public function switchIdentity($identity, $duration = 0)
29   - {
30   - $this->setIdentity($identity);
31   -
32   - if (!$this->enableSession) {
33   - return;
34   - }
35   -
36   - /* Ensure any existing identity cookies are removed. */
37   - if ($this->enableAutoLogin) {
38   - Yii::$app->getResponse()->getCookies()->remove(new Cookie($this->identityCookie));
39   - }
40   -
41   - $session = Yii::$app->getSession();
42   - if (!YII_ENV_TEST) {
43   - $session->regenerateID(true);
44   - }
45   -
46   - $session->remove($this->idParam);
47   - $session->remove($this->authTimeoutParam);
48   -
49   - if ($identity) {
50   - $session->set($this->idParam, $identity->getId());
51   -
52   - if ($this->authTimeout !== null) {
53   - $session->set($this->authTimeoutParam, time() + $this->authTimeout);
54   - }
55   - if ($this->absoluteAuthTimeout !== null) {
56   - $session->set($this->absoluteAuthTimeoutParam, time() + $this->absoluteAuthTimeout);
57   - }
58   - if ($duration > 0 && $this->enableAutoLogin) {
59   - $this->sendIdentityCookie($identity, $duration);
60   - }
61   - }
62   - }
63   -
64   - /**
65   - * @inheritdoc
66   - */
67   - protected function renewAuthStatus()
68   - {
69   - $session = Yii::$app->getSession();
70   - $id = $session->getHasSessionId() || $session->getIsActive() ? $session->get($this->idParam) : null;
71   -
72   - if ($id === null) {
73   - $identity = null;
74   - } else {
75   - $class = 'domain\user\models\User';
76   - $identity = $class::findIdentity($id);
77   - }
78   -
79   - $this->setIdentity($identity);
80   -
81   - if ($identity !== null && ($this->authTimeout !== null || $this->absoluteAuthTimeout !== null)) {
82   - $expire = $this->authTimeout !== null ? $session->get($this->authTimeoutParam) : null;
83   - $expireAbsolute = $this->absoluteAuthTimeout !== null ? $session->get($this->absoluteAuthTimeoutParam) : null;
84   - if ($expire !== null && $expire < time() || $expireAbsolute !== null && $expireAbsolute < time()) {
85   - $this->logout(false);
86   - } elseif ($this->authTimeout !== null) {
87   - $session->set($this->authTimeoutParam, time() + $this->authTimeout);
88   - }
89   - }
90   -
91   - if ($this->enableAutoLogin) {
92   - if ($this->getIsGuest()) {
93   - $this->loginByCookie();
94   - } elseif ($this->autoRenewCookie) {
95   - $this->renewIdentityCookie();
96   - }
97   - }
98   - }
99   -
100   -
101   - /**
102   - * @return int
103   - */
104   - public function getId()
105   - {
106   - if(null === $this->_id){
107   - $session = Yii::$app->getSession();
108   - $this->_id = $session->getHasSessionId() || $session->getIsActive() ? $session->get($this->idParam) : null;
109   - }
110   - return (int)$this->_id;
111   - }
112   -}
app-wx/models/User.php
... ... @@ -3,16 +3,17 @@
3 3 namespace app\wx\models;
4 4  
5 5 use Yii;
6   -use yii\log\Logger;
  6 +use yii\web\IdentityInterface;
7 7 use domain\user\models\User as UserModel;
8 8  
9 9 /**
10 10 * Class User
11 11 * @package app\wx\models
12 12 */
13   -class User extends UserModel
  13 +class User extends UserModel implements IdentityInterface
14 14 {
15 15  
  16 + static $id = null;
16 17 public function register()
17 18 {
18 19  
... ... @@ -30,5 +31,110 @@ class User extends UserModel
30 31  
31 32 }
32 33  
  34 + /**
  35 + * Finds an identity by the given ID.
  36 + *
  37 + * @param string|int $id the ID to be looked for
  38 + * @return IdentityInterface|null the identity object that matches the given ID.
  39 + */
  40 + public static function findIdentity($id)
  41 + {
  42 + return static::findOne($id);
  43 + }
  44 +
  45 + /**
  46 + * Finds an identity by the given token.
  47 + *
  48 + * @param string $token the token to be looked for
  49 + * @return IdentityInterface|null the identity object that matches the given token.
  50 + */
  51 + public static function findIdentityByAccessToken($token, $type = null)
  52 + {
  53 + return static::findOne(['access_token' => $token]);
  54 + }
  55 +
  56 + /**
  57 + * @inheritdoc
  58 + */
  59 + public function getId()
  60 + {
  61 + return self::getIdFromSession();
  62 + }
  63 +
  64 + /**
  65 + * @inheritdoc
  66 + */
  67 + public function getAuthKey()
  68 + {
  69 + return '';
  70 + }
  71 +
  72 + /**
  73 + * @inheritdoc
  74 + */
  75 + public function validateAuthKey($authKey)
  76 + {
  77 + return true;
  78 + }
  79 +
  80 + /**
  81 + * Validates password
  82 + *
  83 + * @param string $password password to validate
  84 + * @return bool if password provided is valid for current user
  85 + */
  86 + public function validatePassword($password)
  87 + {
  88 + return true ;//Yii::$app->security->validatePassword($password, $this->password_hash);
  89 + }
  90 +
  91 + /**
  92 + * Generates password hash from password and sets it to the model
  93 + *
  94 + * @param string $password
  95 + */
  96 + public function setPassword($password)
  97 + {
  98 + $this->password_hash = Yii::$app->security->generatePasswordHash($password);
  99 + }
  100 +
  101 + /**
  102 + * Generates "remember me" authentication key
  103 + */
  104 + public function generateAuthKey()
  105 + {
  106 + $this->auth_key = Yii::$app->security->generateRandomString();
  107 + }
  108 +
  109 + /**
  110 + * Generates new password reset token
  111 + */
  112 + public function generatePasswordResetToken()
  113 + {
  114 + $this->password_reset_token = Yii::$app->security->generateRandomString() . '_' . time();
  115 + }
  116 +
  117 + /**
  118 + * Removes password reset token
  119 + */
  120 + public function removePasswordResetToken()
  121 + {
  122 + $this->password_reset_token = null;
  123 + }
  124 +
  125 + /**
  126 + * @return mixed|null
  127 + */
  128 + protected static function getIdFromSession()
  129 + {
  130 + if (null === self::$id){
  131 + $user = Yii::$app->getUser();
  132 + $session = Yii::$app->getSession();
  133 + $id = $session->getHasSessionId() || $session->getIsActive() ? $session->get($user->idParam) : null;
  134 + self::$id = $id;
  135 + }
  136 +
  137 + return self::$id;
  138 + }
33 139  
34 140 }
... ...
app-wx/modules/order/controllers/BaseController.php
... ... @@ -7,7 +7,7 @@ use app\wx\controllers\BaseController as AppBaseController;
7 7  
8 8 /**
9 9 * Class BaseController
10   - * @package app\wx\modules\toutiao\controllers
  10 + * @package app\wx\modules\order\controllers
11 11 */
12 12 class BaseController extends AppBaseController
13 13 {
... ... @@ -19,6 +19,6 @@ class BaseController extends AppBaseController
19 19 public function init()
20 20 {
21 21 parent::init(); // TODO: Change the autogenerated stub
22   - //$this->handleMallAccessCtrl();
  22 + $this->handleMallAccessCtrl();
23 23 }
24 24 }
25 25 \ No newline at end of file
... ...
app-wx/modules/order/controllers/CustomerBaseController.php 0 → 100644
... ... @@ -0,0 +1,24 @@
  1 +<?php
  2 +
  3 +namespace app\wx\modules\order\controllers;
  4 +
  5 +use Yii;
  6 +use app\wx\controllers\BaseController as AppBaseController;
  7 +
  8 +/**
  9 + * Class BaseController
  10 + * @package app\wx\modules\order\controllers
  11 + */
  12 +class CustomerBaseController extends AppBaseController
  13 +{
  14 + public $layout = 'main';
  15 +
  16 + /**
  17 + * @throws yii\web\BadRequestHttpException
  18 + */
  19 + public function init()
  20 + {
  21 + parent::init(); // TODO: Change the autogenerated stub
  22 +
  23 + }
  24 +}
0 25 \ No newline at end of file
... ...
app-wx/modules/order/controllers/CustomerController.php 0 → 100644
... ... @@ -0,0 +1,98 @@
  1 +<?php
  2 +
  3 +namespace app\wx\modules\order\controllers;
  4 +
  5 +use Yii;
  6 +
  7 +
  8 +use domain\order\RepairOrderRepository;
  9 +use domain\order\RepairOrderStatus;
  10 +
  11 +use stdClass;
  12 +
  13 +/**
  14 + * 控制器
  15 + */
  16 +class CustomerController extends CustomerBaseController
  17 +{
  18 + /**
  19 + * 首页
  20 + */
  21 + public function actionIndex()
  22 + {
  23 + return $this->render('/default/cindex');
  24 + }
  25 +
  26 + /**
  27 + * @return string
  28 + */
  29 + public function actionOrderDetails()
  30 + {
  31 + $e = new stdClass();
  32 + $e->success = false;
  33 + $e->message = 'ok';
  34 + $orderUUId = $this->request->post('id');
  35 + $md5Mobile = $this->request->post('sn');
  36 +
  37 + $orderModel = RepairOrderRepository::findOne(['uuid' => $orderUUId]);
  38 + if (empty($orderModel)) {
  39 + $e->message = '找不到该订单';
  40 + return $this->renderJson($e);
  41 + }
  42 + $brokenImageModels = RepairOrderRepository::findOrderImageAll(['repair_order_id' => $orderModel->id]);
  43 + $brokenImages = [];
  44 + $baseURL = Yii::$app->request->getHostInfo();
  45 + foreach($brokenImageModels as $k => $v) {
  46 + $brokenImages[] = $baseURL.'/'.$v->image_path;
  47 + }
  48 + $totalPrice = $orderModel->order_price;
  49 + $rPlans = RepairOrderRepository::findOrderPlansAll(['repair_order_id' => $orderModel->id]);
  50 + $repairPlans = [];
  51 + foreach($rPlans as $k => $plan) {
  52 + $repairPlans[] = ['plan' => $plan['repair_plan'] ,'price' => $plan['price']];
  53 + }
  54 + $fImages = RepairOrderRepository::findOrderFinishImageAll(['repair_order_id' => $orderModel->id]);
  55 + $finishImages = [];
  56 + foreach($fImages as $k => $image) {
  57 + $finishImages[] = $baseURL.'/'.$image['image_path'];
  58 + }
  59 + $hasComment = false;
  60 +
  61 + $e->success = true;
  62 + $e->item = [
  63 + 'carNo' => $orderModel->car_no,
  64 + 'carModel' => $orderModel->car_model,
  65 + 'customer' => $orderModel->customer,
  66 + 'mobile' => '1*****'.substr($orderModel->contact_mobile,7,4),
  67 + 'preRepair' => $orderModel->predict_fault,
  68 + 'repairPrice' => $orderModel->predict_price.'元',
  69 + 'preFinishDate' => date('Y-m-d H:00', $orderModel->predict_finish_time),
  70 + 'orderDateTime' => date('Y-m-d H:00', $orderModel->created_at),
  71 + 'status' => RepairOrderStatus::getEnLabel($orderModel->status),
  72 + 'hasComment' => $hasComment,
  73 + 'brokenImages' => $brokenImages,
  74 + 'repairPlans' => $repairPlans,
  75 + 'totalPrice' => $totalPrice,
  76 + 'finishImages' => $finishImages
  77 + ];
  78 +
  79 + return $this->renderJson($e);
  80 + }
  81 +
  82 + /**
  83 + * @return string
  84 + */
  85 + public function actionSubmitRate()
  86 + {
  87 + $e = new stdClass();
  88 + $e->success = false;
  89 + $e->message = 'ok';
  90 + $star = $this->request->post('star');
  91 + $comment = $this->request->post('comment');
  92 +
  93 + //echo $star.'_'.$comment;
  94 + $e->success = true;
  95 + return $this->renderJson($e);
  96 + }
  97 +
  98 +}
0 99 \ No newline at end of file
... ...
app-wx/modules/order/controllers/DefaultController.php
... ... @@ -3,8 +3,17 @@
3 3 namespace app\wx\modules\order\controllers;
4 4  
5 5 use Yii;
6   -use stdClass;
7 6 use yii\helpers\HtmlPurifier;
  7 +use yii\base\Exception;
  8 +
  9 +use domain\order\RepairOrder;
  10 +use domain\order\RepairOrderImages;
  11 +use domain\order\RepairOrderRepository;
  12 +use domain\order\RepairOrderStatus;
  13 +use domain\order\RepairFinishImages;
  14 +use domain\order\RepairOrderRepairPlan;
  15 +
  16 +use stdClass;
8 17  
9 18 /**
10 19 * 控制器
... ... @@ -27,19 +36,58 @@ class DefaultController extends BaseController
27 36 $e = new stdClass();
28 37 $e->success = false;
29 38 $e->message = 'ok';
30   - $userId = 0;
31   - $req = Yii::$app->request;
32   - $carNo = HtmlPurifier::process($req->post('carNo'), ['HTML.Allowed' => '']);
33   - $carModel = HtmlPurifier::process($req->post('carModel'), ['HTML.Allowed' => '']);
34   - $customer = HtmlPurifier::process($req->post('customer'), ['HTML.Allowed' => '']);
35   - $phone = HtmlPurifier::process($req->post('phone'), ['HTML.Allowed' => '']);
36   - $preRepair = HtmlPurifier::process($req->post('preRepair'), ['HTML.Allowed' => '']);
37   - $repairPrice = HtmlPurifier::process($req->post('repairPrice'), ['HTML.Allowed' => '']);
38   - $finishDate = HtmlPurifier::process($req->post('finishDate'), ['HTML.Allowed' => '']);
39   - $images = $req->post('images');
40   -
41   - //echo $carNo.'_'.$carModel.'_'.$customer.'_'.$phone.'_'.$preRepair.'_'.$repairPrice.'_'.$finishDate.'_'.json_encode($images);
42   - $e->success = true;
  39 + $userId = $this->getUserId();
  40 + $req = Yii::$app->request;
  41 + $carNo = HtmlPurifier::process($req->post('carNo'), ['HTML.Allowed' => '']);
  42 + $carModel = HtmlPurifier::process($req->post('carModel'), ['HTML.Allowed' => '']);
  43 + $customer = HtmlPurifier::process($req->post('customer'), ['HTML.Allowed' => '']);
  44 + $phone = HtmlPurifier::process($req->post('phone'), ['HTML.Allowed' => '']);
  45 + $preRepair = HtmlPurifier::process($req->post('preRepair'), ['HTML.Allowed' => '']);
  46 + $predictPrice = HtmlPurifier::process($req->post('repairPrice'), ['HTML.Allowed' => '']);
  47 + $finishDate = HtmlPurifier::process($req->post('finishDate'), ['HTML.Allowed' => '']);
  48 + $images = $req->post('images');
  49 +
  50 + if (empty($carNo)) {
  51 + $e->message = '车牌号码未填';
  52 + return $this->renderJson($e);
  53 + }
  54 +
  55 + if (empty($carModel)) {
  56 + $e->message = '车辆型号未填';
  57 + return $this->renderJson($e);
  58 + }
  59 +
  60 + if (empty($phone)) {
  61 + $e->message = '联系电话未填';
  62 + return $this->renderJson($e);
  63 + }
  64 +
  65 + $data = [
  66 + 'user_id' => $userId,
  67 + 'car_no' => $carNo,
  68 + 'car_model' => $carModel,
  69 + 'customer' => $customer,
  70 + 'contact_mobile' => $phone,
  71 + 'predict_fault' => $preRepair,
  72 + 'predict_price' => $predictPrice,
  73 + 'predict_finish_time' => strtotime($finishDate.':00:00'),
  74 + 'status' => RepairOrderStatus::REPAIRING,
  75 + ];
  76 + $tran = Yii::$app->db->beginTransaction();
  77 + try {
  78 + $repairOrder = RepairOrder::create($data);
  79 + $uuid = $repairOrder->uuid;
  80 + RepairOrderImages::createBrokenImages($repairOrder->id, $uuid, $images);
  81 + $tran->commit();
  82 + RepairOrderImages::mvBrokenImages($uuid, $images);
  83 + $e->orderId = $uuid;
  84 + $e->success = true;
  85 + } catch(Exception $ex) {
  86 + $tran->rollBack();
  87 + $e->orderId = '';
  88 + $e->message = '提交失败';
  89 + }
  90 +
43 91 return $this->renderJson($e);
44 92 }
45 93  
... ... @@ -106,34 +154,48 @@ class DefaultController extends BaseController
106 154 $e = new stdClass();
107 155 $e->success = false;
108 156 $e->message = 'ok';
  157 + $orderUUId = $this->request->post('id');
  158 + $userId = $this->getUserId();
  159 + $orderModel = RepairOrderRepository::findOne(['uuid' => $orderUUId, 'user_id' => $userId]);
  160 + if (empty($orderModel)) {
  161 + $e->message = '找不到该订单';
  162 + return $this->renderJson($e);
  163 + }
  164 + $brokenImageModels = RepairOrderRepository::findOrderImageAll(['repair_order_id' => $orderModel->id]);
  165 + $brokenImages = [];
  166 + $baseURL = Yii::$app->request->getHostInfo();
  167 + foreach($brokenImageModels as $k => $v) {
  168 + $brokenImages[] = $baseURL.'/'.$v->image_path;
  169 + }
  170 + $totalPrice = $orderModel->order_price;
  171 + $rPlans = RepairOrderRepository::findOrderPlansAll(['repair_order_id' => $orderModel->id]);
  172 + $repairPlans = [];
  173 + foreach($rPlans as $k => $plan) {
  174 + $repairPlans[] = ['plan' => $plan['repair_plan'] ,'price' => $plan['price']];
  175 + }
  176 + $fImages = RepairOrderRepository::findOrderFinishImageAll(['repair_order_id' => $orderModel->id]);
  177 + $finishImages = [];
  178 + foreach($fImages as $k => $image) {
  179 + $finishImages[] = $baseURL.'/'.$image['image_path'];
  180 + }
  181 + $hasComment = false;
109 182  
110 183 $e->success = true;
111 184 $e->item = [
112   - 'carNo' => 'XX12345',
113   - 'carModel' => '宝马X3',
114   - 'customer' => '李先生',
115   - 'mobile' => '13900139001',
116   - 'preRepair' => '更换轮胎',
117   - 'repairPrice' => '300元',
118   - 'preFinishDate' => '2019-12-15 15:00',
119   - 'orderDateTime' => '2019-12-14 15:00',
120   - 'status' => 'finish',
121   - 'hasComment' => false,
122   - 'brokenImages' => [
123   - Yii::$app->request->baseUrl.'/i/order/demo.jpg', Yii::$app->request->baseUrl.'/i/order/demo.jpg', Yii::$app->request->baseUrl.'/i/order/demo.jpg'
124   - ],
125   - 'repairPlans' => [
126   - ['content' => '更换车胎',
127   - 'price' => 450],
128   - ['content' => '更换车胎',
129   - 'price' => 450],
130   - ['content' => '更换车胎',
131   - 'price' => 450],
132   - ],
133   - 'totalPrice' => 1350,
134   - 'finishImages' => [
135   - Yii::$app->request->baseUrl.'/i/order/demo.jpg', Yii::$app->request->baseUrl.'/i/order/demo.jpg', Yii::$app->request->baseUrl.'/i/order/demo.jpg'
136   - ]
  185 + 'carNo' => $orderModel->car_no,
  186 + 'carModel' => $orderModel->car_model,
  187 + 'customer' => $orderModel->customer,
  188 + 'mobile' => $orderModel->contact_mobile,
  189 + 'preRepair' => $orderModel->predict_fault,
  190 + 'repairPrice' => $orderModel->predict_price.'元',
  191 + 'preFinishDate' => date('Y-m-d H:00', $orderModel->predict_finish_time),
  192 + 'orderDateTime' => date('Y-m-d H:00', $orderModel->created_at),
  193 + 'status' => RepairOrderStatus::getEnLabel($orderModel->status),
  194 + 'hasComment' => $hasComment,
  195 + 'brokenImages' => $brokenImages,
  196 + 'repairPlans' => $repairPlans,
  197 + 'totalPrice' => $totalPrice,
  198 + 'finishImages' => $finishImages
137 199 ];
138 200  
139 201 return $this->renderJson($e);
... ... @@ -149,23 +211,38 @@ class DefaultController extends BaseController
149 211 $e->message = 'ok';
150 212 $repairPlans = $this->request->post('plans');
151 213 $images = $this->request->post('images');
  214 + $orderUUId = $this->request->post('id');
  215 + $userId = $this->getUserId();
  216 + $orderModel = RepairOrderRepository::findOne(['uuid' => $orderUUId, 'user_id' => $userId]);
152 217  
153   - //print_r($images);
154   - //print_r($repairPlans);
155   - $e->success = true;
156   - return $this->renderJson($e);
157   - }
  218 + if (empty($orderModel)) {
  219 + $e->message = '找不到订单';
  220 + return $this->renderJson($e);
  221 + }
158 222  
159   - public function actionSubmitRate()
160   - {
161   - $e = new stdClass();
162   - $e->success = false;
163   - $e->message = 'ok';
164   - $star = $this->request->post('star');
165   - $comment = $this->request->post('comment');
  223 + if (RepairOrderStatus::FINISH == $orderModel->status) {
  224 + $e->message = '订单已完成,不能编辑';
  225 + return $this->renderJson($e);
  226 + }
  227 + $orderId = $orderModel->id;
  228 + $tran = Yii::$app->db->beginTransaction();
  229 + try {
  230 + $totalPrice = RepairOrderRepairPlan::batchCreate($orderId, $repairPlans);
  231 + RepairFinishImages::createFinishImages($orderId, $orderModel->uuid, $images);
  232 + $orderModel->status = RepairOrderStatus::FINISH;
  233 + $orderModel->finish_at = time();
  234 + $orderModel->order_price = $totalPrice;
  235 + $orderModel->save();
  236 + $tran->commit();
  237 + RepairFinishImages::mvFinishImages($orderModel->uuid, $images);
  238 + $e->success = true;
  239 + } catch (Exception $ex) {
  240 + $tran->rollBack();
  241 + $e->success = false;
  242 + $e->message = '提交失败';
  243 + $e->innerMEssage = $ex->getMessage();
  244 + }
166 245  
167   - echo $star.'_'.$comment;
168   - $e->success = true;
169 246 return $this->renderJson($e);
170 247 }
171 248  
... ...
app-wx/modules/order/views/default/cindex.php 0 → 100644
... ... @@ -0,0 +1,40 @@
  1 +<?php
  2 +
  3 +use yii\helpers\Url;
  4 +
  5 +$baseUrl = Url::base(true);
  6 +$assets = $this->getAssetManager();
  7 +$asset = $assets->getBundle('app\wx\assets\AppAsset');
  8 +
  9 +function img($file, $path = '/i/')
  10 +{
  11 + return \Yii::$app->request->baseUrl . $path.$file;
  12 +}
  13 +?>
  14 +<style>
  15 +
  16 +</style>
  17 +<div class="views">
  18 + <div class="view view-main">
  19 + <?=$this->render("@app/views/widgets/ui-loading")?>
  20 + </div>
  21 +</div>
  22 +<div>
  23 +
  24 +</div>
  25 +<?=$this->render('pages/rate-template', ['asset' => $asset])?>
  26 +<?=$this->render('pages/customer-order-template', ['asset' => $asset])?>
  27 +
  28 +<script>
  29 + require.config({baseUrl: $site.assets_url + '/js/',urlArgs : "v=" + require.version});
  30 + require([
  31 + 'order-app'
  32 + ],
  33 + function(app){
  34 + app.bootstrap({
  35 + baseUrl: $site.base_url
  36 + });
  37 + });
  38 +</script>
  39 +
  40 +<?=$this->render("@app/views/widgets/stat-code")?>
... ...
app-wx/modules/order/views/default/index.php
... ... @@ -21,10 +21,10 @@ function img($file, $path = &#39;/i/&#39;)
21 21 </div>
22 22  
23 23 <?=$this->render('pages/index-template', ['asset' => $asset])?>
24   -<?=$this->render('pages/rate-template', ['asset' => $asset])?>
25 24 <?=$this->render('pages/submit-template', ['asset' => $asset])?>
26 25 <?=$this->render('pages/cost-list-template', ['asset' => $asset])?>
27 26 <?=$this->render('pages/order-details-template', ['asset' => $asset])?>
  27 +<?=$this->render('pages/customer-order-template', ['asset' => $asset])?>
28 28  
29 29 <script>
30 30 require.config({baseUrl: $site.assets_url + '/js/',urlArgs : "v=" + require.version});
... ...
app-wx/modules/order/views/default/pages/customer-order-template.php 0 → 100644
... ... @@ -0,0 +1,199 @@
  1 +<?php
  2 +use yii\helpers\Url;
  3 +$baseUrl = Url::base(true);
  4 +?>
  5 +<style>
  6 + body,div,p,span,input,ul,li{padding: 0;margin: 0}
  7 + input{-webkit-appearance: none;}
  8 + ul,li{list-style: none }
  9 + #customer-order .content-div { width:100%; background: #fff; display:inline-flex;padding-top: 1rem}
  10 + #customer-order .left-title-div {width:33%; font-size:1rem; font-weight:400; color:rgba(0,0,0,1); line-height:1.81rem;}
  11 + #customer-order .center-content-div {width:47%; font-size:1rem; font-weight:400; color:rgba(118,118,118,1); line-height:1.81rem;}
  12 + #customer-order .right-content-div {width:20%;font-size:0.94rem; font-weight:400; color:rgba(255,255,255,1);line-height:1.81rem;}
  13 + #customer-order .content-div-two {width:100%; background: #fff; display:inline-flex;height: 1.81rem;}
  14 + #customer-order .page-content{ background-color: #ECF0F2 }
  15 + #customer-order .content-list-div {padding-bottom: 1rem}
  16 + #customer-order .status-tip {width: 4.81rem;
  17 + padding: 0.2rem 0;
  18 + height: 1.81rem;
  19 + background-color:#ff7b24;
  20 + border-top-left-radius: 1rem;
  21 + border-bottom-left-radius: 1rem;
  22 + text-align: center;
  23 + float: right;}
  24 + #customer-order .btn-submit-cls{width:85%;text-align: center;margin: 2rem auto;margin-top:2.5rem;
  25 + background:rgba(255,135,40,1); border-radius:2rem; font-size:1.06rem; font-weight:400;
  26 + color:rgba(255,255,255,1);padding:1rem 0 }
  27 + #customer-order .pic-div {
  28 + width:100%; background: #fff; display:inline-flex;height: 1.81rem;
  29 + }
  30 + #customer-order .pic-image-div {
  31 + width: 100%;background: #fff; padding-bottom: 1rem; margin: 0 auto;
  32 + }
  33 + #customer-order .pic-image-list {
  34 + padding: 0.5rem 1rem;box-sizing: border-box;width:100%;display: block;overflow: hidden;
  35 + }
  36 + #customer-order .pic-image-list .img-cls{width:25%;box-sizing: border-box;float:left;padding-top:0.3rem;padding-right:0.3rem;}
  37 +
  38 + #customer-order .pic-class { margin-right: 0.5rem width:100%;height:0;padding-bottom: 100%;overflow:hidden;
  39 + background-position: center center;
  40 + background-repeat: no-repeat;
  41 + -webkit-background-size:cover;
  42 + -moz-background-size:cover;background-size:cover;position: relative}
  43 + #customer-order .padding-left-1rem {padding-left: 1rem}
  44 + #customer-order .content-wrapper{background:#fff;padding:1rem;box-sizing: border-box;margin-bottom:0.8rem;}
  45 + #customer-order .content-wrapper .content-title{font-size: 1.06rem;color:#000;font-weight: bold;padding-bottom: 0.8rem;}
  46 + #customer-order .content-wrapper .bullet-point{color: #fff;background: #ff7b24;border: 0;display: block;height:1rem;width: 1.0rem;text-align: center;border-radius: 0.5rem;font-size: 0.7rem;line-height: 1rem;}
  47 + #customer-order .content-wrapper .plan-right-cls{padding-bottom: 0.5rem;margin-left:0.5rem;width:100%;}
  48 + #customer-order .content-wrapper .plan-price-cls{font-size:0.75rem;color:#333;line-height: 1.5rem;}
  49 + #customer-order .content-wrapper .repair-plan-list{width:100%;display: block;position: relative}
  50 + #customer-order .content-wrapper .repair-plan-list:after{content:'';width:100%;height: 1px;background:#DBDBDB;display:block;}
  51 + #customer-order .content-wrapper .total-price-cls{margin-top:0.5rem;color:#000}
  52 + #customer-order .content-wrapper .finish-image-list{width:100%;display:block;}
  53 + #customer-order .content-wrapper .finish-image-ul{width:100%;display:block;overflow: hidden;box-sizing: border-box;}
  54 + #customer-order .content-wrapper .finish-image-li{width:25%;display:block;padding-top:0.3rem;padding-right:0.3rem;float:left;box-sizing: border-box;}
  55 + #customer-order .content-wrapper .finishImage{width: 100%;
  56 + height: 0;
  57 + padding-bottom: 100%;
  58 + overflow: hidden;
  59 + background-position: center center;
  60 + background-repeat: no-repeat;
  61 + -webkit-background-size: cover;
  62 + -moz-background-size: cover;
  63 + background-size: cover;
  64 + position: relative;}
  65 + #customer-order .content-wrapper .comment-box{width:100%;display: flex;color:#000;align-items: center;justify-content: space-between;font-size: 1rem;}
  66 + #customer-order .content-wrapper .rate-btn-cls{color:#fff;border-radius: 1.5rem;padding:0.6rem 0.8rem;text-align: center;background:#FF8728;width:4rem;}
  67 + #customer-order .content-wrapper .comment-txt-cls{color:#000;font-size: 1rem;line-height: 1.5rem }
  68 +</style>
  69 +<script id="customer-order-template" type="text/template">
  70 + <div class="pages">
  71 + <div class="page" id="customer-order" style="background: #fff">
  72 + <div class="page-content">
  73 + <div class="content-list-div">
  74 + <div class="content-div">
  75 + <div class="left-title-div"><span class="padding-left-1rem">车牌号码</span></div>
  76 + <div class="center-content-div">{{item.carNo}} </div>
  77 + <div class="right-content-div">
  78 + {{#js_compare "'working' == this.item.status"}}
  79 + <span class="status-tip">
  80 + 进行中
  81 + </span>
  82 + {{else}}
  83 + <span class="status-tip" style="color:#FFA903;background:#fef0d5">
  84 + 已完成
  85 + </span>
  86 + {{/js_compare}}
  87 + </div>
  88 + </div>
  89 + <div class="content-div-two">
  90 + <div class="left-title-div"><span class="padding-left-1rem">车辆型号</span></div>
  91 + <div class="center-content-div">{{item.carModel}}</div>
  92 + <div class="right-content-div">
  93 + </div>
  94 + </div>
  95 + <div class="content-div-two">
  96 + <div class="left-title-div"><span class="padding-left-1rem">客户名称</span></div>
  97 + <div class="center-content-div">{{item.customer}}</div>
  98 + <div class="right-content-div">
  99 + </div>
  100 + </div>
  101 + <div class="content-div-two">
  102 + <div class="left-title-div"><span class="padding-left-1rem">联系电话</span></div>
  103 + <div class="center-content-div">{{item.mobile}}</div>
  104 + <div class="right-content-div">
  105 + </div>
  106 + </div>
  107 + <div class="content-div-two">
  108 + <div class="left-title-div"><span class="padding-left-1rem">预估维修内容</span></div>
  109 + <div class="center-content-div">{{item.preRepair}}</div>
  110 + <div class="right-content-div">
  111 + </div>
  112 + </div>
  113 + <div class="content-div-two">
  114 + <div class="left-title-div"><span class="padding-left-1rem">预估维修费用</span></div>
  115 + <div class="center-content-div">{{item.repairPrice}}</div>
  116 + <div class="right-content-div">
  117 + </div>
  118 + </div>
  119 + <div class="content-div-two">
  120 + <div class="left-title-div"><span class="padding-left-1rem">预估完成时间</span></div>
  121 + <div class="center-content-div">{{item.preFinishDate}}</div>
  122 + <div class="right-content-div">
  123 + </div>
  124 + </div>
  125 + <div class="content-div-two">
  126 + <div class="left-title-div"><span class="padding-left-1rem">订单创建时间</span></div>
  127 + <div class="center-content-div">{{item.orderDateTime}}</div>
  128 + <div class="right-content-div">
  129 + </div>
  130 + </div>
  131 + <div class="pic-div">
  132 + <div class="left-title-div"><span class="padding-left-1rem">车损照片</span></div>
  133 + </div>
  134 + <div class="pic-image-div">
  135 + <div class="pic-image-list">
  136 + {{#each item.brokenImages}}
  137 + <div class="img-cls">
  138 + <div class="pic-class" style="background-image: url({{this}})"></div>
  139 + </div>
  140 + {{/each}}
  141 + </div>
  142 + </div>
  143 + </div>
  144 + {{#js_compare "'working' == this.item.status"}}
  145 + <div class="finish-submit btn-submit-cls"> 完成维修 </div>
  146 + {{/js_compare}}
  147 + {{#js_compare "'finish' == this.item.status"}}
  148 + <div class="content-wrapper">
  149 + <div class="content-title">维修费用清单</div>
  150 + <ul class="repair-plan-list">
  151 + {{#each this.item.repairPlans}}
  152 + <li style="width:100%;display: flex;">
  153 + <div class="bullet-point">{{@index+1}}</div>
  154 + <div class="plan-right-cls">
  155 + <p style="color:#000;font-size: 1rem;">{{plan}}</p>
  156 + <p class="plan-price-cls">金额: ¥{{price}}</p>
  157 + </div>
  158 + </li>
  159 + {{/each}}
  160 + </ul>
  161 + <div class="total-price-cls">总金额: ¥{{this.item.totalPrice}}</div>
  162 + </div>
  163 +
  164 + {{#js_compare "this.item.finishImages.length > 0"}}
  165 + <div class="content-wrapper">
  166 + <div class="content-title">维修完成照片</div>
  167 + <div class="finish-image-list">
  168 + <ul class="finish-image-ul">
  169 + {{#each this.item.finishImages}}
  170 + <li class="finish-image-li">
  171 + <div class="finishImage" style="background-image:url('{{this}}')"> </div></li>
  172 + {{/each}}
  173 + </ul>
  174 + </div>
  175 + </div>
  176 + {{/js_compare}}
  177 +
  178 + <div class="content-wrapper" style="font-size: 1rem;">
  179 + GK车管家 <span style="color:#FF8728">《质保承诺》</span>
  180 + </div>
  181 +
  182 + <div class="content-wrapper">
  183 + {{#js_compare "this.item.hasComment"}}
  184 + <div class="content-title" style="padding-bottom: 0.5rem">评价</div>
  185 + <div class="comment-txt-cls">服务评价:超赞</div>
  186 + <div class="comment-txt-cls">这次修车体验很好,服务满意!</div>
  187 + {{else}}
  188 +
  189 + <div class="comment-box"><div>您对此次维修服务体验如何?</div>
  190 + <div class="rate-btn-cls">去评价</div>
  191 + </div>
  192 +
  193 + {{/js_compare}}
  194 + </div>
  195 + {{/js_compare}}
  196 + </div>
  197 + </div>
  198 + </div>
  199 +</script>
... ...
app-wx/modules/order/views/default/pages/order-details-template.php
... ... @@ -152,7 +152,7 @@ $baseUrl = Url::base(true);
152 152 <li style="width:100%;display: flex;">
153 153 <div class="bullet-point">{{@index+1}}</div>
154 154 <div class="plan-right-cls">
155   - <p style="color:#000;font-size: 1rem;">{{content}}</p>
  155 + <p style="color:#000;font-size: 1rem;">{{plan}}</p>
156 156 <p class="plan-price-cls">金额: ¥{{price}}</p>
157 157 </div>
158 158 </li>
... ... @@ -185,9 +185,12 @@ $baseUrl = Url::base(true);
185 185 <div class="comment-txt-cls">服务评价:超赞</div>
186 186 <div class="comment-txt-cls">这次修车体验很好,服务满意!</div>
187 187 {{else}}
  188 + <div class="comment-box">车主暂未评价</div>
  189 + <!--
188 190 <div class="comment-box"><div>您对此次维修服务体验如何?</div>
189 191 <div class="rate-btn-cls">去评价</div>
190 192 </div>
  193 + -->
191 194 {{/js_compare}}
192 195 </div>
193 196 {{/js_compare}}
... ...
app-wx/modules/order/views/default/pages/submit-template.php
... ... @@ -94,8 +94,8 @@ $baseUrl = Url::base(true);
94 94 <li class="s-li-item">
95 95 <div class="s-li-div">
96 96 <label class="s-li-label">预估完成时间<span class="require-cls">*</span></label>
97   - <div class="s-li-div-input-box">
98   - <input class="s-li-div-input finishDate" type="text" value="" placeholder="请填写预估完成时间" />
  97 + <div class="s-li-div-input-box finish-date-btn">
  98 + <input class="s-li-div-input finishDate finish-date-input" type="text" value="" readonly placeholder="请填写预估完成时间" />
99 99 </div>
100 100 </div>
101 101 </li>
... ...
app-wx/modules/user/controllers/DefaultController.php
... ... @@ -2,14 +2,9 @@
2 2  
3 3 namespace app\wx\modules\user\controllers;
4 4  
5   -use common\helpers\ImageManager;
6   -use common\helpers\ImageUtils;
7   -use common\models\EngineerProfile;
8   -use domain\toutiao\TtDefaultImageRepository;
9   -use domain\toutiao\TtNewsImageRepository;
10   -use domain\toutiao\TtNewsRepository;
11   -use domain\toutiao\TtType;
  5 +
12 6 use Yii;
  7 +use common\helpers\ImageManager;
13 8 use stdClass;
14 9  
15 10 /**
... ... @@ -23,7 +18,8 @@ class DefaultController extends BaseController
23 18 */
24 19 public function actionIndex()
25 20 {
26   - return $this->render('index');
  21 + $params = ['isGuest' => Yii::$app->getUser()->isGuest];
  22 + return $this->render('index', $params);
27 23 }
28 24  
29 25 /**
... ... @@ -52,19 +48,10 @@ class DefaultController extends BaseController
52 48 return $this->renderJson($e);
53 49 }
54 50  
55   - $dir = Yii::getAlias('@site') . "/tmp";
56   - $fileArr = explode('.', $_FILES["file"]['name']);
57   - $tt = time();
58   - $filename = 'auto_'.$tt.md5($_FILES["file"]['name']).'.'.end($fileArr);
59   - $minFileName = 'auto_'.$tt.md5($_FILES["file"]['name']).'_min'.'.'.end($fileArr);
60   - $saveFilePath = $dir.'/'.$filename;
61   - move_uploaded_file($_FILES["file"]['tmp_name'], $saveFilePath);
62   - $tmpUrl = $tmpMinFile= $this->site->base_url.'/tmp/'.$filename;
63   - $imgSource = $this->_imageCreateFromPath($saveFilePath);
64   - if ($imgSource) {
65   - ImageUtils::resizeImage($imgSource, 100, 100, $dir.'/'.$minFileName);
66   - $tmpMinFile = $this->site->base_url.'/tmp/'.$minFileName;
67   - }
  51 + $uploadInfo = ImageManager::uploadImg($_FILES["file"]);
  52 + $filename = $uploadInfo[0];
  53 + $tmpUrl = $this->site->base_url.'/'.$uploadInfo[2];
  54 + $tmpMinFile = $this->site->base_url.'/'.$uploadInfo[3];
68 55  
69 56 $e->success = true;
70 57 $e->tmpFile = $filename;
... ... @@ -75,20 +62,4 @@ class DefaultController extends BaseController
75 62 return $this->renderJson($e);
76 63 }
77 64  
78   - /**
79   - * @param $imgPath
80   - * @return null|resource
81   - */
82   - private function _imageCreateFromPath($imgPath)
83   - {
84   - list($width, $height, $type, $attr) = getimagesize($imgPath);
85   - switch ($type) {
86   - case 3: // png
87   - return imagecreatefrompng($imgPath);
88   - case 2: // jpeg
89   - return imagecreatefromjpeg($imgPath);
90   - default:
91   - return null;
92   - }
93   - }
94 65 }
95 66 \ No newline at end of file
... ...
app-wx/modules/user/controllers/LoginController.php
... ... @@ -2,17 +2,13 @@
2 2  
3 3 namespace app\wx\modules\user\controllers;
4 4  
5   -use common\helpers\ImageManager;
6   -use common\helpers\ImageUtils;
  5 +use Yii;
  6 +use domain\user\User;
7 7 use common\helpers\Utils;
8   -use common\models\EngineerProfile;
9   -use app\wx\models\User;
10 8 use common\helpers\Log as AppLog;
11   -use domain\toutiao\TtDefaultImageRepository;
12   -use domain\toutiao\TtNewsImageRepository;
13   -use domain\toutiao\TtNewsRepository;
14   -use domain\toutiao\TtType;
15   -use Yii;
  9 +use domain\user\UserRepository;
  10 +use common\helpers\ImageManager;
  11 +use domain\user\PhoneCode;
16 12 use stdClass;
17 13  
18 14 /**
... ... @@ -20,7 +16,7 @@ use stdClass;
20 16 */
21 17 class LoginController extends BaseController
22 18 {
23   -
  19 + const CODE_EXPIRE = 120;
24 20 /**
25 21 * @return string
26 22 */
... ... @@ -29,19 +25,143 @@ class LoginController extends BaseController
29 25 $e = new stdClass();
30 26 $e->success = false;
31 27 $e->message = 'ok';
32   - $e->codeDuration = 70;
  28 + $e->codeDuration = self::CODE_EXPIRE;
33 29 $action = $this->request->get('action');
  30 + $mobile = $this->request->get('mobile');
  31 + if (!Utils::isPhone($mobile)) {
  32 + $e->message = '请输入合格手机号码';
  33 + return $this->renderJson($e);
  34 + }
  35 + $tt = time();
34 36 if ('login' == $action) {
  37 + $userInfo = UserRepository::findOne(['mobile' => $mobile]);
  38 + if (empty($userInfo)) {
  39 + $e->message = '登录失败,该手机未注册';
  40 + return $this->renderJson($e);
  41 + }
  42 + $code = $this->getLoginCode($mobile);
  43 + if ($code) {
  44 + // 发送短信
  45 + } else {
  46 + $code = $this->setLoginCode($mobile);
  47 + // 发送短信
  48 + }
35 49  
36 50 } else {
  51 + $userModel = UserRepository::findOne(['mobile' => $mobile]);
  52 + if ($userModel) {
  53 + $e->message = '该手机号码已经注册过';
  54 + return $this->renderJson($e);
  55 + }
37 56  
  57 + $phoneCode = $this->getRegisterCode($mobile);
  58 + if ($phoneCode) {
  59 + $code = $phoneCode;
  60 + //发送短信
  61 + } else {
  62 + $code = $this->setRegisterCode($mobile);
  63 + //发送短信
  64 + }
38 65 }
39 66  
40 67 $e->success = true;
  68 + $e->testCode = $code;
  69 +
41 70 return $this->renderJson($e);
42 71 }
43 72  
44 73 /**
  74 + * @param $mobile
  75 + * @return string
  76 + */
  77 + private function setRegisterCode($mobile)
  78 + {
  79 + $session = Yii::$app->session;
  80 + $code = Utils::randRegCode(6);
  81 + $codeKey = $mobile."_".PhoneCode::REGISTER_TYPE;
  82 + $sessionStr = json_encode(['content' => $code, 'expire_at' => time() + self::CODE_EXPIRE]);
  83 + $session->set($codeKey, $sessionStr);
  84 +
  85 + return $code;
  86 + }
  87 +
  88 + /**
  89 + * @param $mobile
  90 + * @return bool
  91 + */
  92 + private function removeRegisterCode($mobile)
  93 + {
  94 + $session = Yii::$app->session;
  95 + $codeKey = $mobile."_".PhoneCode::REGISTER_TYPE;
  96 + return $session->remove($codeKey);
  97 + }
  98 +
  99 + /**
  100 + * @param $mobile
  101 + * @return mixed
  102 + */
  103 + private function getRegisterCode($mobile)
  104 + {
  105 + $session = Yii::$app->session;
  106 + $codeKey = $mobile."_".PhoneCode::REGISTER_TYPE;
  107 + $sessionContent = $session->get($codeKey);
  108 + if (!$sessionContent) {
  109 + return null;
  110 + }
  111 +
  112 + $sessionContent = json_decode($sessionContent, true);
  113 + if ($sessionContent && isset($sessionContent['expire_at']) && $sessionContent['expire_at'] > time()) {
  114 + return $sessionContent['content'];
  115 + } else {
  116 + $session->remove($codeKey);
  117 + return null;
  118 + }
  119 + }
  120 +
  121 + /**
  122 + * @param $mobile
  123 + * @return mixed
  124 + */
  125 + private function getLoginCode($mobile)
  126 + {
  127 + $session = Yii::$app->session;
  128 + $codeKey = $mobile."_".PhoneCode::LOGIN_TYPE;
  129 + $sessionContent = $session->get($codeKey);
  130 + if (!$sessionContent) {
  131 + return null;
  132 + }
  133 + $sessionContent = json_decode($sessionContent, true);
  134 + if ($sessionContent && isset($sessionContent['expire_at']) && $sessionContent['expire_at'] > time()) {
  135 + return $sessionContent['content'];
  136 + } else {
  137 + $session->remove($codeKey);
  138 + return null;
  139 + }
  140 + }
  141 +
  142 + /**
  143 + * @param $mobile
  144 + * @return string
  145 + */
  146 + private function setLoginCode($mobile)
  147 + {
  148 + $session = Yii::$app->session;
  149 + $code = Utils::randRegCode(6);
  150 + $codeKey = $mobile."_".PhoneCode::LOGIN_TYPE;
  151 + $sessionStr = json_encode(['content' => $code, 'expire_at' => time() + self::CODE_EXPIRE]);
  152 + $session->set($codeKey, $sessionStr);
  153 +
  154 + return $code;
  155 + }
  156 +
  157 + private function removeLoginCode($mobile)
  158 + {
  159 + $session = Yii::$app->session;
  160 + $codeKey = $mobile."_".PhoneCode::LOGIN_TYPE;
  161 + $session->remove($codeKey);
  162 + }
  163 +
  164 + /**
45 165 * 注册界面
46 166 * @return string
47 167 */
... ... @@ -53,7 +173,7 @@ class LoginController extends BaseController
53 173 $name = $this->request->post('name');
54 174 $mobile = $this->request->post('mobile');
55 175 $code = $this->request->post('code');
56   - $img = $this->request->post('img');
  176 + $licensePic = $this->request->post('licensePic');
57 177 if (empty($name)) {
58 178 $e->message = '车厂名称必填';
59 179 return $this->renderJson($e);
... ... @@ -68,15 +188,43 @@ class LoginController extends BaseController
68 188 $e->message = '验证码必填';
69 189 return $this->renderJson($e);
70 190 }
71   - if (empty($img)) {
  191 + if (empty($licensePic)) {
72 192 $e->message = '请上传营业执照';
73 193 return $this->renderJson($e);
74 194 }
75 195 // 校验验证码
  196 + $vcode = $this->getRegisterCode($mobile);
  197 + if (empty($vcode)) {
  198 + $e->message = '验证码已经超时请重新发送';
  199 + return $this->renderJson($e);
  200 + }
  201 + if ($vcode !== $code) {
  202 + $e->message = '验证码不对';
  203 + return $this->renderJson($e);
  204 + }
76 205 // 检查车厂名称是否注册了
77 206 // 检查手机号码是否注册了
78   - echo $name.'_'.$mobile.'_'.$code.'_'.$img;
79   - $e->success = true;
  207 + $userMobile = UserRepository::findOne(['mobile' => $mobile]);
  208 + if ($userMobile) {
  209 + $e->message = '该手机号已经注册过维修厂,请更换其他手机号';
  210 + return $this->renderJson($e);
  211 + }
  212 +
  213 + $uData = [
  214 + 'mobile' => $mobile,
  215 + 'name' => $name,
  216 + 'user_name' => $mobile
  217 + ];
  218 + $userEntity = User::create($uData);
  219 + $this->removeRegisterCode($mobile);
  220 + $saveImageInfo = ImageManager::mvUploadImage($licensePic, $userEntity->uuid);
  221 + $userEntity->license_pic = $saveImageInfo[0].$saveImageInfo[1];
  222 + $userEntity->save();
  223 + if ($this->processLogin($userEntity)) {
  224 + $e->success = true;
  225 + } else {
  226 + $e->message = '注册成功但是登录失败';
  227 + }
80 228  
81 229 return $this->renderJson($e);
82 230 }
... ... @@ -93,7 +241,6 @@ class LoginController extends BaseController
93 241 $mobile = $this->request->post('mobile');
94 242 $code = $this->request->post('code');
95 243  
96   -
97 244 if (!Utils::isPhone($mobile)) {
98 245 $e->message = '手机号码格式不对';
99 246 return $this->renderJson($e);
... ... @@ -105,11 +252,29 @@ class LoginController extends BaseController
105 252 }
106 253  
107 254 // 校验验证码
108   - // 检查车厂名称是否注册了
109   - // 检查手机号码是否注册了
110   - $e->success = true;
111   - $userInfo = \domain\user\models\User::findOne(1);
112   - $this->processLogin($userInfo);
  255 + $logVcode = $this->getLoginCode($mobile);
  256 + if (empty($logVcode)) {
  257 + $e->message = '该手机登录码过期';
  258 + return $this->renderJson($e);
  259 + }
  260 + if ($code != $logVcode ) {
  261 + $e->message = '验证码有误,请确认!';
  262 + return $this->renderJson($e);
  263 + }
  264 +
  265 + $where = ['mobile' => $mobile];
  266 + $userInfo = UserRepository::findOne($where);
  267 + if (empty($userInfo)) {
  268 + $e->message = '登录失败,该手机未注册';
  269 + return $this->renderJson($e);
  270 + }
  271 + if($this->processLogin($userInfo)) {
  272 + $this->removeLoginCode($mobile);
  273 + $e->success = true;
  274 + } else {
  275 + $e->message = '登录失败';
  276 + }
  277 +
113 278 return $this->renderJson($e);
114 279 }
115 280  
... ... @@ -121,10 +286,6 @@ class LoginController extends BaseController
121 286 */
122 287 protected function processLogin($userEntity)
123 288 {
124   - if(!($userEntity instanceof User)) {
125   - AppLog::debug("processLogin: 返回 UserEntity 失败");
126   - return false;
127   - }
128 289 /**
129 290 * 登陆时间为7000秒,目前微信API的access token 的 expires_in 为 7200秒
130 291 */
... ...
app-wx/modules/user/views/default/index.php
... ... @@ -10,6 +10,11 @@ function img($file, $path = &#39;/i/&#39;)
10 10 {
11 11 return \Yii::$app->request->baseUrl . $path.$file;
12 12 }
  13 +if ($isGuest) {
  14 + $isGuest = true;
  15 +} else {
  16 + $isGuest = 0;
  17 +}
13 18 ?>
14 19 <style>
15 20 input{-webkit-appearance: none;}
... ... @@ -25,6 +30,7 @@ function img($file, $path = &#39;/i/&#39;)
25 30 <?=$this->render('pages/login-template', ['asset' => $asset])?>
26 31  
27 32 <script>
  33 + var isGuest = <?=$isGuest?>;
28 34 require.config({baseUrl: $site.assets_url + '/js/',urlArgs : "v=" + require.version});
29 35 require([
30 36 'user-app'
... ...
app-wx/modules/user/views/default/pages/register-template.php
... ... @@ -65,11 +65,12 @@ $baseUrl = Url::base(true);
65 65 <div class="upload-section">
66 66 <div class="upload-title">上传营业执照</div>
67 67 <div class="upload-img-box">
68   - <div class="upload-item upload-btn-cls">
  68 + <div class="upload-item upload-btn-cls licensePic">
69 69 <input type="file" id="upload-btn" class="upload-input-cls" name="file" accept="image/*"/>
70 70 </div>
71 71 </div>
72 72 </div>
  73 + <!--
73 74 <div class="upload-section">
74 75 <div class="upload-title">维修场门头照</div>
75 76 <div class="upload-img-box">
... ... @@ -78,6 +79,7 @@ $baseUrl = Url::base(true);
78 79 </div>
79 80 </div>
80 81 </div>
  82 + -->
81 83 </div>
82 84 <div class="action-box">
83 85 <div class="register-btn-cls register-btn">注册</div>
... ...
common/helpers/ImageManager.php
... ... @@ -2,8 +2,9 @@
2 2  
3 3 namespace common\helpers;
4 4  
  5 +use Yii;
5 6 /**
6   - * 极办公系统的图片资源管理器
  7 + * 系统的图片资源管理器
7 8 * Class ImageManager
8 9 * @package app\wx\helpers
9 10 */
... ... @@ -20,39 +21,10 @@ class ImageManager
20 21 /**
21 22 * 根据系统模块划分, 定义图片一级目录结构
22 23 */
23   - private static $USER_ROOT_PATH = 'user/'; // 用户
24   - private static $DEVICE_ROOT_PATH = 'device/'; // 设备库
25   - public static $ORDER_ROOT_PATH = 'order/'; // 订单
26   - private static $ENGINEER_ROOT_PATH = 'engineer/'; // 工程师
27   - private static $BIND_APPLY_ROOT_PATH = 'bind_apply/'; // 设备绑定申请
28   - private static $SYSTEM_SETTING_ROOT_PATH = 'system_setting/'; // 系统设置
29   - private static $TEMP_ROOT_PATH = 'tmp/'; // 临时目录
30   - private static $INVOICE_ROOT_PATH = 'invoice/'; // 电子发票
31   - private static $USER_ADS_ROOT_PATH = 'user_ads/'; // 小程序用户端广告
32   - private static $ENGINEER_ACT_ROOT_PATH = 'engineer/act/'; // 工程师活动
33   - private static $DEDUCTION_ACTIVITY_ROOT_PATH = 'marketing/'; // 抵扣金活动分享图片路径
34   - private static $CUSTOMIZED_CODE_PATH = 'customized_qrcode/'; // 定制二维码图片路径
35   - private static $SHOP_COVER_PATH = 'shop_cover/'; // 商店头部的cover
36   - private static $SHOP_ITEM_IMAGE_PATH = 'shop_item_image/'; // 商品主图路径
37   - private static $SHOP_ITEM_DESC_IMAGE_PATH = 'shop_item_desc_image/'; // 商品详情图路径
38 24  
39   -
40   - /**
41   - * 文件名拼接随机串再md5,避免重复
42   - * @param $length
43   - * @return null|string
44   - */
45   - private static function rand($length)
46   - {
47   - $str = null;
48   - $strPol = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
49   - $max = strlen($strPol) - 1;
50   - for ($i = 0; $i < $length; $i++) {
51   - $str .= $strPol[mt_rand(0, $max)];
52   - }
53   -
54   - return $str;
55   - }
  25 + public static $MAINTENANCE_PATH = 'maintenance/'; // 维修厂用户注册的图片路径
  26 + public static $ORDER_BROKEN_PATH = 'broken_order/'; // 订单里面车损坏的图片
  27 + public static $ORDER_FINISH_PATH = 'finish_order/'; // 维修好车的时候的图片
56 28  
57 29 /**
58 30 * @param $path 数据库存储的图片相对路径
... ... @@ -60,372 +32,86 @@ class ImageManager
60 32 */
61 33 public static function getUrl($path, $style = null)
62 34 {
63   - if (empty($path)) return '';
64   - return ImageServiceHelper::getUrl($path, $style);
65   - }
66   -
67   - public static function getVoiceUrl($path)
68   - {
69   - if (empty($path)) return '';
70   - return ImageServiceHelper::getUrl($path);
71   - }
72   -
73   - /**
74   - * 添加上传图片
75   - * @param $tmpPath
76   - * @param $savePath
77   - */
78   - public static function add($tmpPath, $savePath)
79   - {
80   - return ImageServiceHelper::add($tmpPath, $savePath);
81   - }
82   -
83   - /**
84   - * 替换图片
85   - * @param $oldPath
86   - * @param $newPath
87   - * @param $tmpPath
88   - */
89   - public static function replace($oldPath, $newPath, $tmpPath)
90   - {
91   - return ImageServiceHelper::replace($oldPath, $newPath, $tmpPath);
92   - }
93   -
94   - /**
95   - * 移动图片存放位置
96   - * @param $oldPath
97   - * @param $newPath
98   - * @return mixed
99   - */
100   - public static function move($oldPath, $newPath)
101   - {
102   - ImageServiceHelper::move($oldPath, $newPath);
103   - }
104   -
105   - /**
106   - * 删除旧图片
107   - * @param $path
108   - */
109   - public static function delete($path)
110   - {
111   - ImageServiceHelper::delete($path);
112   - }
113   -
114   - /**
115   - * 获取[临时图片]的存储路径: tmp/20170509/[16位md5加密串].jpg
116   - * @param $suffix 图片后缀, 如'.jpg'
117   - * @return string
118   - */
119   - public static function getTempImgPath($suffix)
120   - {
121   - $imageName = md5(time() . self::rand(5)) . '.' . $suffix;
122   - $basePath = self::$TEMP_ROOT_PATH . date("Ymd");
123   - $savePath = $basePath . '/' . $imageName;
124   - return $savePath;
125   - }
126   -
127   - /**
128   - * [用户]=> 获取[用户头像]的存储路径: user/20170509/[userId]/[16位md5加密串].jpg
129   - * @param $userId
130   - * @param $suffix 图片后缀, 如'.jpg'
131   - * @return string
132   - */
133   - public static function getUserAvatarPath($userId, $suffix)
134   - {
135   - $imageName = md5(time() . $userId . self::rand(5)) . '.' . $suffix;
136   - $basePath = self::$USER_ROOT_PATH . date("Ymd") . '/' . $userId;
137   - $savePath = $basePath . '/' . $imageName;
138   - return $savePath;
139   - }
140   -
141   -
142   - /**
143   - * [设备库]=> 获取[品牌LOGO]的存储路径: device/brand/[16位md5加密串].jpg
144   - * @param $suffix 图片后缀, 如'.jpg'
145   - * @return string
146   - */
147   - public static function getBrandLogoPath($suffix)
148   - {
149   - $imageName = md5(time() . self::rand(5)) . '.' . $suffix;
150   - $basePath = self::$DEVICE_ROOT_PATH . 'brand';
151   - $savePath = $basePath . '/' . $imageName;
152   - return $savePath;
153   - }
154   -
155   - /**
156   - * [设备库]=> 获取[设备分类图标]的存储路径: device/cat/[deviceCatId]/[16位md5加密串].jpg
157   - * @param $deviceCatId
158   - * @param $suffix 图片后缀, 如'.jpg'
159   - * @return string
160   - */
161   - public static function getDeviceCatIconPath($deviceCatId, $suffix)
162   - {
163   - $imageName = md5(time() . $deviceCatId . self::rand(5)) . '.' . $suffix;
164   - $basePath = self::$DEVICE_ROOT_PATH . 'cat/' . $deviceCatId;
165   - $savePath = $basePath . '/' . $imageName;
166   - return $savePath;
167   - }
168   -
169   - /**
170   - * 获取图片的路径
171   - * device/12/344f8c701b864c1782129fe4f2209514.jpg 设备/分类id/图片名称
172   - * @param $deviceCatId
173   - * @param $suffix
174   - * @return string
175   - */
176   - public static function getDeviceImgPath($deviceCatId, $suffix)
177   - {
178   - $imageName = md5(time() . $deviceCatId . self::rand(5)) . '.' . $suffix;
179   - $basePath = self::$DEVICE_ROOT_PATH . $deviceCatId;
180   - $savePath = $basePath . '/' . $imageName;
181   - return $savePath;
182   - }
183   -
184   - /**
185   - * [设备库]=> 获取[型号LOGO]的存储路径: device/model/[16位md5加密串].jpg
186   - * @param $suffix 图片后缀, 如'.jpg'
187   - * @return string
188   - */
189   - public static function getModelLogoPath($suffix)
190   - {
191   - $imageName = md5(time() . self::rand(5)) . '.' . $suffix;
192   - $basePath = self::$DEVICE_ROOT_PATH . 'model';
193   - $savePath = $basePath . '/' . $imageName;
194   - return $savePath;
195   - }
196   -
197   -
198   - /**
199   - * [订单]=> 获取[订单故障图片]的存储路径: order/20170509/[orderNo]/fault/[16位md5加密串].jpg
200   - * @param $orderNo
201   - * @param $suffix 图片后缀, 如'.jpg'
202   - * @return string
203   - */
204   - public static function getOrderFaultImgPath($orderNo, $suffix)
205   - {
206   - $imageName = md5(time() . $orderNo . self::rand(5)) . '.' . $suffix;
207   - $basePath = self::$ORDER_ROOT_PATH . date("Ymd") . '/' . $orderNo . '/fault';
208   - $savePath = $basePath . '/' . $imageName;
209   - return $savePath;
210   - }
211   -
212   - /**
213   - * [订单]=> 获取[订单质保申请图片]的存储路径: order/20170509/[orderNo]/appeal/[16位md5加密串].jpg
214   - * @param $orderNo
215   - * @param $suffix 图片后缀, 如'.jpg'
216   - * @return string
217   - */
218   - public static function getOrderAppealImgPath($orderNo, $suffix)
219   - {
220   - $imageName = md5(time() . $orderNo . self::rand(5)) . '.' . $suffix;
221   - $basePath = self::$ORDER_ROOT_PATH . date("Ymd") . '/' . $orderNo . '/appeal';
222   - $savePath = $basePath . '/' . $imageName;
223   - return $savePath;
224   - }
225 35  
226   - /**
227   - * [工程师]=> 获取[工程师图片]的存储路径: engineer/20170509/[engineerId]/[16位md5加密串].jpg
228   - * @param $engineerId
229   - * @param $suffix 图片后缀, 如'.jpg'
230   - * @param $fileName 图片另外的名称,工程师图片可以是头像,身份证等
231   - * @return string
232   - */
233   - public static function getEngineerImgPath($engineerId, $fileName = '', $suffix = 'jpg')
234   - {
235   - $imageName = md5(time() . $engineerId . $fileName . self::rand(5)) . '.' . $suffix;
236   - $basePath = self::$ENGINEER_ROOT_PATH . date("Ymd") . '/' . $engineerId;
237   - $savePath = $basePath . '/' . $imageName;
238   - return $savePath;
  36 + return $path;
239 37 }
240 38  
241 39 /**
242   - * [工程师]=> 获取[工程师定制二维码图片]的存储路径: engineer/20170509/customized_qrcode/[engineerId]/[16位md5加密串].jpg
243   - * @param $engineerId
244   - * @param $suffix 图片后缀, 如'.jpg'
245   - * @param $fileName 图片另外的名称
  40 + * @param $licensePic
  41 + * @param $fileTypePath
246 42 * @return string
247 43 */
248   - public static function getEngineerQrcodeImgPath($engineerId, $fileName = '', $suffix = 'jpg')
  44 + public static function mvUploadImage($licensePic, $uuid, $fileTypePath = '')
249 45 {
250   - $imageName = md5(time() . $engineerId . $fileName . self::rand(5)) . '.' . $suffix;
251   - $basePath = self::$ENGINEER_ROOT_PATH . date("Ymd") . '/' . self::$CUSTOMIZED_CODE_PATH . $engineerId;
252   - $savePath = $basePath . '/' . $imageName;
253   - return $savePath;
254   - }
  46 + $dir = Yii::getAlias('@site') . "/tmp";
  47 + $tmpFilePath = $dir.'/'.$licensePic;
  48 + $fileArr = explode('.', $licensePic);
255 49  
256   - /**
257   - * [工程师]=> 获取[考题图片]的存储路径: engineer/exam/[16位md5加密串].jpg
258   - * @param $suffix 图片后缀, 如'.jpg'
259   - * @return string
260   - */
261   - public static function getExamImgPath($suffix)
262   - {
263   - $imageName = md5(time() . self::rand(5)) . '.' . $suffix;
264   - $basePath = self::$ENGINEER_ROOT_PATH . 'exam';
265   - $savePath = $basePath . '/' . $imageName;
266   - return $savePath;
267   - }
  50 + $minFileName = $fileArr[0].'_min'.'.'.end($fileArr);
  51 + $tmpMinFilePath = $dir.'/'.$minFileName;
268 52  
  53 + $desPathFile = self::genImagePath($uuid, $fileTypePath);
269 54  
270   - /**
271   - * [设备绑定申请]=> 获取[设备绑定申请图片]的存储路径: bind_apply/20170509/[applyId]/[16位md5加密串].jpg
272   - * @param $applyId
273   - * @param $suffix 图片后缀, 如'jpg'
274   - * @return string
275   - */
276   - public static function getBindApplyImgPath($applyId, $filename, $suffix = "jpg")
277   - {
278   - $imageName = md5(time() . $filename . self::rand(5)) . '.' . $suffix;
279   - $basePath = self::$BIND_APPLY_ROOT_PATH . date("Ymd") . '/' . $applyId;
280   - $savePath = $basePath . '/' . $imageName;
281   - return $savePath;
282   - }
  55 + $aimPath = Yii::getAlias('@site')."/".$desPathFile .$licensePic;
  56 + FileUtil::moveFile($tmpFilePath, $aimPath,true);
283 57  
284   - /**
285   - * [系统设置]=> 获取[用户小程序-设置图片]的存储路径: system_setting/mina/[16位md5加密串].jpg
286   - * @param $suffix 图片后缀, 如'.jpg'
287   - * @return string
288   - */
289   - public static function getMinaSettingImgPath($suffix)
290   - {
291   - $imageName = md5(time() . self::rand(5)) . '.' . $suffix;
292   - $basePath = self::$SYSTEM_SETTING_ROOT_PATH . 'mina';
293   - $savePath = $basePath . '/' . $imageName;
294   - return $savePath;
295   - }
  58 + $aimTPath = Yii::getAlias('@site')."/".$desPathFile .$minFileName;
  59 + FileUtil::moveFile($tmpMinFilePath, $aimTPath,true);
296 60  
297   - /**
298   - * [工程师商铺头部的图片]=> 存储路径: shop_cover/wx/engineerUUId.jpg
299   - * @param $engineerUUId
300   - * @param $suffix 图片后缀, 如'.jpg'
301   - * @return string
302   - */
303   - public static function getEngineerShopCoverImgPath($engineerUUId, $suffix = 'jpg')
304   - {
305   - $imageName = $engineerUUId . '.' . $suffix;
306   - $basePath = self::$SHOP_COVER_PATH . 'wx';
307   - $savePath = $basePath . '/' . $imageName;
308   - return $savePath;
  61 + return [$desPathFile, $licensePic, $minFileName];
309 62 }
310 63  
311   -
312 64 /**
313   - * [系统设置]=> 获取[工程师服务号-设置图片]的存储路径: system_setting/mp/[16位md5加密串].jpg
314   - * @param $suffix 图片后缀, 如'.jpg'
315   - * @return string
316   - */
317   - public static function getMPSettingImgPath($suffix)
318   - {
319   - $imageName = md5(time() . self::rand(5)) . '.' . $suffix;
320   - $basePath = self::$SYSTEM_SETTING_ROOT_PATH . 'mp';
321   - $savePath = $basePath . '/' . $imageName;
322   - return $savePath;
323   - }
324   -
325   - /** 获取默认图片
326   - * @param int $type
  65 + * @param $uuid
  66 + * @param string $fileTypePath
327 67 * @return string
328 68 */
329   - public static function getDefaultImg($type = 1)
  69 + public static function genImagePath($uuid, $fileTypePath = '')
330 70 {
331   - $domain = \yii::$app->request->getHostInfo();
332   - if ($type == 1) {
333   - $str = $domain . '/i/default-img.jpg';
  71 + if (empty($fileTypePath)) {
  72 + $catPath = self::$MAINTENANCE_PATH;
334 73 } else {
335   - $str = $domain . '/i/default-img.jpg';
  74 + $catPath = $fileTypePath;
336 75 }
337   - return $str;
338   - }
339   -
340   - /**
341   - * 获取电子发票pdf文件存储路径
342   - * @param $sid
343   - * @param string $suffix
344   - * @return string
345   - */
346   - public static function getInvoicePdfPath($sid, $suffix = "pdf")
347   - {
348   - $imageName = $sid . '.' . $suffix;
349   - $basePath = self::$INVOICE_ROOT_PATH . date("Ymd");
350   - $savePath = $basePath . '/' . $imageName;
351   - return $savePath;
352   - }
353   -
354   - /**
355   - * 获取电子发票截图存储路径
356   - * @param string $suffix
357   - * @return string
358   - */
359   - public static function getInvoicePath($suffix)
360   - {
361   - $imageName = md5(time() . self::rand(5)) . '.' . $suffix;
362   - $basePath = self::$INVOICE_ROOT_PATH . date("Ymd");
363   - $savePath = $basePath . '/' . $imageName;
364   - return $savePath;
365   - }
366   -
367   - /**
368   - * [小程序用户端广告]=> 获取[广告图片]的存储路径: user_ads/20180101/[adsId]/[md5加密串].png
369   - * @param $adsId
370   - * @param $suffix 图片后缀, 如'.png'
371   - * @return string
372   - */
373   - public static function getUserAdsPath($adsId, $suffix = "png")
374   - {
375   - $imageName = md5(time() . $adsId . self::rand(5)) . '.' . $suffix;
376   - $basePath = self::$USER_ADS_ROOT_PATH . date("Ymd") . '/' . $adsId;
377   - $savePath = $basePath . '/' . $imageName;
378   - return $savePath;
379   - }
  76 + $desPathFile = "upload/".$catPath.$uuid.'/';
380 77  
381   - /**
382   - * 获取工程师活动图片相对存储路径
383   - */
384   - public static function getEngineerActivityPath()
385   - {
386   - return self::$ENGINEER_ACT_ROOT_PATH;
  78 + return $desPathFile;
387 79 }
388 80  
389   - /**
390   - * 获取抵扣金活动路径
391   - * @param $suffix 图片后缀, 如'.jpg'
392   - * @return string
393   - */
394   - public static function getDeductionActivityPath($suffix)
  81 + private static function _imageCreateFromPath($imgPath)
395 82 {
396   - $imageName = md5(time() . self::rand(5)) . '.' . $suffix;
397   - $basePath = self::$DEDUCTION_ACTIVITY_ROOT_PATH . 'deduction_activity';
398   - $savePath = $basePath . '/' . $imageName;
399   - return $savePath;
  83 + list($width, $height, $type, $attr) = getimagesize($imgPath);
  84 + switch ($type) {
  85 + case 3: // png
  86 + return imagecreatefrompng($imgPath);
  87 + case 2: // jpeg
  88 + return imagecreatefromjpeg($imgPath);
  89 + default:
  90 + return null;
  91 + }
400 92 }
401 93  
402 94 /**
403   - * 商品主图存储路径:shop_item_image/20170509/[engineerId]/[16位md5加密串].jpg
404   - * @param $engineerId
405   - * @param $suffix 图片后缀, 如'.jpg'
406   - * @param $fileName 图片另外的名称,工程师图片可以是头像,身份证等
407   - * @return string
  95 + * 上传到服务器临时文件区
  96 + * @param $fileInfo $_FILE['file']
  97 + * @return array
408 98 */
409   - public static function getShopItemImgPath($engineerId, $fileName = '', $suffix = 'jpg')
  99 + public static function uploadImg($fileInfo)
410 100 {
411   - $imageName = md5(time() . $engineerId . $fileName . self::rand(5)) . '.' . $suffix;
412   - $basePath = self::$SHOP_ITEM_IMAGE_PATH . date("Ymd") . '/' . $engineerId;
413   - $savePath = $basePath . '/' . $imageName;
414   - return $savePath;
415   - }
  101 + $dir = Yii::getAlias('@site') . "/tmp";
  102 + $fileArr = explode('.', $fileInfo['name']);
  103 + $tt = time();
  104 + $filename = 'auto_'.$tt.md5($fileInfo['name']).'.'.end($fileArr);
  105 + $minFileName = 'auto_'.$tt.md5($fileInfo['name']).'_min'.'.'.end($fileArr);
  106 + $saveFilePath = $dir.'/'.$filename;
  107 + move_uploaded_file($fileInfo['tmp_name'], $saveFilePath);
  108 + $tmpUrl = $tmpMinFile = 'tmp/'.$filename;
  109 + $imgSource = self::_imageCreateFromPath($saveFilePath);
  110 + if ($imgSource) {
  111 + ImageUtils::resizeImage($imgSource, 100, 100, $dir.'/'.$minFileName);
  112 + $tmpMinFile = 'tmp/'.$minFileName;
  113 + }
416 114  
417   - /**
418   - * 商品详情图存储路径: shop_item_desc_image/20170509/[engineerId]/[16位md5加密串].jpg
419   - * @param $engineerId
420   - * @param $suffix 图片后缀, 如'.jpg'
421   - * @param $fileName 图片另外的名称,工程师图片可以是头像,身份证等
422   - * @return string
423   - */
424   - public static function getShopItemDescImgPath($engineerId, $fileName = '', $suffix = 'jpg')
425   - {
426   - $imageName = md5(time() . $engineerId . $fileName . self::rand(5)) . '.' . $suffix;
427   - $basePath = self::$SHOP_ITEM_DESC_IMAGE_PATH . date("Ymd") . '/' . $engineerId;
428   - $savePath = $basePath . '/' . $imageName;
429   - return $savePath;
  115 + return [$filename, $minFileName, $tmpUrl, $tmpMinFile];
430 116 }
431 117 }
432 118 \ No newline at end of file
... ...
common/helpers/Utils.php
... ... @@ -454,58 +454,4 @@ class Utils
454 454 }
455 455 }
456 456  
457   - /**
458   - * 生成mac 地址
459   - * @return string
460   - */
461   - static function macGenerate()
462   - {
463   - $adrArray = [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F" ];
464   - $returnMAC = '';
465   -
466   - for($i = 1; $i < 13 ; $i++) {
467   - $index = 0;
468   - if ($i != 2) {
469   - $index = mt_rand(0, 15);
470   - } else {
471   - //第二位只能是偶数
472   - $indexArray = [0, 2, 4, 6, 8, 10, 12, 14];
473   - $index = $indexArray[mt_rand(0, 7)];
474   - }
475   -
476   - $returnMAC = $returnMAC . $adrArray[$index];
477   - }
478   -
479   - return self::coverToMacAddress($returnMAC);
480   - }
481   -
482   - /**
483   - * 把mac地址转化为带:的字符串
484   - * @param $macStr
485   - * @return string
486   - */
487   - static function coverToMacAddress($macStr)
488   - {
489   - if (empty($macStr)) {
490   - return null;
491   - }
492   -
493   - $macSplitArr = str_split($macStr, 2);
494   - $returnStr = implode(":", $macSplitArr);
495   -
496   - return $returnStr;
497   - }
498   -
499   - /**
500   - * @param $mac
501   - * @return bool
502   - */
503   - static function isMacAddress($mac)
504   - {
505   - if(preg_match('/^([0-9a-fA-F]{2})(([:|-]{0,1}[0-9a-fA-F]{2}){5})$/', $mac)) {
506   - return true;
507   - } else {
508   - return false;
509   - }
510   - }
511 457 }
512 458 \ No newline at end of file
... ...
domain/order/RepairFinishImages.php 0 → 100644
... ... @@ -0,0 +1,67 @@
  1 +<?php
  2 +
  3 +namespace domain\order;
  4 +
  5 +use Yii;
  6 +use common\helpers\ImageManager;
  7 +use domain\order\models\RepairFinishImages as RepairFinishImagesModel;
  8 +/**
  9 + * 维修完成的图片
  10 + */
  11 +class RepairFinishImages
  12 +{
  13 + /**
  14 + * @return null|object
  15 + * @throws \yii\base\InvalidConfigException
  16 + */
  17 + static function create($sItems)
  18 + {
  19 + if (empty($sItems)) {
  20 + return null;
  21 + }
  22 + $classData = [
  23 + 'class' => RepairFinishImagesModel::className()
  24 + ];
  25 + foreach($sItems as $k => $v) {
  26 + $classData[$k] = $v;
  27 + }
  28 + $userModel = Yii::createObject($classData);
  29 + if($userModel->save()) {
  30 + return $userModel;
  31 + } else {
  32 + return null;
  33 + }
  34 + }
  35 +
  36 + /**
  37 + * @param $orderId
  38 + * @param $orderUUId
  39 + * @param $images
  40 + */
  41 + static function createFinishImages($orderId, $orderUUId, $images)
  42 + {
  43 + if (empty($images)) {
  44 + return null;
  45 + }
  46 + RepairFinishImagesModel::deleteAll(['repair_order_id' => $orderId]);
  47 + foreach($images as $k => $v) {
  48 + $imgPath = ImageManager::genImagePath($orderUUId, ImageManager::$ORDER_FINISH_PATH);
  49 + $sData = [
  50 + 'repair_order_id' => $orderId,
  51 + 'image_path' => $imgPath.$v
  52 + ];
  53 + self::create($sData);
  54 + }
  55 + }
  56 +
  57 + /**
  58 + * @param $orderUUId
  59 + * @param $images
  60 + */
  61 + static function mvFinishImages($orderUUId, $images)
  62 + {
  63 + foreach($images as $k => $v) {
  64 + ImageManager::mvUploadImage($v, $orderUUId, ImageManager::$ORDER_FINISH_PATH);
  65 + }
  66 + }
  67 +}
0 68 \ No newline at end of file
... ...
domain/order/RepairOrder.php 0 → 100644
... ... @@ -0,0 +1,36 @@
  1 +<?php
  2 +
  3 +namespace domain\order;
  4 +
  5 +use Yii;
  6 +use domain\order\models\RepairOrder as RepairOrderModel;
  7 +
  8 +/**
  9 + * 维修订单
  10 + */
  11 +class RepairOrder
  12 +{
  13 + /**
  14 + * @param $sItems
  15 + * @return null|object
  16 + * @throws \yii\base\InvalidConfigException
  17 + */
  18 + static function create($sItems)
  19 + {
  20 + if (empty($sItems)) {
  21 + return null;
  22 + }
  23 + $classData = [
  24 + 'class' => RepairOrderModel::className()
  25 + ];
  26 + foreach($sItems as $k => $v) {
  27 + $classData[$k] = $v;
  28 + }
  29 + $userModel = Yii::createObject($classData);
  30 + if($userModel->save()) {
  31 + return $userModel;
  32 + } else {
  33 + return null;
  34 + }
  35 + }
  36 +}
0 37 \ No newline at end of file
... ...
domain/order/RepairOrderImages.php 0 → 100644
... ... @@ -0,0 +1,67 @@
  1 +<?php
  2 +
  3 +namespace domain\order;
  4 +
  5 +use Yii;
  6 +use common\helpers\ImageManager;
  7 +use domain\order\models\RepairOrderImages as RepairOrderImagesModel;
  8 +/**
  9 + * 维修订单故障图片
  10 + */
  11 +class RepairOrderImages
  12 +{
  13 + /**
  14 + * @return null|object
  15 + * @throws \yii\base\InvalidConfigException
  16 + */
  17 + static function create($sItems)
  18 + {
  19 + if (empty($sItems)) {
  20 + return null;
  21 + }
  22 + $classData = [
  23 + 'class' => RepairOrderImagesModel::className()
  24 + ];
  25 + foreach($sItems as $k => $v) {
  26 + $classData[$k] = $v;
  27 + }
  28 + $userModel = Yii::createObject($classData);
  29 + if($userModel->save()) {
  30 + return $userModel;
  31 + } else {
  32 + return null;
  33 + }
  34 + }
  35 +
  36 + /**
  37 + * @param $orderId
  38 + * @param $orderUUId
  39 + * @param $images
  40 + */
  41 + static function createBrokenImages($orderId, $orderUUId, $images)
  42 + {
  43 + if (empty($images)) {
  44 + return null;
  45 + }
  46 + foreach($images as $k => $v) {
  47 + $imgPath = ImageManager::genImagePath($orderUUId, ImageManager::$ORDER_BROKEN_PATH);
  48 + $sData = [
  49 + 'repair_order_id' => $orderId,
  50 + 'image_path' => $imgPath.$v
  51 + ];
  52 + self::create($sData);
  53 + }
  54 + }
  55 +
  56 + /**
  57 + * @param $orderUUId
  58 + * @param $images
  59 + */
  60 + static function mvBrokenImages($orderUUId, $images)
  61 + {
  62 + foreach($images as $k => $v) {
  63 + ImageManager::mvUploadImage($v, $orderUUId, ImageManager::$ORDER_BROKEN_PATH);
  64 + }
  65 + }
  66 +
  67 +}
0 68 \ No newline at end of file
... ...
domain/order/RepairOrderRepairPlan.php 0 → 100644
... ... @@ -0,0 +1,56 @@
  1 +<?php
  2 +
  3 +namespace domain\order;
  4 +
  5 +use Yii;
  6 +use domain\order\models\RepairOrderRepairPlan as RepairOrderRepairPlanModel;
  7 +
  8 +
  9 +/**
  10 + * 维修方案
  11 + */
  12 +class RepairOrderRepairPlan
  13 +{
  14 + /**
  15 + * @return null|object
  16 + * @throws \yii\base\InvalidConfigException
  17 + */
  18 + static function create($sItems)
  19 + {
  20 + if (empty($sItems)) {
  21 + return null;
  22 + }
  23 + $classData = [
  24 + 'class' => RepairOrderRepairPlanModel::className()
  25 + ];
  26 + foreach($sItems as $k => $v) {
  27 + $classData[$k] = $v;
  28 + }
  29 + $repairPlanModel = Yii::createObject($classData);
  30 + if($repairPlanModel->save()) {
  31 + return $repairPlanModel;
  32 + } else {
  33 + return null;
  34 + }
  35 + }
  36 +
  37 + /**
  38 + * @param $orderId
  39 + * @param $plans
  40 + */
  41 + static function batchCreate($orderId, $plans)
  42 + {
  43 + RepairOrderRepairPlanModel::deleteAll(['repair_order_id' => $orderId]);
  44 + $totalPrice = 0;
  45 + foreach($plans as $k => $plan) {
  46 + $item = [
  47 + 'repair_order_id' => $orderId,
  48 + 'repair_plan' => $plan['content'],
  49 + 'price' => $plan['price'],
  50 + ];
  51 + $totalPrice = $totalPrice + $plan['price']*1;
  52 + self::create($item);
  53 + }
  54 + return $totalPrice;
  55 + }
  56 +}
0 57 \ No newline at end of file
... ...
domain/order/RepairOrderRepairPlanRepository.php 0 → 100644
... ... @@ -0,0 +1,37 @@
  1 +<?php
  2 +
  3 +namespace domain\order;
  4 +use Yii;
  5 +use domain\order\models\RepairOrderRepairPlan as RepairOrderRepairPlanModel;
  6 +use domain\order\models\RepairFinishImages as RepairFinishImagesModel;
  7 +
  8 +/**
  9 + * 维修订单
  10 + */
  11 +class RepairOrderRepairPlanRepository
  12 +{
  13 + /**
  14 + * @param $condition
  15 + * @return static
  16 + */
  17 + static function findOne($condition)
  18 + {
  19 + return RepairOrderRepairPlanModel::findOne($condition);
  20 + }
  21 +
  22 + /**
  23 + * @param $condition
  24 + * @return array|null|\yii\db\ActiveRecord[]
  25 + */
  26 + static function findOrderPlansAll($condition)
  27 + {
  28 + if (empty($condition)) {
  29 + return null;
  30 + }
  31 + $repairPlans = RepairOrderRepairPlanModel::find();
  32 + $repairPlans->where($condition);
  33 + $plans = $repairPlans->all();
  34 +
  35 + return $plans;
  36 + }
  37 +}
0 38 \ No newline at end of file
... ...
domain/order/RepairOrderRepository.php 0 → 100644
... ... @@ -0,0 +1,72 @@
  1 +<?php
  2 +
  3 +namespace domain\order;
  4 +
  5 +use Yii;
  6 +use domain\order\models\RepairOrder as RepairOrderModel;
  7 +use domain\order\models\RepairOrderImages as RepairOrderImagesModel;
  8 +use domain\order\models\RepairOrderRepairPlan as RepairOrderRepairPlanModel;
  9 +use domain\order\models\RepairFinishImages as RepairFinishImagesModel;
  10 +
  11 +/**
  12 + * 维修订单
  13 + */
  14 +class RepairOrderRepository
  15 +{
  16 + /**
  17 + * @param $condition
  18 + * @return static
  19 + */
  20 + static function findOne($condition)
  21 + {
  22 + return RepairOrderModel::findOne($condition);
  23 + }
  24 +
  25 + /**
  26 + * @param $condition
  27 + * @return array|null|\yii\db\ActiveRecord[]
  28 + */
  29 + static function findOrderImageAll($condition)
  30 + {
  31 + if (empty($condition)) {
  32 + return null;
  33 + }
  34 + $repairOrderImage = RepairOrderImagesModel::find();
  35 + $repairOrderImage->where($condition);
  36 + $images = $repairOrderImage->all();
  37 +
  38 + return $images;
  39 + }
  40 +
  41 + /**
  42 + * @param $condition
  43 + * @return array|null|\yii\db\ActiveRecord[]
  44 + */
  45 + static function findOrderPlansAll($condition)
  46 + {
  47 + if (empty($condition)) {
  48 + return null;
  49 + }
  50 + $repairPlans = RepairOrderRepairPlanModel::find();
  51 + $repairPlans->where($condition);
  52 + $plans = $repairPlans->all();
  53 +
  54 + return $plans;
  55 + }
  56 +
  57 + /**
  58 + * @param $condition
  59 + * @return array|null|\yii\db\ActiveRecord[]
  60 + */
  61 + static function findOrderFinishImageAll($condition)
  62 + {
  63 + if (empty($condition)) {
  64 + return null;
  65 + }
  66 + $repairFinishImage = RepairFinishImagesModel::find();
  67 + $repairFinishImage->where($condition);
  68 + $images = $repairFinishImage->all();
  69 +
  70 + return $images;
  71 + }
  72 +}
0 73 \ No newline at end of file
... ...
domain/order/RepairOrderStatus.php 0 → 100644
... ... @@ -0,0 +1,35 @@
  1 +<?php
  2 +
  3 +namespace domain\order;
  4 +
  5 +use Yii;
  6 +use domain\order\models\RepairOrder as RepairOrderModel;
  7 +
  8 +/**
  9 + * 维修订单状态
  10 + */
  11 +class RepairOrderStatus
  12 +{
  13 + const REPAIRING = 1; //维修中
  14 + const FINISH = 2; // 维修完成
  15 +
  16 + /**
  17 + * @param $index
  18 + * @return string
  19 + */
  20 + static function getEnLabel($index = '')
  21 + {
  22 + $arr = [
  23 + self::REPAIRING => "working",
  24 + self::FINISH => "finish",
  25 + ];
  26 + if ('' === $index) {
  27 + return $arr;
  28 + }
  29 + if (isset($arr[$index])) {
  30 + return $arr[$index];
  31 + } else {
  32 + return '';
  33 + }
  34 + }
  35 +}
0 36 \ No newline at end of file
... ...
domain/order/models/RepairFinishImages.php
1 1 <?php
2 2  
3   -namespace domain\user\models;
  3 +namespace domain\order\models;
4 4  
5 5 use yii\db\ActiveRecord;
6 6 use yii\behaviors\TimestampBehavior;
... ...
domain/order/models/RepairOrder.php
1 1 <?php
2 2  
3   -namespace domain\user\models;
  3 +namespace domain\order\models;
4 4  
5 5 use yii\db\ActiveRecord;
6 6 use yii\behaviors\TimestampBehavior;
  7 +use common\helpers\Utils;
7 8  
8 9 /**
9 10 * 维修订单
... ... @@ -32,4 +33,24 @@ class RepairOrder extends ActiveRecord
32 33 ]
33 34 ];
34 35 }
  36 + /* @inheritdoc */
  37 + public function init()
  38 + {
  39 + parent::init();
  40 + $this->attachEvents();
  41 + }
  42 +
  43 + /* @inheritdoc */
  44 + public function attachEvents()
  45 + {
  46 + $this->on(static::EVENT_BEFORE_INSERT, [$this, 'onBeforeInsert']);
  47 + }
  48 +
  49 + /**
  50 + * 记录插入前的回调处理
  51 + */
  52 + public function onBeforeInsert()
  53 + {
  54 + $this->uuid = Utils::genUUID();
  55 + }
35 56 }
36 57 \ No newline at end of file
... ...
domain/order/models/RepairOrderImages.php
1 1 <?php
2 2  
3   -namespace domain\user\models;
  3 +namespace domain\order\models;
4 4  
5 5 use yii\db\ActiveRecord;
6 6 use yii\behaviors\TimestampBehavior;
... ...
domain/order/models/RepairOrderRate.php
1 1 <?php
2 2  
3   -namespace domain\user\models;
  3 +namespace domain\order\models;
4 4  
5 5 use yii\db\ActiveRecord;
6 6 use yii\behaviors\TimestampBehavior;
... ...
domain/order/models/RepairOrderRepairPlan.php
1 1 <?php
2 2  
3   -namespace domain\user\models;
  3 +namespace domain\order\models;
4 4  
5 5 use yii\db\ActiveRecord;
6 6 use yii\behaviors\TimestampBehavior;
... ...
domain/user/PhoneCode.php 0 → 100644
... ... @@ -0,0 +1,17 @@
  1 +<?php
  2 +
  3 +namespace domain\user;
  4 +
  5 +use Yii;
  6 +use domain\user\models\PhoneCode as PhoneCodeModel;
  7 +
  8 +/**
  9 + * 手机验证码
  10 + */
  11 +class PhoneCode
  12 +{
  13 + const LOGIN_TYPE = 1;
  14 + const REGISTER_TYPE = 2;
  15 + const REGISTER_EXPIRE_AFTER = 120;
  16 +
  17 +}
0 18 \ No newline at end of file
... ...
domain/user/User.php 0 → 100644
... ... @@ -0,0 +1,36 @@
  1 +<?php
  2 +
  3 +namespace domain\user;
  4 +
  5 +use Yii;
  6 +use domain\user\models\User as UserModel;
  7 +
  8 +/**
  9 + * 手机验证码
  10 + */
  11 +class User
  12 +{
  13 + /**
  14 + * @param $data
  15 + * @return null|object
  16 + * @throws \yii\base\InvalidConfigException
  17 + */
  18 + static function create($data)
  19 + {
  20 + if (empty($data)) {
  21 + return null;
  22 + }
  23 + $classData = [
  24 + 'class' => UserModel::className()
  25 + ];
  26 + foreach($data as $k => $v) {
  27 + $classData[$k] = $v;
  28 + }
  29 + $userModel = Yii::createObject($classData);
  30 + if($userModel->save()) {
  31 + return $userModel;
  32 + } else {
  33 + return null;
  34 + }
  35 + }
  36 +}
0 37 \ No newline at end of file
... ...
domain/user/UserRepository.php 0 → 100644
... ... @@ -0,0 +1,20 @@
  1 +<?php
  2 +
  3 +namespace domain\user;
  4 +
  5 +use domain\user\models\User as UserModel;
  6 +
  7 +/**
  8 + * 手机验证码
  9 + */
  10 +class UserRepository
  11 +{
  12 + /**
  13 + * @param $condition
  14 + * @return static
  15 + */
  16 + public static function findOne($condition)
  17 + {
  18 + return UserModel::findOne($condition);
  19 + }
  20 +}
0 21 \ No newline at end of file
... ...
domain/user/models/User.php
... ... @@ -2,6 +2,8 @@
2 2  
3 3 namespace domain\user\models;
4 4  
  5 +use common\helpers\Utils;
  6 +use yii\base\NotSupportedException;
5 7 use yii\db\ActiveRecord;
6 8 use yii\behaviors\TimestampBehavior;
7 9 use yii\web\IdentityInterface;
... ... @@ -33,7 +35,26 @@ class User extends ActiveRecord implements IdentityInterface
33 35 ]
34 36 ];
35 37 }
  38 + /* @inheritdoc */
  39 + public function init()
  40 + {
  41 + parent::init();
  42 + $this->attachEvents();
  43 + }
  44 +
  45 + /* @inheritdoc */
  46 + public function attachEvents()
  47 + {
  48 + $this->on(static::EVENT_BEFORE_INSERT, [$this, 'onBeforeInsert']);
  49 + }
36 50  
  51 + /**
  52 + * 记录插入前的回调处理
  53 + */
  54 + public function onBeforeInsert()
  55 + {
  56 + $this->uuid = Utils::genUUID();
  57 + }
37 58  
38 59 /** @inheritdoc */
39 60 public static function findIdentity($id)
... ...
web/dist/js/order-app.js
1   -define("order-app",["mk7/app"],function(t){var i=Dom7,n=function(){var t=i(".ui-loading-block");0==t.length&&(i(".view-main").html('<div class="ui-loading-block" id="ui-loading"><div class="ui-loading-cnt"><div class="spinner"><div class="bounce1"></div><div class="bounce2"></div><div class="bounce3"></div></div><div id="loader-inner"><p></p></div> </div> </div>'),window.waitingTime=1e4,window.loaderTimer&&clearTimeout(window.loaderTimer),window.loaderTimer=setTimeout(function(){var t=document.getElementById("loader-inner"),i=document.createElement("p");i.className="notice",t&&(i.innerHTML='加载速度太慢?试试<a class="link" href="#" onclick="javascript:location.reload();return false;">重新加载</a>',t.appendChild(i))},window.waitingTime))},e=!0;return t.name="order",t.routes={index:function(){return e=!1,n(),t.runController("index")},"index/:tab":function(i){e=!1,n();var a={tab:i};return t.runController("index",a)},"rate/:id":function(i){e=!1,n();var a={id:i};return t.runController("rate",a)},submit:function(){return e=!1,n(),t.runController("submit")},"order-details/:id":function(i){e=!1,n();var a={id:i};return t.runController("order-details",a)},"cost-list/:id":function(i){e=!1,n();var a={id:i};return t.runController("cost-list",a)},"*":function(){return t.runController("index")}},t}),define("order/cost-list-controller",["mk7/controller","mk7/url","mk7/utils","mk7/uploadjs"],function(t,i,n,e){var a=Dom7,t=(Template7,new t),o="/user/default/upload-file",r="/order/default/submit-repair-plans";return t.run=function(){var t=this;t.setPageTitle("费用列表"),t.imgLimit=9,t.canSubmit=!0,t.render()},t.bindEvents=function(){var t=this;console.log("bindEvents"),t.addEvent(),t.uploadImgEvent(),t.delPlanEvent(),t.inputPriceChangeEvent(),t.submitEvent()},t.addEvent=function(){var t=this;a("#cost-list .add-repair-plan").click(function(i){var n=a("#cost-list .cost-list-div"),e=t.planTpl(n.length+1);a(e).insertBefore(a("#cost-list .cost-total-list-div"))})},t.delPlanEvent=function(){var t=this;a("#cost-list").on("click",".del-plan",function(i){console.log("del plan event"),a(this).parents(".cost-list-div").remove(),a("#cost-list .total-plan-price").html(t.computedPrice())})},t.planTpl=function(t){var i='<div class="cost-list-div"><p class="item-title">第'+t+'项</p><div class="repair-item-cls"><input type="text" class="input-left input-cls" placeholder="填写维修内容" value=""><input type="number" class="input-right input-cls" placeholder="填写价格" value="0"><span class="del-plan"></span></div></div>';return i},t.inputPriceChangeEvent=function(){var t=this;a("#cost-list").on("input propertychange",".input-cls",function(){var i=t.computedPrice();a("#cost-list .total-plan-price").html(i)})},t.computedPrice=function(){var t=a("#cost-list .input-right"),i=0;return a.each(t,function(t,n){i+=1*a(n).val()}),Math.round(i,2)},t.uploadImgEvent=function(){var t=this;a("#cost-list #upload-btn").change(function(){if(""!=a(this).val()&&null!=a(this).val()){var r=a(this).parents("li");e.uploadFile({selector:"#upload-btn",url:i.to(o),processAppendTo:"#cost-list",success:function(i,e){try{if(i.success){var o=i.tmpUrl;a('<li class="upload-li up-img"><div data="'+i.tmpFile+'" data-url="'+o+'" class="upload-item" style="background-image:url('+i.tmpMinUrl+')"></div><span class="del-img"></span></li>').insertBefore(r),t.imgLimit==a("#cost-list #image-list").find(".up-img").length&&a("#cost-list .upload-btn-li").hide()}else n.toast({content:i.message,closeDelay:5e3})}catch(l){console.log(l),n.toast({content:"出错",closeDelay:5e3})}}})}}),a("#cost-list #image-list").on("click",".del-img",function(i){a(this).parent().remove(),t.imgLimit>=a("#cost-list #image-list").find(".up-img").length&&a("#cost-list .upload-btn-li").show()})},t.submitEvent=function(){var t=this;a("#cost-list .btn-submit").click(function(e){var o=a("#cost-list .content-div").find(".repair-item-cls"),l=[],s=!0,c=!0;if(a.each(o,function(t,i){var e=n.trim(a(i).find(".input-left").val()),o=n.trim(a(i).find(".input-right").val());""==e&&(s=!1),""!=o&&0!=o||(c=!1),l.push({content:e,price:o})}),!s)return n.toast({content:"维修清单有部分未填内容"}),!1;if(!c)return n.toast({content:"维修清单有部分未填价格"}),!1;var d=a("#cost-list #image-list").find(".upload-item"),u=[];if(a.each(d,function(t,i){u.push(a(i).attr("data"))}),!t.canSubmit)return!1;t.canSubmit=!1;var m=t.csrf({images:u,plans:l});n.httpPost(r,m,function(e){t.canSubmit=!0,e.success?window.location.replace(i.to("order/#item-details/"+t.id)):n.toast({content:e.message})},!0)})},t}),define("order/index-controller",["mk7/controller","mk7/url","mk7/utils"],function(t,i,n){var e=Dom7,a=Template7,t=new t,o="order/default/order-list";return t.run=function(){var t=this;t.setPageTitle("订单列表"),t.tab=t.params.tab,t.page=0,t.nodata="",t.loading=!1,t.pageCount=1,t.render({tab:t.tab}),t.loadPage()},t.bindEvents=function(){var t=this;console.log("bindEvents"),t.tabEvent(),t.bindScrollEvent(),t.addEvent()},t.tabEvent=function(){e(".tab-cls").click(function(t){var i=e(this).attr("data-href");window.location.replace(i)})},t.handleNodata=function(){var t=this;t.nodata="没有数据了";var i=e(".nodata");0==i.length&&e("#index .order-list").append('<div class="nodata">'+t.nodata+"</div>"),t.app.detachInfiniteScroll(".infinite-scroll"),e("#index .infinite-scroll-preloader").remove()},t.loadPage=function(){var t=this;if(t.loading=!0,t.page>=t.pageCount)return void t.handleNodata();var a={status:t.tab};a.page=t.page+1,a=t.csrf(a),e.ajax({method:"GET",url:i.to(o),data:a,dataType:"json",beforeSend:function(){t.showIndicator()},success:function(i){1==i.success&&(n.isDefined(i.page)&&(t.page=parseInt(i.page)),n.isDefined(i.page_count)&&(t.pageCount=parseInt(i.page_count)),t.renderItems(i.items,!0))},error:function(t){},complete:function(i){t.hideIndicator(),t.loading=!1}})},t.bindScrollEvent=function(){var t=this;t.app.attachInfiniteScroll("#index .infinite-scroll"),e("#index .infinite-scroll").on("infinite",function(){t.loading||t.nodata||t.loadPage()})},t.renderItems=function(t,i){var n=e("#index .order-list"),o=e("script#order-item-template"),r=a.compile(o.html()),l=r({list:t});0==i&&(n.html(""),n.append(l)),n.append(l)},t.addEvent=function(){e("#index .add-btn-cls").click(function(t){window.location.href=i.to("order/#submit")})},t}),define("order/order-details-controller",["mk7/controller","mk7/url","mk7/utils"],function(t,i,n){var e=Dom7,t=(Template7,new t),a="order/default/order-details";return t.run=function(){var t=this;t.id=t.params.id,t.setPageTitle("维修单"),t.loadPage()},t.bindEvents=function(){var t=this;console.log("bindEvents"),t.finishBtnEvent(),t.goToComment()},t.loadPage=function(){var t=this,i=t.csrf({id:t.id});n.httpGet(a,i,function(i){var n=i;t.render(n)},!0)},t.finishBtnEvent=function(){var t=this;e("#order-details .finish-submit").click(function(n){window.location.href=i.to("order/#cost-list/"+t.id)})},t.goToComment=function(){var t=this;e("#order-details .rate-btn-cls").click(function(n){window.location.href=i.to("order/#rate/"+t.id)})},t}),define("order/rate-controller",["mk7/controller","mk7/url","mk7/utils"],function(t,i,n){var e=Dom7,t=(Template7,new t),a="order/default/submit-rate";return t.run=function(){var t=this;t.id=t.params.id,t.setPageTitle("评价"),t.loadPage()},t.bindEvents=function(){var t=this;console.log("bindEvents"),t.starClickEvent(),t.submitEvent()},t.loadPage=function(){var t=this;t.render()},t.starClickEvent=function(){e("#rate").on("click",".quality-box .img-star",function(t){var i=e(this).attr("data-id"),n=e("#rate .quality-box .img-star");e.each(n,function(t,n){var a=e(n).attr("data-id");if(1*a<=i){e(n).addClass("star-on");var o=e("#rate .quality-box").find(".rate-text"),r=e(n).attr("data-txt");o.html(r)}else e(n).removeClass("star-on")})})},t.submitEvent=function(){var t=this;e("#rate .submit-btn").click(function(o){var r=n.trim(e("#rate .text-content").val()),l=e("#rate .img-star"),s=0;e.each(l,function(t,i){e(i).hasClass("star-on")&&s++});var c=t.csrf({star:s,comment:r});n.httpPost(i.to(a),c,function(i){i.success?window.location.replace("order/#order-details/"+t.id):n.toast({content:i.message})},!0)})},t}),define("order/submit-controller",["mk7/controller","mk7/url","mk7/utils","mk7/uploadjs"],function(t,i,n,e){var a=Dom7,t=(Template7,new t),o="/user/default/upload-file",r="/order/default/submit",l=!0;return t.run=function(){var t=this;t.setPageTitle("录入维修单"),t.imgLimit=9,t.render()},t.bindEvents=function(){var t=this;console.log("bindEvents"),t.uploadImgEvent(),t.submitEvent()},t.uploadImgEvent=function(){var t=this;a("#submit #upload-btn").change(function(){if(""!=a(this).val()&&null!=a(this).val()){var r=a(this).parents("li");e.uploadFile({selector:"#upload-btn",url:i.to(o),processAppendTo:"#submit",success:function(i,e){try{if(i.success){var o=i.tmpUrl;a('<li class="upload-li up-img"><div data="'+i.tmpFile+'" data-url="'+o+'" class="upload-item" style="background-image:url('+i.tmpMinUrl+')"></div><span class="del-img"></span></li>').insertBefore(r),t.imgLimit==a("#submit #image-list").find(".up-img").length&&a("#submit .upload-btn-li").hide()}else n.toast({content:i.message,closeDelay:5e3})}catch(l){console.log(l),n.toast({content:"出错",closeDelay:5e3})}}})}}),a("#submit #image-list").on("click",".del-img",function(i){a(this).parent().remove(),t.imgLimit>=a("#submit #image-list").find(".up-img").length&&a("#submit .upload-btn-li").show()})},t.submitEvent=function(){var t=this;a("#submit .submit-btn-cls").click(function(e){var o=n.trim(a("#submit .carNo").val()),s=n.trim(a("#submit .carModel").val()),c=n.trim(a("#submit .customer").val()),d=n.trim(a("#submit .phone").val()),u=n.trim(a("#submit .preRepair").val()),m=n.trim(a("#submit .repairPrice").val()),p=n.trim(a("#submit .finishDate").val());if(0==l)return!1;if(""==o)return n.toast({content:"车牌号必填"}),!1;if(""==s)return n.toast({content:"车辆型号必填"}),!1;if(""==c)return n.toast({content:"客户名称必填"}),!1;if(""==d)return n.toast({content:"客联系电话必填"}),!1;if(!n.isMobile(d)&&!uitls.isTelephone(d))return n.toast({content:"客联系电话有误"}),!1;if(""==u)return n.toast({content:"预估维修内容必填"}),!1;if(""==m)return n.toast({content:"预估维修费用必填"}),!1;if(""==p)return n.toast({content:"预估完成时间必填"}),!1;var f=t.getUploadImgs();if(0==f.length)return n.toast({content:"请上传车损照"}),!1;l=!1;var v=t.csrf({carNo:o,carModel:s,customer:c,phone:d,preRepair:u,repairPrice:m,finishDate:p,images:f});n.httpPost(r,v,function(t){return l=!0,t.success?void(window.location.href=i.to("/")):(n.toast({content:message}),!1)},!0)})},t.getUploadImgs=function(){var t=a("#submit #image-list").find(".up-img"),i=[];return 0==t.length?[]:(a.each(t,function(t,n){var e=a(n).find(".upload-item");i.push(e.attr("data"))}),i)},t});
2 1 \ No newline at end of file
  2 +define("order-app",["mk7/app"],function(t){var e=Dom7,n=function(){var t=e(".ui-loading-block");0==t.length&&(e(".view-main").html('<div class="ui-loading-block" id="ui-loading"><div class="ui-loading-cnt"><div class="spinner"><div class="bounce1"></div><div class="bounce2"></div><div class="bounce3"></div></div><div id="loader-inner"><p></p></div> </div> </div>'),window.waitingTime=1e4,window.loaderTimer&&clearTimeout(window.loaderTimer),window.loaderTimer=setTimeout(function(){var t=document.getElementById("loader-inner"),e=document.createElement("p");e.className="notice",t&&(e.innerHTML='加载速度太慢?试试<a class="link" href="#" onclick="javascript:location.reload();return false;">重新加载</a>',t.appendChild(e))},window.waitingTime))},i=!0;return t.name="order",t.routes={index:function(){return i=!1,n(),t.runController("index")},"index/:tab":function(e){i=!1,n();var a={tab:e};return t.runController("index",a)},submit:function(){return i=!1,n(),t.runController("submit")},"order-details/:id":function(e){i=!1,n();var a={id:e};return t.runController("order-details",a)},"customer-order/:id/:sn":function(e,a){i=!1,n();var r={id:e,sn:a};return t.runController("customer-order",r)},"rate/:id/:sn":function(e,a){i=!1,n();var r={id:e,sn:a};return t.runController("rate",r)},"cost-list/:id":function(e){i=!1,n();var a={id:e};return t.runController("cost-list",a)},"*":function(){return t.runController("index")}},t}),define("order/cost-list-controller",["mk7/controller","mk7/url","mk7/utils","mk7/uploadjs"],function(t,e,n,i){var a=Dom7,t=(Template7,new t),r="/user/default/upload-file",o="/order/default/submit-repair-plans";return t.run=function(){var t=this;t.setPageTitle("费用列表"),t.id=t.params.id,t.imgLimit=9,t.canSubmit=!0,t.render()},t.bindEvents=function(){var t=this;console.log("bindEvents"),t.addEvent(),t.uploadImgEvent(),t.delPlanEvent(),t.inputPriceChangeEvent(),t.submitEvent()},t.addEvent=function(){var t=this;a("#cost-list .add-repair-plan").click(function(e){var n=a("#cost-list .cost-list-div"),i=t.planTpl(n.length+1);a(i).insertBefore(a("#cost-list .cost-total-list-div"))})},t.delPlanEvent=function(){var t=this;a("#cost-list").on("click",".del-plan",function(e){console.log("del plan event"),a(this).parents(".cost-list-div").remove(),a("#cost-list .total-plan-price").html(t.computedPrice())})},t.planTpl=function(t){var e='<div class="cost-list-div"><p class="item-title">第'+t+'项</p><div class="repair-item-cls"><input type="text" class="input-left input-cls" placeholder="填写维修内容" value=""><input type="number" class="input-right input-cls" placeholder="填写价格" value="0"><span class="del-plan"></span></div></div>';return e},t.inputPriceChangeEvent=function(){var t=this;a("#cost-list").on("input propertychange",".input-cls",function(){var e=t.computedPrice();a("#cost-list .total-plan-price").html(e)})},t.computedPrice=function(){var t=a("#cost-list .input-right"),e=0;return a.each(t,function(t,n){e+=1*a(n).val()}),Math.round(e,2)},t.uploadImgEvent=function(){var t=this;a("#cost-list #upload-btn").change(function(){if(""!=a(this).val()&&null!=a(this).val()){var o=a(this).parents("li");i.uploadFile({selector:"#upload-btn",url:e.to(r),processAppendTo:"#cost-list",success:function(e,i){try{if(e.success){var r=e.tmpUrl;a('<li class="upload-li up-img"><div data="'+e.tmpFile+'" data-url="'+r+'" class="upload-item" style="background-image:url('+e.tmpMinUrl+')"></div><span class="del-img"></span></li>').insertBefore(o),t.imgLimit==a("#cost-list #image-list").find(".up-img").length&&a("#cost-list .upload-btn-li").hide()}else n.toast({content:e.message,closeDelay:5e3})}catch(s){console.log(s),n.toast({content:"出错",closeDelay:5e3})}}})}}),a("#cost-list #image-list").on("click",".del-img",function(e){a(this).parent().remove(),t.imgLimit>=a("#cost-list #image-list").find(".up-img").length&&a("#cost-list .upload-btn-li").show()})},t.submitEvent=function(){var t=this;a("#cost-list .btn-submit").click(function(i){var r=a("#cost-list .content-div").find(".repair-item-cls"),s=[],l=!0,c=!0;if(a.each(r,function(t,e){var i=n.trim(a(e).find(".input-left").val()),r=n.trim(a(e).find(".input-right").val());""==i&&(l=!1),""!=r&&0!=r||(c=!1),s.push({content:i,price:r})}),!l)return n.toast({content:"维修清单有部分未填内容"}),!1;if(!c)return n.toast({content:"维修清单有部分未填价格"}),!1;var u=a("#cost-list #image-list").find(".upload-item"),d=[];if(a.each(u,function(t,e){d.push(a(e).attr("data"))}),!t.canSubmit)return!1;t.canSubmit=!1;var m=t.csrf({images:d,plans:s,id:t.id});n.httpPost(o,m,function(i){t.canSubmit=!0,i.success?window.location.replace(e.to("order#order-details/"+t.id)):n.toast({content:i.message})},!0)})},t}),define("order/customer-order-controller",["mk7/controller","mk7/url","mk7/utils"],function(t,e,n){var i=Dom7,t=(Template7,new t),a="order/customer/order-details";return t.run=function(){var t=this;t.id=t.params.id,t.sn=t.params.sn,t.setPageTitle("维修单"),t.loadPage()},t.bindEvents=function(){var t=this;console.log("bindEvents"),t.goToComment()},t.loadPage=function(){var t=this,i=t.csrf({id:t.id});n.httpPost(e.to(a),i,function(e){var n=e;t.render(n)},!0)},t.goToComment=function(){var t=this;i("#customer-order .rate-btn-cls").click(function(n){window.location.replace(e.to("order/customer#rate/"+t.id+"/"+t.sn))})},t}),define("order/index-controller",["mk7/controller","mk7/url","mk7/utils"],function(t,e,n){var i=Dom7,a=Template7,t=new t,r="order/default/order-list";return t.run=function(){var t=this;t.setPageTitle("订单列表"),t.tab=t.params.tab,t.page=0,t.nodata="",t.loading=!1,t.pageCount=1,t.render({tab:t.tab}),t.loadPage()},t.bindEvents=function(){var t=this;console.log("bindEvents"),t.tabEvent(),t.bindScrollEvent(),t.addEvent()},t.tabEvent=function(){i(".tab-cls").click(function(t){var e=i(this).attr("data-href");window.location.replace(e)})},t.handleNodata=function(){var t=this;t.nodata="没有数据了";var e=i(".nodata");0==e.length&&i("#index .order-list").append('<div class="nodata">'+t.nodata+"</div>"),t.app.detachInfiniteScroll(".infinite-scroll"),i("#index .infinite-scroll-preloader").remove()},t.loadPage=function(){var t=this;if(t.loading=!0,t.page>=t.pageCount)return void t.handleNodata();var a={status:t.tab};a.page=t.page+1,a=t.csrf(a),i.ajax({method:"GET",url:e.to(r),data:a,dataType:"json",beforeSend:function(){t.showIndicator()},success:function(e){1==e.success&&(n.isDefined(e.page)&&(t.page=parseInt(e.page)),n.isDefined(e.page_count)&&(t.pageCount=parseInt(e.page_count)),t.renderItems(e.items,!0))},error:function(t){},complete:function(e){t.hideIndicator(),t.loading=!1}})},t.bindScrollEvent=function(){var t=this;t.app.attachInfiniteScroll("#index .infinite-scroll"),i("#index .infinite-scroll").on("infinite",function(){t.loading||t.nodata||t.loadPage()})},t.renderItems=function(t,e){var n=i("#index .order-list"),r=i("script#order-item-template"),o=a.compile(r.html()),s=o({list:t});0==e&&(n.html(""),n.append(s)),n.append(s)},t.addEvent=function(){i("#index .add-btn-cls").click(function(t){window.location.href=e.to("order/#submit")})},t}),define("order/order-details-controller",["mk7/controller","mk7/url","mk7/utils"],function(t,e,n){var i=Dom7,t=(Template7,new t),a="order/default/order-details";return t.run=function(){var t=this;t.id=t.params.id,t.setPageTitle("维修单"),t.loadPage()},t.bindEvents=function(){var t=this;console.log("bindEvents"),t.finishBtnEvent(),t.goToComment()},t.loadPage=function(){var t=this,i=t.csrf({id:t.id});n.httpPost(e.to(a),i,function(e){var n=e;t.render(n)},!0)},t.finishBtnEvent=function(){var t=this;i("#order-details .finish-submit").click(function(n){window.location.href=e.to("order/#cost-list/"+t.id)})},t.goToComment=function(){var t=this;i("#order-details .rate-btn-cls").click(function(n){window.location.href=e.to("order/#rate/"+t.id)})},t}),define("order/rate-controller",["mk7/controller","mk7/url","mk7/utils"],function(t,e,n){var i=Dom7,t=(Template7,new t),a="order/customer/submit-rate";return t.run=function(){var t=this;t.id=t.params.id,t.sn=t.params.sn,t.setPageTitle("评价"),t.loadPage()},t.bindEvents=function(){var t=this;console.log("bindEvents"),t.starClickEvent(),t.submitEvent()},t.loadPage=function(){var t=this;t.render()},t.starClickEvent=function(){i("#rate").on("click",".quality-box .img-star",function(t){var e=i(this).attr("data-id"),n=i("#rate .quality-box .img-star");i.each(n,function(t,n){var a=i(n).attr("data-id");if(1*a<=e){i(n).addClass("star-on");var r=i("#rate .quality-box").find(".rate-text"),o=i(n).attr("data-txt");r.html(o)}else i(n).removeClass("star-on")})})},t.submitEvent=function(){var t=this;i("#rate .submit-btn").click(function(r){var o=n.trim(i("#rate .text-content").val()),s=i("#rate .img-star"),l=0;i.each(s,function(t,e){i(e).hasClass("star-on")&&l++});var c=t.csrf({star:l,comment:o});n.httpPost(e.to(a),c,function(i){i.success?window.location.replace(e.to("order/customer#customer-order/"+t.id+"/"+t.sn)):n.toast({content:i.message})},!0)})},t}),define("order/submit-controller",["mk7/controller","mk7/url","mk7/utils","mk7/uploadjs","mk7/picker"],function(t,e,n,a,r){var o=Dom7,t=(Template7,new t),s="/user/default/upload-file",l="/order/default/submit",c=!0,u="";return t.run=function(){var t=this;t.setPageTitle("录入维修单"),t.imgLimit=9,t.render()},t.bindEvents=function(){var t=this;console.log("bindEvents"),t.uploadImgEvent(),t.submitEvent(),t.selectDateEvent()},t.uploadImgEvent=function(){var t=this;o("#submit #upload-btn").change(function(){if(""!=o(this).val()&&null!=o(this).val()){var i=o(this).parents("li");a.uploadFile({selector:"#upload-btn",url:e.to(s),processAppendTo:"#submit",success:function(e,a){try{if(e.success){var r=e.tmpUrl;o('<li class="upload-li up-img"><div data="'+e.tmpFile+'" data-url="'+r+'" class="upload-item" style="background-image:url('+e.tmpMinUrl+')"></div><span class="del-img"></span></li>').insertBefore(i),t.imgLimit==o("#submit #image-list").find(".up-img").length&&o("#submit .upload-btn-li").hide()}else n.toast({content:e.message,closeDelay:5e3})}catch(s){console.log(s),n.toast({content:"出错",closeDelay:5e3})}}})}}),o("#submit #image-list").on("click",".del-img",function(e){o(this).parent().remove(),t.imgLimit>=o("#submit #image-list").find(".up-img").length&&o("#submit .upload-btn-li").show()})},t.submitEvent=function(){var t=this;o("#submit .submit-btn-cls").click(function(i){var a=n.trim(o("#submit .carNo").val()),r=n.trim(o("#submit .carModel").val()),s=n.trim(o("#submit .customer").val()),u=n.trim(o("#submit .phone").val()),d=n.trim(o("#submit .preRepair").val()),m=n.trim(o("#submit .repairPrice").val()),v=n.trim(o("#submit .finishDate").val());if(0==c)return!1;if(""==a)return n.toast({content:"车牌号必填"}),!1;if(""==r)return n.toast({content:"车辆型号必填"}),!1;if(""==s)return n.toast({content:"客户名称必填"}),!1;if(""==u)return n.toast({content:"客联系电话必填"}),!1;if(!n.isMobile(u)&&!uitls.isTelephone(u))return n.toast({content:"客联系电话有误"}),!1;if(""==d)return n.toast({content:"预估维修内容必填"}),!1;if(""==m)return n.toast({content:"预估维修费用必填"}),!1;if(""==v)return n.toast({content:"预估完成时间必填"}),!1;var p=t.getUploadImgs();if(0==p.length)return n.toast({content:"请上传车损照"}),!1;c=!1;var f=t.csrf({carNo:a,carModel:r,customer:s,phone:u,preRepair:d,repairPrice:m,finishDate:v,images:p});n.httpPost(l,f,function(t){return c=!0,t.success?void window.location.replace(e.to("order#order-details/"+t.orderId)):(n.toast({content:message}),!1)},!0)})},t.getUploadImgs=function(){var t=o("#submit #image-list").find(".up-img"),e=[];return 0==t.length?[]:(o.each(t,function(t,n){var i=o(n).find(".upload-item");e.push(i.attr("data"))}),e)},t.selectDateEvent=function(){var t=this;o("#submit .finish-date-input").click(function(e){var n=o(this).val();console.log(n),t.dateTimeSelector("#submit .finish-date-input",n)})},t.dateTimeSelector=function(t,e){var n=this,a=new Date,r=30,s=a.getFullYear(),l=a.getMonth(),c=a.getDate(),d=a.getHours(),m=s+"-"+(l+1)+"-"+c;if(""!=e&&null!=e&&void 0!==e){var v=e.split(" ");m=v[0],d=v[1]}var p=[];for(i=0;i<=r;i++){var f=new Date;f.setDate(a.getDate()+i);var g=f.getFullYear()+"-"+(f.getMonth()+1)+"-"+f.getDate();p.push(g)}var h=n.app.picker({input:t,toolbarTemplate:'<div class="toolbar"><div class="toolbar-inner"><div class="left">请选择用工时间</div><div class="right"><a href="javascript:void(0);" class="link submit-confirm-picker">确定</a></div></div></div>',value:[m,d],onChange:function(t,e,n){var i,a,r;if(e[0]instanceof Date)i=e[0].getFullYear(),a=e[0].getMonth(),r=e[0].getDate();else{var o=e[0].split("-");i=o[0],a=o[1]-1,r=o[2]}var s=new Date(i,a,r,e[1],0),l=new Date((new Date).getTime()+36e5);if(s<l){if(void 0===t.cols[0])return!1;var c=l.getHours(),u=l.getFullYear()+"-"+(l.getMonth()+1)+"-"+l.getDate(),d=new Date(l.getFullYear(),l.getMonth(),l.getDate(),l.getHours(),0);if(d-new Date<9e5){var m=new Date(d.getTime()+36e5);c=m.getHours(),u=m.getFullYear()+"-"+(m.getMonth()+1)+"-"+m.getDate()}t.cols[0].setValue(u),t.cols[2].setValue(c)}},formatValue:function(t,e,n){var i="";i=e[0]instanceof Date?e[0].getFullYear()+"-"+(e[0].getMonth()+1)+"-"+e[0].getDate():e[0];var a=i+" "+e[1];return a},cols:[{values:p,displayValues:function(){var t=[],e=new Date,n=e.getFullYear(),i=e.getMonth()+1,a=e.getDate();e.setDate(e.getDate()+1);for(var r=0;r<p.length;r++){var o=p[r],s=o.split("-"),l=s[1]+"月"+s[2]+"日";n==s[0]&&1*i==s[1]&&1*a==s[2]&&(l+="(今天)"),1*e.getFullYear()==s[0]&&1*e.getMonth()+1==s[1]&&1*e.getDate()==s[2]&&(l+="(明天)"),t.push(l)}return t}()},{divider:!0,content:" "},{values:function(){for(var t=[],e=0;e<=23;e++)t.push(e);return t}(),displayValues:function(){for(var t=[],e=0;e<=23;e++)t.push(e<10?"0"+e+"时":e+"时");return t}()},{divider:!0,content:" "}],onClose:function(e){if(h){var n=h.value,i=n[1]<10?"0"+n[1]:n[1];u=n[0]+" "+i,o(t).val(u),h.destroy()}}});h.open(),o(".submit-confirm-picker").on("click",function(e){e.preventDefault();var n=h.value,i=n[1]<10?"0"+n[1]:n[1];u=n[0]+" "+i,o(t).val(u),h.destroy()})},t});
3 3 \ No newline at end of file
... ...
web/dist/js/user-app.js
1   -define("user-app",["mk7/app"],function(e){var t=Dom7,n=function(){var e=t(".ui-loading-block");0==e.length&&(t(".view-main").html('<div class="ui-loading-block" id="ui-loading"><div class="ui-loading-cnt"><div class="spinner"><div class="bounce1"></div><div class="bounce2"></div><div class="bounce3"></div></div><div id="loader-inner"><p></p></div> </div> </div>'),window.waitingTime=1e4,window.loaderTimer&&clearTimeout(window.loaderTimer),window.loaderTimer=setTimeout(function(){var e=document.getElementById("loader-inner"),t=document.createElement("p");t.className="notice",e&&(t.innerHTML='加载速度太慢?试试<a class="link" href="#" onclick="javascript:location.reload();return false;">重新加载</a>',e.appendChild(t))},window.waitingTime))},o=!0;return e.name="user",e.routes={index:function(){return o=!1,n(),e.runController("index")},register:function(){return o=!1,n(),e.runController("register")},login:function(){return o=!1,n(),e.runController("login")},"*":function(){return e.runController("index")}},e}),define("user/index-controller",["mk7/controller","mk7/url","mk7/utils"],function(e,t,n){var e=(Dom7,Template7,new e);return e.run=function(){var e=this;e.setPageTitle("首页"),e.hideAllNonBaseMenuItem(window.$site),e.render()},e.bindEvents=function(){console.log("bindEvents")},e}),define("user/login-controller",["mk7/controller","mk7/url","mk7/utils"],function(e,t,n){var o=Dom7,e=(Template7,new e),i="/user/login/get-code",r="/user/login/login",l=!0,c=!0,s=null;return e.run=function(){var e=this;e.setPageTitle("登录"),e.codeDuration=60,e.render()},e.bindEvents=function(){var e=this;console.log("bindEvents"),e.getCodeEvent(),e.gotoRegisterEvent(),e.loginEvent()},e.getCodeEvent=function(){var e=this;o("#login .get-code-cls").click(function(){if(0==l)return!1;clearInterval(s),l=!1;var r=e.csrf({action:"login"});n.httpGet(t.to(i),r,function(t){if(!t.success)return n.toast({content:t.message,closeDelay:3e3}),l=!0,!1;var i=t.codeDuration;e.codeDuration=i,s=setInterval(function(t){e.codeDuration--,0==e.codeDuration?(o("#login .get-code-cls").html("获取验证码"),clearInterval(s),e.codeDuration=i,l=!0):o("#login .get-code-cls").html('<span class="count-down-cls">'+e.codeDuration+"s后重新获取</span>")},1e3)})})},e.loginEvent=function(){var e=this;o("#login .login-btn").click(function(i){var l=n.trim(o("#login .mobile").val()),s=n.trim(o("#login .code").val());if(""==l)return n.toast({content:"手机号码必填"}),!1;if(!n.isMobile(l))return n.toast({content:"手机号码不合格"}),!1;if(""==s)return n.toast({content:"验证码必填"}),!1;if(0==c)return!1;c=!1;var a=e.csrf({mobile:l,code:s});n.httpPost(t.to(r),a,function(e){return e.success?(c=!0,void(window.location.href=t.to("/"))):(n.toast({content:e.message,closeDelay:3e3}),c=!0,!1)})})},e.gotoRegisterEvent=function(){o("#login .register-btn").click(function(e){window.location.href=t.to("user/#register")})},e}),define("user/register-controller",["mk7/controller","mk7/url","mk7/utils","mk7/uploadjs"],function(e,t,n,o){var i=Dom7,e=(Template7,new e),r="/user/login/register",l="/user/default/upload-file",c="/user/login/get-code",s=!0,a=!0,u=null;return e.run=function(){var e=this;e.setPageTitle("注册"),e.codeDuration=60,e.render()},e.bindEvents=function(){var e=this;console.log("bindEvents"),e.uploadEvent(),e.getCodeEvent(),e.registerEvent(),e.gotoLoginEvent()},e.uploadEvent=function(){i("#register .upload-input-cls").change(function(){if(""!=i(this).val()&&null!=i(this).val()){var e=i(this).attr("id"),r=i(this).parent();o.uploadFile({selector:"#"+e,url:t.to(l),processAppendTo:"#register",success:function(e,t){try{if(e.success){var o=e.tmpUrl;r.css("background-image","url("+e.tmpMinUrl+")"),r.attr("data",e.tmpFile),r.attr("data-url",o)}else n.toast({content:e.message,closeDelay:5e3})}catch(i){n.toast({content:"出错",closeDelay:5e3})}}})}})},e.getCodeEvent=function(){var e=this;i("#register .get-code-cls").click(function(){if(0==s)return!1;clearInterval(u),s=!1;var o=e.csrf({action:"register"});n.httpGet(t.to(c),o,function(t){if(!t.success)return n.toast({content:t.message,closeDelay:3e3}),s=!0,!1;var o=t.codeDuration;e.codeDuration=o,u=setInterval(function(t){e.codeDuration--,0==e.codeDuration?(i("#register .get-code-cls").html("获取验证码"),clearInterval(u),e.codeDuration=o,s=!0):i("#register .get-code-cls").html('<span class="count-down-cls">'+e.codeDuration+"s后重新获取</span>")},1e3)})})},e.registerEvent=function(){var e=this;i("#register .register-btn").click(function(o){var l=n.trim(i("#register .name").val()),c=n.trim(i("#register .mobile").val()),s=n.trim(i("#register .code").val());if(""==l)return n.toast({content:"车厂名称必填"}),!1;if(""==c)return n.toast({content:"手机号码必填"}),!1;if(!n.isMobile(c))return n.toast({content:"手机号码不合格"}),!1;if(""==s)return n.toast({content:"验证码必填"}),!1;var u=i("#register .upload-btn-cls").attr("data");if(void 0===u||null==u)return n.toast({content:"请上传营业执照"}),!1;if(0==a)return!1;a=!1;var d=e.csrf({name:l,mobile:c,code:s,img:u});n.httpPost(t.to(r),d,function(e){return e.success?void(window.location.href=t.to("/")):(n.toast({content:e.message,closeDelay:3e3}),a=!0,!1)})})},e.gotoLoginEvent=function(){i("#register .login-btn").click(function(e){window.location.href=t.to("user/#login")})},e});
2 1 \ No newline at end of file
  2 +define("user-app",["mk7/app"],function(e){var t=Dom7,n=function(){var e=t(".ui-loading-block");0==e.length&&(t(".view-main").html('<div class="ui-loading-block" id="ui-loading"><div class="ui-loading-cnt"><div class="spinner"><div class="bounce1"></div><div class="bounce2"></div><div class="bounce3"></div></div><div id="loader-inner"><p></p></div> </div> </div>'),window.waitingTime=1e4,window.loaderTimer&&clearTimeout(window.loaderTimer),window.loaderTimer=setTimeout(function(){var e=document.getElementById("loader-inner"),t=document.createElement("p");t.className="notice",e&&(t.innerHTML='加载速度太慢?试试<a class="link" href="#" onclick="javascript:location.reload();return false;">重新加载</a>',e.appendChild(t))},window.waitingTime))},o=!0;return e.name="user",e.routes={index:function(){return o=!1,n(),e.runController("index")},register:function(){return o=!1,n(),e.runController("register")},login:function(){return o=!1,n(),e.runController("login")},"*":function(){return e.runController("index")}},e}),define("user/index-controller",["mk7/controller","mk7/url","mk7/utils"],function(e,t,n){var e=(Dom7,Template7,new e);return e.run=function(){var e=this;e.setPageTitle("首页"),e.hideAllNonBaseMenuItem(window.$site),e.render()},e.bindEvents=function(){console.log("bindEvents")},e}),define("user/login-controller",["mk7/controller","mk7/url","mk7/utils"],function(e,t,n){var o=Dom7,e=(Template7,new e),i="/user/login/get-code",r="/user/login/login",l=!0,s=!0,c=null;return e.run=function(){var e=this;return e.setPageTitle("登录"),e.codeDuration=60,isGuest?void e.render():(window.location.href=t.to("order/#index"),"")},e.bindEvents=function(){var e=this;console.log("bindEvents"),e.getCodeEvent(),e.gotoRegisterEvent(),e.loginEvent()},e.getCodeEvent=function(){var e=this;o("#login .get-code-cls").click(function(){var r=n.trim(o("#login .mobile").val());if(""==r)return n.toast({content:"手机号码必填"}),!1;if(!n.isMobile(r))return n.toast({content:"手机号码不合格"}),!1;if(0==l)return!1;clearInterval(c),l=!1;var s=e.csrf({action:"login",mobile:r});n.httpGet(t.to(i),s,function(t){if(!t.success)return n.toast({content:t.message,closeDelay:3e3}),l=!0,!1;t.testCode&&o("#login .code").val(t.testCode);var i=t.codeDuration;e.codeDuration=i,c=setInterval(function(t){e.codeDuration--,0==e.codeDuration?(o("#login .get-code-cls").html("获取验证码"),clearInterval(c),e.codeDuration=i,l=!0):o("#login .get-code-cls").html('<span class="count-down-cls">'+e.codeDuration+"s后重新获取</span>")},1e3)})})},e.loginEvent=function(){var e=this;o("#login .login-btn").click(function(i){var l=n.trim(o("#login .mobile").val()),c=n.trim(o("#login .code").val());if(""==l)return n.toast({content:"手机号码必填"}),!1;if(!n.isMobile(l))return n.toast({content:"手机号码不合格"}),!1;if(""==c)return n.toast({content:"验证码必填"}),!1;if(0==s)return!1;s=!1;var a=e.csrf({mobile:l,code:c});n.httpPost(t.to(r),a,function(e){return s=!0,e.success?void(window.location.href=t.to("order/#index")):(n.toast({content:e.message,closeDelay:3e3}),!1)})})},e.gotoRegisterEvent=function(){o("#login .register-btn").click(function(e){window.location.href=t.to("user/#register")})},e}),define("user/register-controller",["mk7/controller","mk7/url","mk7/utils","mk7/uploadjs"],function(e,t,n,o){var i=Dom7,e=(Template7,new e),r="/user/login/register",l="/user/default/upload-file",s="/user/login/get-code",c=!0,a=!0,u=null;return e.run=function(){var e=this;return e.setPageTitle("注册"),e.codeDuration=60,isGuest?void e.render():(window.location.href=t.to("order/#index"),"")},e.bindEvents=function(){var e=this;console.log("bindEvents"),e.uploadEvent(),e.getCodeEvent(),e.registerEvent(),e.gotoLoginEvent()},e.uploadEvent=function(){i("#register .upload-input-cls").change(function(){if(""!=i(this).val()&&null!=i(this).val()){var e=i(this).attr("id"),r=i(this).parent();o.uploadFile({selector:"#"+e,url:t.to(l),processAppendTo:"#register",success:function(e,t){try{if(e.success){var o=e.tmpUrl;r.css("background-image","url("+e.tmpMinUrl+")"),r.attr("data",e.tmpFile),r.attr("data-url",o)}else n.toast({content:e.message,closeDelay:5e3})}catch(i){n.toast({content:"出错",closeDelay:5e3})}}})}})},e.getCodeEvent=function(){var e=this;i("#register .get-code-cls").click(function(){var o=n.trim(i("#register .mobile").val());if(""==o)return n.toast({content:"手机号码必填"}),!1;if(!n.isMobile(o))return n.toast({content:"手机号码不合格"}),!1;if(0==c)return!1;clearInterval(u),c=!1;var r=e.csrf({action:"register",mobile:o});n.httpGet(t.to(s),r,function(t){if(!t.success)return n.toast({content:t.message,closeDelay:3e3}),c=!0,!1;t.testCode&&i("#register .code").val(t.testCode);var o=t.codeDuration;e.codeDuration=o,u=setInterval(function(t){e.codeDuration--,0==e.codeDuration?(i("#register .get-code-cls").html("获取验证码"),clearInterval(u),e.codeDuration=o,c=!0):i("#register .get-code-cls").html('<span class="count-down-cls">'+e.codeDuration+"s后重新获取</span>")},1e3)})})},e.registerEvent=function(){var e=this;i("#register .register-btn").click(function(o){var l=n.trim(i("#register .name").val()),s=n.trim(i("#register .mobile").val()),c=n.trim(i("#register .code").val());if(""==l)return n.toast({content:"车厂名称必填"}),!1;if(""==s)return n.toast({content:"手机号码必填"}),!1;if(!n.isMobile(s))return n.toast({content:"手机号码不合格"}),!1;if(""==c)return n.toast({content:"验证码必填"}),!1;var u=i("#register .licensePic").attr("data");if(void 0===u||null==u)return n.toast({content:"请上传营业执照"}),!1;if(0==a)return!1;a=!1;var d=e.csrf({name:l,mobile:s,code:c,licensePic:u});n.httpPost(t.to(r),d,function(e){return e.success?void(window.location.href=t.to("order/#index")):(n.toast({content:e.message,closeDelay:3e3}),a=!0,!1)})})},e.gotoLoginEvent=function(){i("#register .login-btn").click(function(e){window.location.href=t.to("user/#login")})},e});
3 3 \ No newline at end of file
... ...
web/src/js/order/app.js
... ... @@ -47,26 +47,37 @@ define(
47 47 }
48 48 return app.runController('index',params);
49 49 },
50   - 'rate/:id': function (id) {
  50 +
  51 + 'submit': function () {
  52 + fromOutside = false;
  53 + _autoLoading();
  54 + return app.runController('submit');
  55 + },
  56 + 'order-details/:id': function (id) {
51 57 fromOutside = false;
52 58 _autoLoading();
53 59 var params = {
54 60 id:id
55 61 }
56   - return app.runController('rate',params);
  62 + return app.runController('order-details', params);
57 63 },
58   - 'submit': function () {
  64 + 'customer-order/:id/:sn': function (id,sn) {
59 65 fromOutside = false;
60 66 _autoLoading();
61   - return app.runController('submit');
  67 + var params = {
  68 + id:id,
  69 + sn:sn
  70 + }
  71 + return app.runController('customer-order', params);
62 72 },
63   - 'order-details/:id': function (id) {
  73 + 'rate/:id/:sn': function (id,sn) {
64 74 fromOutside = false;
65 75 _autoLoading();
66 76 var params = {
67   - id:id
  77 + id:id,
  78 + sn:sn
68 79 }
69   - return app.runController('order-details', params);
  80 + return app.runController('rate',params);
70 81 },
71 82 'cost-list/:id': function (id) {
72 83 fromOutside = false;
... ...
web/src/js/order/cost-list-controller.js
... ... @@ -20,6 +20,7 @@ define(
20 20 ctrl.run = function () {
21 21 var me = this;
22 22 me.setPageTitle("费用列表");
  23 + me.id = me.params.id
23 24 me.imgLimit = 9;
24 25 me.canSubmit = true;
25 26 me.render();
... ... @@ -151,11 +152,11 @@ define(
151 152 return false;
152 153 }
153 154 me.canSubmit = false;
154   - var pData = me.csrf({images:images, plans: repairPlan});
  155 + var pData = me.csrf({images:images, plans: repairPlan, id:me.id});
155 156 utils.httpPost(submitURL,pData, function(res){
156 157 me.canSubmit = true;
157 158 if (res.success) {
158   - window.location.replace(url.to('order/#item-details/'+me.id))
  159 + window.location.replace(url.to('order#order-details/'+me.id))
159 160 } else {
160 161 utils.toast({content:res.message})
161 162 }
... ...
web/src/js/order/customer-order-controller.js 0 → 100644
... ... @@ -0,0 +1,50 @@
  1 +/**
  2 + * 维修中页
  3 + */
  4 +define(
  5 + "order/customer-order-controller",
  6 + [
  7 + 'mk7/controller',
  8 + 'mk7/url',
  9 + 'mk7/utils',
  10 + ],
  11 +
  12 + function(ctrl, url, utils) {
  13 +
  14 + var $$ = Dom7;
  15 + var t7 = Template7;
  16 + var ctrl = new ctrl();
  17 +
  18 + var pageURL = 'order/customer/order-details';
  19 + ctrl.run = function () {
  20 + var me = this;
  21 + me.id = me.params.id;
  22 + me.sn = me.params.sn;
  23 + me.setPageTitle("维修单");
  24 + me.loadPage();
  25 + }
  26 + ctrl.bindEvents = function () {
  27 + var me = this;
  28 + console.log("bindEvents");
  29 + me.goToComment();
  30 + }
  31 + ctrl.loadPage = function() {
  32 + var me = this
  33 + var pData = me.csrf({id: me.id});
  34 + utils.httpPost(url.to(pageURL), pData, function(res) {
  35 + var rData = res;
  36 + me.render(rData);
  37 + }, true)
  38 +
  39 + }
  40 +
  41 + ctrl.goToComment = function() {
  42 + var me = this;
  43 + $$('#customer-order .rate-btn-cls').click(function(e){
  44 + window.location.replace(url.to('order/customer#rate/'+me.id+'/'+me.sn))
  45 + })
  46 +
  47 + }
  48 + return ctrl;
  49 + }
  50 +);
... ...
web/src/js/order/order-details-controller.js
... ... @@ -31,7 +31,7 @@ define(
31 31 ctrl.loadPage = function() {
32 32 var me = this
33 33 var pData = me.csrf({id: me.id});
34   - utils.httpGet(pageURL, pData, function(res) {
  34 + utils.httpPost(url.to(pageURL), pData, function(res) {
35 35 var rData = res;
36 36 me.render(rData);
37 37 }, true)
... ...
web/src/js/order/rate-controller.js
1 1 /**
2   - * 订单评价-首页
  2 + * 订单评价
3 3 */
4 4 define(
5 5 "order/rate-controller",
... ... @@ -15,10 +15,11 @@ define(
15 15 var t7 = Template7;
16 16 var ctrl = new ctrl();
17 17  
18   - var submitURL = 'order/default/submit-rate';
  18 + var submitURL = 'order/customer/submit-rate';
19 19 ctrl.run = function () {
20 20 var me = this;
21 21 me.id = me.params.id;
  22 + me.sn = me.params.sn;
22 23 me.setPageTitle("评价");
23 24 me.loadPage();
24 25 }
... ... @@ -65,7 +66,7 @@ define(
65 66 var pData = me.csrf({star:star,comment:comment});
66 67 utils.httpPost(url.to(submitURL), pData, function(res) {
67 68 if (res.success) {
68   - window.location.replace('order/#order-details/'+me.id);
  69 + window.location.replace(url.to('order/customer#customer-order/'+me.id+'/'+me.sn));
69 70 } else {
70 71 utils.toast({content:res.message});
71 72 }
... ...
web/src/js/order/submit-controller.js
... ... @@ -8,9 +8,10 @@ define(
8 8 'mk7/url',
9 9 'mk7/utils',
10 10 'mk7/uploadjs',
  11 + 'mk7/picker'
11 12 ],
12 13  
13   - function(ctrl, url, utils, uploadjs) {
  14 + function(ctrl, url, utils, uploadjs, picker) {
14 15  
15 16 var $$ = Dom7;
16 17 var t7 = Template7;
... ... @@ -19,6 +20,7 @@ define(
19 20 var uploadURL = '/user/default/upload-file';
20 21 var submitURL = '/order/default/submit';
21 22 var canSubmit = true;
  23 + var finishTime = '';
22 24 ctrl.run = function () {
23 25 var me = this;
24 26 me.setPageTitle("录入维修单");
... ... @@ -30,6 +32,7 @@ define(
30 32 console.log("bindEvents");
31 33 me.uploadImgEvent();
32 34 me.submitEvent();
  35 + me.selectDateEvent();
33 36 }
34 37 ctrl.uploadImgEvent = function() {
35 38 var me = this;
... ... @@ -48,7 +51,6 @@ define(
48 51 try {
49 52 if (response.success) {
50 53 var imgUrl = response.tmpUrl;
51   -
52 54 $$('<li class="upload-li up-img"><div data="' + response.tmpFile + '" data-url="' + imgUrl + '" class="upload-item" style="background-image:url(' + response.tmpMinUrl + ')">' + '</div><span class="del-img"></span></li>').insertBefore(uploadParent);
53 55 if (me.imgLimit == $$('#submit #image-list').find('.up-img').length) {
54 56 $$('#submit .upload-btn-li').hide();
... ... @@ -133,7 +135,7 @@ define(
133 135 utils.toast({content:message});
134 136 return false;
135 137 } else {
136   - window.location.href = url.to('/');
  138 + window.location.replace(url.to('order#order-details/'+res.orderId));
137 139 }
138 140 }, true);
139 141  
... ... @@ -152,6 +154,179 @@ define(
152 154  
153 155 return returnImg;
154 156 }
  157 + ctrl.selectDateEvent = function() {
  158 + var me = this
  159 + $$('#submit .finish-date-input').click(function(e) {
  160 + var cData = $$(this).val();
  161 + console.log(cData)
  162 + me.dateTimeSelector('#submit .finish-date-input', cData);
  163 + })
  164 + }
  165 + ctrl.dateTimeSelector = function(dateId, cData) {
  166 + var me = this;
  167 + var curDay = new Date();
  168 + var maxDays = 30;
  169 + var yearDefaultSelect = curDay.getFullYear();
  170 + var monthDefaultSelect = curDay.getMonth();
  171 + var dateDefaultSelect = curDay.getDate();
  172 + var hoursSelect = curDay.getHours();
  173 + var cDateFormat = yearDefaultSelect + '-' + (monthDefaultSelect+1) + '-' +dateDefaultSelect;
  174 + if ('' != cData && null != cData && undefined !== cData) {
  175 + var cD = cData.split(' ')
  176 + cDateFormat = cD[0];
  177 + hoursSelect = cD[1];
  178 + }
  179 +
  180 + //console.log(cDateFormat)
  181 + //console.log(hoursSelect)
  182 + var sDays = [];
  183 + for( i= 0; i<= maxDays; i++){
  184 + var thisDay = new Date();
  185 + thisDay.setDate(curDay.getDate()+i);
  186 + var setD = thisDay.getFullYear()+'-'+(thisDay.getMonth()+1)+'-'+thisDay.getDate();
  187 + sDays.push(setD);
  188 + }
  189 +
  190 + var pickerInline = me.app.picker({
  191 + input : dateId,
  192 + toolbarTemplate :
  193 + '<div class="toolbar">' +
  194 + '<div class="toolbar-inner">' +
  195 + '<div class="left">' +
  196 + '请选择用工时间' +
  197 + '</div>' +
  198 + '<div class="right">' +
  199 + '<a href="javascript:void(0);" class="link submit-confirm-picker">确定</a>' +
  200 + '</div>' +
  201 + '</div>' +
  202 + '</div>',
  203 +
  204 + value : [ cDateFormat, hoursSelect],
  205 +
  206 + onChange: function (picker, values, displayValues) {
  207 +
  208 + var year,month,date;
  209 + if(values[0] instanceof Date){
  210 + year = values[0].getFullYear();
  211 + month = (values[0].getMonth());
  212 + date = values[0].getDate();
  213 + }else{
  214 + var cD = values[0].split('-');
  215 + year = cD[0];
  216 + month = cD[1] - 1;
  217 + date = cD[2];
  218 + }
  219 +
  220 + var selectedDay = new Date(year, month, date, values[1], 0);
  221 + var cDate = new Date(new Date().getTime() + 60 * 60 * 1000); //1小时后
  222 +
  223 + if (selectedDay < cDate) {
  224 +
  225 + if(undefined === picker.cols[0]) {
  226 + return false;
  227 + }
  228 + var setHours = cDate.getHours();
  229 + var myDate = cDate.getFullYear() + '-' + (cDate.getMonth()+1) + '-' + cDate.getDate();
  230 +
  231 + var nextHoursDate = new Date(cDate.getFullYear(), cDate.getMonth(), cDate.getDate(), cDate.getHours(), 0);
  232 + // 还有15分钟就下一个小时的
  233 + if ((nextHoursDate - (new Date())) < 15 * 60 *1000 ) {
  234 + var nextNextHoursDate = new Date(nextHoursDate.getTime() + 60 * 60 * 1000);
  235 + setHours = nextNextHoursDate.getHours();
  236 + myDate = nextNextHoursDate.getFullYear() + '-' + (nextNextHoursDate.getMonth()+1) + '-' + nextNextHoursDate.getDate();
  237 + }
  238 +
  239 + picker.cols[0].setValue(myDate);
  240 + picker.cols[2].setValue(setHours);
  241 + }
  242 + },
  243 +
  244 + formatValue: function (picker, values, displayValues) {
  245 + var date ='';
  246 + if (values[0] instanceof Date) {
  247 + date = values[0].getFullYear()+'-'+ (values[0].getMonth()+1) +'-'+values[0].getDate();
  248 + } else {
  249 + date = values[0];
  250 + }
  251 +
  252 + var rd = date + " " + values[1];// +':'+values[2]
  253 + return rd
  254 + },
  255 +
  256 + cols: [
  257 + // Years
  258 + {
  259 + values: sDays,
  260 + displayValues:(function(){
  261 + var arr = [];
  262 + var date = new Date();
  263 + var todayYear = date.getFullYear();
  264 + var todayMonth = date.getMonth() +1;
  265 + var todayDate = date.getDate();
  266 + date.setDate(date.getDate() + 1);
  267 + for (var i = 0; i < sDays.length; i++) {
  268 + var gd = sDays[i];
  269 + var d = gd.split('-');
  270 + var pushDate = d[1]+'月'+d[2]+'日';
  271 + if(todayYear == d[0] && (todayMonth * 1) == d[1] && (todayDate * 1) == d[2]){
  272 + pushDate = pushDate + '(今天)';
  273 + }
  274 + if((date.getFullYear() *1) == d[0] && ((date.getMonth() *1)+1) == d[1] && (date.getDate() *1) == d[2]){
  275 + pushDate = pushDate + '(明天)';
  276 + }
  277 + arr.push(pushDate);
  278 + }
  279 + return arr;
  280 + })()
  281 + },
  282 + // Space divider
  283 + {
  284 + divider: true,
  285 + content: ' '
  286 + },
  287 + // Hours
  288 + {
  289 + values: (function () {
  290 + var arr = [];
  291 + for (var i = 0; i <= 23; i++) { arr.push(i); }
  292 + return arr;
  293 + })(),
  294 + displayValues:(function(){
  295 + var arr = [];
  296 + for (var i = 0; i <= 23; i++) { arr.push(i < 10 ? '0' + i+ '时' : i+'时'); }
  297 + return arr;
  298 + })()
  299 + },
  300 + // Space divider
  301 + {
  302 + divider: true,
  303 + content: ' '
  304 + },
  305 + ],
  306 + onClose : function(e) {
  307 + if(pickerInline) {
  308 + // 设置年月日
  309 + var values = pickerInline.value;
  310 + var hourStr = values[1] < 10 ? "0"+values[1] : values[1];
  311 + finishTime = values[0]+' '+hourStr;
  312 + $$(dateId).val(finishTime);
  313 +
  314 + pickerInline.destroy();
  315 + }
  316 + }
  317 + });
  318 + pickerInline.open();
  319 + $$('.submit-confirm-picker').on('click', function(e){
  320 + e.preventDefault();
  321 + // 设置年月日
  322 + var values = pickerInline.value;
  323 + var hourStr = values[1] < 10 ? "0"+values[1] : values[1];
  324 + finishTime = values[0]+' '+hourStr; //+':'+minStr
  325 + $$(dateId).val(finishTime);
  326 +
  327 + pickerInline.destroy();
  328 + });
  329 + }
155 330 return ctrl;
156 331 }
157 332 );
... ...
web/src/js/user/login-controller.js
... ... @@ -23,6 +23,10 @@ define(
23 23 var me = this;
24 24 me.setPageTitle("登录");
25 25 me.codeDuration = 60;
  26 + if (!isGuest) {
  27 + window.location.href = url.to('order/#index');
  28 + return '';
  29 + }
26 30 me.render();
27 31 }
28 32 ctrl.bindEvents = function () {
... ... @@ -36,18 +40,30 @@ define(
36 40 ctrl.getCodeEvent = function() {
37 41 var me = this;
38 42 $$('#login .get-code-cls').click(function() {
  43 + var mobile = utils.trim($$('#login .mobile').val());
  44 + if ('' == mobile) {
  45 + utils.toast({content:'手机号码必填'})
  46 + return false;
  47 + }
  48 + if (!utils.isMobile(mobile)) {
  49 + utils.toast({content:'手机号码不合格'})
  50 + return false;
  51 + }
39 52 if (false == clickGetCode) {
40 53 return false;
41 54 }
42 55 clearInterval(tt);
43 56 clickGetCode = false;
44   - var pData = me.csrf({action:'login'})
  57 + var pData = me.csrf({action:'login', mobile:mobile})
45 58 utils.httpGet(url.to(getCodeURL), pData, function(res) {
46 59 if (!res.success) {
47 60 utils.toast({content:res.message,closeDelay:3000})
48 61 clickGetCode = true;
49 62 return false;
50 63 }
  64 + if(res.testCode) {
  65 + $$('#login .code').val(res.testCode);
  66 + }
51 67 var codeDuration = res.codeDuration
52 68 me.codeDuration = codeDuration;
53 69 tt = setInterval(function(e) {
... ... @@ -90,13 +106,12 @@ define(
90 106 loginClick = false;
91 107 var pData = me.csrf({mobile:mobile,code:code})
92 108 utils.httpPost(url.to(loginURL),pData, function(res) {
  109 + loginClick = true;
93 110 if (!res.success) {
94 111 utils.toast({content:res.message,closeDelay:3000})
95   - loginClick = true;
96 112 return false;
97 113 } else {
98   - loginClick = true;
99   - window.location.href = url.to('/');
  114 + window.location.href = url.to('order/#index');
100 115 }
101 116 })
102 117 })
... ...
web/src/js/user/register-controller.js
... ... @@ -28,6 +28,10 @@ define(
28 28 me.setPageTitle("注册");
29 29 //me.hideAllNonBaseMenuItem(window.$site);
30 30 me.codeDuration = 60;
  31 + if (!isGuest) {
  32 + window.location.href = url.to('order/#index');
  33 + return '';
  34 + }
31 35 me.render();
32 36 }
33 37 ctrl.bindEvents = function () {
... ... @@ -71,18 +75,31 @@ define(
71 75 ctrl.getCodeEvent = function() {
72 76 var me = this;
73 77 $$('#register .get-code-cls').click(function() {
  78 + var mobile = utils.trim($$('#register .mobile').val());
  79 + if ('' == mobile) {
  80 + utils.toast({content:'手机号码必填'})
  81 + return false;
  82 + }
  83 + if (!utils.isMobile(mobile)) {
  84 + utils.toast({content:'手机号码不合格'})
  85 + return false;
  86 + }
74 87 if (false == clickGetCode) {
75 88 return false;
76 89 }
77 90 clearInterval(tt);
78 91 clickGetCode = false;
79   - var pData = me.csrf({action:'register'})
  92 +
  93 + var pData = me.csrf({action:'register', mobile:mobile})
80 94 utils.httpGet(url.to(getCodeURL), pData, function(res) {
81 95 if (!res.success) {
82 96 utils.toast({content:res.message,closeDelay:3000})
83 97 clickGetCode = true;
84 98 return false;
85 99 }
  100 + if(res.testCode) {
  101 + $$('#register .code').val(res.testCode);
  102 + }
86 103 var codeDuration = res.codeDuration
87 104 me.codeDuration = codeDuration;
88 105 tt = setInterval(function(e) {
... ... @@ -122,8 +139,8 @@ define(
122 139 return false;
123 140 }
124 141  
125   - var imgURL = $$('#register .upload-btn-cls').attr('data');
126   - if (undefined === imgURL || null == imgURL) {
  142 + var licensePic = $$('#register .licensePic').attr('data');
  143 + if (undefined === licensePic || null == licensePic) {
127 144 utils.toast({content:'请上传营业执照'})
128 145 return false;
129 146 }
... ... @@ -131,14 +148,14 @@ define(
131 148 return false;
132 149 }
133 150 registerClick = false;
134   - var pData = me.csrf({name:name, mobile:mobile,code:code,img:imgURL})
  151 + var pData = me.csrf({name:name, mobile:mobile,code:code,licensePic:licensePic})
135 152 utils.httpPost(url.to(registerUrl),pData, function(res) {
136 153 if (!res.success) {
137 154 utils.toast({content:res.message,closeDelay:3000})
138 155 registerClick = true;
139 156 return false;
140 157 } else {
141   - window.location.href = url.to('/');
  158 + window.location.href = url.to('order/#index');
142 159 }
143 160 })
144 161 })
... ...