<?php
 namespace TechSoft\Laravel\Admin\Traits; use TechOnline\Laravel\Http\InputPackage; use TechOnline\Laravel\Http\Request; use TechOnline\Laravel\Http\Response; use TechSoft\Laravel\Admin\Cms\ConfigCms; use TechSoft\Laravel\Admin\Cms\Field\FieldSwitch; use TechSoft\Laravel\Admin\Cms\Field\FieldText; use TechSoft\Laravel\Sms\SmsTemplate; use TechSoft\Laravel\Sms\SmsUtil; use TechSoft\Laravel\SoftApi\SoftApi; trait ConfigSoftApiTrait { public function softApiDefault(ConfigCms $configCms) { if (Request::isPost()) { $input = InputPackage::buildFromInput(); $ret = SoftApi::instance( $input->getTrimString('softApiDefaultAppId'), $input->getTrimString('softApiDefaultAppSecret') )->ping(); if ($ret['code']) { return Response::send(-1, '对接信息填写错误：' . $ret['msg']); } } return $configCms->execute($this, [ 'group' => 'softApiDefault', 'pageTitle' => 'API对接-默认', 'fields' => [ 'softApiDefaultEnable' => ['type' => FieldSwitch::class, 'title' => '启用', 'desc' => '<div>访问 <a href="http://api.' . __BASE_SITE__ . '" target="_blank">https://api.' . __BASE_SITE__ . '</a> 申请</div>'], 'softApiDefaultAppId' => ['type' => FieldText::class, 'title' => 'AppId', 'desc' => ''], 'softApiDefaultAppSecret' => ['type' => FieldText::class, 'title' => 'AppSecret', 'desc' => ''], ] ]); } public function softApiAsr(ConfigCms $configCms) { return $configCms->execute($this, [ 'group' => 'softApiAsr', 'pageTitle' => 'API对接-ASR', 'fields' => [ 'softApiAsrEnable' => ['type' => FieldSwitch::class, 'title' => '启用', 'desc' => '<div>访问 <a href="http://api.' . __BASE_SITE__ . '" target="_blank">https://api.' . __BASE_SITE__ . '</a> 申请</div>'], 'softApiAsrAppId' => ['type' => FieldText::class, 'title' => 'AppId', 'desc' => ''], 'softApiAsrAppSecret' => ['type' => FieldText::class, 'title' => 'AppSecret', 'desc' => ''], ] ]); } public function softApiAudioConvert(ConfigCms $configCms) { return $configCms->execute($this, [ 'group' => 'softApiAudioConvert', 'pageTitle' => 'API对接-语音转换', 'fields' => [ 'softApiAudioConvertEnable' => ['type' => FieldSwitch::class, 'title' => '启用', 'desc' => '<div>访问 <a href="http://api.' . __BASE_SITE__ . '" target="_blank">https://api.' . __BASE_SITE__ . '</a> 申请</div>'], 'softApiAudioConvertAppId' => ['type' => FieldText::class, 'title' => 'AppId', 'desc' => ''], 'softApiAudioConvertAppSecret' => ['type' => FieldText::class, 'title' => 'AppSecret', 'desc' => ''], ] ]); } public function softApiExpress(ConfigCms $configCms) { return $configCms->execute($this, [ 'group' => 'softApiExpress', 'pageTitle' => 'API对接-快递查询', 'fields' => [ 'softApiExpressEnable' => ['type' => FieldSwitch::class, 'title' => '启用', 'desc' => '<div>访问 <a href="http://api.' . __BASE_SITE__ . '" target="_blank">https://api.' . __BASE_SITE__ . '</a> 申请</div>'], 'softApiExpressAppId' => ['type' => FieldText::class, 'title' => 'AppId', 'desc' => ''], 'softApiExpressAppSecret' => ['type' => FieldText::class, 'title' => 'AppSecret', 'desc' => ''], ] ]); } public function softApiCaptcha(ConfigCms $configCms) { return $configCms->execute($this, [ 'group' => 'softApiCaptcha', 'pageTitle' => '安全验证码', 'fields' => [ 'softApiCaptchaEnable' => ['type' => FieldSwitch::class, 'title' => '启用', 'desc' => '<div>访问 <a href="http://api.' . __BASE_SITE__ . '" target="_blank">https://api.' . __BASE_SITE__ . '</a> 申请</div>'], 'softApiCaptchaAppId' => ['type' => FieldText::class, 'title' => 'AppId', 'desc' => ''], 'softApiCaptchaAppSecret' => ['type' => FieldText::class, 'title' => 'AppSecret', 'desc' => ''], ] ]); } } 