123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- <?php
- namespace app\api\controller;
- use think\cache\driver\Redis;
- use think\Db;
- use think\facade\Validate;
- use think\Request;
- use OSS\OssClient;
- use OSS\Core\OssException;
- use Zxing\Qrcode\Decoder\DataBlock;
- /**
- * @title 公共类
- * @controller Publics
- */
- class Publics extends Base
- {
- /**
- * @title 上传图片
- * @desc 上传图片
- * @url /api/Publics/uploadLocality
- * @method POST
- * @tag 基础
- *
- * @param name:file type:file require:1 desc:上传
- * @return name:data@url type:string desc:图片地址
- **/
- public function uploadLocality(){
- $file = request()->file('file');
- $dir = dirname(realpath(dirname($_SERVER['SCRIPT_FILENAME']))) . '/public/upload';
- if(!file_exists($dir)){
- //检查是否有该文件夹,如果没有就创建,并给予最高权限
- mkdir($dir, 0700,true);
- }
- $info = $file->move($dir);
- $newName = $info->getSaveName();
- $data['url'] = 'http://'.$_SERVER['SERVER_NAME']."/upload/{$newName}";
- $this->success('上传成功',$data);
- }
- /**
- * @title 获取系统配置
- * @desc 获取系统配置
- * @url /api/Publics/config_info
- * @method POST
- * @tag 基础
- *
- * @return name:agreement type:string desc:使用条款
- * @return name:privacy type:string desc:隐私协议
- * @return name:platform_agreement type:string desc:违规处罚
- * @return name:about_us type:string desc:关于我们
- * @return name:registration_agreement type:string desc:用户注册协议
- * @return name:terms_service type:string desc:联通统一认证服务条款
- * @return name:chain_on_query type:string desc:链上查询
- * @return name:examples_illustrate type:string desc:转赠说明
- * @return name:android_version type:string desc:安卓当前版本号
- * @return name:android_package type:string desc:安卓包地址
- * @return name:ios_package type:string desc:ios地址
- * @return name:newbie_guide type:string desc:新手指南
- * @return name:invite_rules type:string desc:邀请规则
- * @return name:service type:string desc:客服
- * @return name:advance_minutes type:string desc:提前抢购时间(分钟)
- * @return name:share_poster type:string desc:分享海报
- **/
- public function config_info(){
- $nameArray = [
- 'agreement',
- 'privacy',
- 'platform_agreement',
- 'newbie_guide',
- 'invite_rules',
- 'service',
- 'about_us',
- 'registration_agreement',
- 'terms_service',
- 'chain_on_query',
- 'examples_illustrate',
- 'android_version',
- 'android_package',
- 'ios_package',
- 'free_lucky_number',
- 'lucky_recharge_price',
- 'service_fee',
- 'royalties',
- 'advance_minutes',
- 'share_poster',
- ];
- $array = getConfig($nameArray);
- $this->success('成功',$array);
- }
- /**
- * @title 获取分享的签名
- * @desc 获取分享的签名
- * @url /api/Publics/getWechatSign
- * @method POST
- * @tag 基础
- *
- **/
- public function getWechatSign(){
- $urls = input('url');
- $appid = 'wx8e47a12d0a1c007f';
- $secret = 'f19bfac2108af3aee75df0a31a1fee1c';
- $redis = new Redis();
- $access_token = $redis->get('access_token');
- if (!$access_token){
- $access_token = '';
- $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appid&secret=$secret";
- $res=curlRequest($url);
- $res = json_decode($res,true);
- if (isset($res['access_token'])){
- $redis->set('access_token',$res['access_token'],'7000');
- $access_token = $res['access_token'];
- }
- }
- $url2 ="https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=".$access_token."&type=jsapi";
- $res2=curlRequest($url2);
- $res2 = json_decode($res2,true);
- if (!isset($res2) || $res2['errcode']!=0){
- $this->error('获取ticket失败');
- }
- $timestamp = time();
- $noncestr = get32Str(15);
- // $urls = 'http://jybl.hdlkeji.com/web/h5/';
- $string = "jsapi_ticket=".$res2['ticket']."&noncestr=$noncestr×tamp=$timestamp&url=".$urls;
- $sign = sha1($string);
- $return = [
- 'appid'=>$appid,
- 'noncestr'=>$noncestr,
- 'timestamp'=>$timestamp,
- 'url'=>$urls,
- 'sign'=>$sign,
- 'ticket'=>$res2['ticket']
- ];
- $this->success('成功',$return);
- }
- }
|