作者 Richer

功能完成

... ... @@ -425,4 +425,94 @@ class CategoriesController extends BaseController
);
}
}
// /**
// * 获取 实例
// *
// * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|JsonResponse
// */
// public function labels($id)
// {
// $list = null;
// try {
// // 获取数据,如果没有获取到抛出异常
// $model = $this->model->findOrFail($id);
//
// $list = $model->labels()->get();
// return view('admin::category.labels', compact('id', 'list')) ;
//
// } catch (ModelNotFoundException $e) {
// return view('admin::category.labels', compact('id', 'list')) ;
// }
// }
/**
* 添加 标签 界面
*
* @param $id
*/
public function childPage($id)
{
$label_id = request('id', 0);
$label = null;
if ($label_id) {
$label = CategoryLabel::find($label_id);
}
// 获取数据,如果没有获取到抛出异常
return view('admin::category.child', compact('id', 'label_id','label')) ;
}
/**
* 添加 标签
*
* @param integer $id 主键id
*
* @return JsonResponse
*/
public function addChild($id)
{
try {
$label_id = request('label_id', 0);
if ($label_id > 0) {
// 获取数据,如果没有获取到抛出异常
$model = CategoryLabel::findOrFail($label_id);
$model->name = request('name');
$model->can_multiple = request('can_multiple', 0);
$model->semantics = request('semantics');
$model->description = request('description');
$model->save();
} else {
// 获取数据,如果没有获取到抛出异常
$model = $this->model->findOrFail($id);
$result = $model->labels()->create([
'name' => request('name'),
'semantics' => request('semantics'),
'description' => request('description'),
'can_multiple' => request('can_multiple', 0),
]);
// 同步到远程服务器
// CategoryLabelCreatedJob::dispatch($result);
}
return response()->json(
[
'code' => 0,
'status' => 1,
'message' => __('operate_succeeded'),
]
);
} catch (\Exception $e) {
return response()->json(
[
'code' => 1,
'status' => 0,
'message' => $e->getMessage(),
]
);
}
}
}
... ...
... ... @@ -107,7 +107,7 @@ class WithdrawalsController extends BaseController
'amount' => $amount,
'type' => WalletRecord::DECREASE,
'event' => WalletRecord::WITHDRAW,
// 'ratio' => TODO
'ratio' => $model->ratio,
];
$r = $model->records()->create($record);
if (!$r) {
... ...
... ... @@ -927,4 +927,31 @@ SCRIPT;
<a href="javascript:;" data-id="{$id}" class="btn btn-sm btn-success grid-add-times" >{$action}</a>
EOT;
}
/**
* 渲染 添加标签
*
* @param integer $id
* @param $url
* @return string
*/
public static function renderChildCategory($id, $url)
{
$action = '<i class="fa fa-check-square-o"></i> ' .__('添加子分类');
$script = <<<SCRIPT
$('.grid-add-label').unbind('click').click(function() {
var id = $(this).data('id');
var url= '{$url}/' + id +'/child';
layer_iframe( url,'$action',2,0.5,['80%','60%'] );
});
SCRIPT;
Admin::script($script);
return <<<EOT
<a href="javascript:;" data-id="{$id}" class="btn btn-sm btn-success grid-add-label" style="display:block;width:120px">{$action}</a>
EOT;
}
}
... ...
... ... @@ -39,14 +39,26 @@ trait CategoryForm
{
// $this->formDisplayField('id', __('ID'));
$this->formTextField('name', '', 20, 1);
$this->formNumberField('consume_times');
$this->formRadioField('context', '', ChatRecord::CONTEXT_OPTIONS);
$this->formSingleSelectField('pid', '一级分类', Category::getParents('store'))
->when('>=', 1, function () {
$this->formNumberField('consume_times')
->setGroupClass('col-sm-12')->setWidth(8, 2)
;
$this->formRadioField('context', '', ChatRecord::CONTEXT_OPTIONS)
->setGroupClass('col-sm-12')->setWidth(8, 2)
;
$this->formTextAreaField('start_statement', '', 0, 5)
->setGroupClass('col-sm-12')->setWidth(8, 2)
;
});
$required = 1;
if ($id > 0) {
$required = 0;
}
$this->formSingleImageField('icon', '图标', $required);
$this->formTextAreaField('start_statement', '', 0, 5);
$this->formTextAreaField('body', '内容', 0, 5);
// $this->formTextAreaField('description', '', 255, 3);
$this->formCommonFields(1, 0, 1, 1);
... ...
... ... @@ -18,7 +18,10 @@ namespace App\Admin\Grids;
use App\Admin\Extensions\CustomActions;
use App\Admin\Grids\Modal\CategoryExampleModal;
use App\Models\Category\Category;
use Encore\Admin\Grid;
use Encore\Admin\Widgets\Table;
use function Clue\StreamFilter\fun;
/**
* Class CategoryGrid.
... ... @@ -48,7 +51,7 @@ trait CategoryGrid
// 执行父类方法,设置默认的查询条件
parent::setGridQuery();
$this->grid->model()->withCount(['labels','examples']);
$this->grid->model()->with(['parent', 'children'])->withCount(['labels','examples', 'children']);
}
/**
... ... @@ -64,9 +67,13 @@ trait CategoryGrid
$id = $actions->getKey();
// 当前的url
$url = $actions->getResource();
if (!$actions->row->pid) {
// $actions->append(CustomActions::renderChildCategory($id, $url));
} else {
$actions->append(CustomActions::renderAddExample($id, $url));
$actions->append(CustomActions::renderAddLabel($id, $url));
}
}
/**
* 为grid增加筛选条件
... ... @@ -80,6 +87,7 @@ trait CategoryGrid
// 筛选条件默认展开
$filter->expand();
$this->filterText($filter, 'name');
$this->filterSingleSelect($filter, 'pid', '一级分类', Category::getParents());
//去掉默认的搜索
$filter->disableIdFilter();
}
... ... @@ -97,12 +105,37 @@ trait CategoryGrid
{
$this->gridRowNo();
$this->gridSingleImageField('icon');
$this->gridTextField('parent.name', '上级分类');
$this->gridTextField('name');
$this->gridTextField('start_statement')->limit(100);
$this->gridBoolField('context');
$this->gridTextField('consume_times');
$this->gridTextField('start_statement')->display(function ($value) {
if ($this->pid == 0) {
return '--';
}
return $value;
});
// $this->gridBoolField('context');
$this->gridTextField('context')->display(function ($value) {
if ($this->pid == 0) {
return '--';
}
if ($value == 1) {
return '<i class="fa fa-check text-green"></i>';
}
return '<i class="fa fa-close text-red"></i>';
});
$this->gridTextField('consume_times')->display(function ($value) {
if ($this->pid == 0) {
return '--';
}
return $value;
});
// $this->gridTextField('body')->limit(100);
$this->gridNumberField('labels_count', '标签')->display(function ($value) {
if ($this->pid == 0) {
return '--';
}
$id = $this->id;
$url= "/admin/categories/$id/labels";
return "<a href='#' onclick=layer_iframe('$url','标签列表',2,0.5,['80%','80%'])>$value</a>";
... ... @@ -110,10 +143,21 @@ trait CategoryGrid
// $this->gridNumberField('examples_count', __('实例展示'))->modal(__('实例展示'), CategoryExampleModal::class);
$this->gridNumberField('examples_count', '实例展示')->display(function ($value) {
if ($this->pid == 0) {
return '--';
}
$id = $this->id;
$url= "/admin/categories/$id/examples";
return "<a href='#' onclick=layer_iframe('$url','实例展示',2,0.5,['80%','80%'])>$value</a>";
});
// $this->grid->column('children_count', '子分类')->expand(function ($model) {
// $comments = $model->children->map(function ($comment) {
// return $comment->only(['id', 'name', 'created_at']);
// });
//
// return new Table(['ID', '内容', '发布时间'], $comments->toArray());
// });
$this->gridCommonFields(1, 0, 1, 1);
}
... ...
... ... @@ -19,6 +19,7 @@ namespace App\Admin\Grids;
use App\Admin\Extensions\Actions\Audit;
use App\Admin\Extensions\CustomActions;
use App\Models\User\WithdrawRecord;
use function Clue\StreamFilter\fun;
/**
* Class WithdrawRecordGrid.
... ... @@ -107,7 +108,11 @@ trait WithdrawRecordGrid
$this->gridTextField('cardholder');
$this->gridSingleImageField('receipt_code');
$this->gridTextField('account');
$this->gridNumberField('amount', '提现金额');
$this->gridCurrencyField('amount', '提现金额');
$this->gridCurrencyField('actual_amount', '实际到账金额');
$this->gridTextField('ratio', '费率')->display(function ($value) {
return $value . '%';
});
$this->gridSingleSelect('status', '提现状态', WithdrawRecord::STATUS_OPTIONS, WithdrawRecord::STATUS_COLOR_OPTIONS);
$this->gridDateField('created_at', '提现时间');
$this->gridDateField('audited_at', '审核时间');
... ...
... ... @@ -226,6 +226,11 @@ Route::group([
$router->post('{id}/labels', 'CategoriesController@addLabel')->where('id', '[0-9]+');
$router->delete('{id}/labels', 'CategoriesController@deleteLabel')->where('id', '[0-9]+');
$router->get('{id}/child', 'CategoriesController@childPage')->where('id', '[0-9]+');
$router->get('{id}/children', 'CategoriesController@children')->where('id', '[0-9]+');
$router->post('{id}/children', 'CategoriesController@addChild')->where('id', '[0-9]+');
$router->delete('{id}/labels', 'CategoriesController@deleteLabel')->where('id', '[0-9]+');
// $router->get('{id}/label-item', 'CategoriesController@labelItemPage')->where('id', '[0-9]+');
// $router->post('{id}/label-items', 'CategoriesController@addLabelItem')->where('id', '[0-9]+');
// $router->delete('{id}/label-items', 'CategoriesController@deleteLabelItem')->where('id', '[0-9]+');
... ...
... ... @@ -42,6 +42,17 @@ class Handler extends ExceptionHandler
*/
public function report(Throwable $exception)
{
// // 捕获异常:路由不存在 No query results for model [App\\Models\
// if ($exception instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException) {
// //捕获路由模型绑定在数据库中找不到模型后抛出的NotFoundHttpException
// return Response::json(
// [
// 'code' => 1001,
// 'msg' => '该路由不存在!',
// 'data' => null,
// ]
// );
// }
parent::report($exception);
}
... ...
... ... @@ -16,6 +16,9 @@
*/
namespace App\Factories\Wechat;
use EasyWeChat\Factory;
use Illuminate\Http\Request;
/**
* Trait Official
*
... ... @@ -29,6 +32,40 @@ namespace App\Factories\Wechat;
*/
trait Official
{
/**
* 通过code获取用户session信息
*
* @return mixed
*/
public function loginOfficialAccount()
{
return $this->official->oauth->user();
}
/**
* @param null $config
* @return $this
*/
public function setOfficialAccountConfigure($config = null)
{
if (!$config) {
$config = $this->getOfficialAccountConfigure();
}
$this->official = Factory::officialAccount($config);
return $this;
}
/**
* @return array|bool
*/
public function getOfficialAccountConfigure()
{
return config('wechat.official_account.default');
}
/**
* 消息发送
*
... ...
... ... @@ -47,7 +47,7 @@ class WechatFactory
public function __construct()
{
// $this->payment = app('wechat.payment');
// $this->official = app('wechat.official_account');
$this->official = app('wechat.official_account');
$this->mini = app('wechat.mini_program');
}
... ...
... ... @@ -55,6 +55,12 @@ class LoginRequest extends BaseRequest
'encryptedData' => 'required',
'iv' => 'required',
];
case User::WECHAT_OFFICIAL_ACCOUNT_AUTHORIZED_LOGIN:
return [
'code' => 'required',
// 'encryptedData' => 'required',
// 'iv' => 'required',
];
default:
return [
'mobile' => 'required',
... ...
... ... @@ -18,6 +18,7 @@ namespace App\Models\Category;
use App\Models\BaseModel;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
/**
... ... @@ -69,6 +70,22 @@ class Category extends BaseModel
}
/**
* @return BelongsTo
*/
public function parent(): BelongsTo
{
return $this->belongsTo(get_class($this), 'pid', 'id');
}
/**
* @return HasMany
*/
public function children(): HasMany
{
return $this->hasMany(get_class($this), 'pid', 'id');
}
/**
* @param $value
*/
public function setIconAttribute($value)
... ... @@ -87,4 +104,27 @@ class Category extends BaseModel
{
return splice_file_path($value);
}
/**
* 生成每个级别的code
* @param string $oprate
* @return array
*/
public static function getParents($oprate = 'query')
{
$models = self::where(function ($query) {
$query->whereNull('pid')->orWhere('pid', 0)->orWhere('pid', '');
})->get(['id','name']);
$options = [];
if ($oprate !== 'query') {
$options = [0 => '无'];
}
foreach ($models as $vo) {
$options[$vo->id] = $vo->name;
}
return $options;
return $models;
}
}
... ...
... ... @@ -41,8 +41,8 @@ class RechargeOrder extends BaseModel
/**
* 支付方式代码集
*/
const WECHAT_PAY = 1;// 微信支付
const H5_PAY = 2;// H5支付
const WECHAT_PAY = 2;// 微信支付
const H5_PAY = 1;// H5支付
const PAY_TYPE_OPTIONS = [
self::WECHAT_PAY => '微信支付',
self::H5_PAY => 'H5支付',
... ...
... ... @@ -51,6 +51,11 @@ use Tymon\JWTAuth\Contracts\JWTSubject;
* @property mixed role
* @property mixed house_number
* @property mixed address
* @property int|mixed pid
* @property int|mixed gid
* @property mixed openid
* @property mixed registered_ip
* @property int|mixed times
*/
class User extends Authenticatable implements JWTSubject
{
... ...
... ... @@ -77,12 +77,14 @@ class WithdrawRecord extends BaseModel
self::FAILED => 'info',
];
const RATIO = 1;// 提现手续费
/**
* 访问器被附加到模型数组的形式。
*
* @var array
*/
protected $appends = ['status_show', 'type_show'];
protected $appends = ['status_show', 'type_show', 'actual_amount'];
/**
* @return BelongsTo
... ... @@ -140,4 +142,13 @@ class WithdrawRecord extends BaseModel
return Arr::get(self::TYPE_OPTIONS, $this->type ? : self::BANK);
}
/**
* 获取类型的中文显示
*
* @return mixed
*/
public function getActualAmountAttribute()
{
return $this->amount * (100 - $this->ratio) / 100;
}
}
... ...
... ... @@ -36,8 +36,29 @@ class AppServiceProvider extends ServiceProvider
return response()->json(['code'=>1001,'msg'=>'暂无相关数据!','data'=> null ], 200);
});
// 公众号收取失败异常捕获
API::error(function (\Overtrue\Socialite\AuthorizeFailedException $exception) {
return response()->json(['code'=>2004,'msg'=> $exception->getMessage(),'data'=> null ], 200);
});
API::error(function (\Exception $exception) {
dd($exception);
return response()->json(['code'=>2004,'msg'=> $exception->getMessage(),'data'=> null ], 200);
});
// add by Richer 于 2022年9月26日15:35:05 增加路由不存在的异常捕获
// // 捕获异常:路由不存在 No query results for model [App\\Models\
// if ($exception instanceof NotFoundHttpException) {
// //捕获路由模型绑定在数据库中找不到模型后抛出的NotFoundHttpException
// return Response::json(
// [
// 'code' => 1,
// 'msg' => '该路由不存在!',
// 'data' => null,
// ]
// );
// }
//
// // add by Richer 于 2022年9月26日15:35:05 增加路由不存在的异常捕获
// \API::error(function (FatalErrorException $exception) {
API::error(function (FatalErrorException $exception) {
return response()->json(['code'=>1001,'msg'=>'路由不存在!','data'=> null ], 200);
... ...
... ... @@ -16,6 +16,7 @@
*/
namespace App\Services;
use App\Http\Requests\LoginRequest;
use App\Models\System\SmsLog;
use App\Models\User\Role;
use App\Models\User\User;
... ... @@ -23,6 +24,7 @@ use App\Models\User\LoginRecord as UserLoginRecord;
use Browser;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use JWTAuth;
... ... @@ -117,6 +119,7 @@ class AuthService extends BaseService
*/
public function login($request)
{
try {
switch ($request->login_method) {
case 'mobile':
return $this->loginWithMobile($request);
... ... @@ -132,7 +135,7 @@ class AuthService extends BaseService
break;
case User::WECHAT_OFFICIAL_ACCOUNT_AUTHORIZED_LOGIN:
$service = app(WechatService::class);
$result = $service->auth($request);
$result = $service->authLoginWithOfficialAccount($request);
break;
default:
return $this->loginWithPassword($request);
... ... @@ -142,6 +145,18 @@ class AuthService extends BaseService
$this->message = $service->getMessage();
}
return $result;
} catch (\Exception $exception) {
$this->message = $exception->getMessage();
// dump($exception->g);
// dump($exception->getMessage());
// dump($exception->getCode());
$message = $exception->getMessage();
// if (Str::contains($message, '"errcode":40125')) {
// $this->message = 'AppSecret '.__('invalid');
// }
return false;
}
}
/**
... ... @@ -293,16 +308,29 @@ class AuthService extends BaseService
"headimgurl" => "https://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83eobkqbPCsjImL5qk7ErZxrRQg34FpGqnbpUwiau6ibNIA9CWic53dwCXPjjECLFqXqRh5gXGLYrjHzoQ/132"
"privilege" => []
*
* @param LoginPost $request request
* @param LoginRequest $request request
*
* @return bool|string
* @throws \Exception
*/
public function wechatAuth($request)
{
try {
$service = app(WechatService::class);
$result = $service->authLoginWithOfficialAccount($request);
if (!$result) {
$this->message = $service->getMessage();
}
} catch (\Exception $exception) {
$this->message = $exception->getMessage();
return false;
}
$service = app(WechatService::class);
// 开启事务
// DB::beginTransaction();
// try {
DB::beginTransaction();
try {
// 正在申请
$userinfo = session('wechat.oauth_user.default')->original; // 拿到授权用户资料
... ... @@ -352,10 +380,10 @@ class AuthService extends BaseService
return $user;
// all good
// } catch (\Exception $e) {
// DB::rollback();
// return false;
// }
} catch (\Exception $e) {
DB::rollback();
return false;
}
}
/**
... ...
... ... @@ -42,12 +42,16 @@ class CategoryService extends BaseService
*/
public function list()
{
return $this->model
return $this->model->with(['children'])
->where(function ($query) {
$query->whereNull('pid')->orWhere('pid', 0)->orWhere('pid', '');
})
->when($q = request('name'), function ($query) use ($q) {
$query->where("name", 'like', "%$q%");
})
->where('status', 1)
->orderBy('sort')
->groupBy('id')
->latest()
->get();
}
... ...
... ... @@ -164,7 +164,7 @@ class RechargeOrderService extends BaseService
// 更新数据库状态
if ($order->status == RechargeOrder::UNPAID) {
$order->status = RechargeOrder::PAID;
$order->paid_type = RechargeOrder::WECHAT_PAY;
$order->paid_type = RechargeOrder::H5_PAY;
$order->paid_at = $paid_at;
$order->paid_info = $data;
$result = $order->save();
... ...
... ... @@ -111,7 +111,7 @@ class RechargePackageService extends BaseService
// $pay['notify_url'] = $notify_url;
// }
// 更新订单
$type = RechargeOrder::WECHAT_PAY;
$type = RechargeOrder::H5_PAY;
$order->out_trade_no = $out_trade_no;
$model->paid_type = $type;
$order->save();
... ...
... ... @@ -528,6 +528,10 @@ class UserService extends BaseService
$wallet = $user->getWallet();
$amount = $request->amount;
if ($amount < 100) {
$this->message = '提现失败,最少提现 100 元。';
return false;
}
// 判断金额
if ($wallet->balance < $amount) {
$this->message = '提现失败,账户余额不足。';
... ... @@ -535,10 +539,10 @@ class UserService extends BaseService
}
// 最低需要保留1元
if ($wallet->balance - $amount < 1) {
$this->message = '提现失败,账户最少需要保留 1 元。';
return false;
}
// if ($wallet->balance - $amount < 1) {
// $this->message = '提现失败,账户最少需要保留 1 元。';
// return false;
// }
// 判断是否有还未审核通过的提现记录
if ($user->withdrawals()->where('status', WithdrawRecord::UNAUDITED)->first()) {
... ... @@ -553,6 +557,7 @@ class UserService extends BaseService
$data = $request->all();
$data['bank_name'] = $bank_name;
$data['ratio'] = WithdrawRecord::RATIO;
$withdrawal = $user->withdrawals()->create($data);
... ...
... ... @@ -403,69 +403,90 @@ class WechatService extends BaseService
"headimgurl" => "https://thirdwx.qlogo.cn/mmopen/vi_32/DYAIOgq83eobkqbPCsjImL5qk7ErZxrRQg34FpGqnbpUwiau6ibNIA9CWic53dwCXPjjECLFqXqRh5gXGLYrjHzoQ/132"
"privilege" => []
*
* @param LoginPost $request request
* @param $request request
*
* @return bool|string
* @throws \Exception
*
*/
public function loginWithOfficialAccount($request)
public function authLoginWithOfficialAccount($request)
{
// 开启事务
// DB::beginTransaction();
// try {
// 正在申请
$userinfo = session('wechat.oauth_user.default')->original; // 拿到授权用户资料
$user_info = session('wechat.oauth_user.default')->original; // 拿到授权用户资料
// $factory = app(WechatFactory::class);
// // 公众号好手气
// $user_info = $factory->setOfficialAccountConfigure()->loginOfficialAccount()->original;
//
// // 拿到静默获取的openid, 静默获取只能获取openid 点击按钮可以获取详细信息
//// $user = $app->user->get($openid);
$openid = Arr::get($user_info, 'openid');
// $user = $app->oauth->user()->toArray();
// 正在申请
// $userinfo = session('wechat.oauth_user.default')->original; // 拿到授权用户资料
// 获取授权参数
$openid = Arr::get($userinfo, 'openid');
$user = null;
if ($openid) {
// TODO 测试登录其他账号
if ($openid == 'osLHa6ruNfzBQKTUryvQs8q02Cmw') {
//$openid = 'osLHa6oDbwJk0XCN7jqojQbY9lO4';
}
$user = User::where('openid', $openid)->first();
}
if ($user) {
$token = JWTAuth::fromuser($user);
$user->token = $token;
if (!$user) {
$user = $this->createUser($request, $openid);
}
if ($user_info) {
$user->avatar = Arr::get($user_info, 'avatarUrl');
$user->nickname = Arr::get($user_info, 'nickName');
$user->gender = Arr::get($user_info, 'gender');
$user->country = Arr::get($user_info, 'country');
$user->province = Arr::get($user_info, 'province');
$user->city = Arr::get($user_info, 'city');
}
$user->token = JWTAuth::fromuser($user);
$user->save();
// 记录登陆日志
$this->recordLoginRecord($request, $user);
return $user;
} else {
$data['openid'] = $openid;
$data['nickname'] = Arr::get($userinfo, 'nickname');
$data['avatar'] = Arr::get($userinfo, 'headimgurl');
$data['gender'] = Arr::get($userinfo, 'gender');
return $data;
}
/**
* 创建用户
*
* @param $request
* @param $openid
* @param string $mobile
* @return User
*/
public function createUser($request, $openid, $mobile = '')
{
$user = new User();
// 创建用户
$pid = $request->inviter_id ? : 0; // 邀请人id
$gid = 0;
if ($pid) {
$inviter = User::find($pid);
$gid = optional($inviter)->pid;
}
$user->times = 10; // 新用户注册赠送 10 条
$user->username = $mobile;
$user->pid = $pid;
$user->gid = $gid;
$user->username = $mobile;
$user->mobile = $mobile;
$user->openid = $openid;
$user->nickname = Arr::get($userinfo, 'nickname');
$user->avatar = Arr::get($userinfo, 'headimgurl');
$user->gender = Arr::get($userinfo, 'gender');
$user->country = Arr::get($userinfo, 'country');
$user->province = Arr::get($userinfo, 'province');
$user->city = Arr::get($userinfo, 'city');
$user->password = bcrypt(config('constants.PASSWORD'));
$user->role = Role::GENERAL;
$user->password = bcrypt(config('constants.PASSWORD'));
$user->registered_at = date('Y-m-d H:i:s');
$user->registered_ip = $request->ip();
$result = $user->save();
$token = JWTAuth::fromuser($user);
$user->token = $token;
$user->save();
}
// 记录登陆日志
$this->recordLoginRecord($request, $user);
return $user;
// all good
// } catch (\Exception $e) {
// DB::rollback();
// return false;
// }
}
/**
... ...
... ... @@ -46,7 +46,24 @@ class CategoryTransformer extends BaseTransformer
'status' => (int)$model->status,
'status_show' => (string)$model->status_show,
'created_at' => format_date($model->created_at),
'updated_at' => format_date($model->updated_at),
// 'updated_at' => format_date($model->updated_at),
'children' => $model->children->map(function ($child) {
return [
'id' => (int) $child->id,
/* place your other model properties here */
'name' => (string)$child->name,
'icon' => $child->icon,
'body' => (string)$child->body,
'description' => (string)$child->description,
'sort' => (int)$child->sort,
'status' => (int)$child->status,
'status_show' => (string)$child->status_show,
'created_at' => format_date($child->created_at),
// 'updated_at' => format_date($child->updated_at),
];
})
];
}
}
... ...
... ... @@ -106,7 +106,7 @@ return [
| If your page is going to be accessed via https, set it to `true`.
|
*/
'https' => env('ADMIN_HTTPS', true),
'https' => env('ADMIN_HTTPS', false),
/*
|--------------------------------------------------------------------------
... ...
... ... @@ -31,7 +31,7 @@ return [
'wechat' => [
// 公众号 APPID
'app_id' => env('WECHAT_MINI_APPID', 'wx3bb38a6c1cb0ed8c'),
'app_id' => env('WECHAT_OFFICIAL_ACCOUNT_APPID', 'wx3bb38a6c1cb0ed8c'),
// APP 引用的 appid
'appid' => env('WECHAT_MINI_APPID', 'wx3bb38a6c1cb0ed8c'),
... ...
... ... @@ -1713,3 +1713,9 @@ a, address, b, big, blockquote, body, center, cite, code, dd, del, div, dl, dt,
/* line-height: 1.5!important;*/
/* border-radius: 3px!important;*/
/*}*/
.cascade-group .form-group{
padding-top: 15px!important;
}
.cascade-group label.col-form-label {
padding-left:55px!important;
}
... ...
<!DOCTYPE html>
<html lang="{{ config('app.locale') }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="csrf-token" content="{{ csrf_token() }}">
<title></title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
{!! Admin::css() !!}
<script src="{{ Admin::jQuery() }}"></script>
{!! Admin::headerJs() !!}
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="/vendor/laravel-admin/toastr/build/toastr.min.css"/>
<script src="/vendor/laravel-admin/toastr/build/toastr.min.js"></script>
<script src="/vendor/laravel-admin/jquery-pjax/jquery.pjax.js"></script>
<script src="/assets/layer-v3.1.1/layer/layer.js"></script>
<script src="/assets/layui/layui.js"></script>
<script src="/vendor/laravel-admin/sweetalert2/dist/sweetalert2.min.js"></script>
<script src="{{ admin_asset("vendor/laravel-admin/AdminLTE/plugins/iCheck/icheck.min.js")}}"></script>
<script src="/assets/admin/js/main.js"></script>
<script src="/assets/admin/js/common.js?1"></script>
<link rel="stylesheet" type="text/css" href="/vendor/laravel-admin/AdminLTE/plugins/select2/select2.min.css" />
<script src="/vendor/laravel-admin/AdminLTE/plugins/select2/select2.full.min.js"></script>
<link type="text/css" rel="stylesheet" href="/assets/admin/css/main.css?11111111"/>
<link type="text/css" rel="stylesheet" href="/vendor/laravel-admin/sweetalert2/dist/sweetalert2.css"/>
<link rel="stylesheet" href="{{ admin_asset("vendor/laravel-admin/AdminLTE/plugins/iCheck/square/blue.css") }}">
</head>
<body class="hold-transition">
<div class="wrapper">
{{-- <form action="categories/{{$id}}/labels" method="post" accept-charset="UTF-8" class="" enctype="multipart/form-data" pjax-container="">--}}
<div class="box-body">
<div class="fields-group">
<div class="col-sm-12">
<div class="form-group col-sm-12 clear-both row " style="clear:both;">
<label for="name" class="col-sm-2 col-form-label asterisk">名称</label>
<div class="col-sm-10">
<input id="name" name="name" class="form-control name" placeholder="输入 标签名称" value="" required />
<span class="form-text text-muted">
<i class="fa fa-info-circle"></i>&nbsp;名称 请勿超过 20 个字
</span>
</div>
</div>
<div class="form-group col-sm-12 clear-both row " style="clear:both;">
<label for="name" class="col-sm-2 col-form-label asterisk">是否可以多选</label>
<div class="col-sm-10">
<span class="icheck">
<label class="radio-inline">
<input type="radio" name="can_multiple" value="0" class="minimal" {{ optional($label)->can_multiple == 0 ?'checked':'' }}/>&nbsp;&nbsp;&nbsp;
</label>
</span>
<span class="icheck">
<label class="radio-inline">
<input type="radio" name="can_multiple" value="1" class="minimal" {{ optional($label)->can_multiple == 1 ?'checked':'' }}/>&nbsp;&nbsp;&nbsp;
</label>
</span>
</div>
</div>
{{--<div class="form-group col-sm-12 clear-both row " style="clear:both;">
<label for="name" class="col-sm-2 col-form-label asterisk">标签语义</label>
<div class="col-sm-10">
<input id="semantics" name="semantics" class="form-control semantics" placeholder="输入 标签语义" value="{{ optional($label)->semantics }}" required />
<span class="form-text text-muted">
<i class="fa fa-info-circle"></i>&nbsp;标签语义 请勿超过 100 个字
</span>
</div>
</div>
<div class="form-group col-sm-12 clear-both row " style="clear:both;">
<label for="description" class="col-sm-2 col-form-label">标签描述</label>
<div class="col-sm-10">
<textarea id="description" name="description" class="form-control description" rows="5" placeholder="输入 标签描述">{{ optional($label)->description }}</textarea>
<span class="form-text text-muted">
<i class="fa fa-info-circle"></i>&nbsp;回答 请勿超过 255 个字
</span>
</div>
</div>--}}
</div>
</div>
</div>
<div class="card-footer" style="height: 50px!important;">
<div class="col-md-1"></div>
<div class="col-md-10 col-md-8">
<div class="d-flex d-sm-inline-flex align-items-center">
<button type="button" class="btn btn-success btn-add">提交</button>
{{--<button type="submit" class="btn btn-primary">提交</button>--}}
</div>
<div class="d-flex d-sm-inline-flex align-items-center"></div>
</div>
</div>
{{-- </form>--}}
</div>
<script>
$(function () {
$("input:radio").iCheck({
checkboxClass: 'icheckbox_square-blue',
radioClass: 'iradio_square-green',
increaseArea: '100%' // optional
});
{{--$("input:radio[name='type']").on('ifChecked', function () {--}}
{{-- if($(this).val()=="1"){--}}
{{-- // 短期密码--}}
{{-- $(this).closest('.fields-group').find('.long-div').hide();--}}
{{-- $(this).closest('.fields-group').find('.short-div').show();--}}
{{-- $(this).closest('.fields-group').find('.password').val("{{optional($short_term)->password}}");--}}
{{-- var short_term_time= "{{$short_term_time}}";--}}
{{-- $(this).closest('.fields-group').find("input[name='short_term_time'][value='" + short_term_time+ "']").iCheck("check");--}}
{{-- // var date = new Date();--}}
{{-- // $('.enabled_at_short').datetimepicker({--}}
{{-- // "format":"YYYY-MM-DD HH:mm","locale":"zh-CN","allowInputToggle":true,--}}
{{-- // // minDate: date,--}}
{{-- // });--}}
{{-- //--}}
{{-- // $('.expired_at_short').datetimepicker({--}}
{{-- // "format":"YYYY-MM-DD HH:m","locale":"zh-CN","allowInputToggle":true,--}}
{{-- // // minDate: date,--}}
{{-- // });--}}
{{-- // 设置选中--}}
{{-- }if($(this).val()=="2"){--}}
{{-- // 长期密码--}}
{{-- $(this).closest('.fields-group').find('.long-div').show();--}}
{{-- $(this).closest('.fields-group').find('.short-div').hide();--}}
{{-- $(this).closest('.fields-group').find('.password').val("{{optional($long_term)->password}}");--}}
{{-- }--}}
{{-- // $(this).attr("checked",false);--}}
{{-- $(this).iCheck('update');--}}
{{--});--}}
$(".btn-add").click(function () {
let name = $("#name").val();
if (!name) {
toastr.error('请输入 标签名称。');
return;
}
// let semantics = $("#semantics").val();
// if (!semantics) {
// toastr.error('请输入 标签语义。');
// return;
// }
let url = "/admin/categories/{{$id}}/labels";
$.ajax({
url: url,
type: "POST",
data: {
label_id:"{{$label_id}}",
name:name,
can_multiple:$("input[name='can_multiple']:checked").val(),
// semantics:semantics,
// description:$("#description").val(),
_token: LA.token,
_method: 'POST'
},
success: function (data) {
if (data.code === 0) {
toastr.success(data.message);
window.parent.location.reload()
} else {
toastr.error(data.message);
}
},
complete:function(xhr,status) {
// if (status == 'success') {
// // _status = xhr.responseJSON.status;
//
// }
}
});
})
})
function LA() {}
LA.token = "{{ csrf_token() }}";
</script>
... ...
... ... @@ -39,34 +39,34 @@ $api->version('v1', ['namespace' => 'App\Http\Api\V1\Controllers', 'middleware'
| 微信授权相关:包含小程序和公众号
|-------------------------------------------------------------------------------------------------------------------
*/
$api->group(['prefix' => 'wechat'], function ($api) {
$controller = 'WechatController';
$prefix = 'wechat';
$api->any('mini-openid', $controller .'@getMiniOpenid')->name($prefix .'.user.openid');// 获取小程序 openid
$api->any('mini-authorized-login', $controller .'@authorizeLoginMini')->name($prefix .'.authorize.Login');// 小程序 授权登录
$api->any('mini-phone', $controller .'@getMiniPhone')->name($prefix .'.phone');// 获取小程序用户手机号
$api->post('auth/token', $controller .'@authLogin')->name($prefix .'.login');// 微信授权登录:根据 method 判断登录方式
$api->post('auth/token/nickname', $controller .'@authLoginByNickname')->name($prefix .'.auth.nickname');// 小程序昵称授权
$api->post('auth/token/mobile', $controller .'@authLoginByMobile')->name($prefix .'.auth.mobile');// 小程序手机号授权
$api->any('mini-openid', $controller .'@getMiniOpenid')->name($prefix .'.user.openid');// 获取小程序 openid
$api->any('login-with-nickname', $controller .'@authorizeLoginByNickname')->name($prefix .'.authorize.Login');// 小程序 授权登录
$api->any('login-with-mobile', $controller .'@authorizeLoginByMobile')->name($prefix .'.phone');// 获取小程序用户手机号
$api->any('mini-user', $controller .'@getMiniUserInfo')->name($prefix .'.user.info'); // 获取微信用户信息
$api->any('mini-decrypt', $controller .'@decrypt')->name($prefix .'decrypt'); // 解密
$api->any('token', $controller .'@token')->name($prefix .'.token');// 验证 token
$api->any('jssdk', $controller .'@jssdk')->name($prefix .'.jssdk');// 验证 token
$api->any('auth', $controller.'@auth')->name($prefix.'.authorize'); // 授权
$api->get('openid', $controller .'@initOpenid')->name($prefix .'.openid')->middleware('check.xcx.user');// 验证 token
$api->post('authorized-login', $controller .'@authorizeLogin')->name($prefix .'.authorize.Login')->middleware('check.xcx.user');// 授权登录
$api->post('openid', $controller .'@getOpenid')->name($prefix .'.user.openid')->middleware('check.xcx.user'); // 列表
$api->post('user', $controller .'@getWxUserInfo')->name($prefix .'.user.info'); // 列表
$api->post('server', $controller .'@server')->name($prefix .'.server');
$api->get('server', $controller .'@server')->name($prefix .'.server');
});
// $api->group(['prefix' => 'wechat'], function ($api) {
// $controller = 'WechatController';
// $prefix = 'wechat';
// $api->any('mini-openid', $controller .'@getMiniOpenid')->name($prefix .'.user.openid');// 获取小程序 openid
// $api->any('mini-authorized-login', $controller .'@authorizeLoginMini')->name($prefix .'.authorize.Login');// 小程序 授权登录
// $api->any('mini-phone', $controller .'@getMiniPhone')->name($prefix .'.phone');// 获取小程序用户手机号
//
//
// $api->post('auth/token', $controller .'@authLogin')->name($prefix .'.login');// 微信授权登录:根据 method 判断登录方式
// $api->post('auth/token/nickname', $controller .'@authLoginByNickname')->name($prefix .'.auth.nickname');// 小程序昵称授权
// $api->post('auth/token/mobile', $controller .'@authLoginByMobile')->name($prefix .'.auth.mobile');// 小程序手机号授权
//
// $api->any('mini-openid', $controller .'@getMiniOpenid')->name($prefix .'.user.openid');// 获取小程序 openid
// $api->any('login-with-nickname', $controller .'@authorizeLoginByNickname')->name($prefix .'.authorize.Login');// 小程序 授权登录
// $api->any('login-with-mobile', $controller .'@authorizeLoginByMobile')->name($prefix .'.phone');// 获取小程序用户手机号
//
// $api->any('mini-user', $controller .'@getMiniUserInfo')->name($prefix .'.user.info'); // 获取微信用户信息
// $api->any('mini-decrypt', $controller .'@decrypt')->name($prefix .'decrypt'); // 解密
// $api->any('token', $controller .'@token')->name($prefix .'.token');// 验证 token
// $api->any('jssdk', $controller .'@jssdk')->name($prefix .'.jssdk');// 验证 token
// $api->any('auth', $controller.'@auth')->name($prefix.'.authorize'); // 授权
// $api->get('openid', $controller .'@initOpenid')->name($prefix .'.openid')->middleware('check.xcx.user');// 验证 token
// $api->post('authorized-login', $controller .'@authorizeLogin')->name($prefix .'.authorize.Login')->middleware('check.xcx.user');// 授权登录
// $api->post('openid', $controller .'@getOpenid')->name($prefix .'.user.openid')->middleware('check.xcx.user'); // 列表
// $api->post('user', $controller .'@getWxUserInfo')->name($prefix .'.user.info'); // 列表
// $api->post('server', $controller .'@server')->name($prefix .'.server');
// $api->get('server', $controller .'@server')->name($prefix .'.server');
// });
/*
|-------------------------------------------------------------------------------------------------------------------
... ...