Jfm.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace app\mobile\controller;
  3. use app\common\model\AppealModel;
  4. use app\common\model\ArticleModel;
  5. use app\common\model\NavigationModel;
  6. use app\common\model\PolicyModel;
  7. use app\common\model\SlideModel;
  8. use app\common\model\StreetModel;
  9. use app\common\validate\AppealValidate;
  10. use app\mobile\MobileBaseController;
  11. use think\exception\ValidateException;
  12. class Jfm extends MobileBaseController
  13. {
  14. public function index()
  15. {
  16. return view();
  17. }
  18. public function appeal()
  19. {
  20. $street_list = StreetModel::select();
  21. $street = [];
  22. foreach ($street_list as $v) {
  23. $street[] = ['text' => $v['name'], 'value' => $v['name']];
  24. }
  25. $cate_list = StreetModel::CATE;
  26. $cate = [];
  27. foreach ($cate_list as $v) {
  28. $cate[] = ['text' => $v, 'value' => $v];
  29. }
  30. return view('', [
  31. 'street' => json_encode($street),
  32. 'cate' => json_encode($cate),
  33. ]);
  34. }
  35. public function appealPost()
  36. {
  37. $data = input('post.');
  38. try {
  39. validate(AppealValidate::class)->check($data);
  40. } catch (ValidateException $e) {
  41. ajax_return(1, $e->getError());
  42. }
  43. AppealModel::create($data);
  44. ajax_return(0, '提交成功');
  45. }
  46. public function policy()
  47. {
  48. $list = PolicyModel::where('status', PolicyModel::STATUS_PUBLISH)->select();
  49. return view('', [
  50. 'list' => $list,
  51. ]);
  52. }
  53. public function policyDetail()
  54. {
  55. $id = input('id', 0);
  56. if (empty($id)) {
  57. jump('文章不存在!');
  58. }
  59. $info = PolicyModel::find($id);
  60. $info->volume++;
  61. $info->save();
  62. $info->content = str_replace('<img','<img @click="showImage($event)"',$info->content);
  63. return view('', [
  64. 'info' => $info,
  65. ]);
  66. }
  67. }