From b535997d60b3e6baae31cdf28c8a7be4651259c1 Mon Sep 17 00:00:00 2001 From: 李忠强 <1354905998@qq.com> Date: Wed, 5 Jan 2022 20:02:40 +0800 Subject: [PATCH] 更新 --- application/admin/controller/litestore/Litestorecategory.php | 4 ++-- application/admin/lang/zh-cn/litestore/litestorecategory.php | 3 +++ application/admin/model/litestore/Litestorecategory.php | 5 +++++ application/admin/view/litestore/litestorecategory/add.html | 11 ----------- application/admin/view/litestore/litestorecategory/edit.html | 6 +++--- application/admin/view/litestore/litestorecategory/index.html | 16 ++++++++-------- application/api/controller/Index.php | 36 ++++++++++++++++++++++++++++++++---- application/api/controller/User.php | 174 +++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------------------------- application/api/model/Category.php | 21 +++++++++++++++++++++ application/api/model/News.php | 21 +++++++++++++++++++++ application/extra/site.php | 14 ++++++++------ public/assets/js/backend/litestore/litestorecategory.js | 6 ++++-- 12 files changed, 130 insertions(+), 187 deletions(-) create mode 100644 application/api/model/Category.php create mode 100644 application/api/model/News.php diff --git a/application/admin/controller/litestore/Litestorecategory.php b/application/admin/controller/litestore/Litestorecategory.php index bf93d3b..c8727ca 100644 --- a/application/admin/controller/litestore/Litestorecategory.php +++ b/application/admin/controller/litestore/Litestorecategory.php @@ -14,7 +14,7 @@ class Litestorecategory extends Backend /** * Litestorecategory模型对象 - * @var \app\admin\model\Litestorecategory + * @var \app\admin\model\litestore\Litestorecategory */ protected $model = null; protected $categorylist = []; @@ -32,7 +32,7 @@ class Litestorecategory extends Backend { $categorydata[$v['id']] = $v; } - $this->view->assign("parentList", $categorydata); + $this->view->assign("isindexList", $this->model->getIsIndexList()); } /** diff --git a/application/admin/lang/zh-cn/litestore/litestorecategory.php b/application/admin/lang/zh-cn/litestore/litestorecategory.php index 13a4162..e496d33 100644 --- a/application/admin/lang/zh-cn/litestore/litestorecategory.php +++ b/application/admin/lang/zh-cn/litestore/litestorecategory.php @@ -6,6 +6,9 @@ return [ 'Name' => '分类名称', 'Image' => '图片', 'Weigh' => '权重', + 'Is_index' => '是否首页展示', + 'Is_index 0' => '否', + 'Is_index 1' => '是', 'Createtime' => '创建时间', 'Updatetime' => '更新时间' ]; diff --git a/application/admin/model/litestore/Litestorecategory.php b/application/admin/model/litestore/Litestorecategory.php index 2f84a1c..6dbee38 100644 --- a/application/admin/model/litestore/Litestorecategory.php +++ b/application/admin/model/litestore/Litestorecategory.php @@ -30,6 +30,11 @@ class Litestorecategory extends Model }); } + public function getIsIndexList() + { + return ['0'=>__('Is_index 0'),'1'=>__('Is_index 1')]; + } + diff --git a/application/admin/view/litestore/litestorecategory/add.html b/application/admin/view/litestore/litestorecategory/add.html index f3d91f1..54cc8ca 100644 --- a/application/admin/view/litestore/litestorecategory/add.html +++ b/application/admin/view/litestore/litestorecategory/add.html @@ -1,17 +1,6 @@ <form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> - <div class="form-group"> - <label for="c-pid" class="control-label col-xs-12 col-sm-2">{:__('Pid')}:</label> - <div class="col-xs-12 col-sm-8"> - - <select id="c-pid" data-rule="required" class="form-control selectpicker" name="row[pid]"> - {foreach name="parentList" item="vo"} - <option data-type="{$vo.name}" value="{$key}" {in name="key" value=""}selected{/in}>{$vo.name}</option> - {/foreach} - </select> - </div> - </div> <div class="form-group"> <label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label> <div class="col-xs-12 col-sm-8"> diff --git a/application/admin/view/litestore/litestorecategory/edit.html b/application/admin/view/litestore/litestorecategory/edit.html index da99425..9e8e104 100644 --- a/application/admin/view/litestore/litestorecategory/edit.html +++ b/application/admin/view/litestore/litestorecategory/edit.html @@ -1,12 +1,12 @@ <form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> <div class="form-group"> - <label for="c-pid" class="control-label col-xs-12 col-sm-2">{:__('Pid')}:</label> + <label for="c-pid" class="control-label col-xs-12 col-sm-2">{:__('Is_index')}:</label> <div class="col-xs-12 col-sm-8"> <select id="c-pid" data-rule="required" class="form-control selectpicker" name="row[pid]"> - {foreach name="parentList" item="vo"} - <option data-type="{$vo.name}" value="{$key}" {in name="key" value="$row.pid"}selected{/in}>{$vo.name}</option> + {foreach name="isindexList" item="vo"} + <option data-type="{$vo}" value="{$key}" {in name="key" value="$row.pid"}selected{/in}>{$vo}</option> {/foreach} </select> diff --git a/application/admin/view/litestore/litestorecategory/index.html b/application/admin/view/litestore/litestorecategory/index.html index beff139..868a076 100644 --- a/application/admin/view/litestore/litestorecategory/index.html +++ b/application/admin/view/litestore/litestorecategory/index.html @@ -10,15 +10,15 @@ <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('litestore/litestorecategory/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a> <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('litestore/litestorecategory/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a> <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('litestore/litestorecategory/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a> - <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('litestore/litestorecategory/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a> +<!-- <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('litestore/litestorecategory/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>--> - <div class="dropdown btn-group {:$auth->check('litestore/litestorecategory/multi')?'':'hide'}"> - <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a> - <ul class="dropdown-menu text-left" role="menu"> - <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li> - <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li> - </ul> - </div> +<!-- <div class="dropdown btn-group {:$auth->check('litestore/litestorecategory/multi')?'':'hide'}">--> +<!-- <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>--> +<!-- <ul class="dropdown-menu text-left" role="menu">--> +<!-- <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>--> +<!-- <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>--> +<!-- </ul>--> +<!-- </div>--> </div> <table id="table" class="table table-striped table-bordered table-hover table-nowrap" data-operate-edit="{:$auth->check('litestore/litestorecategory/edit')}" diff --git a/application/api/controller/Index.php b/application/api/controller/Index.php index 24c615e..479cbe5 100644 --- a/application/api/controller/Index.php +++ b/application/api/controller/Index.php @@ -2,6 +2,7 @@ namespace app\api\controller; +use app\api\model\News; use app\common\controller\Api; /** @@ -13,11 +14,38 @@ class Index extends Api protected $noNeedRight = ['*']; /** - * 首页 - * + * @ApiTitle (首页轮播图) + * @ApiMethod (POST) + * @ApiHeaders (name=token, type=string, required=true, description="请求的Token") + * @ApiReturn ({ + 'code':'1', + 'msg':'返回成功' + 'data':'轮播图数组' + }) */ - public function index() + public function banner() { - $this->success('请求成功'); + + $model = new News(); + $list = $model->where('status','normal')->column('image'); + $this->success('banner',$list); + } + + /** + * @ApiTitle (首页分类) + * @ApiMethod (POST) + * @ApiHeaders (name=token, type=string, required=true, description="请求的Token") + * @ApiReturn ({ + 'code':'1', + 'msg':'返回成功' + 'data':'轮播图数组' + }) + */ + public function category() + { + + $model = new Cat(); + $list = $model->where('status','normal')->column('image'); + $this->success('banner',$list); } } diff --git a/application/api/controller/User.php b/application/api/controller/User.php index cac49bb..1d9e8c0 100644 --- a/application/api/controller/User.php +++ b/application/api/controller/User.php @@ -37,107 +37,6 @@ class User extends Api } /** - * 会员登录 - * - * @ApiMethod (POST) - * @param string $account 账号 - * @param string $password 密码 - */ - public function login() - { - $account = $this->request->post('account'); - $password = $this->request->post('password'); - if (!$account || !$password) { - $this->error(__('Invalid parameters')); - } - $ret = $this->auth->login($account, $password); - if ($ret) { - $data = ['userinfo' => $this->auth->getUserinfo()]; - $this->success(__('Logged in successful'), $data); - } else { - $this->error($this->auth->getError()); - } - } - - /** - * 手机验证码登录 - * - * @ApiMethod (POST) - * @param string $mobile 手机号 - * @param string $captcha 验证码 - */ - public function mobilelogin() - { - $mobile = $this->request->post('mobile'); - $captcha = $this->request->post('captcha'); - if (!$mobile || !$captcha) { - $this->error(__('Invalid parameters')); - } - if (!Validate::regex($mobile, "^1\d{10}$")) { - $this->error(__('Mobile is incorrect')); - } - if (!Sms::check($mobile, $captcha, 'mobilelogin')) { - $this->error(__('Captcha is incorrect')); - } - $user = \app\common\model\User::getByMobile($mobile); - if ($user) { - if ($user->status != 'normal') { - $this->error(__('Account is locked')); - } - //如果已经有账号则直接登录 - $ret = $this->auth->direct($user->id); - } else { - $ret = $this->auth->register($mobile, Random::alnum(), '', $mobile, []); - } - if ($ret) { - Sms::flush($mobile, 'mobilelogin'); - $data = ['userinfo' => $this->auth->getUserinfo()]; - $this->success(__('Logged in successful'), $data); - } else { - $this->error($this->auth->getError()); - } - } - - /** - * 注册会员 - * - * @ApiMethod (POST) - * @param string $username 用户名 - * @param string $password 密码 - * @param string $email 邮箱 - * @param string $mobile 手机号 - * @param string $code 验证码 - */ - public function register() - { - $username = $this->request->post('username'); - $password = $this->request->post('password'); - $email = $this->request->post('email'); - $mobile = $this->request->post('mobile'); - $code = $this->request->post('code'); - if (!$username || !$password) { - $this->error(__('Invalid parameters')); - } - if ($email && !Validate::is($email, "email")) { - $this->error(__('Email is incorrect')); - } - if ($mobile && !Validate::regex($mobile, "^1\d{10}$")) { - $this->error(__('Mobile is incorrect')); - } - $ret = Sms::check($mobile, $code, 'register'); - if (!$ret) { - $this->error(__('Captcha is incorrect')); - } - $ret = $this->auth->register($username, $password, $email, $mobile, []); - if ($ret) { - $data = ['userinfo' => $this->auth->getUserinfo()]; - $this->success(__('Sign up successful'), $data); - } else { - $this->error($this->auth->getError()); - } - } - - /** * 退出登录 * @ApiMethod (POST) */ @@ -299,57 +198,30 @@ class User extends Api } /** - * 重置密码 - * - * @ApiMethod (POST) - * @param string $mobile 手机号 - * @param string $newpassword 新密码 - * @param string $captcha 验证码 + * @ApiTitle (用户协议) + * @ApiMethod (POST) + * @ApiReturn ({ + 'code':'1', + 'msg':'用户协议' + 'data':'富文本' + }) */ - public function resetpwd() + public function userAgreement() { - $type = $this->request->post("type"); - $mobile = $this->request->post("mobile"); - $email = $this->request->post("email"); - $newpassword = $this->request->post("newpassword"); - $captcha = $this->request->post("captcha"); - if (!$newpassword || !$captcha) { - $this->error(__('Invalid parameters')); - } - if ($type == 'mobile') { - if (!Validate::regex($mobile, "^1\d{10}$")) { - $this->error(__('Mobile is incorrect')); - } - $user = \app\common\model\User::getByMobile($mobile); - if (!$user) { - $this->error(__('User not found')); - } - $ret = Sms::check($mobile, $captcha, 'resetpwd'); - if (!$ret) { - $this->error(__('Captcha is incorrect')); - } - Sms::flush($mobile, 'resetpwd'); - } else { - if (!Validate::is($email, "email")) { - $this->error(__('Email is incorrect')); - } - $user = \app\common\model\User::getByEmail($email); - if (!$user) { - $this->error(__('User not found')); - } - $ret = Ems::check($email, $captcha, 'resetpwd'); - if (!$ret) { - $this->error(__('Captcha is incorrect')); - } - Ems::flush($email, 'resetpwd'); - } - //模拟一次登录 - $this->auth->direct($user->id); - $ret = $this->auth->changepwd($newpassword, '', true); - if ($ret) { - $this->success(__('Reset password successful')); - } else { - $this->error($this->auth->getError()); - } + $this->success('用户协议', Config::get('site.user_agreement')); + } + + /** + * @ApiTitle (隐私协议) + * @ApiMethod (POST) + * @ApiReturn ({ + 'code':'1', + 'msg':'隐私协议' + 'data':'富文本' + }) + */ + public function privacyAgreement() + { + $this->success('隐私协议', Config::get('site.privacy_agreement')); } } diff --git a/application/api/model/Category.php b/application/api/model/Category.php new file mode 100644 index 0000000..a928861 --- /dev/null +++ b/application/api/model/Category.php @@ -0,0 +1,21 @@ +<?php + + +namespace app\api\model; + + +use think\Model; + +class Category extends Model +{ + protected $name = 'litestore_category'; + protected $append = [ + 'image_text' + ]; + + public function getImageTextAttr($value,$data) + { + $value = empty($data['image'])?'':cdnurl($data['image'],true); + return $value; + } +} \ No newline at end of file diff --git a/application/api/model/News.php b/application/api/model/News.php new file mode 100644 index 0000000..bab19e4 --- /dev/null +++ b/application/api/model/News.php @@ -0,0 +1,21 @@ +<?php + + +namespace app\api\model; + + +use think\Model; + +class News extends Model +{ + protected $name = 'litestore_news'; + protected $append = [ + 'image_text' + ]; + + public function getImageTextAttr($value,$data) + { + $value = !empty($data['image']) ? cdnurl($data['image'],true) : ''; + return $value; + } +} \ No newline at end of file diff --git a/application/extra/site.php b/application/extra/site.php index e341d64..639d588 100644 --- a/application/extra/site.php +++ b/application/extra/site.php @@ -28,12 +28,6 @@ return array ( 'user' => 'User', 'example' => 'Example', ), - 'attachmentcategory' => - array ( - 'category1' => 'Category1', - 'category2' => 'Category2', - 'custom' => 'Custom', - ), 'mail_type' => '1', 'mail_smtp_host' => 'smtp.qq.com', 'mail_smtp_port' => '465', @@ -41,4 +35,12 @@ return array ( 'mail_smtp_pass' => 'password', 'mail_verify_type' => '2', 'mail_from' => '10000@qq.com', + 'attachmentcategory' => + array ( + 'category1' => 'Category1', + 'category2' => 'Category2', + 'custom' => 'Custom', + ), + 'user_agreement' => '<p>64645646564公开警告</p><p>;回来了框架</p>', + 'privacy_agreement' => '<p>45315448</p><p>他房间后</p>', ); diff --git a/public/assets/js/backend/litestore/litestorecategory.js b/public/assets/js/backend/litestore/litestorecategory.js index ecf2028..16aa616 100644 --- a/public/assets/js/backend/litestore/litestorecategory.js +++ b/public/assets/js/backend/litestore/litestorecategory.js @@ -24,15 +24,17 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin sortName: 'weigh', pagination: false, commonSearch: false, + search: false, + showExport:false, columns: [ [ {checkbox: true}, {field: 'id', title: __('Id')}, - {field: 'pid', title: __('Pid')}, - //{field: 'name', title: __('Name')}, + // {field: 'pid', title: __('Pid')}, {field: 'name', title: __('Name'), align: 'left'}, {field: 'image', title: __('Image'), formatter: Table.api.formatter.image}, {field: 'weigh', title: __('Weigh')}, + {field: 'is_index', title: __('Is_index'), formatter: Table.api.formatter.status, searchList: {0: __('Is_index 0'), 1: __('Is_index 1')}}, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime}, {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} -- libgit2 0.24.0