isMobile()) { return $this->fetch("mobile_index"); } return $this->fetch(); } public function mobile_order($uid) { if (!request()->isMobile()) { return $this->redirect(Url("index")); } $userInfo = User::get($uid); $this->assign("userInfo", $userInfo); return $this->fetch(); } public function mobile_chat($uid) { if (!request()->isMobile()) { return $this->redirect(Url("index")); } $userInfo = User::get($uid); $this->assign("userInfo", $userInfo); return $this->fetch(); } public function login() { return $this->fetch(); } public function account_login() { $params = request()->param(); $kefuAccount = (new KefuModel)->where("account", $params['account'])->find(); if (!$kefuAccount) return Json::fail("账号不存在!"); if (!$kefuAccount['status']) return Json::fail("账号已被禁用!"); $input_pwd = $params['password']; if (md5($input_pwd) !== $kefuAccount['password']) return Json::fail("密码不正确!"); Session::set("kefuId", $kefuAccount["id"], "kefu"); return Json::successful("登录成功!"); } public function logout() { Session::delete("kefuId", "kefu"); return Json::successful("退出登录成功!"); } private function createToken($kefuId) { $tokenService = new JwtService("kefu"); return $tokenService->getToken((int)$kefuId); } public function get_token() { $token = $this->createToken($this->kefuId); return Json::successful('ok', ['token' => $token]); } public function user_record($nickname = "", $is_tourist = 0) { $service = new KefuRecordService; $data = $service->getRecordList($this->kefuId, $nickname, $is_tourist); return Json::successful($data); } public function get_chat_list($uid, $upper_id, $is_tourist) { $service = new KefuChatService; $data = $service->getChatList($this->kefuId, $uid, $upper_id, $is_tourist); return Json::successful($data); } public function get_product_cart($uid, $store_name) { $carts = []; return Json::successful($carts); } public function set_msg_isread($uid) { if (!$uid) return Json::fail("找不到用户!"); (new KefuUserRecordModel)->where([ 'is_kefu_send' => 1, 'user_id' => $this->kefuId, 'to_uid' => $uid ])->update([ 'mssage_num' => 0 ]); return Json::successful("更新成功!"); } public function transfer_list() { $data = (new KefuModel) ->field('id, nickname, avatar, online') ->where('id', '<>', $this->kefuId) ->where('online', 1) ->select(); return Json::successful($data); } }