DefaultController.php
3.1 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
<?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];
}
}