validate($data,[ 'id'=>['require'], ]); $agreement=Agreement::where('id',$data['id'])->value('content',''); $agreement=$this->_($agreement); $this->success('',$agreement); } /** * 获取轮播图 * @param string pos 位置index首页 * @ApiReturnParams (name=img,description=图片地址) * @ApiReturnParams (name=link,description=链接) */ public function ads(){ $data=input(); $this->validate($data,[ 'pos'=>'require', ]); $chanId=getChanId(); $ads=Ad::getAd($data['pos'],$chanId); $this->success('',$ads); } /** * 上传文件 * @ApiMethod (POST) * @param File $file 文件流 */ public function upload() { Config::set('default_return_type', 'json'); //必须设定cdnurl为空,否则cdnurl函数计算错误 Config::set('upload.cdnurl', ''); $chunkid = $this->request->post("chunkid"); if ($chunkid) { if (!Config::get('upload.chunking')) { $this->error(__('Chunk file disabled')); } $action = $this->request->post("action"); $chunkindex = $this->request->post("chunkindex/d"); $chunkcount = $this->request->post("chunkcount/d"); $filename = $this->request->post("filename"); $method = $this->request->method(true); if ($action == 'merge') { $attachment = null; //合并分片文件 try { $upload = new Upload(); $attachment = $upload->merge($chunkid, $chunkcount, $filename); } catch (UploadException $e) { $this->error($e->getMessage()); } $this->success(__('Uploaded successful'), ['url' => $attachment->url, 'fullurl' => cdnurl($attachment->url, true)]); } elseif ($method == 'clean') { //删除冗余的分片文件 try { $upload = new Upload(); $upload->clean($chunkid); } catch (UploadException $e) { $this->error($e->getMessage()); } $this->success(); } else { //上传分片文件 //默认普通上传文件 $file = $this->request->file('file'); try { $upload = new Upload($file); $upload->chunk($chunkid, $chunkindex, $chunkcount); } catch (UploadException $e) { $this->error($e->getMessage()); } $this->success(); } } else { $attachment = null; //默认普通上传文件 $file = $this->request->file('file'); try { $upload = new Upload($file); $attachment = $upload->upload(); } catch (UploadException $e) { $this->error($e->getMessage()); } $this->success(__('Uploaded successful'), ['url' => $attachment->url, 'fullurl' => cdnurl($attachment->url, true)]); } } /** * 意见反馈 * @ApiParams (name=name,description="称呼") * @ApiParams (name=phone,description=电话) * @ApiParams (name=sms_code,description=验证码) * @ApiParams (name=title,description=标题) * @ApiParams (name=content,description=内容) * @ApiParams (name=images,description=图片数组) */ public function feedback(){ $data=input(); $this->validate($data,[ 'name|姓名'=>['require','max:10'], 'phone|手机号'=>['require','integer','length:11'], 'title|标题'=>['require','max:10'], 'content|内容'=>['require','max:120'], 'images|图片'=>['require','array','max:3','min:1'], 'images.0'=>['require','url'], ]); SmsSend::setMobile($data['phone'])->setCode($data['sms_code']??'')->check(); $feedback=new Feedback(); $feedback->allowField(true)->save($data); $this->success('',$feedback); } /** * 商务合作 * @ApiParams (name=type,description="1个人2公司") * @ApiParams (name=name,description="名称") * @ApiParams (name=for,description="方向1直播合作2学习直播3卡商合作") * @ApiParams (name=has_exp,description="1有0无经验") * @ApiParams (name=phone,description="手机号") * @ApiParams (name=sms_code,description="验证码") * */ public function business_form(){ $data=$this->_validate([ 'type|类型'=>['require','in:1,2'], 'name|名称'=>['require','max:50'], 'for|方向'=>['require','in:1,2,3'], 'has_exp'=>['require','in:1,0'], 'phone|手机号'=>['require','integer','length:11'], ]); SmsSend::setMobile($data['phone'])->setCode($data['sms_code']??'')->check(); $feedback=new FeedbackBusiness; $feedback->allowField(true)->save($data); $this->success('',$feedback); } /** * 获取地区信息 * @ApiParams (name=level,description=1省2市3区) * @ApiParams (name=pid,description=上级区域ID) */ public function area(){ $data=$this->_validate([ 'level'=>['require'], 'pid'=>['require'], ]); $this->success( '', Area::where('level',$data['level']) ->where('pid',$data['pid']) ->order('pinyin') ->select() ); } /** * 获取地区信息(按字母排序) */ public function area_sort(){ $citys=Area::area()->field(['id','name','first'])->select(); $a=[]; for ($i=65;$i<91;$i++) { $one=[ 'index'=>chr($i), 'child'=>[] ]; foreach ($citys as $key=>&$city) { if($city['first']==$one['index']){ $one['child'][]=[ 'title'=>$city['name'], 'weight'=>$city['id'], 'id' =>$city['id'], ]; unset($citys[$key]); } } $a[]=$one; } $this->success('',$a); } /** * 地区递归三级联动 */ public function area_tree(){ function area(&$data,$areas,$first=false){ foreach ($areas as $k=>$area){ if($first){ if($area['pid']==0) { area($area, $areas); unset($area['pid']); $data[] = $area; unset($areas[$k]); } }else{ if($data['value']==$area['pid']){ area($area, $areas); unset($area['pid']); $data['children'][]=$area; unset($areas[$k]); } } } } $fromCache=Cache::get('app_area'); if(!$fromCache){ $fina=[]; $areas=Area::where('level','<=',3)->field('id as value,name as label,pid')->select()->toArray(); area($fina,$areas,true); $fromCache=$fina; Cache::remember('app_area',$fina,0); } $this->success('',$fromCache); } /** * 根据名称获取信息 * @ApiParams (name="name",description="城市名") * @ApiReturnParams (name="id",description="城市ID") */ public function get_area(){ $rs=null; if($name=input('name')){ $cacheName="area_name_".$name; $rs=Cache::get($cacheName,null); if(!$rs){ $rs=Area::where('name|shortname',$name)->find(); Cache::set($cacheName,$rs); } } $this->success('',$rs); } /** * 获取系统配置 * @ApiReturnParams (name="site_name",description="站点名称") * @ApiReturnParams (name="com_name",description="公司名称") * @ApiReturnParams (name="wxp_name",description="微信公众号名称") * @ApiReturnParams (name="wxp_qrcode",description="微信公众号二维码") * @ApiReturnParams (name="service_mobile",description="客服手机号") * @ApiReturnParams (name="system_service_mobile_show",description="是否展示客服手机号") * @ApiReturnParams (name="service_work_time",description="客服工作时间") * @ApiReturnParams (name="system_sms_open",description="短信验证码开关") * @ApiReturnParams (name="disable_send_province",description="禁止发货地区") * @ApiReturnParams (name="system_index_tr",description="首页右上角展示1投诉2商务合作") * @ApiReturnParams (name="system_index_m1",description="首页特价号1流量卡2号码定制3特价号") * @ApiReturnParams (name="system_id_form_open",description="身份证开关") * @ApiReturnParams (name="flow_main_logo",description="流量卡上方图片") * @ApiReturnParams (name="flow_main_link",description="流量卡上方图片链接") * @ApiReturnParams (name="flow_order_bg",description="流量卡订单查询背景图") * @ApiReturnParams (name="bussiness_contact_mobile",description="商务合作电话") * @ApiReturnParams (name="beauti_no_detail_bg",description="详情页背景图") * @ApiReturnParams (name="beauti_no_detail_text",description="详情页详情文本") * @ApiReturnParams (name="index_no_type",description="首页进入展示列表all全部local本地") * @ApiReturnParams (name="copy_btn_title",description="靓号详情复制按钮显示字符") * @ApiReturnParams (name="click_pop_content",description="复制按钮点击后弹窗内容") * @ApiReturnParams (name="flow_service_h5",description="平台h5客服类型1电话,2链接,3二维码") * @ApiReturnParams (name="flow_service_dy",description="平台抖音客服类型1电话,2链接,3二维码") * @ApiReturnParams (name="flow_service_ks",description="平台快手客服类型1电话,2链接,3二维码") * @ApiReturnParams (name="flow_service_tel",description="电话号") * @ApiReturnParams (name="flow_service_link",description="跳转链接") * @ApiReturnParams (name="flow_service_qrcode",description="二维码") * @ApiReturnParams (name="flow_service_qrcode_name",description="二维码名称") */ public function config(){ $chanId=getChanId(); $data=[ 'site_name'=>\config('site.name'), 'com_name'=>\config('site.base_company_name'), 'wxp_name'=>\config('site.system_wxp_name'), 'wxp_qrcode'=>\config('site.system_wxp_qrcode'), 'service_mobile'=>\config('site.system_service_mobile'), 'system_service_mobile_show'=>\config('site.system_service_mobile_show')?true:false, 'service_work_time'=>\config('site.service_work_time'), 'system_sms_open'=>\config('site.system_sms_open')?true:false, 'disable_send_province'=>Area::whereIn('id',\config('site.disable_send_province')?:0)->field('id,name')->select(), 'system_index_tr'=>config('site.system_index_tr')?:1, 'system_index_m1'=>config('site.system_index_m1')?:1, 'system_id_form_open'=>config('site.system_id_form_open')?1:0, 'flow_main_logo'=>config('site.flow_main_logo'), 'flow_main_link'=>config('site.flow_main_link'), 'flow_order_bg'=>config('site.flow_order_bg'), 'bussiness_contact_mobile'=>config('site.bussiness_contact_mobile'), 'beauti_no_detail_bg'=>config('site.beauti_no_detail_bg'), 'beauti_no_detail_text'=>\config('site.beauti_no_detail_text'), 'index_no_type'=>config('site.index_no_type')?:'all', 'copy_btn_title'=>config('site.copy_btn_title')?:'申请优惠', 'click_pop_content'=>config('site.click_pop_content'), 'flow_service_h5' => config('site.flow_service_h5'), 'flow_service_dy' => config('site.flow_service_dy'), 'flow_service_ks' => config('site.flow_service_ks'), 'flow_service_tel' => config('site.flow_service_tel'), 'flow_service_link' => config('site.flow_service_link'), 'flow_service_qrcode_name' => config('site.flow_service_qrcode_name'), 'flow_service_qrcode' => config('site.flow_service_qrcode'), ]; if($chanId){ if(getSub()->getAdmin('wx_qr')){ $data['wxp_qrcode']=getSub()->getAdmin('wx_qr'); } if(getSub()->getAdmin('wxp_name')){ $data['wxp_name']=getSub()->getAdmin('wxp_name'); } if($service = getSub()->getAdmin('flow_service')){ $platform = \app\admin\model\AuthGroup::$servicePlatform; $tmpService = json_decode($service, true); foreach($platform as $key=>$val){ $tmpKey = 'flow_service_'.$key; if(isset($tmpService[$tmpKey]) && $tmpService[$tmpKey]) $data[$tmpKey] = $tmpService[$tmpKey]; } $tmp_flow_service_tel = getSub()->getAdmin('flow_service_tel'); $tmp_flow_service_link = getSub()->getAdmin('flow_service_link'); $tmp_flow_service_qrcode = getSub()->getAdmin('flow_service_qrcode'); $tmp_flow_service_qrcode_name = getSub()->getAdmin('flow_service_qrcode_name'); if($tmp_flow_service_tel) $data['flow_service_tel'] = $tmp_flow_service_tel; if($tmp_flow_service_link) $data['flow_service_link'] = $tmp_flow_service_link; if($tmp_flow_service_qrcode) $data['flow_service_qrcode'] = $tmp_flow_service_qrcode; if($tmp_flow_service_qrcode_name) $data['flow_service_qrcode_name'] = $tmp_flow_service_qrcode_name; } } $data['beauti_no_detail_text']=$this->_($data['beauti_no_detail_text']); $this->success('',$data); } protected function _($agreement){ $agreement=str_replace('