qq小程序优化,unionid优先处理
parent
cf0437df06
commit
2db570cd64
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ShopXO 国内领先企业级B2C免费开源电商系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2011~2019 http://shopxo.net All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: Devil
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\service\ConfigService;
|
||||
|
||||
/**
|
||||
* QQ小程序 - 配置
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-01T21:51:08+0800
|
||||
*/
|
||||
class AppMiniQQConfig extends Common
|
||||
{
|
||||
/**
|
||||
* 构造方法
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-03T12:39:08+0800
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// 调用父类前置方法
|
||||
parent::__construct();
|
||||
|
||||
// 登录校验
|
||||
$this->IsLogin();
|
||||
|
||||
// 权限校验
|
||||
$this->IsPower();
|
||||
}
|
||||
|
||||
/**
|
||||
* [Index 配置列表]
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-06T21:31:53+0800
|
||||
*/
|
||||
public function Index()
|
||||
{
|
||||
// 配置信息
|
||||
$this->assign('data', ConfigService::ConfigList());
|
||||
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* [Save 配置数据保存]
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2017-01-02T23:08:19+0800
|
||||
*/
|
||||
public function Save()
|
||||
{
|
||||
return ConfigService::ConfigSave($_POST);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -0,0 +1,113 @@
|
|||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ShopXO 国内领先企业级B2C免费开源电商系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2011~2019 http://shopxo.net All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: Devil
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\service\AppMiniService;
|
||||
|
||||
/**
|
||||
* QQ小程序管理
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-01T21:51:08+0800
|
||||
*/
|
||||
class AppMiniQQList extends Common
|
||||
{
|
||||
private $application_name;
|
||||
private $old_path;
|
||||
private $new_path;
|
||||
private $params;
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-03T12:39:08+0800
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// 调用父类前置方法
|
||||
parent::__construct();
|
||||
|
||||
// 登录校验
|
||||
$this->IsLogin();
|
||||
|
||||
// 权限校验
|
||||
$this->IsPower();
|
||||
|
||||
// 参数
|
||||
$this->params = input();
|
||||
$this->params['application_name'] = 'qq';
|
||||
}
|
||||
|
||||
/**
|
||||
* [Index 列表]
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-06T21:31:53+0800
|
||||
*/
|
||||
public function Index()
|
||||
{
|
||||
$this->assign('data_list', AppMiniService::DataList($this->params));
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* [Created 生成]
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2017-02-05T20:12:30+0800
|
||||
*/
|
||||
public function Created()
|
||||
{
|
||||
// 是否ajax请求
|
||||
if(!IS_AJAX)
|
||||
{
|
||||
$this->error('非法访问');
|
||||
}
|
||||
|
||||
// 配置内容
|
||||
$app_mini_title = MyC('common_app_mini_qq_title');
|
||||
$app_mini_describe = MyC('common_app_mini_qq_describe');
|
||||
if(empty($app_mini_title) || empty($app_mini_describe))
|
||||
{
|
||||
return DataReturn('配置信息不能为空', -1);
|
||||
}
|
||||
|
||||
// 开始操作
|
||||
$this->params['app_mini_title'] = $app_mini_title;
|
||||
$this->params['app_mini_describe'] = $app_mini_describe;
|
||||
return AppMiniService::Created($this->params);
|
||||
}
|
||||
|
||||
/**
|
||||
* [Delete 删除包]
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2016-12-09T21:13:47+0800
|
||||
*/
|
||||
public function Delete()
|
||||
{
|
||||
// 是否ajax请求
|
||||
if(!IS_AJAX)
|
||||
{
|
||||
$this->error('非法访问');
|
||||
}
|
||||
|
||||
// 开始操作
|
||||
return AppMiniService::Delete($this->params);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
{{include file="public/header" /}}
|
||||
|
||||
<!-- right content start -->
|
||||
<div class="content-right">
|
||||
<div class="content">
|
||||
<!-- form start -->
|
||||
<form class="am-form form-validation view-save" action="{{:MyUrl('admin/appminiqqconfig/save')}}" method="POST" request-type="ajax-url" request-value="{{:MyUrl('admin/appminiqqconfig/index')}}">
|
||||
<div class="am-form-group">
|
||||
<label>{{$data.common_app_mini_qq_appid.name}}<span class="am-form-group-label-tips">{{$data.common_app_mini_qq_appid.describe}}</span></label>
|
||||
<input type="text" name="{{$data.common_app_mini_qq_appid.only_tag}}" placeholder="{{$data.common_app_mini_qq_appid.name}}" data-validation-message="{{$data.common_app_mini_qq_appid.error_tips}}" class="am-radius" {{if !empty($data)}}value="{{$data.common_app_mini_qq_appid.value}}"{{/if}} />
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label>{{$data.common_app_mini_qq_appsecret.name}}<span class="am-form-group-label-tips">{{$data.common_app_mini_qq_appsecret.describe}}</span></label>
|
||||
<input type="text" name="{{$data.common_app_mini_qq_appsecret.only_tag}}" placeholder="{{$data.common_app_mini_qq_appsecret.name}}" data-validation-message="{{$data.common_app_mini_qq_appsecret.error_tips}}" class="am-radius" {{if !empty($data)}}value="{{$data.common_app_mini_qq_appsecret.value}}"{{/if}} />
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label>{{$data.common_app_mini_qq_apptoken.name}}<span class="am-form-group-label-tips">{{$data.common_app_mini_qq_apptoken.describe}}</span></label>
|
||||
<input type="text" name="{{$data.common_app_mini_qq_apptoken.only_tag}}" placeholder="{{$data.common_app_mini_qq_apptoken.name}}" data-validation-message="{{$data.common_app_mini_qq_apptoken.error_tips}}" class="am-radius" {{if !empty($data)}}value="{{$data.common_app_mini_qq_apptoken.value}}"{{/if}} />
|
||||
</div>
|
||||
|
||||
<div class="am-form-group">
|
||||
<label>{{$data.common_app_mini_qq_title.name}}</label>
|
||||
<input type="text" name="{{$data.common_app_mini_qq_title.only_tag}}" placeholder="{{$data.common_app_mini_qq_title.name}}" data-validation-message="{{$data.common_app_mini_qq_title.error_tips}}" class="am-radius" {{if !empty($data)}}value="{{$data.common_app_mini_qq_title.value}}"{{/if}} />
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label>{{$data.common_app_mini_qq_describe.name}}</label>
|
||||
<input type="text" name="{{$data.common_app_mini_qq_describe.only_tag}}" placeholder="{{$data.common_app_mini_qq_describe.name}}" data-validation-message="{{$data.common_app_mini_qq_describe.error_tips}}" class="am-radius" {{if !empty($data)}}value="{{$data.common_app_mini_qq_describe.value}}"{{/if}} />
|
||||
</div>
|
||||
<div class="am-form-group am-form-group-refreshing">
|
||||
<button type="submit" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm am-btn-block" data-am-loading="{loadingText:'处理中...'}">保存</button>
|
||||
</div>
|
||||
</form>
|
||||
<!-- form end -->
|
||||
</div>
|
||||
</div>
|
||||
<!-- right content end -->
|
||||
|
||||
<!-- footer start -->
|
||||
{{include file="public/footer" /}}
|
||||
<!-- footer end -->
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
{{include file="public/header" /}}
|
||||
|
||||
<!-- right content start -->
|
||||
<div class="content-right">
|
||||
<div class="content">
|
||||
<!-- operation start -->
|
||||
<div class="am-g">
|
||||
<button class="am-btn am-btn-secondary am-radius am-btn-xs am-icon-plus submit-ajax" data-url="{{:MyUrl('admin/appminiqqlist/created')}}" data-view="reload" data-msg="生成时间比较长,请不要关闭浏览器窗口!"> 生成</button>
|
||||
</div>
|
||||
<!-- operation end -->
|
||||
|
||||
<!-- miniapp develop tips -->
|
||||
{{if config('shopxo.is_develop') eq true}}
|
||||
<div class="am-alert am-alert-warning am-radius" data-am-alert="">
|
||||
当前为开发模式<br />
|
||||
1. 发布小程序必须采用 https 协议,上线需确认 app.js 中 request_url 参数值是否正确。<br />
|
||||
2. 发布小程序,建议关闭开发者模式、从正式环境重新生成小程序下载使用开发者工具上传审核。<br />
|
||||
3. 非 https 环境下,在开发者工具 -> 顶部导航 -> 详情 -> 不校验合法域名、web-view(业务域名)TLS版本以及HTTPS证书(勾选改选项即可进行小程序开发调试)。
|
||||
</div>
|
||||
{{else /}}
|
||||
<div class="am-alert am-alert-warning am-radius" data-am-alert="">
|
||||
1. 生成小程序必须在 https 协议下进行操作、请配置好服务器 ssl 并使用 https 协议登录后台管理生成小程序。<br />
|
||||
2. 如需非 https 协议下生成小程序,请在 config/shopxo.php 文件中 is_develop值改为true开启开发者模式。
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<!-- list start -->
|
||||
<table class="am-table am-table-striped am-table-hover am-text-middle am-margin-top-sm am-margin-left-xs">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>包名</th>
|
||||
<th>大小</th>
|
||||
<th>创建时间</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{if !empty($data_list)}}
|
||||
{{foreach $data_list as $v}}
|
||||
<tr>
|
||||
<td>{{$v.name}}</td>
|
||||
<td>{{$v.size}}</td>
|
||||
<td>{{$v.time}}</td>
|
||||
<td class="view-operation">
|
||||
{{if !empty($v.url)}}
|
||||
<a href="{{$v.url}}">
|
||||
<button class="am-btn am-btn-success am-btn-xs am-radius am-icon-download"> 下载</button>
|
||||
</a>
|
||||
{{/if}}
|
||||
<button class="am-btn am-btn-danger am-btn-xs am-radius am-icon-trash-o submit-delete" data-url="{{:MyUrl('admin/appminiqqlist/delete')}}" data-id="{{$v.name}}" data-view="reload"> 删除</button>
|
||||
</td>
|
||||
</tr>
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{if empty($data_list)}}
|
||||
<div class="table-no"><i class="am-icon-warning"></i> 没有相关数据</div>
|
||||
{{/if}}
|
||||
<!-- lis end -->
|
||||
</div>
|
||||
</div>
|
||||
<!-- right content end -->
|
||||
|
||||
<!-- footer start -->
|
||||
{{include file="public/footer" /}}
|
||||
<!-- footer end -->
|
||||
|
|
@ -336,8 +336,7 @@ class User extends Common
|
|||
}
|
||||
|
||||
// 授权
|
||||
$result = (new \base\QQ(MyC('common_app_mini_qq_appid', '1109990622'), MyC('common_app_mini_qq_appsecret', 'PdVsj1n2sByQQBCi
|
||||
')))->GetAuthSessionKey($this->data_post['authcode']);
|
||||
$result = (new \base\QQ(MyC('common_app_mini_qq_appid'), MyC('common_app_mini_qq_appsecret')))->GetAuthSessionKey($this->data_post['authcode']);
|
||||
if($result !== false)
|
||||
{
|
||||
return DataReturn('授权登录成功', 0, $result);
|
||||
|
|
@ -383,8 +382,7 @@ class User extends Common
|
|||
$user = UserService::AppUserInfoHandle(null, 'qq_openid', $this->data_post['openid']);
|
||||
if(empty($user))
|
||||
{
|
||||
$result = (new \base\QQ(MyC('common_app_mini_qq_appid', '1109990622'), MyC('common_app_mini_qq_appsecret', 'PdVsj1n2sByQQBCi
|
||||
')))->DecryptData($this->data_post['encrypted_data'], $this->data_post['iv'], $this->data_post['openid']);
|
||||
$result = (new \base\QQ(MyC('common_app_mini_qq_appid'), MyC('common_app_mini_qq_appsecret')))->DecryptData($this->data_post['encrypted_data'], $this->data_post['iv'], $this->data_post['openid']);
|
||||
if(is_array($result))
|
||||
{
|
||||
$result['nick_name'] = isset($result['nickName']) ? $result['nickName'] : '';
|
||||
|
|
|
|||
|
|
@ -1659,24 +1659,39 @@ class UserService
|
|||
'referrer' => isset($params['referrer']) ? $params['referrer'] : 0,
|
||||
];
|
||||
|
||||
// 微信用户unionid
|
||||
if(!empty($params['weixin_unionid']))
|
||||
{
|
||||
$data['weixin_unionid'] = $params['weixin_unionid'];
|
||||
}
|
||||
|
||||
// QQ用户unionid
|
||||
if(!empty($params['qq_unionid']))
|
||||
{
|
||||
$data['qq_unionid'] = $params['qq_unionid'];
|
||||
}
|
||||
|
||||
// 用户信息处理
|
||||
$user = self::AppUserInfoHandle(null, $field, $params['openid']);
|
||||
if(!empty($user))
|
||||
{
|
||||
return DataReturn('授权成功', 0, $user);
|
||||
} else {
|
||||
// 用户unionid列表
|
||||
// 微信用户unionid
|
||||
// QQ用户unionid
|
||||
$unionid_all = ['weixin_unionid', 'qq_unionid'];
|
||||
foreach($unionid_all as $unionid)
|
||||
{
|
||||
if(!empty($params[$unionid]))
|
||||
{
|
||||
// unionid字段是否存在用户
|
||||
$user_unionid = UserService::AppUserInfoHandle(null, $unionid, $params[$unionid]);
|
||||
if(!empty($user_unionid))
|
||||
{
|
||||
// openid绑定
|
||||
if(Db::name('User')->where(['id'=>$user_unionid['id']])->update([$field=>$params['openid'], 'upd_time'=>time()]))
|
||||
{
|
||||
// 直接返回用户信息
|
||||
$user_unionid[$field] = $params['openid'];
|
||||
return DataReturn('授权成功', 0, $user_unionid);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果用户不存在数据库中,则unionid放入用户data中
|
||||
$data[$unionid] = $params[$unionid];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 不强制绑定手机则写入用户信息
|
||||
if(intval(MyC('common_user_is_mandatory_bind_mobile')) != 1)
|
||||
{
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -67,7 +67,7 @@ App({
|
|||
// 请求地址
|
||||
request_url: "{{request_url}}",
|
||||
request_url: 'http://tp5-dev.com/',
|
||||
request_url: 'https://test.shopxo.net/',
|
||||
//request_url: 'https://test.shopxo.net/',
|
||||
|
||||
// 基础信息
|
||||
application_title: "{{application_title}}",
|
||||
|
|
|
|||
|
|
@ -405,7 +405,7 @@ ul {margin-top:0;}
|
|||
.admin-sidebar-sub {margin-top:0;margin-bottom:0;box-shadow:0 16px 8px -15px #e2e2e2 inset;background:#646464;padding-left:10px;}
|
||||
.admin-sidebar-sub li:first-child {border-top:1px solid #dedede;}
|
||||
.admin-sidebar {height:100%;overflow-x:hidden;overflow-y:scroll;-webkit-overflow-scrolling:touch;}
|
||||
.admin-sidebar .am-icon-angle-down {margin-top: 5px;}
|
||||
.admin-sidebar .am-icon-angle-down {margin-top: 2px;}
|
||||
@media only screen and (min-width:641px) {
|
||||
header { left: 169px; }
|
||||
header .am-topbar-brand, .am-topbar-nav > li > a { line-height: 35px; }
|
||||
|
|
@ -427,6 +427,7 @@ ul {margin-top:0;}
|
|||
/*---right Content---*/
|
||||
.content-right .content {padding:10px 10px 0 10px;}
|
||||
.admin-sidebar-list li a {padding:0.6rem;}
|
||||
.admin-sidebar-list li a .iconfont { vertical-align: middle; }
|
||||
.common-left-menu a:hover { background:rgba(118, 119, 120, 0.45); }
|
||||
.common-left-menu-active {background:#1cc09f !important;color:#fff !important;}
|
||||
#ifcontent {border:0px;}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue