DefaultController.php
5.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<?php
namespace app\wx\modules\order\controllers;
use Yii;
use stdClass;
use yii\helpers\HtmlPurifier;
/**
* 控制器
*/
class DefaultController extends BaseController
{
/**
* 首页
*/
public function actionIndex()
{
return $this->render('index');
}
/**
* @return string
*/
public function actionSubmit()
{
$e = new stdClass();
$e->success = false;
$e->message = 'ok';
$userId = 0;
$req = Yii::$app->request;
$carNo = HtmlPurifier::process($req->post('carNo'), ['HTML.Allowed' => '']);
$carModel = HtmlPurifier::process($req->post('carModel'), ['HTML.Allowed' => '']);
$customer = HtmlPurifier::process($req->post('customer'), ['HTML.Allowed' => '']);
$phone = HtmlPurifier::process($req->post('phone'), ['HTML.Allowed' => '']);
$preRepair = HtmlPurifier::process($req->post('preRepair'), ['HTML.Allowed' => '']);
$repairPrice = HtmlPurifier::process($req->post('repairPrice'), ['HTML.Allowed' => '']);
$finishDate = HtmlPurifier::process($req->post('finishDate'), ['HTML.Allowed' => '']);
$images = $req->post('images');
//echo $carNo.'_'.$carModel.'_'.$customer.'_'.$phone.'_'.$preRepair.'_'.$repairPrice.'_'.$finishDate.'_'.json_encode($images);
$e->success = true;
return $this->renderJson($e);
}
/**
* @return string
*/
public function actionOrderList()
{
$e = new stdClass();
$e->success = false;
$e->page = null;
$e->page_count = null;
$e->items = [];
$page = $this->request->get('page');
$status = $this->request->get('status');
if (empty($page)) {
$page = 1;
}
$allItemList = [0, 0, 0];
if ('working' == $status || '' == $status) {
$allItemList = $this->getOrderList($page, 1);
} else {
$allItemList = $this->getOrderList($page, 0);
}
$e->page_count = $allItemList[1];
$e->page = $page ;
$e->items = $allItemList[2];
$e->success = true;
return $this->renderJson($e);
}
/**
* @param $page
* @param $status
*/
private function getOrderList($page, $status)
{
$pageSize = 5 ;
$pager_offset = ($page -1) * $pageSize;
$limitPage = $pageSize;
$count = 15;
$items = [];
$pageCount = ceil(($count*1) / $pageSize);
$carModelList = ['宝马X3','宝马X4','宝马X5','宝马X6','奔驰c200l','奔驰E260','奔驰E260','奔驰E300'];
$customerList = ['张先生','李先生','王先生','赵先生','刘先生','宝先生','好先生','费先生'];
for ($i = $pager_offset; $i < ($pager_offset+$limitPage); $i++ ) {
$carModel = $carModelList[mt_rand(0,7)];
$customer = $customerList[mt_rand(0,7)];
$items[] = ['id'=> $i ,'carNo' => 'XA'.mt_rand(10000,99999), 'carModel' => $carModel, 'status' => $status, 'customer' => $customer ,'createdTime' => date('Y-m-d H:i')];
}
return [$count, $pageCount, $items];
}
/**
* @return string
*/
public function actionOrderDetails()
{
$e = new stdClass();
$e->success = false;
$e->message = 'ok';
$e->success = true;
$e->item = [
'carNo' => 'XX12345',
'carModel' => '宝马X3',
'customer' => '李先生',
'mobile' => '13900139001',
'preRepair' => '更换轮胎',
'repairPrice' => '300元',
'preFinishDate' => '2019-12-15 15:00',
'orderDateTime' => '2019-12-14 15:00',
'status' => 'finish',
'hasComment' => false,
'brokenImages' => [
Yii::$app->request->baseUrl.'/i/order/demo.jpg', Yii::$app->request->baseUrl.'/i/order/demo.jpg', Yii::$app->request->baseUrl.'/i/order/demo.jpg'
],
'repairPlans' => [
['content' => '更换车胎',
'price' => 450],
['content' => '更换车胎',
'price' => 450],
['content' => '更换车胎',
'price' => 450],
],
'totalPrice' => 1350,
'finishImages' => [
Yii::$app->request->baseUrl.'/i/order/demo.jpg', Yii::$app->request->baseUrl.'/i/order/demo.jpg', Yii::$app->request->baseUrl.'/i/order/demo.jpg'
]
];
return $this->renderJson($e);
}
/**
* @return string
*/
public function actionSubmitRepairPlans()
{
$e = new stdClass();
$e->success = false;
$e->message = 'ok';
$repairPlans = $this->request->post('plans');
$images = $this->request->post('images');
//print_r($images);
//print_r($repairPlans);
$e->success = true;
return $this->renderJson($e);
}
public function actionSubmitRate()
{
$e = new stdClass();
$e->success = false;
$e->message = 'ok';
$star = $this->request->post('star');
$comment = $this->request->post('comment');
echo $star.'_'.$comment;
$e->success = true;
return $this->renderJson($e);
}
}