创建版本
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<?php namespace Gdoo\Wap\Controllers;
|
||||
|
||||
use Auth;
|
||||
use Cache;
|
||||
use Request;
|
||||
use DB;
|
||||
use Hash;
|
||||
|
||||
use Gdoo\User\Models\UserAsset;
|
||||
use Gdoo\System\Models\Setting;
|
||||
|
||||
use Gdoo\Index\Controllers\Controller;
|
||||
use Gdoo\User\Services\UserAssetService;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
public $permission = [];
|
||||
|
||||
/**
|
||||
* 用户登录
|
||||
*/
|
||||
public function loginAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$gets = Request::all();
|
||||
$username = $gets['username'];
|
||||
$password = $gets['password'];
|
||||
$ret = [];
|
||||
$user = DB::table('user')->where('username', $username)->first();
|
||||
if (Hash::check($password, $user['password'])) {
|
||||
$ret['access'] = UserAssetService::getRoleAssets($user['role_id']);
|
||||
$ret['token'] = create_token($user['id'], 365);
|
||||
$ret['user'] = $user;
|
||||
return $this->json($ret, true);
|
||||
} else {
|
||||
return $this->json('帐号或密码不正确。');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户注销
|
||||
*/
|
||||
public function logoutAction()
|
||||
{
|
||||
Auth::logout();
|
||||
return $this->json('解绑成功。', true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php namespace Gdoo\Wap\Controllers;
|
||||
|
||||
use Gdoo\Index\Controllers\Controller as BaseController;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php namespace Gdoo\Wap\Controllers;
|
||||
|
||||
use Cache;
|
||||
use Request;
|
||||
use DB;
|
||||
|
||||
use Gdoo\System\Models\Setting;
|
||||
|
||||
use Gdoo\Index\Controllers\DefaultController;
|
||||
|
||||
class IndexController extends DefaultController
|
||||
{
|
||||
public $permission = [];
|
||||
|
||||
protected $layout = 'layouts.wechat';
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$gets = Request::all();
|
||||
foreach ($gets as $key => $value) {
|
||||
Setting::where('type', 'wechat')->where('key', $key)->update([
|
||||
'value' => $value,
|
||||
]);
|
||||
}
|
||||
return $this->json('保存成功。', true);
|
||||
}
|
||||
return $this->display([
|
||||
'app' => $this->config,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
<?php namespace Gdoo\Wap\Controllers;
|
||||
|
||||
use Auth;
|
||||
use Cache;
|
||||
use Request;
|
||||
use DB;
|
||||
use Hash;
|
||||
|
||||
use Gdoo\User\Models\UserAsset;
|
||||
use Gdoo\System\Models\Setting;
|
||||
use Gdoo\Wechat\Services\WechatService;
|
||||
|
||||
use Gdoo\Index\Controllers\Controller;
|
||||
use Gdoo\User\Services\UserAssetService;
|
||||
|
||||
class WechatController extends Controller
|
||||
{
|
||||
public $permission = [];
|
||||
|
||||
public function configAction()
|
||||
{
|
||||
$config = Setting::where('type', 'wechat')->get()->pluck('value', 'key');
|
||||
return $this->json($config, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信用户绑定
|
||||
*/
|
||||
public function loginAction()
|
||||
{
|
||||
if (Request::method() == 'POST') {
|
||||
$gets = Request::all();
|
||||
$username = $gets['username'];
|
||||
$password = $gets['password'];
|
||||
$openid = $gets['openid'];
|
||||
$ret = [];
|
||||
$wechat = DB::table('wechat_user')->where('openid', $openid)->first();
|
||||
$user = DB::table('user')->where('username', $username)->first();
|
||||
if (Hash::check($password, $user['password'])) {
|
||||
if ($wechat) {
|
||||
DB::table('wechat_user')
|
||||
->where('openid', $openid)
|
||||
->update(['user_id' => $user['id']]);
|
||||
} else {
|
||||
DB::table('wechat_user')->insert([
|
||||
'openid' => $openid,
|
||||
'user_id' => $user['id'],
|
||||
]);
|
||||
}
|
||||
$ret['access'] = UserAssetService::getRoleAssets($user['role_id']);
|
||||
$ret['token'] = create_token($user['id'], 365);
|
||||
$ret['user'] = $user;
|
||||
return $this->json($ret, true);
|
||||
} else {
|
||||
return $this->json('帐号或密码不正确。');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取微信登录数据
|
||||
*/
|
||||
public function authorizeAction()
|
||||
{
|
||||
try {
|
||||
$app = WechatService::getApp();
|
||||
$user = $app->oauth->user();
|
||||
$openid = $user['id'];
|
||||
$wechat = DB::table('wechat_user')->where('openid', $openid)->first();
|
||||
$ret = ['openid' => $openid];
|
||||
if ($wechat) {
|
||||
$user = DB::table('user')->where('id', $wechat['user_id'])->first();
|
||||
$ret['access'] = UserAssetService::getRoleAssets($user['role_id']);
|
||||
$ret['token'] = create_token($user['id'], 365);
|
||||
$ret['user'] = $user;
|
||||
return $this->json($ret, true);
|
||||
} else {
|
||||
return $this->json($ret);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->json($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信用户解绑
|
||||
*/
|
||||
public function logoutAction()
|
||||
{
|
||||
$openid = Request::get('openid');
|
||||
DB::table('wechat_user')->where('openid', $openid)->delete();
|
||||
Auth::logout();
|
||||
return $this->json('解绑成功。', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信获取配置
|
||||
*/
|
||||
public function jsConfigAction()
|
||||
{
|
||||
$app = WechatService::getApp();
|
||||
$url = Request::get('url');
|
||||
$app->jssdk->setUrl($url);
|
||||
return $app->jssdk->buildConfig(['chooseImage', 'getLocation'], false, false, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信获取配置
|
||||
*/
|
||||
public function mapGeocoderAction()
|
||||
{
|
||||
$location = Request::get('location');
|
||||
$text = file_get_contents('https://apis.map.qq.com/ws/geocoder/v1/?location=' . $location . '&key=W6FBZ-JV4K4-O6WU5-XGZOL-GMTPJ-KIFWJ&get_poi=0');
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
return [
|
||||
"name" => "Wap",
|
||||
"version" => "1.0",
|
||||
"description" => "Wap",
|
||||
"controllers" => [
|
||||
]
|
||||
];
|
||||
@@ -0,0 +1,94 @@
|
||||
<div class="panel">
|
||||
|
||||
@include('tabs', ['tabKey' => 'mp'])
|
||||
<!--
|
||||
<div class="panel-heading tabs-box">
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="@if($type == 'list') active @endif">
|
||||
<a class="text-sm" href="{{url('wechat/mp/qrcode',['type'=>'list'])}}">二维码列表</a>
|
||||
</li>
|
||||
<li class="@if($type == 'statistics') active @endif">
|
||||
<a class="text-sm" href="{{url('wechat/mp/qrcode',['type'=>'statistics'])}}">二维码扫描统计</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
-->
|
||||
<div class="wrapper">
|
||||
<form id="search-form" class="form-inline" name="mysearch" action="{{url()}}" method="get">
|
||||
<div class="pull-right">
|
||||
@if(isset($access['showdelete']))
|
||||
<a class="btn btn-sm btn-danger" href="javascript:optionDelete('#myform','{{url('showdelete')}}');">
|
||||
<i class="icon icon-remove"></i> 删除</a>
|
||||
@endif
|
||||
</div>
|
||||
@include('searchForm')
|
||||
</form>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
$('#search-form').searchForm({
|
||||
data: {{ json_encode($search['forms'])}},
|
||||
init: function (e) {
|
||||
var self = this;
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover m-b-none table-hover">
|
||||
<tr>
|
||||
<th align="center">
|
||||
<input type="checkbox" class="select-all">
|
||||
</th>
|
||||
<th>场景ID</th>
|
||||
<th>类型</th>
|
||||
<th>到期时间</th>
|
||||
<th>二维码链接</th>
|
||||
<th>ID</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
@foreach($rows as $vo)
|
||||
<tr>
|
||||
<td align="center">
|
||||
<input type="checkbox" class="select-row" value="{{$vo['id']}}" name="id[]">
|
||||
</td>
|
||||
<td class="text-center">{{$vo['scene_id']}}</td>
|
||||
<td class="text-center">
|
||||
@if($vo['qr_type'] == 0)
|
||||
临时
|
||||
@else
|
||||
永久
|
||||
@endif
|
||||
</td>
|
||||
<td class="text-center">
|
||||
@if($vo['qr_type'] == 0)
|
||||
@datetime($vo['created_at'] + $vo['expire'])
|
||||
@else
|
||||
长期有效
|
||||
@endif
|
||||
</td>
|
||||
<td class="text-center">
|
||||
{{$vo['url']}}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
{{$vo['id']}}
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<a target="_blank" href="{{$vo['qrcode_url']}}" class="option">查看</a>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<footer class="panel-footer">
|
||||
<div class="row">
|
||||
<div class="col-sm-1 hidden-xs">
|
||||
</div>
|
||||
<div class="col-sm-11 text-right text-center-xs">
|
||||
{{$rows->render()}}
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
Reference in New Issue
Block a user