success(compact('version', 'apk')); } /** * 图片上传 * @param SystemAttachmentServices $services * @return mixed * @throws InvalidArgumentException */ public function upload_image(SystemAttachmentServices $services) { $request = $this->request; $data = $request->postMore([ ['filename', 'file'], ]); if (!$data['filename']) return $this->error('参数有误'); if (CacheService::has('start_uploads_' . $request->uid()) && CacheService::get('start_uploads_' . $request->uid()) >= 100) return $this->error('非法操作'); $upload = UploadService::init(); $info = $upload->to('store/comment')->validate()->move($data['filename']); if ($info === false) { return $this->error($upload->getError()); } $res = $upload->getUploadInfo(); $services->attachmentAdd($res['name'], $res['size'], $res['type'], $res['dir'], $res['thumb_path'], 1, (int)sys_config('upload_type', 1), $res['time'], 3); if (CacheService::has('start_uploads_' . $request->uid())) $start_uploads = (int)CacheService::get('start_uploads_' . $request->uid()); else $start_uploads = 0; $start_uploads++; CacheService::set('start_uploads_' . $request->uid(), $start_uploads, 86400); $res['dir'] = path_to_url($res['dir']); if (strpos($res['dir'], 'http') === false) $res['dir'] = sys_config('site_url') . $res['dir']; return $this->success('图片上传成功!', ['name' => $res['name'], 'url' => $res['dir']]); } /** * 获取城市 * @param CityAreaServices $services * @return mixed * @throws DataNotFoundException * @throws DbException * @throws ModelNotFoundException */ public function city(CityAreaServices $services) { $pid = $this->request->get('pid', 0); $type = $this->request->get('type', 0); return $this->success($services->getCityTreeList((int)$pid, (int)$type)); } /** * 解析(获取导入微信地址) * @param CityAreaServices $services * @return mixed * @throws DataNotFoundException * @throws DbException * @throws ModelNotFoundException */ public function cityList(CityAreaServices $services) { $address = $this->request->param('address', ''); if (!$address) return app('json')->fail('地址不存在'); $city = $services->searchCity(compact('address')); if (!$city) return app('json')->fail('地址暂未录入,请联系管理员'); $where = [['id', 'in', array_merge([$city['id']], explode('/', trim($city->path, '/')))]]; return app('json')->success($services->getCityList($where, 'id as value,id,name as label,parent_id as pid', ['children'])); } }