家政小程序
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

ClassifyController.php 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Models\HomePage;
  4. use Illuminate\Http\Request;
  5. use App\Models\Classify;
  6. class ClassifyController extends Controller
  7. {
  8. public function list(Request $request)
  9. {
  10. return Classify::paginate(100);
  11. }
  12. public function setHome(Request $request) {
  13. $top1 = $request->input("top1");
  14. $top2 = $request->input("top2");
  15. $top3 = $request->input("top3");
  16. $bottom = $request->input("bottom");
  17. $introduce = $request->input("introduce");
  18. if($top1 && $top2 && $top3 && $bottom && $introduce) {
  19. $homePage = HomePage::find(1);
  20. $homePage->top1 = $top1;
  21. $homePage->top2 = $top2;
  22. $homePage->top3 = $top3;
  23. $homePage->bottom = $bottom;
  24. $homePage->introduce = $introduce;
  25. $homePage->save();
  26. return response()->json([
  27. "status" => 0,
  28. "message" => '修改成功'
  29. ]);
  30. } else {
  31. return Response()->json([
  32. "status" => -1,
  33. "message" => "信息不能为空!"
  34. ]);
  35. }
  36. }
  37. /**
  38. * 每页20进行分页
  39. * @param Request $request
  40. * @return mixed
  41. */
  42. public function home(Request $request)
  43. {
  44. $homePage = HomePage::find(1);
  45. $top1 = HomePage::find($homePage->top1);
  46. $top2 = HomePage::find($homePage->top2);
  47. $top3 = HomePage::find($homePage->top3);
  48. $bottom = HomePage::find($homePage->bottom);
  49. $introduce = HomePage::find($homePage->introduce);
  50. return Response()->json([
  51. "top" => [
  52. [
  53. "id" => $top1["id"],
  54. "server" => $top1["server"],
  55. "content" => $top1["content"],
  56. "photo" => $top1["photo"],
  57. ],
  58. [
  59. "id" => $top2["id"],
  60. "server" => $top2["server"],
  61. "content" => $top2["content"],
  62. "photo" => $top2["photo"],
  63. ],
  64. [
  65. "id" => $top3["id"],
  66. "server" => $top3["server"],
  67. "content" => $top3["content"],
  68. "photo" => $top3["photo"],
  69. ]
  70. ],
  71. "introduce" => $introduce,
  72. "bottom" => [
  73. "id" => $bottom["id"],
  74. "server" => $bottom["server"],
  75. "content" => $bottom["content"],
  76. "photo" => $bottom["photo"],
  77. ]
  78. ]);
  79. }
  80. /**
  81. * 获取某个记录
  82. * @param Request $request
  83. * @param $id
  84. * @return \Illuminate\Http\JsonResponse
  85. */
  86. public function get(Request $request, $id)
  87. {
  88. $id = $request->route("id");
  89. $fields_josn = "";
  90. if($id == 6) {
  91. $fields_josn ='{
  92. "id": 6,
  93. "api": "maternity_matron_order/store",
  94. "fields": [
  95. {
  96. "name": "level",
  97. "name_cn": "一价全包",
  98. "input_group": [
  99. {
  100. "type": "radio",
  101. "value": "8800(初级月嫂)"
  102. },
  103. {
  104. "type": "radio",
  105. "value": "9800(普通月嫂)"
  106. },
  107. {
  108. "type": "radio",
  109. "value": "12800(高级月嫂)"
  110. },
  111. {
  112. "type": "radio",
  113. "value": "15800(金牌月嫂)"
  114. },
  115. {
  116. "type": "radio",
  117. "value": "18800(特级月嫂)"
  118. }
  119. ]
  120. }
  121. ]
  122. }';
  123. } else {
  124. $fields_josn = '{
  125. "id": 7,
  126. "api": "housekeeper_order/store",
  127. "fields": [
  128. {
  129. "name": "contents",
  130. "name_cn": "服务内容",
  131. "input_group": [
  132. {
  133. "type": "radio",
  134. "value": "保洁"
  135. },
  136. {
  137. "type": "radio",
  138. "value": "婴儿看护"
  139. },
  140. {
  141. "type": "radio",
  142. "value": "老人看护"
  143. },
  144. {
  145. "type": "radio",
  146. "value": "全护理老人"
  147. },
  148. {
  149. "type": "radio",
  150. "value": "空调清洗"
  151. },
  152. {
  153. "type": "radio",
  154. "value": "冰箱清洗"
  155. },
  156. {
  157. "type": "radio",
  158. "value": "抽油烟机清洗"
  159. },
  160. {
  161. "type": "radio",
  162. "value": "家庭除螨"
  163. },
  164. {
  165. "type": "radio",
  166. "value": "开荒清洁"
  167. },
  168. {
  169. "type": "radio",
  170. "value": "催乳"
  171. },
  172. {
  173. "type": "radio",
  174. "value": "产后康复"
  175. }
  176. ]
  177. },
  178. {
  179. "name": "people_num",
  180. "name_cn": "人口数量",
  181. "input_group": [
  182. {
  183. "type": "radio",
  184. "value": "1-2人"
  185. },
  186. {
  187. "type": "radio",
  188. "value": "3-4人"
  189. },
  190. {
  191. "type": "radio",
  192. "value": "5-6人"
  193. },
  194. {
  195. "type": "radio",
  196. "value": "6人以上"
  197. }
  198. ]
  199. },
  200. {
  201. "name": "area",
  202. "name_cn": "房屋面积",
  203. "input_group": [
  204. {
  205. "type": "radio",
  206. "value": "60平以下"
  207. },
  208. {
  209. "type": "radio",
  210. "value": "60-120平"
  211. },
  212. {
  213. "type": "radio",
  214. "value": "120-160平"
  215. },
  216. {
  217. "type": "radio",
  218. "value": "160-200平"
  219. },
  220. {
  221. "type": "radio",
  222. "value": "200平以上"
  223. }
  224. ]
  225. },
  226. {
  227. "name": "server_time",
  228. "name_cn": "服务时间",
  229. "input_group": [
  230. {
  231. "type": "radio",
  232. "value": "全白天"
  233. },
  234. {
  235. "type": "radio",
  236. "value": "住家"
  237. }
  238. ]
  239. },
  240. {
  241. "name": "rest",
  242. "name_cn": "休息安排",
  243. "input_group": [
  244. {
  245. "type": "radio",
  246. "value": "每周单休"
  247. },
  248. {
  249. "type": "radio",
  250. "value": "每周双休"
  251. }
  252. ]
  253. }
  254. ]
  255. }';
  256. }
  257. $data = json_decode($fields_josn, true);
  258. $data["id"] = $id;
  259. if ($id) {
  260. $record = Classify::find($id);
  261. if ($record) {
  262. return Response()->json([
  263. "status" => 0,
  264. "data" => [
  265. "id" => $record->id,
  266. "pid" => $record->pid,
  267. "name" => $record->name,
  268. "info" => $record->info,
  269. "content" => $record->summary,
  270. "photo" => $record->photo,
  271. "api" => $data["api"],
  272. "fields" => $data["fields"],
  273. "type" => $record->name,
  274. ]
  275. ]);
  276. }
  277. return Response()->json([
  278. "status" => -2,
  279. "message" => "不存在的记录!"
  280. ]);
  281. } else {
  282. return Response()->json([
  283. "status" => -1,
  284. "message" => "id不能为空!"
  285. ]);
  286. }
  287. }
  288. /**
  289. * @param Request $request
  290. * @param $id
  291. * @return \Illuminate\Http\JsonResponse
  292. */
  293. public function server_content(Request $request, $id) {
  294. $id = $request->route("id");
  295. if ($id) {
  296. $record = Classify::find($id);
  297. if ($record) {
  298. return Response()->json([
  299. "status" => 0,
  300. "data" => [
  301. "id" => $record->id,
  302. "server" => $record->server,
  303. "content" => $record->content,
  304. "photo" => $record->photo,
  305. "location" => $record->location,
  306. ]
  307. ]);
  308. }
  309. return Response()->json([
  310. "status" => -2,
  311. "message" => "不存在的记录!"
  312. ]);
  313. } else {
  314. return Response()->json([
  315. "status" => -1,
  316. "message" => "id不能为空!"
  317. ]);
  318. }
  319. }
  320. /**
  321. * @param Request $request
  322. * @return \Illuminate\Http\JsonResponse
  323. */
  324. public function store(Request $request)
  325. {
  326. $id = $request->input('id');
  327. $pid = $request->input('pid');
  328. $name = $request->input('name');
  329. $info = $request->input('info');
  330. $summary = $request->input('summary');
  331. $server = $request->input('server');
  332. $content = $request->input('content');
  333. $photo = $request->input('photo');
  334. $location = $request->input('location');
  335. if ($id) {
  336. $classify = Classify::find($id);
  337. } else {
  338. $classify = new Classify;
  339. }
  340. if ($pid && $name && $info && $summary && $server && $content && $photo && $location) {
  341. $classify->pid = $pid;
  342. $classify->name = $name;
  343. $classify->info = $info;
  344. $classify->summary = $summary;
  345. $classify->server = $server;
  346. $classify->content = $content;
  347. $classify->photo = $photo;
  348. $classify->location = $location;
  349. $classify->save();
  350. return Response()->json([
  351. "status" => 0,
  352. "message" => "保存成功!"
  353. ]);
  354. } else {
  355. return Response()->json([
  356. "status" => -1,
  357. "message" => "信息不能为空!"
  358. ]);
  359. }
  360. }
  361. }