Membermallconsult.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <?php
  2. namespace app\home\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. * ============================================================================
  7. *
  8. * ============================================================================
  9. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  10. * 网站地址: https://www.valimart.net/
  11. * ----------------------------------------------------------------------------
  12. *
  13. * ============================================================================
  14. * 控制器
  15. */
  16. class Membermallconsult extends BaseMember {
  17. public function initialize() {
  18. parent::initialize(); // TODO: Change the autogenerated stub
  19. Lang::load(base_path() . 'home/lang/'.config('lang.default_lang').'/membermallconsult.lang.php');
  20. }
  21. /**
  22. * 平台客服咨询首页
  23. */
  24. public function index() {
  25. // 咨询列表
  26. $mallconsult_model = model('mallconsult');
  27. $consult_list = $mallconsult_model->getMallconsultList(array('member_id' => session('member_id')), '*', '10');
  28. View::assign('consult_list', $consult_list);
  29. View::assign('show_page', $mallconsult_model->page_info->render());
  30. // 回复状态
  31. $this->typeState();
  32. $this->setMemberCurMenu('member_mallconsult');
  33. $this->setMemberCurItem('consult_list');
  34. return View::fetch($this->template_dir . 'member_mallconsult_list');
  35. }
  36. /**
  37. * 平台咨询详细
  38. */
  39. public function mallconsult_info() {
  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. $type_list = model('mallconsulttype')->getMallconsulttypeList(array());
  64. View::assign('type_list', $type_list);
  65. if (input('param.inajax')) {
  66. return View::fetch($this->template_dir . 'add_inajax');
  67. } else {
  68. $this->setMemberCurMenu('member_mallconsult');
  69. $this->setMemberCurItem('consult_list');
  70. return View::fetch($this->template_dir . 'member_mallconsult_add');
  71. }
  72. }
  73. /**
  74. * 保存平台咨询
  75. */
  76. public function save_mallconsult() {
  77. if (!request()->isPost()) {
  78. ds_json_encode(10001,lang('param_error'));
  79. }
  80. //验证表单信息
  81. $data = [
  82. 'type_id' => input('post.type_id'),
  83. 'consult_content' => input('post.consult_content')
  84. ];
  85. $mallconsult_validate = ds_validate('mallconsult');
  86. if (!$mallconsult_validate->scene('save_mallconsult')->check($data)) {
  87. ds_json_encode(10001,$mallconsult_validate->getError());
  88. }
  89. $insert = array();
  90. $insert['mallconsulttype_id'] = input('post.type_id');
  91. $insert['member_id'] = session('member_id');
  92. $insert['member_name'] = session('member_name');
  93. $insert['mallconsult_content'] = input('post.consult_content');
  94. $res=word_filter($insert['mallconsult_content']);
  95. if(!$res['code']){
  96. ds_json_encode(10001,$res['msg']);
  97. }
  98. $insert['mallconsult_content']=$res['data']['text'];
  99. $result = model('mallconsult')->addMallconsult($insert);
  100. if ($result) {
  101. ds_json_encode(10000,lang('ds_common_op_succ'));
  102. } else {
  103. ds_json_encode(10001,lang('ds_common_op_fail'));
  104. }
  105. }
  106. /**
  107. * 删除平台客服咨询
  108. */
  109. public function del_mallconsult() {
  110. $id = intval(input('param.id'));
  111. if ($id <= 0) {
  112. ds_json_encode(10001,lang('param_error'));
  113. }
  114. $result = model('mallconsult')->delMallconsult(array('mallconsult_id' => $id, 'member_id' => session('member_id')));
  115. if ($result) {
  116. ds_json_encode(10000,lang('ds_common_del_succ'));
  117. } else {
  118. ds_json_encode(10001,lang('ds_common_del_fail'));
  119. }
  120. }
  121. /**
  122. * 咨询的回复状态
  123. */
  124. private function typeState() {
  125. $state = array('0' => lang('did_not_return'), '1' => lang('have_to_reply'));
  126. View::assign('state', $state);
  127. }
  128. /**
  129. * 用户中心右边,小导航
  130. *
  131. * @param string $menu_key 当前导航的menu_key
  132. * @return
  133. */
  134. protected function getMemberItemList() {
  135. $menu_array = array(
  136. array(
  137. 'name' => 'consult_list', 'text' => lang('platform_customer_service_consultation_list'),
  138. 'url' => (string)url('Membermallconsult/index')
  139. ),
  140. );
  141. return $menu_array;
  142. }
  143. }