138 lines
5.1 KiB
PHP
138 lines
5.1 KiB
PHP
<?php
|
|
namespace app\controllers\channel;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Yii;
|
|
use app\models\common\Config;
|
|
class MiniUploadController extends CommonController{
|
|
//查看版本
|
|
public function actionGetEdition(){
|
|
if(Yii::$app->params['isDev']==true) {
|
|
return $this->result(1, '成功',1);
|
|
}else{
|
|
return $this->result(1, '成功',2);
|
|
}
|
|
}
|
|
public function actionGetLoginCode(){
|
|
$uniacid=$this->wqData['uniacid'];
|
|
$post=axios_request();
|
|
|
|
if($post['type']=='shd'){
|
|
$appId = Config::getSystemSet('merchantConfig', 0);
|
|
$url=$this->shdUrl."index.php?r=api/index/login";
|
|
}else{
|
|
$appId=Config::getSystemSet('miniConfig',$uniacid);
|
|
$url=$this->cloudUrl."index.php?r=api/index/login";
|
|
}
|
|
// if(Yii::$app->params['isDev']==true){
|
|
// return $this->result(2, '请在微擎后台上传小程序');
|
|
// }
|
|
$wqUrl="";
|
|
/* if(Yii::$app->params['isDev']==true){
|
|
$wqUrl="/app/index.php";
|
|
}*/
|
|
$data['auth_type']=Yii::$app->params['auth_type'];
|
|
$data['domain_url']=Yii::$app->request->hostInfo;
|
|
$data['host']=Yii::$app->request->hostInfo.$wqUrl;
|
|
$res=httpRequest($url,$data);
|
|
$res=json_decode($res,true);
|
|
if($res['code']==2){
|
|
return $this->result(2, $res['msg']);
|
|
}
|
|
if($res['msg']=='成功' AND $res['data']){
|
|
return $this->result(1, '成功',$res['data']);
|
|
}else{
|
|
return $this->result(2, $res['msg']);
|
|
}
|
|
}
|
|
public function actionGetLoginStatus(){
|
|
// if(Yii::$app->params['isDev']==true){
|
|
// return $this->result(2, '请在微擎后台上传小程序');
|
|
// }
|
|
$uniacid=$this->wqData['uniacid'];
|
|
$post=axios_request();
|
|
if($post['type']=='shd'){
|
|
$uniacid=0;
|
|
$config = Config::getSystemSet('shdUpdateConfig', 0);
|
|
$url=$this->shdUrl."index.php?r=api/index/login-status";
|
|
$appId=Config::getSystemSet('merchantConfig',0);
|
|
$config['appId']=$appId['miniAppId'];
|
|
}else {
|
|
$url = $this->cloudUrl . "index.php?r=api/index/login-status";
|
|
$config = Config::getSystemSet('wxUpdateConfig', $uniacid);
|
|
$appId=Config::getSystemSet('miniConfig',$uniacid);
|
|
$config['appId']=$appId['appId'];
|
|
}
|
|
$wqUrl="";
|
|
/* if(Yii::$app->params['isDev']==true){
|
|
$wqUrl="/app/index.php";
|
|
}*/
|
|
$config['host']=Yii::$app->request->hostInfo.$wqUrl;
|
|
$config['uniacid']=$uniacid;
|
|
$config['plugin']=json_encode($config['plugin']);
|
|
//var_dump($config).PHP_EOL.$url;die;
|
|
$res=httpRequest($url,$config);
|
|
$res=json_decode($res,true);
|
|
if($res['msg']=='登录成功'){
|
|
return $this->result(1, '成功',$res['data']);
|
|
}else{
|
|
return $this->result(1, '等待扫码');
|
|
}
|
|
}
|
|
public function actionPreview(){
|
|
// if(Yii::$app->params['isDev']==true){
|
|
// $this->result(2, '请在微擎后台上传小程序');
|
|
// }
|
|
$uniacid=$this->wqData['uniacid'];
|
|
$post=axios_request();
|
|
if($post['type']=='shd'){
|
|
$uniacid=0;
|
|
$config = Config::getSystemSet('shdUpdateConfig', 0);
|
|
$url=$this->shdUrl."index.php?r=api/index/update";
|
|
$appId=Config::getSystemSet('merchantConfig',0);
|
|
$config['appId']=$appId['miniAppId'];
|
|
}else {
|
|
$url = $this->cloudUrl . "index.php?r=api/index/update";
|
|
$config = Config::getSystemSet('wxUpdateConfig', $uniacid);
|
|
$appId=Config::getSystemSet('miniConfig',$uniacid);
|
|
$config['appId']=$appId['appId'];
|
|
}
|
|
$wqUrl="";
|
|
/*if(Yii::$app->params['isDev']==true){
|
|
$wqUrl="/app/index.php";
|
|
}*/
|
|
$config['host']=Yii::$app->request->hostInfo.$wqUrl;
|
|
$config['uniacid']=$uniacid;
|
|
$config['plugin']=json_encode($config['plugin']);
|
|
$res=httpRequest($url,$config);
|
|
$res=json_decode($res,true);
|
|
if($res['msg']=='成功' AND !json_decode($res['data'],true)){
|
|
return $this->result(1, '成功',"data:image/jpeg;base64,".$res['data']);
|
|
}else{
|
|
return $this->result(1, json_decode($res['data'],true)['message'],$res['data']);
|
|
}
|
|
}
|
|
|
|
//设置
|
|
public function actionConfig(){
|
|
$request = Yii::$app->request;
|
|
$result=axios_request();
|
|
if(!$result['ident']){
|
|
return $this->result(2,'数据异常');
|
|
}
|
|
if ($request->isGet) {
|
|
$res=Config::getSystemSet($result['ident'],0);
|
|
echo json_encode(['code'=>1,'msg'=>'成功','data'=>$res]);die;
|
|
}
|
|
if(Yii::$app->params['isDev']==true){
|
|
$result['isDev']=1;
|
|
}else{
|
|
$result['isDev']=2;
|
|
}
|
|
$re=Config::saveSystemSet($result,$result['ident'],0,$result['identName']?:'');
|
|
if($re){
|
|
return $this->result(1,'成功');
|
|
}else{
|
|
return $this->result(2,'网络异常,请稍后再试');
|
|
}
|
|
}
|
|
} |