diff --git a/app/controller/About.php b/app/controller/About.php deleted file mode 100644 index 5ea704c..0000000 --- a/app/controller/About.php +++ /dev/null @@ -1,35 +0,0 @@ -setSeo(); - $about = CmsRepository::getInstance()->getAbout($this->aboutCategory['id']); - $this->data['about'] = $about; - $this->data['category'] = $this->aboutCategory; - - return $this->view(); - } -} \ No newline at end of file diff --git a/app/controller/Account.php b/app/controller/Account.php deleted file mode 100644 index c11d643..0000000 --- a/app/controller/Account.php +++ /dev/null @@ -1,513 +0,0 @@ -data['countList'] = OrderRepository::getInstance()->findOrderCount($this->authId); - $this->data['markList'] = OrderRepository::getInstance()->auctionMarkList('', [$this->authId]); - $this->data['biddingList'] = GoodsRepository::getInstance()->auctionBiddingList($this->authId); - return $this->view(); - } - - /** - * 个人资料 - * - * @return View|Json - * @throws RepositoryException - */ - public function profile() - { - $repo = AccountRepository::getInstance(); - $item = $repo->findById($this->authId); - if ($this->request->isPost()) { - $post = input('post.'); - $update = []; - $update['headimgurl'] = $post['headimgurl'] ?? ''; - $update['sex'] = $post['sex']; - $update['nickname'] = $post['nickname']; - if (!empty($post['nickname']) && $item['nickname'] !== $post['nickname']) { - if ($item['nickname_time'] > 0) { - return $this->json(4001, '每人仅先修改一次昵称,您已修改过了。'); - } - $update['nickname_time'] = $item['nickname_time'] + 1; - } - $item->save($update); - return $this->json(); - } - $this->data['item'] = $item; - return $this->view(); - } - - /** - * 我的订单 - * - * @return View - */ - public function order(): View - { - $accountId = $this->auth['id'] ?? 0; - $tag = input('get.tag/s', 'waiting'); - - $this->data['items'] = OrderRepository::getInstance()->getOrderGoods($accountId, $tag); - $this->data['tag'] = $tag; - return $this->view(); - } - - /** - * 保证金 - * - * @return View - * @throws RepositoryException - */ - public function deposit(): View - { - $accountId = $this->auth['id'] ?? 0; - if (!$accountId) { - $this->error('请先登录'); - } - - $item = AccountRepository::getInstance()->findById($accountId, ['quota', 'id', 'deposit']); - - $this->data['item'] = $item; - return $this->view(); - } - - /** - * 实名认证 - * - * @return View|Json - * @throws RepositoryException - */ - public function realName() - { - $accountId = $this->auth['id'] ?? 0; - $account = AccountRepository::getInstance()->findById($accountId); - if ($this->request->isPost()) { - if (!$account) { - return $this->json(4001, '请先登录'); - } - - if ($account['is_real_name']) { - return $this->json(4002, '您已通过认证'); - } - - $post = input('post.'); - $validate = new VAccount(); - if (!$validate->scene('real_name')->check($post)) { - return $this->json(4003, $validate->getError()); - } - - $post['is_real_name'] = 1; - $account->save($post); - return $this->json(); - } - - $this->data['item'] = $account; - return $this->view(); - } - - /** - * 个人账户 - * - * @return View - * @throws RepositoryException - */ - public function info(): View - { - $accountId = $this->auth['id'] ?? 0; - $item = AccountRepository::getInstance()->findById($accountId); - $rechargeList = AccountRepository::getInstance()->fetchRechargeList($accountId); - $withdrawalList = AccountRepository::getInstance()->fetchWithdrawalList($accountId); - - $this->data['item'] = $item; - $this->data['rechargeList'] = $rechargeList['list']; - $this->data['withdrawalList'] = $withdrawalList['list']; - return $this->view(); - } - - /** - * 中标清单 - * - * @return View - * @throws DbException - */ - public function biddingList(): View - { - $accountId = $this->auth['id'] ?? 0; - $pageParams['query'] = input('get.'); - $list = OrderRepository::getInstance()->auctionMarkList('', [$accountId], $pageParams); - - $this->data['list'] = $list; - return $this->view(); - } - - /** - * 竞价清单 - * - * @return View - */ - public function biddingLog(): View - { - $list = GoodsRepository::getInstance()->auctionBiddingList($this->authId); - - $this->data['items'] = $list; - return $this->view(); - } - - /** - * 关注的拍品 - * - * @return View - * @throws DataNotFoundException - * @throws DbException - * @throws ModelNotFoundException - */ - public function auctionCollection(): View - { - $accountId = $this->auth['id'] ?? 0; - $items = AccountRepository::getInstance()->fetchCollection($accountId, GoodsRepository::TYPE_AUCTION); - $this->data['items'] = $items; - return $this->view(); - } - - /** - * 商品收藏 - * - * @return View - * @throws DataNotFoundException - * @throws DbException - * @throws ModelNotFoundException - */ - public function goodsCollection(): View - { - $accountId = $this->auth['id'] ?? 0; - $items = AccountRepository::getInstance()->fetchCollection($accountId, GoodsRepository::TYPE_GOODS); - $this->data['items'] = $items; - return $this->view(); - } - - - /** - * 地址管理 - * - * @return View - * @throws DataNotFoundException - * @throws DbException - * @throws ModelNotFoundException - */ - public function address(): View - { - $accountId = $this->auth['id'] ?? 0; - //地址列表 - $addressList = AccountRepository::getInstance()->findAddressByUid($accountId); - - $this->data['addressList'] = $addressList; - return $this->view(); - } - - /** - * 地址详情 - * - * @return Json|View - * @throws DataNotFoundException - * @throws DbException - * @throws ModelNotFoundException - */ - public function addressDetail() - { - $resp = AccountRepository::getInstance(); - $accountId = $this->auth['id'] ?? 0; - $id = input('param.id/d', 0); - $item = $resp->findAddressById($id); - if ($this->request->isPost()) { - $postItem = input('post.'); - $postItem['user_id'] = $postItem['user_id'] ?? $accountId; - $resp->saveAddress($postItem); - return $this->json(); - } - - $this->data['item'] = $item; - return $this->view(); - } - - /** - * 地址删除 - * - * @return Json - */ - public function addressDel(): Json - { - if ($this->request->isPost()) { - $id = input('post.id/d', 0); - AccountRepository::getInstance()->delAddress($id); - return $this->json(); - } - - return $this->json(4002, '请求方式错误'); - } - - /** - * 修改密码 - * - * @return Json - */ - public function editPwd(): Json - { - $post = input('post.'); - $accountId = $this->auth['id'] ?? 0; - $validate = new VAccount(); - if (!$validate->scene('edit_password')->check($post)) { - return $this->json(4002, $validate->getError()); - } - - try { - AccountRepository::getInstance()->modifyPwd($accountId, $post['old_password'], $post['password']); - } catch (Exception $e) { - $this->json(4003, $e->getMessage()); - } - - return $this->json(); - } - - /** - * 取消收藏|关注 - * - * @return Json - * @throws DataNotFoundException - * @throws DbException - * @throws ModelNotFoundException - */ - public function unCollect(): Json - { - $accountId = $this->auth['id'] ?? 0; - $goodsId = input('post.id/d'); - AccountRepository::getInstance()->unCollectGoods($accountId, $goodsId); - return $this->json(); - } - - /** - * 操作保证金 充值|退回 相应改变额度 - * - * @return Json - * @throws RepositoryException - */ - public function operateDeposit(): Json - { - if ($this->request->isPost()) { - $accountId = $this->auth['id'] ?? 0; - $amount = input('post.value', 0); - $type = input('post.type/s', 'recharge'); - if (!AccountRepository::getInstance()->isEnough($accountId, $amount, 'deposit')) { - return $this->json(4000, '余额不足'); - } - try { - AccountRepository::getInstance()->operateDeposit($accountId, $amount, $type); - } catch (RepositoryException $e) { - return $this->json(4002, $e->getMessage()); - } catch (Exception $e) { - CommonRepository::log('保证金充值失败', $e); - return $this->json(5001, '充值失败'); - } - return $this->json(); - } - - return $this->json(4002, '请求方式错误'); - } - - /** - * 充值 - * - * @return Json - * @throws GuzzleException - */ - public function rechargeAmount(): Json - { - if ($this->request->isPost()) { - $accountId = $this->auth['id'] ?? 0; - $amount = input('post.amount', 0); - $type = input('post.type/s'); - if (!$accountId) { - return $this->json(4001, '请先登录'); - } - - try { - $qr = AccountRepository::getInstance()->recharge($accountId, (float) $amount, $type); - return $this->json(0, 'success', ['payment_order_number' => $qr['order_id'], 'code_url' => $qr['qr']]); - } catch (Exception $e) { - CommonRepository::log('充值失败', $e); - return $this->json(5001, '充值失败:'.$e->getMessage()); - } - } - - return $this->json(4002, '请求方式错误'); - } - - /** - * 重新充值 - * - * @return Json - * @throws GuzzleException - */ - public function rechargeAgain(): Json - { - if ($this->request->isPost()) { - $accountId = $this->auth['id'] ?? 0; - $orderId = input('post.order_id', 0); - $type = input('post.type/s'); - if (!$accountId) { - return $this->json(4001, '请先登录'); - } - - try { - $qr = AccountRepository::getInstance()->rechargeAgain($accountId, $orderId, $type); - return $this->json(0, 'success', ['payment_order_number' => $qr['order_id'], 'code_url' => $qr['qr']]); - } catch (Exception $e) { - CommonRepository::log('充值失败', $e); - return $this->json(5001, '充值失败:'.$e->getMessage()); - } - } - - return $this->json(4002, '请求方式错误'); - } - - /** - * 查询订单 - * - * @return array|Json - * @throws DataNotFoundException - * @throws DbException - * @throws ModelNotFoundException - */ - public function checkPayment() - { - if ($this->request->isPost()) { - $res['code'] = 0; - $res['msg'] = 'success'; - $res['data']['paid'] = true; - $orderId = input('post.order_id/s', ''); //订单ID - $type = input('post.type/s', 'all'); //支付方式 - - if (!$orderId || !$type) { - $res['code'] = 1; - $res['msg'] = '参数错误'; - return $res; - } - - //根据支付类型 请求接口查询订单 - $hasPaid = AccountRepository::getInstance()->hasPaid($orderId, $type); - if ($hasPaid) { - AccountRepository::getInstance()->paymentLogPaid($orderId, $type); - } - $res['data']['paid'] = $hasPaid; - return $res; - } - - return $this->json(1, '非法请求!'); - } - - /** - * 提现 - * - * @return Json - */ - public function withdrawal(): Json - { - if ($this->request->isPost()) { - $amount = input('post.amount', ''); - $accountId = $this->auth['id'] ?? 0; - - try { - AccountRepository::getInstance()->withdrawal($accountId, $amount); - return $this->json(); - } catch (Exception $e) { - CommonRepository::log('提现失败', $e); - return $this->json(5001, '提现失败'); - } - - } - - return $this->json(1, '非法请求!'); - } - - /** - * 获取已有订单号的支付二维码 - * - * @return Json - * @throws GuzzleException - */ - public function getPaymentQr(): Json - { - if ($this->request->isPost()) { - $type = input('post.type', ''); - $orderId = input('post.order_id', ''); - - try { - $codeQr = OrderRepository::getInstance()->generatePaymentQrCode($type, $orderId); - return $this->json(0, 'success', ['payment_order_number' => $orderId, 'code_url' => $codeQr]); - } catch (Exception $e) { - CommonRepository::log('获取支付二维码', $e); - return $this->json(5001, '获取支付二维码'); - } - - } - - } - - /** - * 物流查询 - * - * @return Json - * @throws DataNotFoundException - * @throws DbException - * @throws ModelNotFoundException - */ - public function logistics(): Json - { - $orderId = input('post.order_id'); - $type = input('post.type', 'goods'); - - // $com = 'shunfeng'; - // $num = 'SF1980860132707'; - - if ($type == 'goods') { - if (!$delivery = OrderRepository::getInstance()->findExpressByOrder($orderId)) { - return $this->json(4001, '物流信息不存在'); - } - } else { - if (!$delivery = OrderRepository::getInstance()->findExpressByAuction($orderId)) { - return $this->json(4001, '物流信息不存在'); - } - } - $com = $delivery['express_code']; - $num = $delivery['express_number']; - - return $this->json(0, 'success', ['res' => Kd100::query($com, $num)]); - } -} \ No newline at end of file diff --git a/app/controller/Article.php b/app/controller/Article.php deleted file mode 100644 index 5e687cc..0000000 --- a/app/controller/Article.php +++ /dev/null @@ -1,99 +0,0 @@ -error('错误页面'); - } - $article = MArticle::getById($id); - if (empty($article)) { - return $this->error('无此文章'); - } - MArticle::updateById($id, ['views' => $article['views'] + 1]); - $category = Category::getById($article['category_id']); - $prev = MArticle::getPrevArticleByIdAndCategoryId($id, $article['category_id']); - $next = MArticle::getNextArticleByIdAndCategoryId($id, $article['category_id']); - - $keywords = $article['seo_keywords'] ?: $this->system['seo_keywords']; - $description = $article['seo_description'] ?: $this->system['seo_description']; - $this->setSeo($article['title'], $keywords, $description); - $this->data['article'] = $article; - $this->data['category'] = $category; - $this->data['categoryId'] = $category['id']; - $this->data['prev'] = $prev; - $this->data['next'] = $next; - return $this->view($category['template_detail'] ?? ''); - } - - //列表页 - public function index() - { - $categoryId = input('category_id/d', 0); - if ($categoryId <= 0) { - return $this->error('错误页面'); - } - $category = Category::getById($categoryId); - $page_size = 20; - if( $category['number'])$page_size= $category['number']; - - if( $this->request->param("page_size/d")){ - $page_size= $this->request->param("page_size/d"); - cookie("article_page_size",$this->request->param("page_size/d")); - }else{ - if( cookie("?article_page_size"))$page_size= cookie("article_page_size"); - } - - if (empty($category)) { - return $this->error('错误页面'); - } - $description = $category['description'] ?: $this->system['seo_description']; - $this->setSeo($category['title'], $this->system['seo_keywords'], $description); - $this->data['items'] = MArticle::getListPageByCategory($categoryId, $page_size); - $this->data['category'] = $category; - $this->data['categoryId'] = $categoryId; - $this->data['page_size'] = $page_size; - $this->data['article_count'] = MArticle::getListCount($categoryId); - - return $this->view($category['template_list'] ?? ''); - } - - //查询 - public function query(): \think\response\View - { - $keyword = $this->request->param("keyword/s"); - //无key值跳转到产品 - if (!$keyword) $this->redirect((string)url('/articles/12.html')); - - $where = [ - ['category_id', 'in', [5, 12, 13, 14, 15]], - ['status', '=', 1], - ]; - - $where[] = ['title', 'like', '%' . $keyword . '%']; - $param['keyword'] = $keyword; - - $paginate = [ - 'list_rows' => 20, - 'query' => $param - ]; - $data = MArticle::where($where) - ->order("sort desc") - ->paginate($paginate, false); - - View::assign("items", $data); - View::assign("keyword", $keyword); - $this->data['category'] = Category::getById(5); - $this->data['categoryId'] = 5; - return $this->view("/article/product_query"); - } - -} \ No newline at end of file diff --git a/app/controller/Contact.php b/app/controller/Contact.php deleted file mode 100644 index c8e3943..0000000 --- a/app/controller/Contact.php +++ /dev/null @@ -1,26 +0,0 @@ -slideListByPosition($position); - - $this->data['blocks'] = BlockRepository::getInstance()->getByCateName(BlockRepository::CATEGORY_CONTACT); - $this->data['slide'] = $slides; - $this->setSeo(); - return $this->view(); - } -} \ No newline at end of file diff --git a/app/controller/Page.php b/app/controller/Page.php deleted file mode 100644 index c96e281..0000000 --- a/app/controller/Page.php +++ /dev/null @@ -1,28 +0,0 @@ -request->param("category_id"); - $category = Category::getById($this->request->param("category_id")); - - if ($category) { - $description = $category['description'] ?: $this->system['seo_description']; - $this->setSeo($category['title'], $this->system['seo_keywords'], $description); - } else { - return $this->error('错误页面'); - } - $childCategory = Category::getChildrenByParentId($categoryId); - - $this->data['categoryId'] = $categoryId; - $this->data['category'] = $category; - $this->data['childCategory'] = $childCategory; - $this->data['blocks'] = Block::getByCategoryId($categoryId); - return $this->view($category['template_detail']); - } -} \ No newline at end of file diff --git a/app/controller/Search.php b/app/controller/Search.php deleted file mode 100644 index cd3c198..0000000 --- a/app/controller/Search.php +++ /dev/null @@ -1,40 +0,0 @@ -', 0]; - $where['where'][] = ['title', 'like', '%'.$keyword.'%']; - $items = GoodsRepository::getInstance()->findListWithPaginate($where, $pageParams); - - $position = ['search_banner']; - $slides = OperationRepository::getInstance()->slideListByPosition($position); - $collectedIds = $this->authId ? AccountRepository::getInstance()->getCollectedIds($this->authId, $tag) : []; - - $this->data['items'] = $items; - $this->data['collectedIds'] = $collectedIds; - $this->data['slide'] = $slides; - return $this->view(); - } -} \ No newline at end of file diff --git a/app/controller/manager/Business.php b/app/controller/manager/Business.php index 7bb2efb..41651de 100644 --- a/app/controller/manager/Business.php +++ b/app/controller/manager/Business.php @@ -10,7 +10,6 @@ use app\model\Recharge; use app\model\Business as BusinessModel; use app\model\Member; use app\repository\BusinessRepository; -use app\repository\CouponRepository; use app\repository\RechargeRepository; use app\service\wx\WechatPay; use Exception; @@ -23,7 +22,6 @@ use think\response\View; class Business extends Base { - protected $noNeedLogin = ['queryManagerRecharge']; /** * 商家列表列表 * diff --git a/app/controller/manager/Consumer.php b/app/controller/manager/Consumer.php new file mode 100644 index 0000000..1aae2a7 --- /dev/null +++ b/app/controller/manager/Consumer.php @@ -0,0 +1,126 @@ +request->isPost()) { + $repo = AccountRepository::getInstance(); + $keyword = $this->request->param('keyword/s', ''); + $state = $this->request->param('state/d', "-1"); + $page = $this->request->param('page/d', 1); + $size = $this->request->param('size/d', 30); + + $whereMap = [["type", "=", Account::type_consumer]]; + $orders = ['id' => 'desc']; + if (!empty($keyword)) { + $whereMap[] = ['nick_name', 'like', "%$keyword%"]; + } + if (isset($stateArray[$state])) { + $whereMap[] = ['state', '=', $state]; + } + $list = $repo->findList($whereMap, [], $page, $size, function ($q) { + return $q->with("tag"); + }, $orders); + $list["list"]->each(function ($item) { + //优惠券领取总数 + $item->coupon_total_count = Coupon::where(["consumer_code" => $item->user_code])->count("id"); + //优惠券使用总数 + $item->coupon_used_count = Coupon::where(["consumer_code" => $item->user_code])->where("is_verificated", Coupon::is_verificated_on)->count("id"); + //优惠券未使用总数 + $item->coupon_not_use_count = Coupon::where(["consumer_code" => $item->user_code])->where("is_verificated", Coupon::is_verificated_off)->count("id"); + }); + + return $this->json(0, 'success', $list); + + } + $this->data["state"] = $stateArray; + return $this->view(); + } + + /** + * 消费者详情 + * + * @return Json|View + * @throws Exception + */ + public function info() + { + $id = input("id/d", 0); + $consumer = Account::findOne(["id" => $id], [], function ($q) { + return $q->with("tag"); + }); + //只查询优惠券持有 + if ($this->request->isPost()) { + $repo = AccountRepository::getInstance(); + $page = $this->request->param('page/d', 1); + $size = $this->request->param('size/d', 30); + + $list = $repo->consumerCouponList($consumer['user_code'], $page, $size); + $time = time(); + $list["list"]->each(function ($item) use ($time) { + if(strtotime($item['end_time']) < $time){ + $item->time_state = '已过期'; + }else{ + $item->time_state = '未过期'; + } + + }); + return $this->json(0, 'success', $list); + } + if (empty($consumer)) { + return $this->json(4001, "消费者不存在"); + } + $rep = AccountRepository::getInstance(); + //评论总数数 + $this->data["totalComment"] = $rep->consumerTotalComment($consumer["user_code"]); + //评论总数数 + $this->data["totalTheMonthComment"] = $rep->consumerTheMonthTotalComment($consumer["user_code"]); + + //优惠券领取总数 + $this->data["couponTotalCount"] = $rep->consumerTotalCoupon($consumer["user_code"]); + + //优惠券使用总数 + $this->data["couponUsedTotalCount"] = $rep->consumerUsedTotalCoupon($consumer["user_code"]); + //优惠券未使用总数 + $this->data["couponNotUsedTotalCount"] = $rep->consumerNotUsedTotalCoupon($consumer["user_code"]); + + $this->data["consumer"] = $consumer->toArray(); + + return $this->view(); + } + +} \ No newline at end of file diff --git a/app/model/Account.php b/app/model/Account.php index a3a738a..4d3a629 100644 --- a/app/model/Account.php +++ b/app/model/Account.php @@ -8,4 +8,27 @@ use think\exception\ValidateException; class Account extends Base { + public const type_consumer = 0;//个人消费者 + public const type_business = 1;//商家 + public const type_staff = 2;//员工 + + public const state_default = 0;// 未提交 + public const state_examineing = 1 ;// 1审核中 + public const state_fail = 2;// 2拒绝 + public const state_success = 3;// 3审核通过 + + public static function allState(){ + return [ + self::state_default=>"未提交", + self::state_examineing=>"审核中", + self::state_fail=>"拒绝", + self::state_success=>"审核通过", + ]; + } + + public function tag() + { + return $this->hasOne(Tag::class,"id","tag_id"); + } + } diff --git a/app/model/Tag.php b/app/model/Tag.php new file mode 100644 index 0000000..7584a2b --- /dev/null +++ b/app/model/Tag.php @@ -0,0 +1,10 @@ +findList(); - } - + use CommentTrait; + use CouponTrait; /** * 获取指定账户记录By手机号 * diff --git a/app/traits/CommentTrait.php b/app/traits/CommentTrait.php new file mode 100644 index 0000000..dc8b7c2 --- /dev/null +++ b/app/traits/CommentTrait.php @@ -0,0 +1,30 @@ +where("is_delete",Comment::COMMON_OFF)->count("id"); + } + /**消费者评论本月总数 + * @param string $userCode + * + **/ + public function consumerTheMonthTotalComment($userCode){ + return Comment::where("user_code",$userCode) + ->where("is_delete",Comment::COMMON_OFF) + ->whereTime("create_time",">=",date("Y-m-1 00:00:00")) + ->count("id"); + } +} \ No newline at end of file diff --git a/app/traits/CouponTrait.php b/app/traits/CouponTrait.php new file mode 100644 index 0000000..795741e --- /dev/null +++ b/app/traits/CouponTrait.php @@ -0,0 +1,57 @@ +count("id"); + } + + /**消费者已使用优惠券总数 + * @param string $userCode + * + * + * @return int + */ + public function consumerUsedTotalCoupon($userCode) + { + return Coupon::where("consumer_code", $userCode)->where("is_verificated", Coupon::is_verificated_on)->count("id"); + } + + /**消费者已使用优惠券总数 + * @param string $userCode + * + * + * @return int + */ + public function consumerNotUsedTotalCoupon($userCode) + { + return Coupon::where("consumer_code", $userCode)->where("is_verificated", Coupon::is_verificated_off)->count("id"); + } + + /**消费者已使用优惠券总数 + * @param string $userCode + * + * + * @return array + * @throws \Exception + */ + public function consumerCouponList($userCode, $page, $size) + { + return Coupon::findList(["consumer_code" => $userCode], [], $page, $size, null, ["id" => "desc"]); + } + + +} \ No newline at end of file diff --git a/public/static/manager/js/business/business.js b/public/static/manager/js/business/business.js index c668b04..e4dce02 100644 --- a/public/static/manager/js/business/business.js +++ b/public/static/manager/js/business/business.js @@ -46,10 +46,10 @@ layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect'], function {templet: '#row-cover', title: '头像', style: 'height: 90px;'}, {templet:function(d){ return d.account.nick_name - },field: 'nick_name', title: '昵称'}, + }, title: '昵称'}, {templet:function(d){ - return d.business.business_name - },field: 'business_name', title: '商家名称'}, + return d.business.business_name + } ,title: '商家名称'}, {field: 'coupon_total_count', title: '优惠券总数量'}, {field: 'coupon_doing_count', title: '进行中优惠券数量'}, {field: 'coupon_receive_count', title: '已领取优惠券数量'}, diff --git a/public/static/manager/js/consumer/index.js b/public/static/manager/js/consumer/index.js new file mode 100644 index 0000000..3d19428 --- /dev/null +++ b/public/static/manager/js/consumer/index.js @@ -0,0 +1,80 @@ +layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect'], function () { + let $ = layui.jquery, + form = layui.form, + table = layui.table, + layer = layui.layer, + xmSelect = layui.xmSelect, + miniTab = layui.miniTab; + + /**** index begin ***/ + //index页面 + if ($('.location-index-page').length > 0) { + miniTab.listen(); + + // 渲染表格 + let listUrl = $('#table-container').data('url'); + let insTb = table.render({ + elem: '#table-container', + toolbar: '#toolbar-tpl', + defaultToolbar: [{ //自定义头部工具栏右侧图标。如无需自定义,去除该参数即可 + title: '搜索' + , layEvent: 'search' + , icon: 'layui-icon-search' + }], + url: listUrl, + method: 'post', + even: true, + limits: [10,20,50,100,200,500,1000], + request: { + pageName: 'page', + limitName: 'size', + }, + parseData: function (res) { + return { + "code": res.code, //解析接口状态 + "msg": res.msg, //解析提示文本 + "count": res.data.total, //解析数据长度 + "data": res.data.list //解析数据列表 + }; + }, + page: true, + cols: [[ + // {type: 'checkbox'}, + {field: 'id' , width: 80, title: 'ID'}, + {templet: '#row-cover', title: '头像', style: 'height: 90px;'}, + {field: 'nick_name', title: '昵称'}, + {field: 'gender', title: '性别'}, + {field: 'coupon_total_count', title: '优惠券领取数'}, + {field: 'coupon_used_count', title: '优惠券使用数'}, + {field: 'coupon_not_use_count', title: '优惠券未使用数'}, + {field: 'login_time', title: '最近登录'}, + + + {templet:function(d){ + if( d.tag != undefined && d.tag.name != null){ + return d.tag.name + } + return ''; + },title: '用户标签'}, + {templet: '#row-operate', minWidth: 350, field: 'right', align: 'center', title: '操作', fixed: 'right'} + ]], + done: function () { + Tools.setInsTb(insTb); + } + }); + + // 监听搜索操作 + form.on('submit(data-search-btn)', function (data) { + //执行搜索重载 + table.reload('table-container', { + page: {curr: 1} + , where: data.field + }, 'data'); + + return false; + }); + + } + /*** index end ***/ + +}); \ No newline at end of file diff --git a/public/static/manager/js/consumer/info.js b/public/static/manager/js/consumer/info.js new file mode 100644 index 0000000..47f4e13 --- /dev/null +++ b/public/static/manager/js/consumer/info.js @@ -0,0 +1,59 @@ +layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect'], function () { + let $ = layui.jquery, + form = layui.form, + table = layui.table, + layer = layui.layer, + xmSelect = layui.xmSelect, + miniTab = layui.miniTab; + + /**** index begin ***/ + //index页面 + if ($('.location-index-page').length > 0) { + miniTab.listen(); + + // 渲染表格 + let listUrl = $('#table-container').data('url'); + let insTb = table.render({ + elem: '#table-container', + toolbar: '#toolbar-tpl', + defaultToolbar: [{ //自定义头部工具栏右侧图标。如无需自定义,去除该参数即可 + title: '搜索' + , layEvent: 'search' + , icon: 'layui-icon-search' + }], + url: listUrl, + method: 'post', + even: true, + limits: [10,20,50,100,200,500,1000], + request: { + pageName: 'page', + limitName: 'size', + }, + parseData: function (res) { + return { + "code": res.code, //解析接口状态 + "msg": res.msg, //解析提示文本 + "count": res.data.total, //解析数据长度 + "data": res.data.list //解析数据列表 + }; + }, + page: true, + cols: [[ + // {type: 'checkbox'}, + {field: 'id' , width: 80, title: 'ID'}, + {field: 'name', title: '名称'}, + {field: 'type_name', title: '优惠券类型'}, + {field: 'money', title: '金额'}, + {field: 'business_name', title: '商家名称'}, + {templet: '#row-state', title: '状态'}, + ]], + done: function () { + Tools.setInsTb(insTb); + } + }); + + + } + /*** index end ***/ + +}); \ No newline at end of file diff --git a/view/manager/consumer/index.html b/view/manager/consumer/index.html new file mode 100644 index 0000000..2c5fe73 --- /dev/null +++ b/view/manager/consumer/index.html @@ -0,0 +1,79 @@ +{layout name="manager/layout" /} + + +