From 32926e460f8938a8d21fd8a91cbc3115462c621e Mon Sep 17 00:00:00 2001 From: xu Date: Fri, 27 Dec 2019 16:11:16 +0800 Subject: [PATCH] app-wx(v0.1.0 build 11) 1. F 调整维修厂登录和注册的User 类 2. A 注册登录集成 发短信码 3. F 提交维修单界面,录入车型改为查找筛选. 非必填字段调整 4. A 完成维修订单那里默认价格0 去除了 --- app-wx/config/main.php | 2 +- app-wx/config/params.php | 2 +- app-wx/models/User.php | 94 ++++++++++++++++------------------------------------------------------------------------------ app-wx/models/UserIdentity.php | 70 ++++++++++++++++++++++++++++++++++++++++++++++++---------------------- app-wx/modules/order/controllers/CustomerController.php | 15 +++++++++++---- app-wx/modules/order/controllers/DefaultController.php | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- app-wx/modules/order/views/default/pages/cost-list-template.php | 6 +++--- app-wx/modules/order/views/default/pages/submit-template.php | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------- app-wx/modules/user/controllers/LoginController.php | 26 ++++++++++++++++++++------ domain/user/models/User.php | 31 ------------------------------- web/dist/js/order-app.js | 2 +- web/dist/js/user-app.js | 2 +- web/src/js/order/cost-list-controller.js | 2 +- web/src/js/order/submit-controller.js | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- web/src/js/user/login-controller.js | 1 + web/src/js/user/register-controller.js | 1 + 16 files changed, 298 insertions(+), 162 deletions(-) diff --git a/app-wx/config/main.php b/app-wx/config/main.php index d6d3e41..38adad9 100644 --- a/app-wx/config/main.php +++ b/app-wx/config/main.php @@ -23,7 +23,7 @@ return [ ], 'components' => [ 'user' => [ - 'identityClass' => 'app\wx\models\User', + 'identityClass' => 'app\wx\models\UserIdentity', 'enableAutoLogin' => true, 'identityCookie' => ['name' => '_identity-gk', 'httpOnly' => true], ], diff --git a/app-wx/config/params.php b/app-wx/config/params.php index 705a1c0..beab61d 100644 --- a/app-wx/config/params.php +++ b/app-wx/config/params.php @@ -1,5 +1,5 @@ 'admin@example.com', - 'VERSION' => 'v0.1.0 build 9', // 当前发布版本号: v0.1.0 是版本号 | build 1 是编译次数 + 'VERSION' => 'v0.1.0 build 11', // 当前发布版本号: v0.1.0 是版本号 | build 1 是编译次数 ]; diff --git a/app-wx/models/User.php b/app-wx/models/User.php index 2af34c6..89e88ea 100644 --- a/app-wx/models/User.php +++ b/app-wx/models/User.php @@ -3,6 +3,7 @@ namespace app\wx\models; use Yii; +use yii\base\NotSupportedException; use yii\web\IdentityInterface; use domain\user\models\User as UserModel; @@ -12,105 +13,42 @@ use domain\user\models\User as UserModel; */ class User extends UserModel implements IdentityInterface { - - static $id = null; - public function register() + /** + * @param mixed $condition + * @return static + */ + static function findOne($condition) { - + return parent::findOne($condition); // TODO: Change the autogenerated stub } - - - - - /** - * Finds an identity by the given ID. - * - * @param string|int $id the ID to be looked for - * @return IdentityInterface|null the identity object that matches the given ID. - */ + /** @inheritdoc */ public static function findIdentity($id) { return static::findOne($id); } - /** - * Finds an identity by the given token. - * - * @param string $token the token to be looked for - * @return IdentityInterface|null the identity object that matches the given token. - */ + /** @inheritdoc */ public static function findIdentityByAccessToken($token, $type = null) { - return static::findOne(['access_token' => $token]); + throw new NotSupportedException('"findIdentityByAccessToken" is not implemented.'); } - /** - * @inheritdoc - */ + /** @inheritdoc */ public function getId() { - return self::getIdFromSession(); + return $this->getAttribute('id'); } - /** - * @inheritdoc - */ + /** @inheritdoc */ public function getAuthKey() { - return ''; + return $this->getAttribute('auth_key'); } - /** - * @inheritdoc - */ + /** @inheritdoc */ public function validateAuthKey($authKey) { - return true; - } - - /** - * Validates password - * - * @param string $password password to validate - * @return bool if password provided is valid for current user - */ - public function validatePassword($password) - { - return true ;//Yii::$app->security->validatePassword($password, $this->password_hash); - } - - /** - * Generates password hash from password and sets it to the model - * - * @param string $password - */ - public function setPassword($password) - { - $this->password_hash = Yii::$app->security->generatePasswordHash($password); - } - - /** - * Generates new password reset token - */ - public function generatePasswordResetToken() - { - $this->password_reset_token = Yii::$app->security->generateRandomString() . '_' . time(); - } - - /** - * @return mixed|null - */ - protected static function getIdFromSession() - { - if (null === self::$id){ - $user = Yii::$app->getUser(); - $session = Yii::$app->getSession(); - $id = $session->getHasSessionId() || $session->getIsActive() ? $session->get($user->idParam) : null; - self::$id = $id; - } - - return self::$id; + return $this->getAttribute('auth_key') == $authKey; } - } diff --git a/app-wx/models/UserIdentity.php b/app-wx/models/UserIdentity.php index 2a44115..47bba90 100644 --- a/app-wx/models/UserIdentity.php +++ b/app-wx/models/UserIdentity.php @@ -1,42 +1,41 @@ $token]); } /** - * @return int|string $id + * @inheritdoc */ public function getId() { @@ -44,17 +43,15 @@ class UserIdentity implements IdentityInterface } /** - *不启动自动登录,AuthKey 是用来设定到cookie的字符串 - * + * @inheritdoc */ public function getAuthKey() { - return ""; + return ''; } /** - * 不启动自动登录,这里默认返回true - * @param string $authKey + * @inheritdoc */ public function validateAuthKey($authKey) { @@ -62,12 +59,41 @@ class UserIdentity implements IdentityInterface } /** + * Validates password + * + * @param string $password password to validate + * @return bool if password provided is valid for current user + */ + public function validatePassword($password) + { + return true ;//Yii::$app->security->validatePassword($password, $this->password_hash); + } + + /** + * Generates password hash from password and sets it to the model + * + * @param string $password + */ + public function setPassword($password) + { + $this->password_hash = Yii::$app->security->generatePasswordHash($password); + } + + /** + * Generates new password reset token + */ + public function generatePasswordResetToken() + { + $this->password_reset_token = Yii::$app->security->generateRandomString() . '_' . time(); + } + + /** * @return mixed|null */ protected static function getIdFromSession() { if (null === self::$id){ - $user = \Yii::$app->getUser(); + $user = Yii::$app->getUser(); $session = Yii::$app->getSession(); $id = $session->getHasSessionId() || $session->getIsActive() ? $session->get($user->idParam) : null; self::$id = $id; diff --git a/app-wx/modules/order/controllers/CustomerController.php b/app-wx/modules/order/controllers/CustomerController.php index 2a1590d..c3e0cb7 100644 --- a/app-wx/modules/order/controllers/CustomerController.php +++ b/app-wx/modules/order/controllers/CustomerController.php @@ -68,16 +68,23 @@ class CustomerController extends CustomerBaseController $hasComment = true; $comments = ['starTxt' => RepairOrderRate::starLabel($rateModel->star_count), 'comment' => $rateModel->comment]; } - + $preFinishDate = '暂无'; + $predictPrice = '暂无'; + if($orderModel->predict_finish_time) { + $preFinishDate = date('Y-m-d H:00', $orderModel->predict_finish_time); + } + if($orderModel->predict_price) { + $predictPrice = $orderModel->predict_price.'元'; + } $e->success = true; $e->item = [ 'carNo' => $orderModel->car_no, 'carModel' => $orderModel->car_model, 'customer' => $orderModel->customer, 'mobile' => '1*****'.substr($orderModel->contact_mobile,7,4), - 'preRepair' => $orderModel->predict_fault, - 'repairPrice' => $orderModel->predict_price.'元', - 'preFinishDate' => date('Y-m-d H:00', $orderModel->predict_finish_time), + 'preRepair' => empty($orderModel->predict_fault)?'暂无':$orderModel->predict_fault, + 'repairPrice' => $predictPrice, + 'preFinishDate' => $preFinishDate, 'orderDateTime' => date('Y-m-d H:00', $orderModel->created_at), 'status' => RepairOrderStatus::getEnLabel($orderModel->status), 'hasComment' => $hasComment, diff --git a/app-wx/modules/order/controllers/DefaultController.php b/app-wx/modules/order/controllers/DefaultController.php index 9232e46..b12afde 100644 --- a/app-wx/modules/order/controllers/DefaultController.php +++ b/app-wx/modules/order/controllers/DefaultController.php @@ -63,6 +63,12 @@ class DefaultController extends BaseController $e->message = '联系电话未填'; return $this->renderJson($e); } + if (empty($finishDate)) { + $predict_finish_time= null; + } else { + $predict_finish_time = strtotime($finishDate.':00:00'); + } + $data = [ 'user_id' => $userId, @@ -72,7 +78,7 @@ class DefaultController extends BaseController 'contact_mobile' => $phone, 'predict_fault' => $preRepair, 'predict_price' => $predictPrice, - 'predict_finish_time' => strtotime($finishDate.':00:00'), + 'predict_finish_time' => $predict_finish_time, 'status' => RepairOrderStatus::WORKING, ]; $tran = Yii::$app->db->beginTransaction(); @@ -195,15 +201,23 @@ class DefaultController extends BaseController $comments = ['starTxt' => RepairOrderRate::starLabel($rateModel->star_count), 'comment' => $rateModel->comment]; } $shortId = $orderModel->short_uuid; + $preFinishDate = '暂无'; + $predictPrice = '暂无'; + if($orderModel->predict_finish_time) { + $preFinishDate = date('Y-m-d H:00', $orderModel->predict_finish_time); + } + if($orderModel->predict_price) { + $predictPrice = $orderModel->predict_price.'元'; + } $e->success = true; $e->item = [ 'carNo' => $orderModel->car_no, 'carModel' => $orderModel->car_model, 'customer' => $orderModel->customer, 'mobile' => $orderModel->contact_mobile, - 'preRepair' => $orderModel->predict_fault, - 'repairPrice' => $orderModel->predict_price.'元', - 'preFinishDate' => date('Y-m-d H:00', $orderModel->predict_finish_time), + 'preRepair' => empty($orderModel->predict_fault)?'暂无':$orderModel->predict_fault, + 'repairPrice' => $predictPrice, + 'preFinishDate' => $preFinishDate, 'orderDateTime' => date('Y-m-d H:00', $orderModel->created_at), 'status' => RepairOrderStatus::getEnLabel($orderModel->status), 'hasComment' => $hasComment, @@ -264,4 +278,43 @@ class DefaultController extends BaseController return $this->renderJson($e); } + /** + * 查找汽车型号 + * @return string + */ + public function actionSearchModel() + { + $e = new stdClass(); + $e->success = false; + $request = Yii::$app->request; + $keyword = $request->post('keyword'); + if (empty($keyword)) { + $e->message = '关键字为空'; + return $this->renderJson($e); + } + $items = []; + $models = [ + ['name' => '宝马X1'], + ['name' => '宝马X2'], + ['name' => '宝马X3'], + ['name' => '宝马X4'], + ['name' => '宝马X5'], + ['name' => '宝马X6'], + ['name' => '宝马X7'], + ['name' => '奔驰C200K'], + ['name' => '奔驰C280'], + ['name' => '奔驰E200K'], + ['name' => '奔驰E230'], + ['name' => '奔驰E280'], + ]; + foreach ($models as $k => $v) { + if (false !== strpos($v['name'], strtoupper($keyword))) { + $items[] = $v; + } + } + $e->items = $items; + $e->success = true; + return $this->renderJson($e); + } + } \ No newline at end of file diff --git a/app-wx/modules/order/views/default/pages/cost-list-template.php b/app-wx/modules/order/views/default/pages/cost-list-template.php index 5061334..833046f 100644 --- a/app-wx/modules/order/views/default/pages/cost-list-template.php +++ b/app-wx/modules/order/views/default/pages/cost-list-template.php @@ -22,8 +22,8 @@ $baseUrl = Url::base(true); #cost-list .img-plus {width: 1rem; height: 1rem; vertical-align: text-top; margin-right: 0.2rem} #cost-list .item-title { font-size:0.88rem;display:inline-block;font-weight:400; color:rgba(186,186,186,1); line-height:1.81rem;} #cost-list .input-cls{font-size: 1rem;line-height: inherit} - #cost-list .input-left {width:70%; padding: 0 0.5rem; height:2.47rem; background:rgba(255,255,255,1); border:1px solid rgba(221,221,221,1); border-radius:0rem 0rem 0rem 0rem;} - #cost-list .input-right {width:30%; height:2.47rem; padding: 0 0.5rem; text-align: center; background:rgba(255,255,255,1); border:1px solid rgba(221,221,221,1); border-radius:0rem 0rem 0rem 0rem; border-left: none} + #cost-list .input-left {width:70%; padding: 0 0.5rem; height:2.47rem; background:rgba(255,255,255,1); border:1px solid rgba(221,221,221,1); border-radius:0;} + #cost-list .input-right {width:30%; height:2.47rem; padding: 0 0.5rem; text-align: center; background:rgba(255,255,255,1); border:1px solid rgba(221,221,221,1); border-radius:0; border-left: none} #cost-list .repair-item-cls .del-plan{width:1.2rem;position: absolute;top: -18px;right: -2px;height: 1.2rem;background: url('/i/order/trash.png');background-repeat: no-repeat;background-size: 1rem auto;background-position: 1px 1px;display:inline-block;z-index:12} #cost-list .upload-box{padding: 1rem;box-sizing: border-box;background:#fff;margin-top:1rem;} #cost-list .upload-box .upload-title{line-height: 1.5rem;color:#000000;margin-bottom: 0.5rem;font-size:1rem;} @@ -62,7 +62,7 @@ $baseUrl = Url::base(true);

第1项

- +
diff --git a/app-wx/modules/order/views/default/pages/submit-template.php b/app-wx/modules/order/views/default/pages/submit-template.php index d65427a..7bc3ee5 100644 --- a/app-wx/modules/order/views/default/pages/submit-template.php +++ b/app-wx/modules/order/views/default/pages/submit-template.php @@ -19,7 +19,13 @@ $baseUrl = Url::base(true); #submit .s-li-div .s-li-div-input{font-size: 1rem;width:100%;border: 0;line-height: inherit} #submit .s-li-label{color:#000000;font-size:1rem;line-height: 1.25rem;display: flex;align-items: center;padding:0.3rem 0;} #submit .s-li-div .require-cls{color:#FC7621;display:flex;align-items: center;margin-left: 0.3rem;} - + #submit .s-li-div .repairPrice{padding-right: 1.5rem;box-sizing: border-box;} + #submit .s-li-div .price-union-cls{display: inline-block;position: absolute; right: 0.5rem;top:0.5rem} + #submit .s-li-div .down-arrow{ width: 0; + height: 0; + border-width: 0.4rem; + border-top-width: 0.5rem; + border-bottom:0;position: absolute;right: 0.5rem;top:0.8rem;border-style: solid;border-color: #999 rgba(0,0,0,0) rgba(0,0,0,0) rgba(0,0,0,0);} #submit .upload-box{padding: 1rem;box-sizing: border-box;background:#fff;margin-top:1rem;} #submit .upload-box .upload-title{line-height: 1.5rem;color:#000000;margin-bottom: 0.5rem;font-size:1rem;} #submit .upload-box .note-cls{color:#555555;font-size:0.75rem} @@ -36,6 +42,22 @@ $baseUrl = Url::base(true); #submit .upload-box .del-img{position: absolute;top: 0;left: 0;width: 0.8rem;height: 0.9rem;background-image:url('/i/order/trash.png');background-repeat: no-repeat;background-size: 0.8rem auto;background-color:#fff;border-radius: 0.2rem;} #submit .submit-btn-box{width:100%;display: block;padding:2rem ;box-sizing: border-box} #submit .submit-btn-box .submit-btn-cls{width:100%;background-color:#FF8728;color:#fff;border-radius: 2rem;padding:1rem; box-sizing: border-box;font-size: 1rem;text-align: center;margin:0 auto;} + #submit #search-wrapper{position: absolute;top: 0;bottom: 0;width: 100%;z-index: 2;padding:3rem 2rem;box-sizing: border-box;background: rgba(0,0,0,0.3);} + #submit #search-wrapper .search-wrapper-inner{width:100%;background: #fff;height:100%;} + #submit #search-wrapper .search-input-cls{ font-size: 1rem;line-height: inherit; width: 100%;padding: 0; border: 0;background: #EFEFEF;} + #submit #search-wrapper .search-box-cls{width: 100%;line-height: 1.0rem;padding: 0.5rem 0.8rem;box-sizing: border-box;padding-top:1.25rem;position: relative} + + .pages #search-wrapper .search-box-cls .closeBtn{position: absolute;top:-1rem;right:-0.5rem;width:1.5rem;height:1.5rem;border-radius: 1rem;background: #fff;border: 1px solid #999;} + .pages #search-wrapper .search-box-cls .closeBtn:before, + .pages #search-wrapper .search-box-cls .closeBtn:after{content:'';display:block;width:1px ;height:0.8rem;background: #999;transform: rotate(45deg); top: 5px;right: 11px;position:absolute} + .pages #search-wrapper .search-box-cls .closeBtn:after{transform: rotate(-45deg); top: 5px;right: 11px;} + .pages #search-wrapper .model-list{padding: 0 0.8rem;width: 100%;box-sizing: border-box;} + .pages #search-wrapper .model-list .model-div-cls{padding-bottom: 0.3rem;border-bottom: 1px solid #ccc;line-height: 1.5rem} + .pages #search-wrapper .model-list .model-item-cls{padding:0.5rem 0;padding-top:0;width: 100%;} + + #search-wrapper .search-form{display:flex;width:100%;} + #search-wrapper .model-search-cls{background:#EFEFEF;color:#2c2a2a;width: 5rem;text-align: center;padding: 0.3rem;box-sizing: border-box;margin-left: 0.2rem;} + #search-wrapper .search-input-box{width:100%;background:#EFEFEF;padding: 0.3rem;box-sizing: border-box;} + + \ No newline at end of file diff --git a/app-wx/modules/user/controllers/LoginController.php b/app-wx/modules/user/controllers/LoginController.php index 23725a7..8c1d195 100644 --- a/app-wx/modules/user/controllers/LoginController.php +++ b/app-wx/modules/user/controllers/LoginController.php @@ -3,12 +3,14 @@ namespace app\wx\modules\user\controllers; use Yii; +use app\wx\models\User as ClientUserModel; use domain\user\User; use common\helpers\Utils; use common\helpers\Log as AppLog; use domain\user\UserRepository; use common\helpers\ImageManager; use domain\user\PhoneCode; +use domain\system\SmsMessage; use stdClass; /** @@ -32,23 +34,29 @@ class LoginController extends BaseController $e->message = '请输入合格手机号码'; return $this->renderJson($e); } - $tt = time(); + if ('login' == $action) { - $userInfo = UserRepository::findOne(['mobile' => $mobile]); + $userInfo = ClientUserModel::findOne(['mobile' => $mobile]); if (empty($userInfo)) { $e->message = '登录失败,该手机未注册'; return $this->renderJson($e); } $code = $this->getLoginCode($mobile); + $sms = new SmsMessage(); if ($code) { // 发送短信 + $sms->sendLoginCode($mobile, $code); + $e->message = '您的登录码已经发送,请注意查收短信!'; } else { $code = $this->setLoginCode($mobile); // 发送短信 + $sms->sendLoginCode($mobile, $code); + $e->message = '您的登录码已经发送,请注意查收短信!'; } } else { - $userModel = UserRepository::findOne(['mobile' => $mobile]); + $userModel = ClientUserModel::findOne(['mobile' => $mobile]); + $sms = new SmsMessage(); if ($userModel) { $e->message = '该手机号码已经注册过'; return $this->renderJson($e); @@ -58,9 +66,13 @@ class LoginController extends BaseController if ($phoneCode) { $code = $phoneCode; //发送短信 + $sms->sendRegCode($mobile, $code); + $e->message = '您的注册码已经发送,请注意查收短信!'; } else { $code = $this->setRegisterCode($mobile); //发送短信 + $sms->sendRegCode($mobile, $code); + $e->message = '您的注册码已经发送,请注意查收短信!'; } } @@ -204,7 +216,7 @@ class LoginController extends BaseController } // 检查车厂名称是否注册了 // 检查手机号码是否注册了 - $userMobile = UserRepository::findOne(['mobile' => $mobile]); + $userMobile = ClientUserModel::findOne(['mobile' => $mobile]); if ($userMobile) { $e->message = '该手机号已经注册过维修厂,请更换其他手机号'; return $this->renderJson($e); @@ -220,7 +232,9 @@ class LoginController extends BaseController $saveImageInfo = ImageManager::mvUploadImage($licensePic, $userEntity->uuid); $userEntity->license_pic = $saveImageInfo[0].$saveImageInfo[1]; $userEntity->save(); - if ($this->processLogin($userEntity)) { + // 必须用 app\wx\models\User 才能登录 + $loginUserModel = ClientUserModel::findOne(['id' => $userEntity->id]); + if ($this->processLogin($loginUserModel)) { $e->success = true; } else { $e->message = '注册成功但是登录失败'; @@ -263,7 +277,7 @@ class LoginController extends BaseController } $where = ['mobile' => $mobile]; - $userInfo = UserRepository::findOne($where); + $userInfo = ClientUserModel::findOne($where); if (empty($userInfo)) { $e->message = '登录失败,该手机未注册'; return $this->renderJson($e); diff --git a/domain/user/models/User.php b/domain/user/models/User.php index 2f2b0e2..698f0c8 100644 --- a/domain/user/models/User.php +++ b/domain/user/models/User.php @@ -3,10 +3,8 @@ namespace domain\user\models; use common\helpers\Utils; -use yii\base\NotSupportedException; use yii\db\ActiveRecord; use yii\behaviors\TimestampBehavior; -use yii\web\IdentityInterface; /** * 用户 @@ -56,33 +54,4 @@ class User extends ActiveRecord $this->uuid = Utils::genUUID(); } - /** @inheritdoc */ - public static function findIdentity($id) - { - return static::findOne($id); - } - - /** @inheritdoc */ - public static function findIdentityByAccessToken($token, $type = null) - { - throw new NotSupportedException('"findIdentityByAccessToken" is not implemented.'); - } - - /** @inheritdoc */ - public function getId() - { - return $this->getAttribute('id'); - } - - /** @inheritdoc */ - public function getAuthKey() - { - return $this->getAttribute('auth_key'); - } - - /** @inheritdoc */ - public function validateAuthKey($authKey) - { - return $this->getAttribute('auth_key') == $authKey; - } } \ No newline at end of file diff --git a/web/dist/js/order-app.js b/web/dist/js/order-app.js index 04336a1..ed271da 100644 --- a/web/dist/js/order-app.js +++ b/web/dist/js/order-app.js @@ -1 +1 @@ -define("order-app",["mk7/app"],function(t){var e=Dom7,i=function(){var t=e(".ui-loading-block");0==t.length&&(e(".view-main").html('

'),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='加载速度太慢?试试重新加载',t.appendChild(e))},window.waitingTime))},n=!0;return t.name="order",t.routes={index:function(){return n=!1,i(),t.runController("index")},"index/:tab":function(e){n=!1,i();var r={tab:e};return t.runController("index",r)},submit:function(){return n=!1,i(),t.runController("submit")},"order-details/:id":function(e){n=!1,i();var r={id:e};return t.runController("order-details",r)},"customer-order/:id/:sn":function(e,r){n=!1,i();var a={id:e,sn:r};return t.runController("customer-order",a)},"rate/:id/:sn":function(e,r){n=!1,i();var a={id:e,sn:r};return t.runController("rate",a)},"cost-list/:id":function(e){n=!1,i();var r={id:e};return t.runController("cost-list",r)},"*":function(){return t.runController("index")}},t}),define("order/cost-list-controller",["mk7/controller","mk7/url","mk7/utils","mk7/uploadjs"],function(t,e,i,n){var r=Dom7,t=(Template7,new t),a="/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;r("#cost-list .add-repair-plan").click(function(e){var i=r("#cost-list .cost-list-div"),n=t.planTpl(i.length+1);r(n).insertBefore(r("#cost-list .cost-total-list-div"))})},t.delPlanEvent=function(){var t=this;r("#cost-list").on("click",".del-plan",function(e){console.log("del plan event"),r(this).parents(".cost-list-div").remove(),r("#cost-list .total-plan-price").html(t.computedPrice())})},t.planTpl=function(t){var e='

第'+t+'项

';return e},t.inputPriceChangeEvent=function(){var t=this;r("#cost-list").on("input propertychange",".input-cls",function(){var e=t.computedPrice();r("#cost-list .total-plan-price").html(e)})},t.computedPrice=function(){var t=r("#cost-list .input-right"),e=0;return r.each(t,function(t,i){e+=1*r(i).val()}),Math.round(e,2)},t.uploadImgEvent=function(){var t=this;r("#cost-list #upload-btn").change(function(){if(""!=r(this).val()&&null!=r(this).val()){var o=r(this).parents("li");n.uploadFile({selector:"#upload-btn",url:e.to(a),processAppendTo:"#cost-list",success:function(e,n){try{if(e.success){var a=e.tmpUrl;r('
  • ').insertBefore(o),t.imgLimit==r("#cost-list #image-list").find(".up-img").length&&r("#cost-list .upload-btn-li").hide()}else i.toast({content:e.message,closeDelay:5e3})}catch(s){console.log(s),i.toast({content:"出错",closeDelay:5e3})}}})}}),r("#cost-list #image-list").on("click",".del-img",function(e){r(this).parent().remove(),t.imgLimit>=r("#cost-list #image-list").find(".up-img").length&&r("#cost-list .upload-btn-li").show()})},t.submitEvent=function(){var t=this;r("#cost-list .btn-submit").click(function(n){var a=r("#cost-list .content-div").find(".repair-item-cls"),s=[],l=!0,c=!0;if(r.each(a,function(t,e){var n=i.trim(r(e).find(".input-left").val()),a=i.trim(r(e).find(".input-right").val());""==n&&(l=!1),""!=a&&0!=a||(c=!1),s.push({content:n,price:a})}),!l)return i.toast({content:"维修清单有部分未填内容"}),!1;if(!c)return i.toast({content:"维修清单有部分未填价格"}),!1;var d=r("#cost-list #image-list").find(".upload-item"),u=[];if(r.each(d,function(t,e){u.push(r(e).attr("data"))}),!t.canSubmit)return!1;t.canSubmit=!1;var m=t.csrf({images:u,plans:s,id:t.id});i.httpPost(o,m,function(n){t.canSubmit=!0,n.success?window.location.replace(e.to("order#order-details/"+t.id)):i.toast({content:n.message})},!0)})},t}),define("order/customer-order-controller",["mk7/controller","mk7/url","mk7/utils"],function(t,e,i){var n=Dom7,t=(Template7,new t),r="order/customer/order-details";return t.run=function(){var t=this;t.id=t.params.id,t.sn=t.params.sn,t.success=!0,t.setPageTitle("维修单"),t.loadPage()},t.bindEvents=function(){var t=this;console.log("bindEvents"),t.goToComment(),t.popupImageLayer()},t.beforeRender=function(){var t=this;console.log("beforeRender"),t.success||(this.view="customer-order-error")},t.loadPage=function(){var t=this,n=t.csrf({id:t.id});i.httpPost(e.to(r),n,function(e){var i=e;t.success=e.success,t.render(i)},!0)},t.goToComment=function(){var t=this;n("#customer-order .rate-btn-cls").click(function(i){window.location.replace(e.to("order/customer#rate/"+t.id+"/"+t.sn))})},t.popupImageLayer=function(){n("#customer-order").on("click",".view-img-cls",function(t){var e=n(this).attr("data-url");n("#img-mask").remove();var i='
    ';n("#customer-order").append(i)}),n("#customer-order").on("click","#img-mask, #img-mask img",function(t){t.preventDefault(),t.stopPropagation();var e=document.body.clientHeight,i=n("#img-mask img").height();console.log(e+"dddd"+i);var r=Math.abs(i-e);if(r>=0&&r<=20)n("#img-mask").remove();else{var a=n(t.target).attr("id");"img-mask"==a&&n("#img-mask").remove()}})},t}),define("order/index-controller",["mk7/controller","mk7/url","mk7/utils"],function(t,e,i){var n=Dom7,r=Template7,t=new t,a="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.orderClickEvent()},t.tabEvent=function(){n(".tab-cls").click(function(t){var e=n(this).attr("data-href");window.location.replace(e)})},t.handleNodata=function(){var t=this;t.nodata="没有数据了";var e=n(".nodata");0==e.length&&n("#index .order-list").append('
    '+t.nodata+"
    "),t.app.detachInfiniteScroll(".infinite-scroll"),n("#index .infinite-scroll-preloader").remove()},t.loadPage=function(){var t=this;if(t.loading=!0,t.page>=t.pageCount)return void t.handleNodata();var r={status:t.tab};r.page=t.page+1,r=t.csrf(r),n.ajax({method:"GET",url:e.to(a),data:r,dataType:"json",beforeSend:function(){t.showIndicator()},success:function(e){if(1==e.success&&(i.isDefined(e.page)&&(t.page=parseInt(e.page)),i.isDefined(e.page_count)&&(t.pageCount=parseInt(e.page_count)),t.renderItems(e.items,!0),t.page>=t.pageCount))return void t.handleNodata()},error:function(t){},complete:function(e){t.hideIndicator(),t.loading=!1}})},t.bindScrollEvent=function(){var t=this;t.app.attachInfiniteScroll("#index .infinite-scroll"),n("#index .infinite-scroll").on("infinite",function(){t.loading||t.nodata||t.loadPage()})},t.renderItems=function(t,e){var i=n("#index .order-list"),a=n("script#order-item-template"),o=r.compile(a.html()),s=o({list:t});0==e&&(i.html(""),i.append(s)),i.append(s)},t.addEvent=function(){n("#index .add-btn-cls").click(function(t){window.location.href=e.to("order/#submit")})},t.orderClickEvent=function(){n("#index").on("click",".order-item",function(t){var i=n(this).attr("data-id");window.location.href=e.to("order#order-details/"+i)})},t}),define("order/order-details-controller",["mk7/controller","mk7/url","mk7/utils"],function(t,e,i){var n=Dom7,t=(Template7,new t),r="order/default/order-details";return t.run=function(){var t=this;t.id=t.params.id,t.success=!0,t.setPageTitle("维修单"),t.loadPage()},t.bindEvents=function(){var t=this;console.log("bindEvents"),t.finishBtnEvent(),t.popupImageLayer()},t.beforeRender=function(){var t=this;console.log("beforeRender"),t.success||(t.view="order-details-error")},t.loadPage=function(){var t=this,n=t.csrf({id:t.id});i.httpPost(e.to(r),n,function(e){var i=e;t.success=e.success,t.render(i)},!0)},t.finishBtnEvent=function(){var t=this;n("#order-details .finish-submit").click(function(i){window.location.href=e.to("order/#cost-list/"+t.id)})},t.popupImageLayer=function(){n("#order-details").on("click",".view-img-cls",function(t){var e=n(this).attr("data-url");n("#img-mask").remove();var i='
    ';n("#order-details").append(i)}),n("#order-details").on("click","#img-mask, #img-mask img",function(t){t.preventDefault(),t.stopPropagation();var e=document.body.clientHeight,i=n("#img-mask img").height();console.log(e+"dddd"+i);var r=Math.abs(i-e);if(r>=0&&r<=20)n("#img-mask").remove(),console.log("dddd");else{var a=n(t.target).attr("id");"img-mask"==a&&n("#img-mask").remove()}})},t}),define("order/rate-controller",["mk7/controller","mk7/url","mk7/utils"],function(t,e,i){var n=Dom7,t=(Template7,new t),r="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(){n("#rate").on("click",".quality-box .img-star",function(t){var e=n(this).attr("data-id"),i=n("#rate .quality-box .img-star");n.each(i,function(t,i){var r=n(i).attr("data-id");if(1*r<=e){n(i).addClass("star-on");var a=n("#rate .quality-box").find(".rate-text"),o=n(i).attr("data-txt");a.html(o)}else n(i).removeClass("star-on")})})},t.submitEvent=function(){var t=this;n("#rate .submit-btn").click(function(a){var o=i.trim(n("#rate .text-content").val()),s=n("#rate .img-star"),l=0;n.each(s,function(t,e){n(e).hasClass("star-on")&&l++});var c=t.csrf({star:l,comment:o,id:t.id});i.httpPost(e.to(r),c,function(n){n.success?window.location.replace(e.to("order/customer#customer-order/"+t.id+"/"+t.sn)):i.toast({content:n.message})},!0)})},t}),define("order/submit-controller",["mk7/controller","mk7/url","mk7/utils","mk7/uploadjs","mk7/picker"],function(t,e,n,r,a){var o=Dom7,t=(Template7,new t),s="/user/default/upload-file",l="/order/default/submit",c=!0,d="";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");r.uploadFile({selector:"#upload-btn",url:e.to(s),processAppendTo:"#submit",success:function(e,r){try{if(e.success){var a=e.tmpUrl;o('
  • ').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 r=n.trim(o("#submit .carNo").val()),a=n.trim(o("#submit .carModel").val()),s=n.trim(o("#submit .customer").val()),d=n.trim(o("#submit .phone").val()),u=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(""==r)return n.toast({content:"车牌号必填"}),!1;if(""==a)return n.toast({content:"车辆型号必填"}),!1;if(""==s)return n.toast({content:"客户名称必填"}),!1;if(""==d)return n.toast({content:"客联系电话必填"}),!1;if(!n.isMobile(d)&&!n.isTelephone(d))return n.toast({content:"客联系电话有误"}),!1;if(""==u)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:r,carModel:a,customer:s,phone:d,preRepair:u,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,i){var n=o(i).find(".upload-item");e.push(n.attr("data"))}),e)},t.selectDateEvent=function(){var t=this;o("#submit .finish-date-input").click(function(e){var i=o(this).val();console.log(i),t.dateTimeSelector("#submit .finish-date-input",i)})},t.dateTimeSelector=function(t,e){var n=this,r=new Date,a=30,s=r.getFullYear(),l=r.getMonth(),c=r.getDate(),u=r.getHours(),m=s+"-"+(l+1)+"-"+c;if(""!=e&&null!=e&&void 0!==e){var v=e.split(" ");m=v[0],u=v[1]}var p=[];for(i=0;i<=a;i++){var f=new Date;f.setDate(r.getDate()+i);var g=f.getFullYear()+"-"+(f.getMonth()+1)+"-"+f.getDate();p.push(g)}var h=n.app.picker({input:t,toolbarTemplate:'
    请选择用工时间
    ',value:[m,u],onChange:function(t,e,i){var n,r,a;if(e[0]instanceof Date)n=e[0].getFullYear(),r=e[0].getMonth(),a=e[0].getDate();else{var o=e[0].split("-");n=o[0],r=o[1]-1,a=o[2]}var s=new Date(n,r,a,e[1],0),l=new Date((new Date).getTime()+36e5);if(s

    '),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='加载速度太慢?试试重新加载',t.appendChild(e))},window.waitingTime))},n=!0;return t.name="order",t.routes={index:function(){return n=!1,i(),t.runController("index")},"index/:tab":function(e){n=!1,i();var r={tab:e};return t.runController("index",r)},submit:function(){return n=!1,i(),t.runController("submit")},"order-details/:id":function(e){n=!1,i();var r={id:e};return t.runController("order-details",r)},"customer-order/:id/:sn":function(e,r){n=!1,i();var a={id:e,sn:r};return t.runController("customer-order",a)},"rate/:id/:sn":function(e,r){n=!1,i();var a={id:e,sn:r};return t.runController("rate",a)},"cost-list/:id":function(e){n=!1,i();var r={id:e};return t.runController("cost-list",r)},"*":function(){return t.runController("index")}},t}),define("order/cost-list-controller",["mk7/controller","mk7/url","mk7/utils","mk7/uploadjs"],function(t,e,i,n){var r=Dom7,t=(Template7,new t),a="/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;r("#cost-list .add-repair-plan").click(function(e){var i=r("#cost-list .cost-list-div"),n=t.planTpl(i.length+1);r(n).insertBefore(r("#cost-list .cost-total-list-div"))})},t.delPlanEvent=function(){var t=this;r("#cost-list").on("click",".del-plan",function(e){console.log("del plan event"),r(this).parents(".cost-list-div").remove(),r("#cost-list .total-plan-price").html(t.computedPrice())})},t.planTpl=function(t){var e='

    第'+t+'项

    ';return e},t.inputPriceChangeEvent=function(){var t=this;r("#cost-list").on("input propertychange",".input-cls",function(){var e=t.computedPrice();r("#cost-list .total-plan-price").html(e)})},t.computedPrice=function(){var t=r("#cost-list .input-right"),e=0;return r.each(t,function(t,i){e+=1*r(i).val()}),Math.round(e,2)},t.uploadImgEvent=function(){var t=this;r("#cost-list #upload-btn").change(function(){if(""!=r(this).val()&&null!=r(this).val()){var o=r(this).parents("li");n.uploadFile({selector:"#upload-btn",url:e.to(a),processAppendTo:"#cost-list",success:function(e,n){try{if(e.success){var a=e.tmpUrl;r('
  • ').insertBefore(o),t.imgLimit==r("#cost-list #image-list").find(".up-img").length&&r("#cost-list .upload-btn-li").hide()}else i.toast({content:e.message,closeDelay:5e3})}catch(s){console.log(s),i.toast({content:"出错",closeDelay:5e3})}}})}}),r("#cost-list #image-list").on("click",".del-img",function(e){r(this).parent().remove(),t.imgLimit>=r("#cost-list #image-list").find(".up-img").length&&r("#cost-list .upload-btn-li").show()})},t.submitEvent=function(){var t=this;r("#cost-list .btn-submit").click(function(n){var a=r("#cost-list .content-div").find(".repair-item-cls"),s=[],l=!0,c=!0;if(r.each(a,function(t,e){var n=i.trim(r(e).find(".input-left").val()),a=i.trim(r(e).find(".input-right").val());""==n&&(l=!1),""!=a&&0!=a||(c=!1),s.push({content:n,price:a})}),!l)return i.toast({content:"维修清单有部分未填内容"}),!1;if(!c)return i.toast({content:"维修清单有部分未填价格"}),!1;var d=r("#cost-list #image-list").find(".upload-item"),u=[];if(r.each(d,function(t,e){u.push(r(e).attr("data"))}),!t.canSubmit)return!1;t.canSubmit=!1;var m=t.csrf({images:u,plans:s,id:t.id});i.httpPost(o,m,function(n){t.canSubmit=!0,n.success?window.location.replace(e.to("order#order-details/"+t.id)):i.toast({content:n.message})},!0)})},t}),define("order/customer-order-controller",["mk7/controller","mk7/url","mk7/utils"],function(t,e,i){var n=Dom7,t=(Template7,new t),r="order/customer/order-details";return t.run=function(){var t=this;t.id=t.params.id,t.sn=t.params.sn,t.success=!0,t.setPageTitle("维修单"),t.loadPage()},t.bindEvents=function(){var t=this;console.log("bindEvents"),t.goToComment(),t.popupImageLayer()},t.beforeRender=function(){var t=this;console.log("beforeRender"),t.success||(this.view="customer-order-error")},t.loadPage=function(){var t=this,n=t.csrf({id:t.id});i.httpPost(e.to(r),n,function(e){var i=e;t.success=e.success,t.render(i)},!0)},t.goToComment=function(){var t=this;n("#customer-order .rate-btn-cls").click(function(i){window.location.replace(e.to("order/customer#rate/"+t.id+"/"+t.sn))})},t.popupImageLayer=function(){n("#customer-order").on("click",".view-img-cls",function(t){var e=n(this).attr("data-url");n("#img-mask").remove();var i='
    ';n("#customer-order").append(i)}),n("#customer-order").on("click","#img-mask, #img-mask img",function(t){t.preventDefault(),t.stopPropagation();var e=document.body.clientHeight,i=n("#img-mask img").height();console.log(e+"dddd"+i);var r=Math.abs(i-e);if(r>=0&&r<=20)n("#img-mask").remove();else{var a=n(t.target).attr("id");"img-mask"==a&&n("#img-mask").remove()}})},t}),define("order/index-controller",["mk7/controller","mk7/url","mk7/utils"],function(t,e,i){var n=Dom7,r=Template7,t=new t,a="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.orderClickEvent()},t.tabEvent=function(){n(".tab-cls").click(function(t){var e=n(this).attr("data-href");window.location.replace(e)})},t.handleNodata=function(){var t=this;t.nodata="没有数据了";var e=n(".nodata");0==e.length&&n("#index .order-list").append('
    '+t.nodata+"
    "),t.app.detachInfiniteScroll(".infinite-scroll"),n("#index .infinite-scroll-preloader").remove()},t.loadPage=function(){var t=this;if(t.loading=!0,t.page>=t.pageCount)return void t.handleNodata();var r={status:t.tab};r.page=t.page+1,r=t.csrf(r),n.ajax({method:"GET",url:e.to(a),data:r,dataType:"json",beforeSend:function(){t.showIndicator()},success:function(e){if(1==e.success&&(i.isDefined(e.page)&&(t.page=parseInt(e.page)),i.isDefined(e.page_count)&&(t.pageCount=parseInt(e.page_count)),t.renderItems(e.items,!0),t.page>=t.pageCount))return void t.handleNodata()},error:function(t){},complete:function(e){t.hideIndicator(),t.loading=!1}})},t.bindScrollEvent=function(){var t=this;t.app.attachInfiniteScroll("#index .infinite-scroll"),n("#index .infinite-scroll").on("infinite",function(){t.loading||t.nodata||t.loadPage()})},t.renderItems=function(t,e){var i=n("#index .order-list"),a=n("script#order-item-template"),o=r.compile(a.html()),s=o({list:t});0==e&&(i.html(""),i.append(s)),i.append(s)},t.addEvent=function(){n("#index .add-btn-cls").click(function(t){window.location.href=e.to("order/#submit")})},t.orderClickEvent=function(){n("#index").on("click",".order-item",function(t){var i=n(this).attr("data-id");window.location.href=e.to("order#order-details/"+i)})},t}),define("order/order-details-controller",["mk7/controller","mk7/url","mk7/utils"],function(t,e,i){var n=Dom7,t=(Template7,new t),r="order/default/order-details";return t.run=function(){var t=this;t.id=t.params.id,t.success=!0,t.setPageTitle("维修单"),t.loadPage()},t.bindEvents=function(){var t=this;console.log("bindEvents"),t.finishBtnEvent(),t.popupImageLayer()},t.beforeRender=function(){var t=this;console.log("beforeRender"),t.success||(t.view="order-details-error")},t.loadPage=function(){var t=this,n=t.csrf({id:t.id});i.httpPost(e.to(r),n,function(e){var i=e;t.success=e.success,t.render(i)},!0)},t.finishBtnEvent=function(){var t=this;n("#order-details .finish-submit").click(function(i){window.location.href=e.to("order/#cost-list/"+t.id)})},t.popupImageLayer=function(){n("#order-details").on("click",".view-img-cls",function(t){var e=n(this).attr("data-url");n("#img-mask").remove();var i='
    ';n("#order-details").append(i)}),n("#order-details").on("click","#img-mask, #img-mask img",function(t){t.preventDefault(),t.stopPropagation();var e=document.body.clientHeight,i=n("#img-mask img").height();console.log(e+"dddd"+i);var r=Math.abs(i-e);if(r>=0&&r<=20)n("#img-mask").remove(),console.log("dddd");else{var a=n(t.target).attr("id");"img-mask"==a&&n("#img-mask").remove()}})},t}),define("order/rate-controller",["mk7/controller","mk7/url","mk7/utils"],function(t,e,i){var n=Dom7,t=(Template7,new t),r="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(){n("#rate").on("click",".quality-box .img-star",function(t){var e=n(this).attr("data-id"),i=n("#rate .quality-box .img-star");n.each(i,function(t,i){var r=n(i).attr("data-id");if(1*r<=e){n(i).addClass("star-on");var a=n("#rate .quality-box").find(".rate-text"),o=n(i).attr("data-txt");a.html(o)}else n(i).removeClass("star-on")})})},t.submitEvent=function(){var t=this;n("#rate .submit-btn").click(function(a){var o=i.trim(n("#rate .text-content").val()),s=n("#rate .img-star"),l=0;n.each(s,function(t,e){n(e).hasClass("star-on")&&l++});var c=t.csrf({star:l,comment:o,id:t.id});i.httpPost(e.to(r),c,function(n){n.success?window.location.replace(e.to("order/customer#customer-order/"+t.id+"/"+t.sn)):i.toast({content:n.message})},!0)})},t}),define("order/submit-controller",["mk7/controller","mk7/url","mk7/utils","mk7/uploadjs","mk7/picker"],function(t,e,n,r,a){var o=Dom7,s=Template7,t=new t,l="/user/default/upload-file",c="/order/default/submit",d=!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.openCarModel(),t.searchCarModel(),t.carModelClick()},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");r.uploadFile({selector:"#upload-btn",url:e.to(l),processAppendTo:"#submit",success:function(e,r){try{if(e.success){var a=e.tmpUrl;o('
  • ').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 r=n.trim(o("#submit .carNo").val()),a=n.trim(o("#submit .carModel").val()),s=n.trim(o("#submit .customer").val()),l=n.trim(o("#submit .phone").val()),u=n.trim(o("#submit .preRepair").val()),m=n.trim(o("#submit .repairPrice").val()),v=n.trim(o("#submit .finishDate").val());if(0==d)return!1;if(""==r)return n.toast({content:"车牌号必填"}),!1;if(""==a)return n.toast({content:"车辆型号必填"}),!1;if(""==s)return n.toast({content:"客户名称必填"}),!1;if(""==l)return n.toast({content:"客联系电话必填"}),!1;if(!n.isMobile(l)&&!n.isTelephone(l))return n.toast({content:"客联系电话有误"}),!1;var p=t.getUploadImgs();if(0==p.length)return n.toast({content:"请上传车损照"}),!1;d=!1;var f=t.csrf({carNo:r,carModel:a,customer:s,phone:l,preRepair:u,repairPrice:m,finishDate:v,images:p});n.httpPost(c,f,function(t){return d=!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,i){var n=o(i).find(".upload-item");e.push(n.attr("data"))}),e)},t.selectDateEvent=function(){var t=this;o("#submit .finish-date-input").click(function(e){var i=o("#submit .finish-date-input").val();console.log(i),t.dateTimeSelector("#submit .finish-date-input",i)})},t.dateTimeSelector=function(t,e){var n=this,r=new Date,a=30,s=r.getFullYear(),l=r.getMonth(),c=r.getDate(),d=r.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<=a;i++){var f=new Date;f.setDate(r.getDate()+i);var g=f.getFullYear()+"-"+(f.getMonth()+1)+"-"+f.getDate();p.push(g)}var h=n.app.picker({input:t,toolbarTemplate:'
    请选择用工时间
    ',value:[m,d],onChange:function(t,e,i){var n,r,a;if(e[0]instanceof Date)n=e[0].getFullYear(),r=e[0].getMonth(),a=e[0].getDate();else{var o=e[0].split("-");n=o[0],r=o[1]-1,a=o[2]}var s=new Date(n,r,a,e[1],0),l=new Date((new Date).getTime()+36e5);if(s

    '),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='加载速度太慢?试试重新加载',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(''+e.codeDuration+"s后重新获取")},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(''+e.codeDuration+"s后重新获取")},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}); \ No newline at end of file +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('

    '),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='加载速度太慢?试试重新加载',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",s=!0,l=!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==s)return!1;clearInterval(c),s=!1;var l=e.csrf({action:"login",mobile:r});n.httpGet(t.to(i),l,function(t){if(!t.success)return n.toast({content:t.message,closeDelay:3e3}),s=!0,!1;n.toast({content:t.message}),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,s=!0):o("#login .get-code-cls").html(''+e.codeDuration+"s后重新获取")},1e3)})})},e.loginEvent=function(){var e=this;o("#login .login-btn").click(function(i){var s=n.trim(o("#login .mobile").val()),c=n.trim(o("#login .code").val());if(""==s)return n.toast({content:"手机号码必填"}),!1;if(!n.isMobile(s))return n.toast({content:"手机号码不合格"}),!1;if(""==c)return n.toast({content:"验证码必填"}),!1;if(0==l)return!1;l=!1;var a=e.csrf({mobile:s,code:c});n.httpPost(t.to(r),a,function(e){return l=!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",s="/user/default/upload-file",l="/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(s),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(l),r,function(t){if(!t.success)return n.toast({content:t.message,closeDelay:3e3}),c=!0,!1;n.toast({content:t.message}),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(''+e.codeDuration+"s后重新获取")},1e3)})})},e.registerEvent=function(){var e=this;i("#register .register-btn").click(function(o){var s=n.trim(i("#register .name").val()),l=n.trim(i("#register .mobile").val()),c=n.trim(i("#register .code").val());if(""==s)return n.toast({content:"车厂名称必填"}),!1;if(""==l)return n.toast({content:"手机号码必填"}),!1;if(!n.isMobile(l))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:s,mobile:l,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}); \ No newline at end of file diff --git a/web/src/js/order/cost-list-controller.js b/web/src/js/order/cost-list-controller.js index fdf3c0c..2beedcb 100644 --- a/web/src/js/order/cost-list-controller.js +++ b/web/src/js/order/cost-list-controller.js @@ -56,7 +56,7 @@ define( var str = '
    '+ '

    第'+i+'项

    '+ '
    '+ - ''+ + ''+ ''+ '
    '+ '
    '; diff --git a/web/src/js/order/submit-controller.js b/web/src/js/order/submit-controller.js index 0f05b57..000251d 100644 --- a/web/src/js/order/submit-controller.js +++ b/web/src/js/order/submit-controller.js @@ -33,6 +33,10 @@ define( me.uploadImgEvent(); me.submitEvent(); me.selectDateEvent(); + me.openCarModel(); + me.searchCarModel(); + me.carModelClick() + } ctrl.uploadImgEvent = function() { var me = this; @@ -107,6 +111,7 @@ define( utils.toast({content:'客联系电话有误'}); return false; } + /* if ('' == preRepair) { utils.toast({content:'预估维修内容必填'}); return false; @@ -119,6 +124,7 @@ define( utils.toast({content:'预估完成时间必填'}); return false; } + */ var imgs = me.getUploadImgs(); if (0 == imgs.length) { utils.toast({content:'请上传车损照'}); @@ -157,7 +163,7 @@ define( ctrl.selectDateEvent = function() { var me = this $$('#submit .finish-date-input').click(function(e) { - var cData = $$(this).val(); + var cData = $$('#submit .finish-date-input').val(); console.log(cData) me.dateTimeSelector('#submit .finish-date-input', cData); }) @@ -327,6 +333,75 @@ define( pickerInline.destroy(); }); } + + ctrl.openCarModel= function() { + var me = this; + $$('#submit').on('click', '.carModel',function(e) { + $$('#search-wrapper').remove(); + var page = $$('#submit'); + var ele = $$('script#search-carr-model-template'); + var compiled = t7.compile(ele.html()); + var doms = compiled({keyword: ''}); + page.append(doms); + + }) + } + ctrl.renderCarModelItem = function (items) { + + var addressList = $$('#search-wrapper .model-list'); + var ele = $$('script#search-car-model-item-template'); + var compiled = t7.compile(ele.html()); + var doms = compiled({items: items}); + addressList.html(doms); + } + ctrl.searchCarModel = function() { + var me = this; + $$('#submit').on('click', '.model-search-btn', function(e){ + me.ajaxSearch(); + }) + + $$('#submit').on('submit', '#search-form', function(e){ + e.preventDefault(); + me.ajaxSearch(); + return false; + }) + } + ctrl.ajaxSearch = function() { + var me = this; + var pData = {keyword: $$('#search-wrapper .search-input').val()}; + $$.ajax({ + method : "POST", + url: url.to('order/default/search-model'), + data : pData, + dataType : "json", + beforeSend : function(){ + me.showIndicator(); + }, + success : function(res){ + if (res.success) { + me.renderCarModelItem(res.items); + } else { + me.renderCarModelItem([]); + } + }, + error : function(res){}, + complete : function(res){ + me.hideIndicator(); + } + }) + } + ctrl.carModelClick = function(){ + var me = this; + $$('#submit').on('click','.model-div-btn', function(e){ + var model = $$(this).attr('data-value'); + $$('#submit .carModel').val(model); + + $$('#search-wrapper').remove(); + }) + $$('#submit').on('click','.closeBtn', function(e){ + $$('#search-wrapper').remove(); + }) + } return ctrl; } ); diff --git a/web/src/js/user/login-controller.js b/web/src/js/user/login-controller.js index edb5044..66ebddd 100644 --- a/web/src/js/user/login-controller.js +++ b/web/src/js/user/login-controller.js @@ -61,6 +61,7 @@ define( clickGetCode = true; return false; } + utils.toast({content:res.message}); if(res.testCode) { $$('#login .code').val(res.testCode); } diff --git a/web/src/js/user/register-controller.js b/web/src/js/user/register-controller.js index a2e19e2..f709d4f 100644 --- a/web/src/js/user/register-controller.js +++ b/web/src/js/user/register-controller.js @@ -97,6 +97,7 @@ define( clickGetCode = true; return false; } + utils.toast({content:res.message}); if(res.testCode) { $$('#register .code').val(res.testCode); } -- libgit2 0.21.0