家政小程序
Ви не можете вибрати більше 25 тем Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ServerInfoController.php 9.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <?php
  2. namespace App\Http\Controllers;
  3. use Illuminate\Http\Request;
  4. use Illuminate\Support\Facades\Storage;
  5. use App\Models\ServerInfo;
  6. class ServerInfoController extends Controller
  7. {
  8. /**
  9. * 创建活动
  10. * @param Request $request
  11. * @return \Illuminate\Http\JsonResponse
  12. */
  13. public function store(Request $request)
  14. {
  15. $id = $request->input('id');
  16. $server = $request->input('server');
  17. $content = $request->input('content');;
  18. $photo = $request->input('photo');
  19. $location = $request->input('location');
  20. if ($id) {
  21. $serverInfo = ServerInfo::find($id);
  22. } else {
  23. $serverInfo = new Campaign;
  24. }
  25. if ($server && $content) {
  26. $serverInfo->server = $server;
  27. $serverInfo->content = $content;
  28. $serverInfo->photo = $photo;
  29. $serverInfo->location = $location;
  30. $serverInfo->save();
  31. return Response()->json([
  32. "status" => 0,
  33. "message" => "保存成功!"
  34. ]);
  35. } else {
  36. return Response()->json([
  37. "status" => -1,
  38. "message" => "信息不能为空!"
  39. ]);
  40. }
  41. }
  42. /**
  43. * 获取某个记录
  44. * @param Request $request
  45. * @param $id
  46. * @return \Illuminate\Http\JsonResponse
  47. */
  48. public function get(Request $request, $id)
  49. {
  50. $id = $request->route("id");
  51. $fields_josn = "";
  52. if($id === 6) {
  53. $fields_josn ='{
  54. "id": 6,
  55. "api": "/api/maternity_matron_order/store",
  56. "fields": [
  57. {
  58. "name": "level",
  59. "name_cn": "一价全包",
  60. "input_group": [
  61. {
  62. "type": "radio",
  63. "value": "8800(初级月嫂)"
  64. },
  65. {
  66. "type": "radio",
  67. "value": "9800(普通月嫂)"
  68. },
  69. {
  70. "type": "radio",
  71. "value": "12800(高级月嫂)"
  72. },
  73. {
  74. "type": "radio",
  75. "value": "15800(金牌月嫂)"
  76. },
  77. {
  78. "type": "radio",
  79. "value": "18800(特级月嫂)"
  80. }
  81. ]
  82. }
  83. ]
  84. }';
  85. } else {
  86. $fields_josn = '{
  87. "id": 7,
  88. "api": "/api/housekeeper_order/store",
  89. "fields": [
  90. {
  91. "name": "contents",
  92. "name_cn": "服务内容",
  93. "input_group": [
  94. {
  95. "type": "radio",
  96. "value": "保洁"
  97. },
  98. {
  99. "type": "radio",
  100. "value": "婴儿看护"
  101. },
  102. {
  103. "type": "radio",
  104. "value": "老人看护"
  105. },
  106. {
  107. "type": "radio",
  108. "value": "全护理老人"
  109. },
  110. {
  111. "type": "radio",
  112. "value": "空调清洗"
  113. },
  114. {
  115. "type": "radio",
  116. "value": "冰箱清洗"
  117. },
  118. {
  119. "type": "radio",
  120. "value": "抽油烟机清洗"
  121. },
  122. {
  123. "type": "radio",
  124. "value": "家庭除螨"
  125. },
  126. {
  127. "type": "radio",
  128. "value": "开荒清洁"
  129. },
  130. {
  131. "type": "radio",
  132. "value": "催乳"
  133. },
  134. {
  135. "type": "radio",
  136. "value": "产后康复"
  137. }
  138. ]
  139. },
  140. {
  141. "name": "people_num",
  142. "name_cn": "人口数量",
  143. "input_group": [
  144. {
  145. "type": "radio",
  146. "value": "1-2人"
  147. },
  148. {
  149. "type": "radio",
  150. "value": "3-4人"
  151. },
  152. {
  153. "type": "radio",
  154. "value": "5-6人"
  155. },
  156. {
  157. "type": "radio",
  158. "value": "6人以上"
  159. }
  160. ]
  161. },
  162. {
  163. "name": "area",
  164. "name_cn": "房屋面积",
  165. "input_group": [
  166. {
  167. "type": "radio",
  168. "value": "60平以下"
  169. },
  170. {
  171. "type": "radio",
  172. "value": "60-120平"
  173. },
  174. {
  175. "type": "radio",
  176. "value": "120-160平"
  177. },
  178. {
  179. "type": "radio",
  180. "value": "160-200平"
  181. },
  182. {
  183. "type": "radio",
  184. "value": "200平以上"
  185. }
  186. ]
  187. },
  188. {
  189. "name": "server_time",
  190. "name_cn": "服务时间",
  191. "input_group": [
  192. {
  193. "type": "radio",
  194. "value": "全白天"
  195. },
  196. {
  197. "type": "radio",
  198. "value": "住家"
  199. }
  200. ]
  201. },
  202. {
  203. "name": "rest",
  204. "name_cn": "休息安排",
  205. "input_group": [
  206. {
  207. "type": "radio",
  208. "value": "每周单休"
  209. },
  210. {
  211. "type": "radio",
  212. "value": "每周双休"
  213. }
  214. ]
  215. }
  216. ]
  217. }';
  218. }
  219. $data = json_decode($fields_josn, true);
  220. $data["id"] = $id;
  221. if ($id) {
  222. $record = ServerInfo::find($id);
  223. if ($record) {
  224. return Response()->json([
  225. "status" => 0,
  226. "data" => [
  227. "id" => $record->id,
  228. "server" => $record->server,
  229. "content" => $recore->content,
  230. "photo" => $recore->photo,
  231. "location" => $recore->location,
  232. "api" => $data["api"],
  233. "fields" => $data["fields"]
  234. ]
  235. ]);
  236. }
  237. return Response()->json([
  238. "status" => -2,
  239. "message" => "不存在的记录!"
  240. ]);
  241. } else {
  242. return Response()->json([
  243. "status" => -1,
  244. "message" => "id不能为空!"
  245. ]);
  246. }
  247. }
  248. /**
  249. * 每页20进行分页
  250. * @param Request $request
  251. * @return mixed
  252. */
  253. public function list(Request $request)
  254. {
  255. $top = ServerInfo::where("location", "top")->get();
  256. $bottom = ServerInfo::where("location", "bottom")->first();
  257. return Response()->json([
  258. "top" => $top,
  259. "introduce" => "服务介绍",
  260. "bottom" => $bottom
  261. ]);
  262. }
  263. }