Membermallconsult.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <?php
  2. namespace app\home\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. *
  7. *
  8. * ----------------------------------------------------------------------------
  9. *
  10. * 控制器
  11. */
  12. class Membermallconsult extends BaseMember
  13. {
  14. public function initialize()
  15. {
  16. parent::initialize(); // TODO: Change the autogenerated stub
  17. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/membermallconsult.lang.php');
  18. }
  19. /**
  20. * 平台客服咨询首页
  21. */
  22. public function index()
  23. {
  24. // 咨询列表
  25. $mallconsult_model = model('mallconsult');
  26. $consult_list = $mallconsult_model->getMallconsultList(array('member_id' => session('member_id')), '*', '10');
  27. View::assign('consult_list', $consult_list);
  28. View::assign('show_page', $mallconsult_model->page_info->render());
  29. // 回复状态
  30. $this->typeState();
  31. $this->setMemberCurMenu('member_mallconsult');
  32. $this->setMemberCurItem('consult_list');
  33. return View::fetch($this->template_dir . 'member_mallconsult_list');
  34. }
  35. /**
  36. * 平台咨询详细
  37. */
  38. public function mallconsult_info()
  39. {
  40. $id = intval(input('param.id'));
  41. if ($id <= 0) {
  42. $this->error(lang('param_error'));
  43. }
  44. // 咨询详细信息
  45. $consult_info = model('mallconsult')->getMallconsultInfo(array(
  46. 'mallconsult_id' => $id, 'member_id' => session('member_id')
  47. ));
  48. View::assign('consult_info', $consult_info);
  49. // 咨询类型列表
  50. $type_list = model('mallconsulttype')->getMallconsulttypeList(array(), 'mallconsulttype_id,mallconsulttype_name', 'mallconsulttype_id');
  51. View::assign('type_list', $type_list);
  52. // 回复状态
  53. $this->typeState();
  54. $this->setMemberCurMenu('member_mallconsult');
  55. $this->setMemberCurItem('consult_list');
  56. return View::fetch($this->template_dir . 'member_mallconsult_info');
  57. }
  58. /**
  59. * 添加平台客服咨询
  60. */
  61. public function add_mallconsult()
  62. {
  63. // 咨询类型列表
  64. $type_list = model('mallconsulttype')->getMallconsulttypeList(array());
  65. View::assign('type_list', $type_list);
  66. if (input('param.inajax')) {
  67. return View::fetch($this->template_dir . 'add_inajax');
  68. } else {
  69. $this->setMemberCurMenu('member_mallconsult');
  70. $this->setMemberCurItem('consult_list');
  71. return View::fetch($this->template_dir . 'member_mallconsult_add');
  72. }
  73. }
  74. /**
  75. * 保存平台咨询
  76. */
  77. public function save_mallconsult()
  78. {
  79. if (!request()->isPost()) {
  80. ds_json_encode(10001, lang('param_error'));
  81. }
  82. //验证表单信息
  83. $data = [
  84. 'type_id' => input('post.type_id'),
  85. 'consult_content' => input('post.consult_content')
  86. ];
  87. $mallconsult_validate = ds_validate('mallconsult');
  88. if (!$mallconsult_validate->scene('save_mallconsult')->check($data)) {
  89. ds_json_encode(10001, $mallconsult_validate->getError());
  90. }
  91. $insert = array();
  92. $insert['mallconsulttype_id'] = input('post.type_id');
  93. $insert['member_id'] = session('member_id');
  94. $insert['member_name'] = session('member_name');
  95. $insert['mallconsult_content'] = input('post.consult_content');
  96. $res = word_filter($insert['mallconsult_content']);
  97. if (!$res['code']) {
  98. ds_json_encode(10001, $res['msg']);
  99. }
  100. $insert['mallconsult_content'] = $res['data']['text'];
  101. $result = model('mallconsult')->addMallconsult($insert);
  102. if ($result) {
  103. ds_json_encode(10000, lang('ds_common_op_succ'));
  104. } else {
  105. ds_json_encode(10001, lang('ds_common_op_fail'));
  106. }
  107. }
  108. /**
  109. * 删除平台客服咨询
  110. */
  111. public function del_mallconsult()
  112. {
  113. $id = intval(input('param.id'));
  114. if ($id <= 0) {
  115. ds_json_encode(10001, lang('param_error'));
  116. }
  117. $result = model('mallconsult')->delMallconsult(array('mallconsult_id' => $id, 'member_id' => session('member_id')));
  118. if ($result) {
  119. ds_json_encode(10000, lang('ds_common_del_succ'));
  120. } else {
  121. ds_json_encode(10001, lang('ds_common_del_fail'));
  122. }
  123. }
  124. /**
  125. * 咨询的回复状态
  126. */
  127. private function typeState()
  128. {
  129. $state = array('0' => lang('did_not_return'), '1' => lang('have_to_reply'));
  130. View::assign('state', $state);
  131. }
  132. /**
  133. * 用户中心右边,小导航
  134. *
  135. * @param string $menu_key 当前导航的menu_key
  136. * @return
  137. */
  138. protected function getMemberItemList()
  139. {
  140. $menu_array = array(
  141. array(
  142. 'name' => 'consult_list', 'text' => lang('platform_customer_service_consultation_list'),
  143. 'url' => (string)url('Membermallconsult/index')
  144. ),
  145. );
  146. return $menu_array;
  147. }
  148. }