// +---------------------------------------------------------------------- namespace addon\wxchat\controller\api; use think\facade\Db; use think\facade\Request; use ywxapp\controller\FrontendBase; /** * Feedback 类 * * @author ywxapp */ class Feedback extends FrontendBase { protected $noNeedLogin = []; protected $noNeedVerify = ['*']; protected function initialize() {} /** * 提交意见反馈 * type: 1-功能建议 2-投诉举报 3-其他 */ public function save() { $uid = $this->uid; $content = trim((string) Request::post('content', '')); $type = (int) Request::post('type', 1); $contact = trim((string) Request::post('contact', '')); if ($content === '') { $this->error('反馈内容不能为空'); } if (mb_strlen($content) > 500) { $this->error('反馈内容过长(最多500字)'); } Db::name('wxchat_feedback')->insert([ 'uid' => $uid, 'type' => $type, 'content' => $content, 'contact' => $contact, 'status' => 0, 'create_at' => time(), ]); $this->success([], '提交成功'); } /** * 我的反馈列表 */ public function index() { $uid = $this->uid; $list = Db::name('wxchat_feedback') ->where('uid', $uid) ->order('create_at', 'desc') ->limit(50) ->field('id,type,content,status,create_at') ->select(); $this->success(['list' => $list]); } }