初始上传
This commit is contained in:
40
addon/weapp/api/controller/Auth.php
Executable file
40
addon/weapp/api/controller/Auth.php
Executable file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\weapp\api\controller;
|
||||
|
||||
use addon\weapp\model\Weapp;
|
||||
use app\Controller;
|
||||
use think\facade\Log;
|
||||
|
||||
class Auth extends Controller
|
||||
{
|
||||
|
||||
public $wechat;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$site_id = request()->siteid();
|
||||
$this->wechat = new Weapp($site_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 小程序消息推送
|
||||
*/
|
||||
public function relateWeixin()
|
||||
{
|
||||
Log::write('微信小程序消息推送');
|
||||
$this->wechat->relateWeixin();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
89
addon/weapp/api/controller/Weapp.php
Executable file
89
addon/weapp/api/controller/Weapp.php
Executable file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\weapp\api\controller;
|
||||
|
||||
use addon\weapp\model\Config;
|
||||
use addon\weapp\model\Message;
|
||||
use app\api\controller\BaseApi;
|
||||
use addon\weapp\model\Weapp as WeappModel;
|
||||
use app\model\system\Pay as PayModel;
|
||||
|
||||
class Weapp extends BaseApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 获取openid
|
||||
*/
|
||||
public function authCodeToOpenid()
|
||||
{
|
||||
$weapp_model = new WeappModel($this->site_id);
|
||||
$res = $weapp_model->authCodeToOpenid($this->params);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取消息模板id(最多三条)
|
||||
*/
|
||||
public function messageTmplIds()
|
||||
{
|
||||
$keywords = $this->params[ 'keywords' ] ?? '';
|
||||
$message = new Message();
|
||||
$res = $message->getMessageTmplIds($this->site_id, $keywords);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取小程序码
|
||||
*/
|
||||
public function qrcode()
|
||||
{
|
||||
$config_model = new Config();
|
||||
$config = $config_model->getWeappConfig($this->site_id);
|
||||
$qrcode = $config[ 'data' ][ 'value' ][ 'qrcode' ] ?? '';
|
||||
return $this->response($this->success($qrcode));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分享
|
||||
* @return false|string
|
||||
*/
|
||||
public function share()
|
||||
{
|
||||
/*$config_model = new Config();
|
||||
$config = $config_model->getShareConfig($this->site_id, 'shop');
|
||||
$share_config = $config['data']['value'];*/
|
||||
|
||||
$this->checkToken();
|
||||
|
||||
//页面路径
|
||||
$path = $this->params[ 'path' ] ?? '';
|
||||
|
||||
//分享配置
|
||||
$share_config = [];
|
||||
$share_data = event('WeappShareData', [
|
||||
'path' => $path,
|
||||
'site_id' => $this->site_id,
|
||||
'member_id' => $this->member_id,
|
||||
], true);
|
||||
if (!empty($share_data)) {
|
||||
$share_config[ 'permission' ] = $share_data[ 'permission' ];
|
||||
$share_config[ 'data' ] = $share_data[ 'data' ];
|
||||
} else {
|
||||
$share_config[ 'permission' ] = [
|
||||
'onShareAppMessage' => false,
|
||||
'onShareTimeline' => false,
|
||||
];
|
||||
$share_config[ 'data' ] = null;
|
||||
}
|
||||
|
||||
return $this->response($this->success($share_config));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user