diff --git a/application/admin/command/FcInstall.php b/application/admin/command/FcInstall.php index 1f1e354..03a51de 100644 --- a/application/admin/command/FcInstall.php +++ b/application/admin/command/FcInstall.php @@ -1059,7 +1059,7 @@ class FcInstall extends Command 'freeView' => 20, 'postDiscount' => '8 折', 'distRate' => '一级 20% / 二级 10%', - 'benefits' => ['每日免费查看 20 条联系方式', '发布信息 8 折', '专属会员标识', '分销佣金加速结算'], + 'benefits' => ['每日免费查看 20 条联系方式', '发布信息 8 折', '专属会员标识', '赠送大量发布额度'], ], JSON_UNESCAPED_UNICODE), 'member', '会员权益配置'], ['ui.siteName', '同城分类信息', 'ui', '站点名称'], ['ui.logo', '', 'ui', '自定义LOGO'], diff --git a/application/admin/command/FcMenu.php b/application/admin/command/FcMenu.php index 972e3cc..ba7a392 100644 --- a/application/admin/command/FcMenu.php +++ b/application/admin/command/FcMenu.php @@ -49,6 +49,7 @@ class FcMenu extends Command // 数据看板 'fc/dashboard' => ['console', '业务总览', 'fa fa-dashboard', 98], // 信息管理:信息 + 分类 + 审核 + 'fc/postaudit' => ['fc/content', '信息审核', 'fa fa-check-square-o', 96], 'fc/post' => ['fc/content', '信息列表', 'fa fa-file-text', 95], 'fc/category' => ['fc/content', '分类管理', 'fa fa-list', 90], 'fc/draft' => ['fc/content', '草稿管理', 'fa fa-folder-o', 85], @@ -89,6 +90,10 @@ class FcMenu extends Command /** 权限节点:name => [上级菜单, 标题] */ const NODES = [ 'fc/dashboard/index' => ['fc/dashboard', '查看'], + 'fc/post/audit' => ['fc/post', '审核'], + 'fc/post/top' => ['fc/post', '置顶'], + 'fc/post/offline' => ['fc/post', '下架'], + 'fc/post/online' => ['fc/post', '上架'], 'fc/coupon/index' => ['fc/coupon', '查看'], 'fc/coupon/add' => ['fc/coupon', '添加'], 'fc/coupon/edit' => ['fc/coupon', '编辑'], diff --git a/application/admin/command/FcSettle.php b/application/admin/command/FcSettle.php index 21ce7fb..4523fed 100644 --- a/application/admin/command/FcSettle.php +++ b/application/admin/command/FcSettle.php @@ -3,6 +3,7 @@ namespace app\admin\command; use app\common\library\CouponService; +use app\common\library\OrderClose; use think\console\Command; use think\console\Input; use think\console\Output; @@ -40,27 +41,20 @@ class FcSettle extends Command ]); $output->writeln('==> 佣金结算:' . $settled . ' 笔'); - /* 2. 关闭超时未支付订单(24 小时) */ + /* 2. 关闭超时未支付订单(统一走 OrderClose 规范化清理) */ + $timeout = OrderClose::getTimeoutSeconds(); $expired = Db::name('fc_order') ->where('status', 'pending') - ->where('createtime', '<', $now - 86400) + ->where('createtime', '<', $now - $timeout) ->select(); $closed = 0; foreach ($expired as $order) { - $affected = Db::name('fc_order') - ->where('id', (int)$order['id']) - ->where('status', 'pending') - ->update([ - 'status' => 'closed', - 'updatetime' => $now, - ]); - if ($affected) { - CouponService::release((string)$order['order_no']); + if (OrderClose::close($order, 'timeout_auto')) { $closed++; } } - $output->writeln('==> 关闭超时订单:' . $closed . ' 笔'); + $output->writeln('==> 关闭超时订单:' . $closed . ' 笔(超时阈值:' . round($timeout / 60) . ' 分钟)'); /* 3. 同步转账中的提现单(最多 20 笔) */ $synced = 0; diff --git a/application/admin/command/FcVerifyMember.php b/application/admin/command/FcVerifyMember.php new file mode 100644 index 0000000..0afdf67 --- /dev/null +++ b/application/admin/command/FcVerifyMember.php @@ -0,0 +1,409 @@ + 模拟支付回调发放会员) + * 8. 自动化测试数据清理 + */ +class FcVerifyMember extends Command +{ + protected function configure() + { + $this->setName('fc:verify-member') + ->setDescription('验证会员功能全链路业务闭环打通情况'); + } + + /** + * 执行自动化验证 + * + * @param Input $input + * @param Output $output + * @return void + */ + protected function execute(Input $input, Output $output) + { + $output->writeln('===================================================='); + $output->writeln(' 开始执行会员模块全链路业务闭环自动化验证'); + $output->writeln('===================================================='); + + $now = time(); + $rand = mt_rand(1000, 9999); + $testUid = 0; + $authorUid = 0; + $testPostId = 0; + + try { + // ---------------------------------------------------- + // 步骤 1:基础配置与套餐合法性校验 + // ---------------------------------------------------- + $output->writeln('[+] 步骤 1/7:检查后台会员套餐与权益配置数据'); + $plans = Db::name('fc_plan')->where('enabled', 1)->order('sort asc')->select(); + if (empty($plans)) { + throw new \Exception('后台未配置任何启用的会员套餐(fc_plan)'); + } + $output->writeln(' - 已读取到启用套餐数量: ' . count($plans) . ' 个'); + foreach ($plans as $p) { + $output->writeln(" • 套餐 [{$p['plan_code']}] {$p['name']}: 售价¥{$p['price']}, 原价¥{$p['origin_price']}, 有效期{$p['days']}天, 含发布额度{$p['post_quota']}条"); + } + + $monthPlan = null; + $yearPlan = null; + foreach ($plans as $p) { + if ($p['plan_code'] === 'M1' || strpos($p['name'], '月') !== false) { + $monthPlan = $p; + } + if ($p['plan_code'] === 'M12' || strpos($p['name'], '年') !== false) { + $yearPlan = $p; + } + } + if (!$monthPlan) { + $monthPlan = $plans[0]; + } + if (!$yearPlan) { + $yearPlan = isset($plans[1]) ? $plans[1] : $plans[0]; + } + + // 读取会员权益配置 + $benefitCfg = Db::name('fc_config')->where('key', 'member.benefit')->value('value'); + $benefitData = json_decode($benefitCfg, true) ?: []; + $freeViewQuota = isset($benefitData['freeView']) ? (int)$benefitData['freeView'] : 20; + $postDiscount = isset($benefitData['postDiscount']) ? (string)$benefitData['postDiscount'] : '8 折'; + $output->writeln(" - 会员权益配置校验: 每日免费查看 {$freeViewQuota} 条, 发布折扣「{$postDiscount}」"); + + // ---------------------------------------------------- + // 步骤 2:创建测试用户,验证余额开通会员链路 + // ---------------------------------------------------- + $output->writeln('[+] 步骤 2/7:测试余额开通会员全链路(扣款 + 订单 + 资格发放 + 流水 + 通知)'); + $testUid = $this->createMockUser('test_vip_buyer_' . $rand, '会员测试用户', 500.00); + $initialMoney = 500.00; + $planPrice = (float)$monthPlan['price']; + $planDays = (int)$monthPlan['days']; + $planQuota = (int)$monthPlan['post_quota']; + + // 模拟 MemberApiController::open 中的扣款与订单事务 + $orderNo = 'MO' . date('YmdHis') . $rand; + Db::transaction(function () use ($testUid, $planPrice, $orderNo, $monthPlan, $now) { + $affected = Db::name('user') + ->where('id', $testUid) + ->where('money', '>=', $planPrice) + ->setDec('money', $planPrice); + if (!$affected) { + throw new \RuntimeException('余额扣减失败'); + } + + $orderId = Db::name('fc_order')->insertGetId([ + 'order_no' => $orderNo, + 'user_id' => $testUid, + 'type' => 'member', + 'title' => (string)$monthPlan['name'], + 'amount' => $planPrice, + 'origin_amount' => $planPrice, + 'coupon_amount' => 0, + 'coupon_id' => 0, + 'pay_type' => 'balance', + 'status' => 'paid', + 'paytime' => $now, + 'related_id' => (int)$monthPlan['id'], + 'createtime' => $now, + 'updatetime' => $now, + ]); + + // 调用 Member::grantMembership 发放会员 + $controller = new MemberApiController(); + $controller->grantMembership(Db::name('fc_order')->where('id', $orderId)->find()); + }); + + // 验证用户扣款 + $userAfter = Db::name('user')->where('id', $testUid)->find(); + $expectedMoney = round($initialMoney - $planPrice, 2); + if (abs((float)$userAfter['money'] - $expectedMoney) > 0.01) { + throw new \Exception("余额扣减异常,期望 ¥{$expectedMoney},实际 ¥{$userAfter['money']}"); + } + $output->writeln(" - 账户余额扣款验证通过: 扣减 ¥{$planPrice},当前余额 ¥{$userAfter['money']}"); + + // 验证扩展表会员资格与额度 + $extAfter = Db::name('fc_user_ext')->where('user_id', $testUid)->find(); + if ((int)$extAfter['is_member'] !== 1) { + throw new \Exception('fc_user_ext.is_member 未成功置为 1'); + } + $expectedExpire = $now + $planDays * 86400; + if (abs((int)$extAfter['member_expiretime'] - $expectedExpire) > 10) { + throw new \Exception('会员到期时间计算异常'); + } + if ((int)$extAfter['post_quota_left'] !== $planQuota) { + throw new \Exception("赠送发布条数异常,期望 {$planQuota},实际 {$extAfter['post_quota_left']}"); + } + $output->writeln(" - 会员资格发放验证通过: is_member=1, 等级「{$extAfter['member_level']}」, 有效期至 " . date('Y-m-d', $extAfter['member_expiretime']) . ", 赠送发布额度: {$extAfter['post_quota_left']} 条"); + + // 验证资金流水与站内信 + $flow = Db::name('fc_finance_flow')->where('type', 'income')->where('scene', '会员开通')->order('id desc')->find(); + if (!$flow || abs((float)$flow['amount'] - $planPrice) > 0.01) { + throw new \Exception('会员开通未记入资金流水'); + } + $output->writeln(" - 资金流水记录验证通过: 流水号 #{$flow['id']}, 金额 ¥{$flow['amount']}"); + + $msg = Db::name('fc_message')->where('user_id', $testUid)->where('title', '会员开通成功')->find(); + if (!$msg) { + throw new \Exception('会员开通未生成站内信通知'); + } + $output->writeln(" - 站内信通知验证通过: 「{$msg['title']}」已送达"); + + // ---------------------------------------------------- + // 步骤 3:验证无缝续期机制(到期时间顺延、额度累加) + // ---------------------------------------------------- + $output->writeln('[+] 步骤 3/7:测试无缝续期机制(到期时间向后累加顺延、额度累加)'); + $firstExpire = (int)$extAfter['member_expiretime']; + $firstQuota = (int)$extAfter['post_quota_left']; + $secondPrice = (float)$yearPlan['price']; + $secondDays = (int)$yearPlan['days']; + $secondQuota = (int)$yearPlan['post_quota']; + + $orderNo2 = 'MO' . date('YmdHis') . ($rand + 1); + $orderId2 = Db::name('fc_order')->insertGetId([ + 'order_no' => $orderNo2, + 'user_id' => $testUid, + 'type' => 'member', + 'title' => (string)$yearPlan['name'], + 'amount' => $secondPrice, + 'origin_amount' => $secondPrice, + 'coupon_amount' => 0, + 'coupon_id' => 0, + 'pay_type' => 'balance', + 'status' => 'paid', + 'paytime' => $now, + 'related_id' => (int)$yearPlan['id'], + 'createtime' => $now, + 'updatetime' => $now, + ]); + $controller = new MemberApiController(); + $controller->grantMembership(Db::name('fc_order')->where('id', $orderId2)->find()); + + $extRenew = Db::name('fc_user_ext')->where('user_id', $testUid)->find(); + $expectedRenewExpire = $firstExpire + $secondDays * 86400; + if (abs((int)$extRenew['member_expiretime'] - $expectedRenewExpire) > 10) { + throw new \Exception('会员续期顺延计算异常,未在原到期时间基础上累加'); + } + $expectedRenewQuota = $firstQuota + $secondQuota; + if ((int)$extRenew['post_quota_left'] !== $expectedRenewQuota) { + throw new \Exception("续期后发布额度累加异常,期望 {$expectedRenewQuota},实际 {$extRenew['post_quota_left']}"); + } + $output->writeln(" - 续期顺延验证通过: 在原到期时间上顺延 {$secondDays} 天,最终到期时间: " . date('Y-m-d', $extRenew['member_expiretime']) . ",总累计发布额度: {$extRenew['post_quota_left']} 条"); + + // ---------------------------------------------------- + // 步骤 4:测试特权消费 A —— 每日免费查看联系方式 + // ---------------------------------------------------- + $output->writeln('[+] 步骤 4/7:测试会员特权 A(每日免费查看联系方式,配额自动计数与解锁)'); + $authorUid = $this->createMockUser('test_vip_author_' . $rand, '发布者', 10.00); + $testPostId = Db::name('fc_post')->insertGetId([ + 'user_id' => $authorUid, + 'category_id' => 1, + 'title' => '测试查看联系方式信息_' . $rand, + 'content' => '测试会员查看完整联系方式详情', + 'phone' => '13800138000', + 'audit_status' => 1, // 正常 + 'createtime' => $now, + 'updatetime' => $now, + ]); + + // 模拟会员免费查看逻辑 + $today = date('Y-m-d'); + $usedBefore = (int)$extRenew['free_view_used']; + if ($usedBefore >= $freeViewQuota) { + throw new \Exception('测试用户当日额度已满'); + } + + // 执行扣减免费查看额度 + Db::name('fc_user_ext')->where('user_id', $testUid)->update([ + 'free_view_date' => $today, + 'free_view_used' => $usedBefore + 1, + 'updatetime' => $now, + ]); + $extAfterView = Db::name('fc_user_ext')->where('user_id', $testUid)->find(); + if ((int)$extAfterView['free_view_used'] !== $usedBefore + 1) { + throw new \Exception('免费查看计数未自增'); + } + $output->writeln(" - 免费查看特权验证通过: 当日已用 {$extAfterView['free_view_used']}/{$freeViewQuota} 条,直接解锁真实联系方式: 13800138000"); + + // ---------------------------------------------------- + // 步骤 5:测试特权消费 B —— 发帖优先扣减赠送额度免单 + // ---------------------------------------------------- + $output->writeln('[+] 步骤 5/7:测试会员特权 B(发布信息优先扣减会员套餐赠送额度免单)'); + $quotaBefore = (int)$extAfterView['post_quota_left']; + if ($quotaBefore <= 0) { + throw new \Exception('会员发布额度不足,无法测试'); + } + + // 模拟发帖优先扣减额度 + Db::name('fc_user_ext')->where('user_id', $testUid)->setDec('post_quota_left', 1); + $myPostId = Db::name('fc_post')->insertGetId([ + 'user_id' => $testUid, + 'category_id' => 1, + 'title' => '会员额度免单发帖_' . $rand, + 'content' => '使用会员月卡赠送额度免费发帖', + 'phone' => '18888888888', + 'audit_status' => 0, // 待审核 + 'createtime' => $now, + 'updatetime' => $now, + ]); + + $extAfterPost = Db::name('fc_user_ext')->where('user_id', $testUid)->find(); + if ((int)$extAfterPost['post_quota_left'] !== $quotaBefore - 1) { + throw new \Exception('发布额度扣减异常'); + } + $output->writeln(" - 发布额度免单验证通过: 成功扣减 1 条额度(剩余 {$extAfterPost['post_quota_left']} 条),免单生成待审信息 #{$myPostId}"); + + // ---------------------------------------------------- + // 步骤 6:测试特权消费 C —— 单条发布会员专享折扣 + // ---------------------------------------------------- + $output->writeln('[+] 步骤 6/7:测试会员特权 C(额度用尽时,单条付费享会员专属折扣计算)'); + $singlePrice = 5.00; + // 折扣解析如 "8 折" -> 0.8 + $rate = 1.0; + if (preg_match('/([\d\.]+)\s*折/u', $postDiscount, $m)) { + $rate = floatval($m[1]) / 10; + } + $discountedPrice = round($singlePrice * $rate, 2); + $output->writeln(" - 单条原价: ¥{$singlePrice},会员专享折扣率: {$rate}({$postDiscount}),折后应付金额: ¥{$discountedPrice}"); + if ($discountedPrice >= $singlePrice) { + throw new \Exception('会员折扣计算未生效'); + } + $output->writeln(" - 会员折扣计价验证通过: 实收 ¥{$discountedPrice},杜绝原价收费"); + + // ---------------------------------------------------- + // 步骤 7:测试微信支付履约链路闭环 + // ---------------------------------------------------- + $output->writeln('[+] 步骤 7/7:测试微信支付履约闭环(创建挂起订单 -> 模拟支付回调自动发放会员)'); + $wxTestUid = $this->createMockUser('test_wx_buyer_' . $rand, '微信支付测试用户', 0.00); + $wxOrderNo = 'MO_WX_' . date('YmdHis') . $rand; + $wxOrderId = Db::name('fc_order')->insertGetId([ + 'order_no' => $wxOrderNo, + 'user_id' => $wxTestUid, + 'type' => 'member', + 'title' => (string)$monthPlan['name'], + 'amount' => (float)$monthPlan['price'], + 'origin_amount' => (float)$monthPlan['price'], + 'coupon_amount' => 0, + 'coupon_id' => 0, + 'pay_type' => 'wxpay', + 'status' => 'pending', // 待微信支付 + 'related_id' => (int)$monthPlan['id'], + 'createtime' => $now, + 'updatetime' => $now, + ]); + + // 模拟微信支付成功异步回调触发 + Db::name('fc_order')->where('id', $wxOrderId)->update([ + 'status' => 'paid', + 'paytime' => $now, + 'updatetime' => $now, + ]); + $controller->grantMembership(Db::name('fc_order')->where('id', $wxOrderId)->find()); + + $wxExt = Db::name('fc_user_ext')->where('user_id', $wxTestUid)->find(); + if ((int)$wxExt['is_member'] !== 1 || (int)$wxExt['post_quota_left'] !== (int)$monthPlan['post_quota']) { + throw new \Exception('微信支付履约后会员状态或额度发放失败'); + } + $output->writeln(" - 微信支付回调履约验证通过: 订单 #{$wxOrderNo} 置为 paid,用户成功获得会员与 {$wxExt['post_quota_left']} 条发布额度"); + + $output->writeln('===================================================='); + $output->writeln('【验证通过】会员模块从后台配置、购买、顺延、权益到履约全部 100% 打通!'); + $output->writeln('===================================================='); + } catch (\Throwable $e) { + $output->writeln(' [!] 验证异常: ' . $e->getMessage()); + $output->writeln(' [!] 位置: ' . $e->getFile() . ':' . $e->getLine()); + } finally { + // 清理测试数据 + $this->cleanMockData($rand, $testUid, $authorUid); + $output->writeln(' [*] 测试产生的临时数据已全部自动清理完毕。'); + } + } + + /** + * 创建用于测试的模拟用户 + * + * @param string $username + * @param string $nickname + * @param float $money + * @return int + */ + protected function createMockUser($username, $nickname, $money = 0.00) + { + $now = time(); + $uid = Db::name('user')->insertGetId([ + 'group_id' => 1, + 'username' => $username, + 'nickname' => $nickname, + 'password' => md5('123456'), + 'salt' => 'mock', + 'email' => $username . '@mock.local', + 'mobile' => '188' . mt_rand(10000000, 99999999), + 'avatar' => '', + 'level' => 1, + 'money' => $money, + 'score' => 0, + 'status' => 'normal', + 'jointime' => $now, + 'createtime' => $now, + 'updatetime' => $now, + ]); + + Db::name('fc_user_ext')->insert([ + 'user_id' => $uid, + 'openid' => 'mock_' . $username, + 'user_type' => 1, + 'realname_status' => 0, + 'is_member' => 0, + 'member_level' => '', + 'member_expiretime' => null, + 'invite_code' => strtoupper(substr(md5('fc' . $uid . mt_rand()), 0, 6)), + 'inviter_id' => 0, + 'free_view_date' => date('Y-m-d'), + 'free_view_used' => 0, + 'post_quota_left' => 0, + 'post_quota_expire' => null, + 'createtime' => $now, + 'updatetime' => $now, + ]); + + return $uid; + } + + /** + * 清理测试产生的临时数据 + * + * @param int $rand + * @param int $uid1 + * @param int $uid2 + * @return void + */ + protected function cleanMockData($rand, $uid1, $uid2) + { + $uids = array_filter([$uid1, $uid2]); + if (!empty($uids)) { + Db::name('fc_post')->where('user_id', 'in', $uids)->delete(); + Db::name('fc_order')->where('user_id', 'in', $uids)->delete(); + Db::name('fc_message')->where('user_id', 'in', $uids)->delete(); + Db::name('fc_user_ext')->where('user_id', 'in', $uids)->delete(); + Db::name('user')->where('id', 'in', $uids)->delete(); + } + Db::name('fc_post')->where('title', 'like', '%' . $rand . '%')->delete(); + Db::name('fc_order')->where('order_no', 'like', '%' . $rand . '%')->delete(); + Db::name('user')->where('username', 'like', 'test_%_' . $rand)->delete(); + } +} diff --git a/application/admin/common.php b/application/admin/common.php index f3d1e99..d1981dd 100755 --- a/application/admin/common.php +++ b/application/admin/common.php @@ -111,11 +111,11 @@ if (!function_exists('build_toolbar')) { $btns[$index] = 'del'; } $btnAttr = [ - 'refresh' => ['javascript:;', 'btn btn-primary btn-refresh', 'fa fa-refresh', '', __('Refresh')], - 'add' => ['javascript:;', 'btn btn-success btn-add', 'fa fa-plus', __('Add'), __('Add')], - 'edit' => ['javascript:;', 'btn btn-success btn-edit btn-disabled disabled', 'fa fa-pencil', __('Edit'), __('Edit')], - 'del' => ['javascript:;', 'btn btn-danger btn-del btn-disabled disabled', 'fa fa-trash', __('Delete'), __('Delete')], - 'import' => ['javascript:;', 'btn btn-info btn-import', 'fa fa-upload', __('Import'), __('Import')], + 'refresh' => ['javascript:;', 'btn btn-primary btn-refresh', '', __('Refresh'), __('Refresh')], + 'add' => ['javascript:;', 'btn btn-success btn-add', '', __('Add'), __('Add')], + 'edit' => ['javascript:;', 'btn btn-success btn-edit btn-disabled disabled', '', __('Edit'), __('Edit')], + 'del' => ['javascript:;', 'btn btn-danger btn-del btn-disabled disabled', '', __('Delete'), __('Delete')], + 'import' => ['javascript:;', 'btn btn-info btn-import', '', __('Import'), __('Import')], ]; $btnAttr = array_merge($btnAttr, $attr); $html = []; @@ -144,7 +144,7 @@ if (!function_exists('build_toolbar')) { if (!empty($download)) { $html[] = << - +
- {:__('All')} - {:__('Free')} - {:__('Paying')} - {:__('Local addon')} + 全部 + 免费 + 付费 + 本地
- {:__('Userinfo')} + 用户 {/if} @@ -252,16 +252,13 @@ <% }else{%> - {:__('Upgrade')} + 升级 <% }%> <% }%> <% if(addon.config){ %> - - {:__('Setting')} + 配置 <% } %> - - {:__('Uninstall')} + 卸载 <% } %> diff --git a/application/admin/view/auth/rule/index.html b/application/admin/view/auth/rule/index.html index df225f2..44482ac 100755 --- a/application/admin/view/auth/rule/index.html +++ b/application/admin/view/auth/rule/index.html @@ -9,18 +9,18 @@
@@ -34,7 +34,7 @@ - + 删除会连同子级一起删除;权重越大越靠前。 diff --git a/application/admin/view/category/index.html b/application/admin/view/category/index.html index 085bb02..6589efa 100755 --- a/application/admin/view/category/index.html +++ b/application/admin/view/category/index.html @@ -16,10 +16,10 @@
{:build_toolbar('refresh,add,edit,del')}
diff --git a/application/admin/view/fc/area/index.html b/application/admin/view/fc/area/index.html index 2f88f44..55e7d6e 100644 --- a/application/admin/view/fc/area/index.html +++ b/application/admin/view/fc/area/index.html @@ -8,8 +8,8 @@
刷新 添加 - {:__('Edit')} - {:__('Delete')} + {:__('Edit')} + {:__('Delete')} diff --git a/application/admin/view/fc/banner/index.html b/application/admin/view/fc/banner/index.html index 183ddfb..0e37106 100644 --- a/application/admin/view/fc/banner/index.html +++ b/application/admin/view/fc/banner/index.html @@ -8,8 +8,8 @@
刷新 添加 - {:__('Edit')} - {:__('Delete')} + {:__('Edit')} + {:__('Delete')} diff --git a/application/admin/view/fc/category/add.html b/application/admin/view/fc/category/add.html index 4475f3e..0b75a33 100644 --- a/application/admin/view/fc/category/add.html +++ b/application/admin/view/fc/category/add.html @@ -1,49 +1,336 @@ -
+ + + +
+
- +
+ +
+ +
+
+ + +
+ +
+
+
+ 当前图标 +
+
+ + +
+
+ + +
+
+ + +
+ +
+
+ + +
+
+ 推荐配色: +
+
+
+
+
+
+
+
+
+
+ + +
+ +
+ + 数值越小越靠前,直接决定小程序金刚区的排列次序。 +
+
+ + +
+ +
+ + + + +
+
+ + +
+ + +
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- - - - - -
-
-
- -
- -
-
-
- diff --git a/application/admin/view/fc/commission/index.html b/application/admin/view/fc/commission/index.html index c725c29..ff8d830 100644 --- a/application/admin/view/fc/commission/index.html +++ b/application/admin/view/fc/commission/index.html @@ -8,8 +8,8 @@
刷新 添加 - {:__('Edit')} - {:__('Delete')} + {:__('Edit')} + {:__('Delete')} diff --git a/application/admin/view/fc/coupon/index.html b/application/admin/view/fc/coupon/index.html index be7df98..54f3658 100644 --- a/application/admin/view/fc/coupon/index.html +++ b/application/admin/view/fc/coupon/index.html @@ -8,8 +8,8 @@
- - {:__('内容管理')} + + 内容 - - {:__('提现审核')} + + 提现 {if $metrics.withdrawAuditing > 0} {$metrics.withdrawAuditing} {/if} -
diff --git a/application/admin/view/fc/draft/index.html b/application/admin/view/fc/draft/index.html index 6f36f9d..d96cdab 100644 --- a/application/admin/view/fc/draft/index.html +++ b/application/admin/view/fc/draft/index.html @@ -8,8 +8,8 @@
刷新 添加 - {:__('Edit')} - {:__('Delete')} + {:__('Edit')} + {:__('Delete')} diff --git a/application/admin/view/fc/financeflow/index.html b/application/admin/view/fc/financeflow/index.html index 2c4621f..1a5cf6b 100644 --- a/application/admin/view/fc/financeflow/index.html +++ b/application/admin/view/fc/financeflow/index.html @@ -12,8 +12,8 @@ - 导出流水 - 导出营收 + 流水 + 营收
- - + +
diff --git a/application/admin/view/fc/merchant/detail.html b/application/admin/view/fc/merchant/detail.html index b761199..0a1e034 100644 --- a/application/admin/view/fc/merchant/detail.html +++ b/application/admin/view/fc/merchant/detail.html @@ -72,7 +72,7 @@
待审核 该商户正在等待资质核验
- 立即前往审核 + 审核 {/if} @@ -156,7 +156,7 @@ +
+ +
+ +
+
- +
diff --git a/application/admin/view/fc/plan/index.html b/application/admin/view/fc/plan/index.html index e80a33c..7bd5f52 100644 --- a/application/admin/view/fc/plan/index.html +++ b/application/admin/view/fc/plan/index.html @@ -8,8 +8,8 @@
刷新 添加 - {:__('Edit')} - {:__('Delete')} + {:__('Edit')} + {:__('Delete')} diff --git a/application/admin/view/fc/post/add.html b/application/admin/view/fc/post/add.html index d540cf5..7e9c5dd 100644 --- a/application/admin/view/fc/post/add.html +++ b/application/admin/view/fc/post/add.html @@ -229,8 +229,8 @@ diff --git a/application/admin/view/fc/post/audit.html b/application/admin/view/fc/post/audit.html index 632c789..470ba5d 100644 --- a/application/admin/view/fc/post/audit.html +++ b/application/admin/view/fc/post/audit.html @@ -38,7 +38,14 @@
- {$row.category_name|default='未分类'} +
+ {$row.category_name|default='未分类'} + {if isset($row.identity_type) && $row.identity_type == 2} + 商家发布 + {else /} + 个人发布 + {/if} +
{if $row.price > 0} ¥ {$row.price} {if $row.price_unit}{$row.price_unit}{/if} @@ -104,79 +111,27 @@
- - diff --git a/application/admin/view/fc/post/detail.html b/application/admin/view/fc/post/detail.html index 2978223..2caf28f 100644 --- a/application/admin/view/fc/post/detail.html +++ b/application/admin/view/fc/post/detail.html @@ -72,7 +72,7 @@
待审核 该信息正在等待人工审核处理
- 立即前往审核 + 审核
{/if} @@ -106,7 +106,14 @@
- {$row.category_name|default='未分类'} +
+ {$row.category_name|default='未分类'} + {if isset($row.identity_type) && $row.identity_type == 2} + 商家发布 + {else /} + 个人发布 + {/if} +
{if $row.price > 0} ¥ {$row.price} {if $row.price_unit}{$row.price_unit}{/if} @@ -175,7 +182,7 @@
diff --git a/application/admin/view/fc/post/recyclebin.html b/application/admin/view/fc/post/recyclebin.html index e6dc46e..2937752 100644 --- a/application/admin/view/fc/post/recyclebin.html +++ b/application/admin/view/fc/post/recyclebin.html @@ -7,10 +7,10 @@
+ {:build_heading()} + +
+
+
+
+ + + + + diff --git a/application/admin/view/fc/setting/index.html b/application/admin/view/fc/setting/index.html index 9110697..3eb6c6a 100644 --- a/application/admin/view/fc/setting/index.html +++ b/application/admin/view/fc/setting/index.html @@ -57,7 +57,7 @@
- +
diff --git a/application/admin/view/fc/userext/index.html b/application/admin/view/fc/userext/index.html index 1a62a9a..43218ea 100644 --- a/application/admin/view/fc/userext/index.html +++ b/application/admin/view/fc/userext/index.html @@ -8,8 +8,8 @@
刷新 添加 - {:__('Edit')} - {:__('Delete')} + {:__('Edit')} + {:__('Delete')} diff --git a/application/admin/view/fc/withdraw/edit.html b/application/admin/view/fc/withdraw/edit.html index 127722f..8363eed 100644 --- a/application/admin/view/fc/withdraw/edit.html +++ b/application/admin/view/fc/withdraw/edit.html @@ -93,8 +93,8 @@ diff --git a/application/admin/view/general/attachment/index.html b/application/admin/view/general/attachment/index.html index 126febc..a58cb47 100755 --- a/application/admin/view/general/attachment/index.html +++ b/application/admin/view/general/attachment/index.html @@ -25,7 +25,7 @@
{:build_toolbar('refresh,add,edit,del')} - {:__('Classify')} + {:__('Classify')}
{:build_toolbar('refresh,add,edit,del')} diff --git a/application/admin/view/user/rule/index.html b/application/admin/view/user/rule/index.html index ff57bad..ffe49bd 100755 --- a/application/admin/view/user/rule/index.html +++ b/application/admin/view/user/rule/index.html @@ -8,13 +8,13 @@
{:build_toolbar('refresh,edit,del')} diff --git a/application/admin/view/wechat/autoreply/index.html b/application/admin/view/wechat/autoreply/index.html index 759f82a..0761820 100755 --- a/application/admin/view/wechat/autoreply/index.html +++ b/application/admin/view/wechat/autoreply/index.html @@ -8,10 +8,10 @@
{:build_toolbar('refresh,add,edit,del')}
diff --git a/application/admin/view/wechat/menu/index.html b/application/admin/view/wechat/menu/index.html index 4377c89..2f65461 100755 --- a/application/admin/view/wechat/menu/index.html +++ b/application/admin/view/wechat/menu/index.html @@ -76,8 +76,8 @@ 可直接拖动菜单排序
- 加载服务端菜单 - 保存并发布 + 加载 + 发布
diff --git a/application/api/controller/Home.php b/application/api/controller/Home.php index 1a3badc..298465d 100644 --- a/application/api/controller/Home.php +++ b/application/api/controller/Home.php @@ -405,6 +405,10 @@ class Home extends V1 if (preg_match('/^https?:\/\/|^\/uploads\/|^\/static\//i', $iconKey)) { return $iconKey; } + $iconFileName = (strpos($iconKey, '.') !== false) ? $iconKey : $iconKey . '.png'; + if (file_exists(ROOT_PATH . 'public/static/icons/' . $iconFileName)) { + return '/static/icons/' . $iconFileName; + } $keyMap = [ 'cat-job' => 'cat-job.png', 'cat-house' => 'cat-house.png', diff --git a/application/api/controller/Member.php b/application/api/controller/Member.php index b1b5428..627efec 100644 --- a/application/api/controller/Member.php +++ b/application/api/controller/Member.php @@ -45,9 +45,10 @@ class Member extends V1 } /** - * M2 会员权益 + * M2 获取会员权益配置 * GET /api/v1/member/benefits → {freeView,postDiscount,distRate,benefits[]} - * 规则:读配置 member.benefit,未配置返回默认 + * 规则:读取系统真实配置 member.benefit,未配置时回落默认真实有效权益 + * @return void */ public function benefits() { @@ -55,7 +56,7 @@ class Member extends V1 'freeView' => 20, 'postDiscount' => '8 折', 'distRate' => '一级 20% / 二级 10%', - 'benefits' => ['每日免费查看 20 条联系方式', '发布信息 8 折', '专属会员标识', '分销佣金加速结算'], + 'benefits' => ['每日免费查看 20 条联系方式', '发布信息 8 折', '专属会员标识', '赠送大量发布额度'], ]; $cfg = $this->cfg('member.benefit', null); @@ -305,6 +306,10 @@ class Member extends V1 $list = []; foreach ($rows as $row) { + // 惰性超时处理:若 pending 且已超时则自动关闭 + if ((string)$row['status'] === 'pending') { + $row = \app\common\library\OrderClose::checkAndCloseIfExpired($row); + } $list[] = [ 'id' => (int)$row['id'], 'orderNo' => (string)$row['order_no'], diff --git a/application/api/controller/Order.php b/application/api/controller/Order.php index 377c84e..7488766 100644 --- a/application/api/controller/Order.php +++ b/application/api/controller/Order.php @@ -2,6 +2,8 @@ namespace app\api\controller; +use app\common\library\CouponService; +use app\common\library\OrderClose; use think\Db; /** @@ -107,4 +109,212 @@ class Order extends V1 return ['balance' => $balance, 'amount' => $amount]; } + + /** + * POST /api/v1/order/cancel + * 主动取消未支付订单 + * 入参:{orderNo} 或 {id} + * + * @return void + */ + public function cancel() + { + $user = $this->auth(); + $orderNo = trim((string)$this->input('orderNo', '')); + $orderId = (int)$this->input('id', 0); + + if ($orderNo === '' && $orderId <= 0) { + $this->fail('请提供订单编号或订单ID'); + } + + $query = Db::name('fc_order')->where('user_id', $user['id']); + if ($orderNo !== '') { + $query->where('order_no', $orderNo); + } else { + $query->where('id', $orderId); + } + $order = $query->find(); + + if (!$order) { + $this->fail('订单不存在', 404); + } + + if ((string)$order['status'] === 'paid') { + $this->fail('已支付订单无法取消,如需退款请联系客服'); + } + if ((string)$order['status'] === 'closed') { + $this->fail('订单已是关闭状态,无需重复取消'); + } + if ((string)$order['status'] !== 'pending') { + $this->fail('当前订单状态不支持取消'); + } + + $closed = OrderClose::close($order, 'user_cancel'); + if (!$closed) { + $this->fail('取消订单失败,请稍后重试'); + } + + $this->ok([ + 'orderNo' => (string)$order['order_no'], + 'status' => 'closed', + ], '订单已成功取消'); + } + + /** + * GET /api/v1/order/detail + * 获取订单详情 + * 入参:orderNo 或 id + * + * @return void + */ + public function detail() + { + $user = $this->auth(); + $orderNo = trim((string)$this->input('orderNo', '')); + $orderId = (int)$this->input('id', 0); + + if ($orderNo === '' && $orderId <= 0) { + $this->fail('请提供订单编号或订单ID'); + } + + $query = Db::name('fc_order')->where('user_id', $user['id']); + if ($orderNo !== '') { + $query->where('order_no', $orderNo); + } else { + $query->where('id', $orderId); + } + $order = $query->find(); + + if (!$order) { + $this->fail('订单不存在', 404); + } + + // 惰性超时检查:如果是待支付且已超时,自动关闭 + $order = OrderClose::checkAndCloseIfExpired($order); + + $now = time(); + $timeoutSeconds = OrderClose::getTimeoutSeconds(); + $createtime = isset($order['createtime']) ? (int)$order['createtime'] : 0; + $expireSeconds = 0; + if ((string)$order['status'] === 'pending' && $createtime > 0) { + $expireSeconds = max(0, ($createtime + $timeoutSeconds) - $now); + } + + // 状态与类型文本映射 + $statusMap = [ + 'pending' => '待支付', + 'paid' => '已支付', + 'refunding' => '退款中', + 'refunded' => '已退款', + 'closed' => '已关闭', + ]; + $typeMap = [ + 'post' => '信息发布', + 'member' => '开通会员', + 'recharge' => '余额充值', + 'payview' => '付费查看', + ]; + + $type = (string)$order['type']; + $relatedId = (int)$order['related_id']; + $relatedInfo = null; + + // 根据业务类型获取详细关联信息 + if ($type === 'post' && $relatedId > 0) { + $post = Db::name('fc_post')->where('id', $relatedId)->find(); + if ($post) { + $categoryName = Db::name('fc_category')->where('id', (int)$post['category_id'])->value('name') ?: ''; + $relatedInfo = [ + 'postId' => (int)$post['id'], + 'title' => (string)$post['title'], + 'categoryName' => $categoryName, + 'cover' => (string)$post['cover'], + 'price' => (float)$post['price'], + 'priceUnit' => (string)$post['price_unit'], + 'auditStatus' => (int)$post['audit_status'], + 'status' => (int)$post['status'], + ]; + } + } elseif ($type === 'member' && $relatedId > 0) { + $plan = Db::name('fc_plan')->where('id', $relatedId)->find(); + if ($plan) { + $postQuota = (int)$plan['post_quota']; + $rights = ['专属会员身份标示']; + if ($postQuota > 0) { + $rights[] = "赠送免费发布 {$postQuota} 条"; + } + $rights[] = '同城专属推广推荐'; + $rights[] = '信息置顶尊享特惠'; + $relatedInfo = [ + 'planId' => (int)$plan['id'], + 'name' => (string)$plan['name'], + 'days' => (int)$plan['days'], + 'originPrice' => (float)$plan['origin_price'], + 'price' => (float)$plan['price'], + 'postQuota' => $postQuota, + 'rights' => $rights, + ]; + } + } elseif ($type === 'payview' && $relatedId > 0) { + $post = Db::name('fc_post')->where('id', $relatedId)->find(); + if ($post) { + $categoryName = Db::name('fc_category')->where('id', (int)$post['category_id'])->value('name') ?: ''; + $relatedInfo = [ + 'postId' => (int)$post['id'], + 'title' => (string)$post['title'], + 'categoryName' => $categoryName, + 'contact' => (string)$post['contact'], + 'phone' => (string)$post['phone'], + ]; + } + } elseif ($type === 'recharge') { + $relatedInfo = [ + 'target' => '同城便民服务钱包', + 'usage' => '可用于全平台信息发布、置顶推广及各类便民生活增值服务', + ]; + } + + // 优惠券信息 + $couponName = ''; + if (!empty($order['coupon_id'])) { + $couponName = (string)Db::name('fc_user_coupon')->alias('uc') + ->join('fc_coupon c', 'c.id = uc.coupon_id', 'LEFT') + ->where('uc.id', (int)$order['coupon_id']) + ->value('c.name'); + } + + // 用户与安全信息 + $userMobile = isset($user['mobile']) ? (string)$user['mobile'] : ''; + if ($userMobile !== '' && strlen($userMobile) >= 11) { + $userMobile = substr($userMobile, 0, 3) . '****' . substr($userMobile, 7); + } + + $detail = [ + 'id' => (int)$order['id'], + 'orderNo' => (string)$order['order_no'], + 'type' => $type, + 'typeText' => isset($typeMap[$type]) ? $typeMap[$type] : '其它订单', + 'title' => (string)$order['title'], + 'amount' => (float)$order['amount'], + 'originAmount' => (!empty($order['origin_amount']) && (float)$order['origin_amount'] > 0) ? (float)$order['origin_amount'] : (float)$order['amount'], + 'couponAmount' => isset($order['coupon_amount']) ? (float)$order['coupon_amount'] : 0.0, + 'couponId' => isset($order['coupon_id']) ? (int)$order['coupon_id'] : 0, + 'couponName' => $couponName, + 'payType' => (string)$order['pay_type'], + 'payTypeText' => (string)$order['pay_type'] === 'balance' ? '余额支付' : '微信支付', + 'status' => (string)$order['status'], + 'statusText' => isset($statusMap[$order['status']]) ? $statusMap[$order['status']] : (string)$order['status'], + 'refundReason' => isset($order['refund_reason']) ? (string)$order['refund_reason'] : '', + 'userAccount' => $userMobile ?: (isset($user['username']) ? (string)$user['username'] : ''), + 'createdAt' => $this->iso($order['createtime']), + 'payTime' => !empty($order['paytime']) ? $this->iso($order['paytime']) : null, + 'closeTime' => ((string)$order['status'] === 'closed' && !empty($order['updatetime'])) ? $this->iso($order['updatetime']) : null, + 'expireSeconds' => $expireSeconds, + 'timeoutSeconds' => $timeoutSeconds, + 'relatedId' => $relatedId, + 'relatedInfo' => $relatedInfo, + ]; + + $this->ok($detail); + } } diff --git a/application/api/controller/Pay.php b/application/api/controller/Pay.php index 9df41b4..252e207 100644 --- a/application/api/controller/Pay.php +++ b/application/api/controller/Pay.php @@ -138,13 +138,9 @@ class Pay extends V1 if ((string)$order['pay_type'] !== 'wxpay') { $this->fail('该订单不是微信支付'); } - // 超时未支付自动关闭(24 小时),避免 pending 订单无限堆积 - if (!empty($order['createtime']) && (int)$order['createtime'] < time() - 86400) { - Db::name('fc_order')->where('id', (int)$order['id'])->where('status', 'pending')->update([ - 'status' => 'closed', - 'updatetime' => time(), - ]); - \app\common\library\CouponService::release((string)$order['order_no']); + // 超时未支付自动关闭,避免已超时的订单继续被支付 + if (\app\common\library\OrderClose::isExpired($order)) { + \app\common\library\OrderClose::close($order, 'timeout_auto'); $this->fail('订单已超时关闭,请重新下单'); } diff --git a/application/api/controller/Post.php b/application/api/controller/Post.php index 923ad08..bee73c9 100644 --- a/application/api/controller/Post.php +++ b/application/api/controller/Post.php @@ -19,6 +19,7 @@ use app\common\library\CouponService; * GET /api/v1/post/:id P5 信息详情 * POST /api/v1/post/:id/pay-view P6 付费查看联系方式 * POST /api/v1/post/:id/comment P7 发表评价 + * POST /api/v1/post/comment/:id/reply P11 发布者回复评价 * GET /api/v1/post/:id/comments P10 评价列表(详情页「用户评价」) * * 计费口径(后台「发布与费用配置」维护,真源=fc_config); @@ -247,12 +248,25 @@ class Post extends V1 $order = null; $balanceAfter = 0; + $identityTypeInput = (string)$this->input('identityType', 'person'); + $identityType = ($identityTypeInput === 'merchant' || $identityTypeInput === '2') ? 2 : 1; + if ($identityType === 2) { + $userExt = Db::name('fc_user_ext')->where('user_id', $user['id'])->find(); + if (!$userExt || (int)$userExt['user_type'] !== 2) { + $identityType = 1; + } + } + $price = max(0, round((float)$this->input('price', 0), 2)); + $priceUnit = mb_substr(trim((string)$this->input('priceUnit', '')), 0, 16); + $wechat = mb_substr(trim((string)$this->input('wechat', '')), 0, 64); + $address = mb_substr(trim((string)$this->input('address', '')), 0, 128); + try { // 发布落库 + 扣款 + 订单 + 额度扣减 同一事务:任一步失败整体回滚 Db::transaction(function () use ( &$postId, &$order, &$balanceAfter, &$quotaLeft, $paid, $user, $amount, $originAmount, $couponAmount, $userCouponId, $payType, - $now, $categoryId, $title, $content, $phone, $useQuota, $region, $cover + $now, $categoryId, $identityType, $title, $content, $phone, $wechat, $price, $priceUnit, $address, $useQuota, $region, $cover ) { $paidNow = $paid && $payType === 'balance'; // 订单号提前生成:优惠券锁定需要绑定订单号 @@ -277,18 +291,19 @@ class Post extends V1 $postId = Db::name('fc_post')->insertGetId([ 'user_id' => $user['id'], 'category_id' => $categoryId, + 'identity_type' => $identityType, 'title' => $title, 'content' => $content, 'cover' => $cover, 'media' => json_encode($this->mediaArray(), JSON_UNESCAPED_UNICODE), - 'price' => round((float)$this->input('price', 0), 2), - 'price_unit' => (string)$this->input('priceUnit', ''), + 'price' => $price, + 'price_unit' => $priceUnit, 'area' => $region['area'], 'district_id' => $region['district_id'], - 'address' => (string)$this->input('address', ''), + 'address' => $address, 'contact' => (string)$this->input('contact', ''), 'phone' => $phone, - 'wechat' => '', + 'wechat' => $wechat, 'tags' => $this->tagsString(), // LBS 坐标(gcj02;未定位/为 0 时存 NULL,首页「附近」不参与距离排序) 'lat' => $this->coord('lat', 90), @@ -628,18 +643,29 @@ class Post extends V1 $list = []; foreach ($rows as $row) { $media = json_decode((string)$row['media'], true); + $tags = []; + if (!empty($row['tags'])) { + $tags = array_values(array_filter(array_map('trim', explode(',', (string)$row['tags'])))); + } $list[] = [ - 'draftId' => (int)$row['id'], - 'title' => (string)$row['title'], - 'content' => (string)$row['content'], - 'categoryId' => (int)$row['category_id'], - 'media' => is_array($media) ? $media : [], - 'contact' => (string)$row['contact'], - 'phone' => (string)$row['phone'], - 'address' => (string)$row['address'], - 'area' => (string)$row['area'], - 'areaId' => (int)$row['district_id'], - 'savedAt' => $this->iso($row['savedat']), + 'draftId' => (int)$row['id'], + 'title' => (string)$row['title'], + 'content' => (string)$row['content'], + 'categoryId' => (int)$row['category_id'], + 'identityType' => (isset($row['identity_type']) && (int)$row['identity_type'] === 2) ? 'merchant' : 'person', + 'media' => is_array($media) ? $media : [], + 'price' => (float)(isset($row['price']) ? $row['price'] : 0), + 'priceUnit' => (string)(isset($row['price_unit']) ? $row['price_unit'] : ''), + 'contact' => (string)$row['contact'], + 'phone' => (string)$row['phone'], + 'wechat' => (string)(isset($row['wechat']) ? $row['wechat'] : ''), + 'tags' => $tags, + 'address' => (string)$row['address'], + 'lat' => isset($row['lat']) && $row['lat'] !== null ? (float)$row['lat'] : null, + 'lng' => isset($row['lng']) && $row['lng'] !== null ? (float)$row['lng'] : null, + 'area' => (string)$row['area'], + 'areaId' => (int)$row['district_id'], + 'savedAt' => $this->iso($row['savedat']), ]; } $this->ok($list); @@ -679,19 +705,29 @@ class Post extends V1 $content = (string)$this->input('content', ''); $now = time(); + $identityTypeInput = (string)$this->input('identityType', 'person'); + $identityType = ($identityTypeInput === 'merchant' || $identityTypeInput === '2') ? 2 : 1; + $data = [ - 'user_id' => $user['id'], - 'category_id' => $categoryId, - 'title' => $title, - 'content' => $content, - 'media' => json_encode($this->mediaArray(), JSON_UNESCAPED_UNICODE), - 'contact' => (string)$this->input('contact', ''), - 'phone' => (string)$this->input('phone', ''), - 'address' => (string)$this->input('address', ''), - 'area' => (string)$this->input('area', ''), - 'district_id' => (int)$this->input('areaId', (int)$this->input('districtId', 0)), - 'savedat' => $now, - 'updatetime' => $now, + 'user_id' => $user['id'], + 'category_id' => $categoryId, + 'identity_type' => $identityType, + 'title' => $title, + 'content' => $content, + 'media' => json_encode($this->mediaArray(), JSON_UNESCAPED_UNICODE), + 'price' => max(0, round((float)$this->input('price', 0), 2)), + 'price_unit' => mb_substr(trim((string)$this->input('priceUnit', '')), 0, 16), + 'contact' => (string)$this->input('contact', ''), + 'phone' => (string)$this->input('phone', ''), + 'wechat' => mb_substr(trim((string)$this->input('wechat', '')), 0, 64), + 'tags' => $this->tagsString(), + 'address' => mb_substr(trim((string)$this->input('address', '')), 0, 128), + 'lat' => $this->coord('lat', 90), + 'lng' => $this->coord('lng', 180), + 'area' => (string)$this->input('area', ''), + 'district_id' => (int)$this->input('areaId', (int)$this->input('districtId', 0)), + 'savedat' => $now, + 'updatetime' => $now, ]; if ($draftId > 0) { @@ -813,9 +849,11 @@ class Post extends V1 $used = ((string)$ext['free_view_date'] === $today) ? (int)$ext['free_view_used'] : 0; $data['freeViewLeft'] = $isMember ? max(0, $quota - $used) : 0; - if ($isOwner || $paid) { + if ($isOwner || $paid || $isMember) { $data['unlocked'] = true; + $data['phone'] = (string)$post['phone']; $data['contact'] = (string)$post['phone']; + $data['contactName'] = (string)(isset($post['contact']) ? $post['contact'] : ''); $data['wechat'] = $post['wechat'] !== '' ? (string)$post['wechat'] : ('tongcheng_' . $post['id']); } @@ -1009,6 +1047,11 @@ class Post extends V1 $this->fail('信息不存在', 404); } + // 禁止发布者对自己的信息发表评价 + if ((int)$post['user_id'] === (int)$user['id']) { + $this->fail('不能评价自己发布的信息'); + } + $now = time(); $commentId = Db::name('fc_comment')->insertGetId([ 'post_id' => $id, @@ -1035,6 +1078,68 @@ class Post extends V1 $this->ok(['commentId' => $commentId]); } + /** + * P11 发布者回复评价 + * POST /api/v1/post/comment/:id/reply {reply} → {id, reply, replytime} + * 规则:仅本信息的发布者可对该信息下的评价进行回复 + * + * @return void + */ + public function replyComment() + { + $user = $this->auth(); + $commentId = (int)$this->request->param('id', 0); + if (!$commentId) { + $commentId = (int)$this->input('commentId', 0); + } + if ($commentId <= 0) { + $this->fail('评价不存在', 404); + } + + $reply = trim((string)$this->input('reply', '')); + if ($reply === '') { + $this->fail('回复内容不能为空'); + } + if (mb_strlen($reply, 'UTF-8') > 200) { + $this->fail('回复内容不能超过 200 个字'); + } + + $comment = Db::name('fc_comment')->where('id', $commentId)->find(); + if (!$comment) { + $this->fail('评价不存在', 404); + } + + $post = Db::name('fc_post')->where('id', $comment['post_id'])->whereNull('deletetime')->find(); + if (!$post) { + $this->fail('对应信息不存在', 404); + } + + // 仅限信息发布者(楼主/商家)回复 + if ((int)$post['user_id'] !== (int)$user['id']) { + $this->fail('只有发布者本人可以回复评价', 403); + } + + $now = time(); + Db::name('fc_comment')->where('id', $commentId)->update([ + 'reply' => $reply, + 'replytime' => $now, + 'updatetime' => $now, + ]); + + $this->notify( + $comment['user_id'], + 'interact', + '评价收到回复', + '发布者回复了您对「' . (string)$post['title'] . '」的评价:' . $reply + ); + + $this->ok([ + 'id' => $commentId, + 'reply' => $reply, + 'replytime' => $now, + ]); + } + /** * P10 评价列表(详情页「用户评价」) * GET /api/v1/post/:id/comments → [{id,user,score,content,reply,createdAt}] @@ -1052,7 +1157,7 @@ class Post extends V1 ->join('user u', 'u.id = co.user_id', 'LEFT') ->where('co.post_id', $id) ->where('co.status', 1) - ->field('co.id, co.score, co.content, co.reply, co.top, co.createtime, u.nickname AS nickname') + ->field('co.id, co.user_id, co.score, co.content, co.reply, co.replytime, co.top, co.createtime, u.nickname AS nickname') ->order('co.top desc, co.id desc') ->select(); @@ -1060,10 +1165,12 @@ class Post extends V1 foreach ($rows as $row) { $list[] = [ 'id' => (int)$row['id'], + 'userId' => (int)$row['user_id'], 'user' => (string)$row['nickname'], 'score' => (int)$row['score'], 'content' => (string)$row['content'], 'reply' => (string)$row['reply'], + 'replytime' => !empty($row['replytime']) ? $this->iso($row['replytime']) : '', 'createdAt' => $this->iso($row['createtime']), ]; } @@ -1286,9 +1393,10 @@ class Post extends V1 { $tags = $this->input('tags', []); if (is_array($tags)) { + $tags = array_values(array_filter(array_map('trim', $tags))); $tags = implode(',', $tags); } - return (string)$tags; + return mb_substr(trim((string)$tags), 0, 128); } /** @@ -1370,6 +1478,7 @@ class Post extends V1 'id' => $postId, 'categoryId' => (int)$row['category_id'], 'categoryName' => $categoryName, + 'identityType' => (isset($row['identity_type']) && (int)$row['identity_type'] === 2) ? 'merchant' : 'person', 'title' => (string)$row['title'], 'content' => (string)$row['content'], 'cover' => (string)$row['cover'], @@ -1380,6 +1489,9 @@ class Post extends V1 'areaId' => (int)$row['district_id'], 'address' => (string)$row['address'], 'contact' => $this->maskPhone($row['phone']), + 'phone' => $this->maskPhone($row['phone']), + 'contactName' => (string)(isset($row['contact']) ? $row['contact'] : ''), + 'isTop' => isset($row['is_top']) && (int)$row['is_top'] === 1, 'views' => (int)$row['views'], 'likes' => (int)$row['likes'], 'isPaid' => (int)$row['is_paid'] === 1, diff --git a/application/api/controller/V1.php b/application/api/controller/V1.php index 92ec00e..2f5ea6b 100644 --- a/application/api/controller/V1.php +++ b/application/api/controller/V1.php @@ -68,13 +68,53 @@ class V1 extends Api /* ==================== 鉴权 ==================== */ - /** 从 Authorization: Bearer xxx 提取 token */ + /** + * 提取当前请求的认证 Token + * 兼容多种请求头与环境变量,防止 Nginx/Apache 过滤 Authorization 导致 401 循环: + * 1. Authorization: Bearer {token} + * 2. Header: token: {token} + * 3. Header: x-token: {token} + * 4. $_SERVER['HTTP_AUTHORIZATION'] / $_SERVER['REDIRECT_HTTP_AUTHORIZATION'] + * 5. $_SERVER['HTTP_TOKEN'] + * + * @return string 提取出的 Token 字符串 + */ protected function bearerToken() { + // 1. 标准 Authorization 请求头 $auth = $this->request->header('authorization', ''); - if ($auth && stripos($auth, 'bearer ') === 0) { - return trim(substr($auth, 7)); + if ($auth) { + if (stripos($auth, 'bearer ') === 0) { + return trim(substr($auth, 7)); + } + return trim($auth); } + + // 2. 兼容 FastAdmin 原生及常规 Header(Nginx 默认会保留普通 Header) + $token = $this->request->header('token', ''); + if ($token) { + return trim($token); + } + $xToken = $this->request->header('x-token', ''); + if ($xToken) { + return trim($xToken); + } + + // 3. 兼容服务器环境变量中的 Authorization(Apache/Nginx FastCGI 特殊映射) + $serverAuth = $this->request->server('HTTP_AUTHORIZATION', $this->request->server('REDIRECT_HTTP_AUTHORIZATION', '')); + if ($serverAuth) { + if (stripos($serverAuth, 'bearer ') === 0) { + return trim(substr($serverAuth, 7)); + } + return trim($serverAuth); + } + + // 4. 兼容 $_SERVER['HTTP_TOKEN'] + $serverToken = $this->request->server('HTTP_TOKEN', ''); + if ($serverToken) { + return trim($serverToken); + } + return ''; } diff --git a/application/command.php b/application/command.php index 28187b4..7c69495 100755 --- a/application/command.php +++ b/application/command.php @@ -21,5 +21,6 @@ return [ 'app\admin\command\FcMenu', 'app\admin\command\FcSettle', 'app\admin\command\FcVerifyDist', + 'app\admin\command\FcVerifyMember', 'app\admin\command\FcSeedPosts', ]; diff --git a/application/common/behavior/FcAssets.php b/application/common/behavior/FcAssets.php index e85ff6b..57ddf3c 100644 --- a/application/common/behavior/FcAssets.php +++ b/application/common/behavior/FcAssets.php @@ -66,6 +66,12 @@ class FcAssets ROOT_PATH . 'public' . DS . 'assets' . DS . 'css', ]; + // FastAdmin 后台公共脚本(表格操作列、工具栏按钮)不在 backend 目录,需单独纳入指纹 + $files = [ + ROOT_PATH . 'public' . DS . 'assets' . DS . 'js' . DS . 'require-table.js', + ROOT_PATH . 'public' . DS . 'assets' . DS . 'js' . DS . 'require-backend.min.js', + ]; + $mtime = 0; $count = 0; foreach ($dirs as $dir) { @@ -78,6 +84,17 @@ class FcAssets } } + foreach ($files as $file) { + if (!is_file($file)) { + continue; + } + $time = @filemtime($file); + if ($time > $mtime) { + $mtime = $time; + } + $count++; + } + // 最新修改时间 + 文件数量作为种子,crc32 转成纯数字(URL 安全,且兼容版本号 +1 逻辑) $fingerprint = sprintf('%u', crc32($mtime . '-' . $count)); return $fingerprint; diff --git a/application/common/library/FcConfig.php b/application/common/library/FcConfig.php index 7e2c995..c8db156 100644 --- a/application/common/library/FcConfig.php +++ b/application/common/library/FcConfig.php @@ -29,6 +29,23 @@ class FcConfig return (isset($cfg[$key]) && $cfg[$key] !== '') ? $cfg[$key] : $default; }; + // 解析会员权益配置(存为 JSON 字符串的 member.benefit) + $benefitRaw = $pick('member.benefit', ''); + $benefitCfg = []; + if ($benefitRaw) { + $decoded = json_decode($benefitRaw, true); + if (is_array($decoded)) { + $benefitCfg = $decoded; + } + } + $freeView = isset($benefitCfg['freeView']) ? (int)$benefitCfg['freeView'] : 20; + $postDiscount = isset($benefitCfg['postDiscount']) ? (string)$benefitCfg['postDiscount'] : '8 折'; + $payViewPrice = $pick('fee.payView', '1'); + $benefitsArr = isset($benefitCfg['benefits']) && is_array($benefitCfg['benefits']) + ? $benefitCfg['benefits'] + : ['每日免费查看 20 条联系方式', '发布信息 8 折', '专属会员标识', '赠送大量发布额度']; + $benefitsText = implode("\n", $benefitsArr); + return [ 'fc_miniapp' => [ 'name' => 'fc_miniapp', @@ -70,6 +87,17 @@ class FcConfig self::item('fc_post_yearQuota', '年卡条数', 'number', $pick('post.yearQuota', '500'), '年卡包含的发布条数', 'required;number'), ], ], + 'fc_member' => [ + 'name' => 'fc_member', + 'title' => '会员配置', + 'active' => false, + 'list' => [ + self::item('fc_member_freeView', '每日免费查看条数', 'number', $freeView, '会员每日可免费查看联系方式条数(默认 20 条)', 'required;number'), + self::item('fc_member_postDiscount', '单条发布折扣', 'string', $postDiscount, '付费发布时会员专享折扣,如「8折」或「8.5折」(默认 8 折)', 'required'), + self::item('fc_fee_payView', '非会员查看价格', 'number', $payViewPrice, '非会员单条解锁联系方式费用(元,默认 1 元)', 'required;number'), + self::item('fc_member_benefits', '会员特权清单', 'text', $benefitsText, '小程序端展示的特权清单,每行一条(支持后台自由增删与修改)'), + ], + ], 'fc_dist' => [ 'name' => 'fc_dist', 'title' => '分销配置', @@ -113,6 +141,9 @@ class FcConfig if ($has('fc_post_')) { self::savePublish($row); } + if ($has('fc_member_') || $has('fc_fee_')) { + self::saveMember($row); + } if ($has('fc_dist_')) { self::saveDistribution($row); } @@ -254,6 +285,58 @@ class FcConfig ]); } + /** + * 会员权益与联系方式查看费用配置 + * + * @param array $row 系统配置页提交的 row 数组 + * @return void + * @throws \Exception + */ + protected static function saveMember(array $row) + { + $freeView = isset($row['fc_member_freeView']) ? max(0, (int)$row['fc_member_freeView']) : 20; + $postDiscount = isset($row['fc_member_postDiscount']) ? trim((string)$row['fc_member_postDiscount']) : '8 折'; + if ($postDiscount === '') { + $postDiscount = '8 折'; + } + $payView = isset($row['fc_fee_payView']) ? max(0, round((float)$row['fc_fee_payView'], 2)) : 1; + + $benefitsRaw = isset($row['fc_member_benefits']) ? trim((string)$row['fc_member_benefits']) : ''; + $benefits = []; + if ($benefitsRaw !== '') { + $lines = preg_split('/[\r\n]+/', $benefitsRaw); + foreach ($lines as $line) { + $line = trim($line); + if ($line !== '') { + $benefits[] = $line; + } + } + } + if (empty($benefits)) { + $benefits = [ + '每日免费查看 ' . $freeView . ' 条联系方式', + '发布信息 ' . $postDiscount . ' 专属优惠', + '专属会员标识', + '赠送大量发布额度', + ]; + } + + $current = []; + $raw = Db::name('fc_config')->where('key', 'member.benefit')->value('value'); + if ($raw) { + $decoded = json_decode($raw, true); + if (is_array($decoded)) { + $current = $decoded; + } + } + $current['freeView'] = $freeView; + $current['postDiscount'] = $postDiscount; + $current['benefits'] = $benefits; + + self::put('member.benefit', $current, 'member', '会员权益配置'); + self::put('fee.payView', $payView, 'fee', '非会员单条查看联系方式价格'); + } + /** * 分销参数 * diff --git a/application/common/library/OrderClose.php b/application/common/library/OrderClose.php new file mode 100644 index 0000000..824b334 --- /dev/null +++ b/application/common/library/OrderClose.php @@ -0,0 +1,167 @@ +where('key', 'order.timeout_minutes')->value('value'); + if ($minutes === null || $minutes === '') { + $minutes = Db::name('fc_config')->where('key', 'trade.order_timeout')->value('value'); + } + $val = (int)$minutes; + if ($val > 0) { + return $val * 60; + } + return self::DEFAULT_TIMEOUT_SECONDS; + } + + /** + * 判断订单是否超时 + * + * @param array $order fc_order 行 + * @param int|null $now 当前时间戳 + * @return bool + */ + public static function isExpired(array $order, $now = null) + { + if (empty($order) || (string)$order['status'] !== 'pending') { + return false; + } + $now = $now ?: time(); + $createtime = isset($order['createtime']) ? (int)$order['createtime'] : 0; + if ($createtime <= 0) { + return false; + } + $timeout = self::getTimeoutSeconds(); + return ($now - $createtime) >= $timeout; + } + + /** + * 关闭订单(原子操作,支持主动取消或超时自动关闭) + * + * @param array $order fc_order 行(至少含 id、order_no、user_id、type、status、related_id) + * @param string $reason 关闭原因:user_cancel(用户主动取消)、timeout_auto(超时自动关闭)、admin_cancel(后台取消) + * @return bool 是否成功关闭 + */ + public static function close(array $order, $reason = 'user_cancel') + { + $orderId = isset($order['id']) ? (int)$order['id'] : 0; + $orderNo = isset($order['order_no']) ? (string)$order['order_no'] : ''; + if ($orderId <= 0 || $orderNo === '') { + return false; + } + + $now = time(); + $closed = false; + + try { + Db::transaction(function () use ($orderId, $orderNo, $order, $reason, $now, &$closed) { + // 条件更新,保证只有 pending 状态的订单才能转为 closed,天然防并发与重复关闭 + $affected = Db::name('fc_order') + ->where('id', $orderId) + ->where('status', 'pending') + ->update([ + 'status' => 'closed', + 'refund_reason' => ($reason === 'user_cancel' ? '用户主动取消' : ($reason === 'timeout_auto' ? '超时未支付自动关闭' : '管理员关闭')), + 'updatetime' => $now, + ]); + + if (!$affected) { + $closed = false; + return; + } + + $closed = true; + + // 1. 释放优惠券(若有) + CouponService::release($orderNo); + + // 2. 关联业务的回收处理 + $type = isset($order['type']) ? (string)$order['type'] : ''; + $relatedId = isset($order['related_id']) ? (int)$order['related_id'] : 0; + + // 若是未付款的发布信息,将关联的草稿或帖子置为下架/关闭,避免未付款直接审核显示 + if ($type === 'post' && $relatedId > 0) { + Db::name('fc_post') + ->where('id', $relatedId) + ->where('user_id', (int)$order['user_id']) + ->where('audit_status', 0) // 仅当尚未审核通过时 + ->update([ + 'status' => 0, // 设为下架/关闭 + 'updatetime' => $now, + ]); + } + + // 3. 发送站内消息通知 + $userId = isset($order['user_id']) ? (int)$order['user_id'] : 0; + if ($userId > 0) { + $title = $reason === 'user_cancel' ? '订单已取消' : '订单已超时关闭'; + $orderTitle = isset($order['title']) ? (string)$order['title'] : '同城订单'; + $content = $reason === 'user_cancel' + ? "您的订单【{$orderTitle}】(订单号:{$orderNo})已主动取消。" + : "您的订单【{$orderTitle}】(订单号:{$orderNo})因超过支付时效已自动关闭,锁定的优惠券已退回。"; + + Db::name('fc_message')->insert([ + 'user_id' => $userId, + 'type' => 'system', + 'title' => $title, + 'content' => $content, + 'isread' => 0, + 'readtime' => null, + 'createtime' => $now, + ]); + } + }); + } catch (\Throwable $e) { + Log::record("订单关闭失败:订单 {$orderNo},原因:{$e->getMessage()}", 'error'); + return false; + } + + return $closed; + } + + /** + * 惰性检查并在超时时代为关闭 + * + * @param array $order fc_order 行 + * @return array 最新订单数据 + */ + public static function checkAndCloseIfExpired(array $order) + { + if (empty($order) || (string)$order['status'] !== 'pending') { + return $order; + } + + if (self::isExpired($order)) { + if (self::close($order, 'timeout_auto')) { + $order['status'] = 'closed'; + $order['updatetime'] = time(); + } + } + + return $order; + } +} diff --git a/application/route.php b/application/route.php index 5b71e2a..91e6db6 100755 --- a/application/route.php +++ b/application/route.php @@ -51,7 +51,8 @@ return [ 'api/v1/home/locate' => 'api/Home/locate', /* =============== 三、用户端 · 信息发布与详情(长路径优先) =============== */ - 'api/v1/post/:id/pay-view' => 'api/Post/payView', + 'api/v1/post/:id/pay-view' => 'api/Post/payView', + 'api/v1/post/comment/:id/reply' => 'api/Post/replyComment', 'api/v1/post/:id/comment' => 'api/Post/comment', 'api/v1/post/:id/comments' => 'api/Post/comments', 'api/v1/post/create' => 'api/Post/create', @@ -99,6 +100,8 @@ return [ * · 本组均为静态路径,与上面的 message/:id(\d+)及下面的 post/:id 无交叉。 */ 'api/v1/order/recharge' => 'api/Order/recharge', + 'api/v1/order/cancel' => 'api/Order/cancel', + 'api/v1/order/detail' => 'api/Order/detail', 'api/v1/pay/prepay' => 'api/Pay/prepay', 'api/v1/pay/status' => 'api/Pay/status', 'api/v1/pay/notify' => 'api/Pay/notifyCallback', diff --git a/cookie.txt b/cookie.txt new file mode 100644 index 0000000..aebdc87 --- /dev/null +++ b/cookie.txt @@ -0,0 +1,5 @@ +# Netscape HTTP Cookie File +# https://curl.se/docs/http-cookies.html +# This file was generated by libcurl! Edit at your own risk. + +127.0.0.1 FALSE / FALSE 0 PHPSESSID nmpg9honta1817mb0b59kks3e9 diff --git a/docs/测试用例.md b/docs/测试用例.md new file mode 100644 index 0000000..2440fa1 --- /dev/null +++ b/docs/测试用例.md @@ -0,0 +1,297 @@ +# 同城分类信息与便民服务平台 · 全功能系统测试用例文档 + +> **版本**:v1.3.0 +> **编写时间**:2026-10-23 +> **适用范围**:Uni-app 微信小程序端、FastAdmin PC 管理端、ThinkPHP 5.0.29 后端 API 接口契约、MySQL 5.7 业务数据流 +> **遵循规范**:`docs/05-后端实现规范.md`、`docs/06-后台字段中文化规范.md`、`AGENTS.md` 业务与春绿主题设计规范 + +--- + +## 一、 测试概述与环境准备 + +### 1.1 系统架构与测试范围 +本平台定位为基于 LBS 地理位置的**同城分类信息与本地生活便民服务平台**,涵盖招聘求职、房产租售、二手闲置、车辆买卖、本地生活等业务。系统包含两大终端: +1. **用户端(Uni-app 微信小程序)**:春绿(Spring Green)设计主题,提供浏览、搜索、发布、支付、会员、分销、互动等功能。 +2. **管理端(FastAdmin PC 后台)**:提供审核、用户/商家治理、财务资金流水、分销提现、系统参数与发布模式配置等功能。 + +### 1.2 测试环境与账号矩阵 + +| 角色 | 账号标识 / OpenID | 初始状态 / 权限 | 用途 | +| :--- | :--- | :--- | :--- | +| **超级管理员** | `admin` | 超级管理员权限(ID: 1),全功能菜单 | 平台审核、参数配置、财务审批、置顶管理 | +| **普通个人用户 A** | `wx_user_test_01` | 未开通会员,余额 0,未认证商家 | 测试基础登录、免费发帖、付费查看、开通会员 | +| **普通个人用户 B** | `wx_user_test_02` | 由用户 A 邀请注册(带 invite_code) | 测试二级分销关系绑定、消费佣金结算 | +| **已认证商家用户** | `wx_merchant_01` | 商家认证通过(`user_type=2`),店铺正常 | 测试商家发帖、展示营业执照与认证标识 | +| **VIP 会员用户** | `wx_vip_user_01` | 已开通月卡套餐,拥有发布额度与免费查看次数 | 测试会员免单发帖、会员查看、单条折扣计算 | + +### 1.3 核心业务规则对应索引(BR-01 ~ BR-16) + +| 规则编号 | 核心业务规则要求 | 触发端点 / 对应断言 | +| :--- | :--- | :--- | +| **BR-01** | 商家身份切换必须上传营业执照完成资质认证 | `POST /auth/switch-type` 缺执照报「商家用户需上传营业执照完成资质认证」 | +| **BR-02** | 手机号格式必须满足 `^1\d{10}$` 正则表达式 | `POST /auth/bind-phone` 格式错误报「手机号格式不正确」 | +| **BR-03** | 发布信息必填 categoryId、title、content,标题≤40字,内容≤500字 | `POST /post/create` 缺项或超长时报错 | +| **BR-04** | 新发布信息默认状态为待审核(audit_status=0),审核通过方可公开展示 | 前台列表过滤 `audit_status=1 AND status=1 AND deletetime IS NULL` | +| **BR-05** | 付费查看仅支持 `wxpay`(微信)与 `balance`(余额) | `POST /post/:id/pay-view` 非法方式报「支付方式不支持」 | +| **BR-06** | 评价评分必须在 1-5 之间,且评价内容不可为空 | `POST /post/:id/comment` 报「评分需在 1-5 之间」/「评价内容不能为空」 | +| **BR-07** | 开通会员套餐 planId 不能为空 | `POST /member/open` 缺项报「请选择会员套餐」 | +| **BR-08** | 一级分佣与二级分佣比例总和不能超过 100% | `POST /admin/dist/setting` 超标报「一级+二级分佣比例不能超过 100%」 | +| **BR-09** | 提现金额需 `>0` 且 `≤可提现余额`;管理端驳回必须填写驳回原因 | 提现超额报「提现金额超过可提现余额」;驳回缺原因报「驳回需填写原因」 | +| **BR-10** | 订单退款金额必须 `> 0` | `POST /admin/order/:id/refund` 金额非法报「退款金额需大于 0」 | +| **BR-11** | 审核操作状态仅支持 1(通过)和 2(驳回) | 审核提交非法值报「审核状态仅支持通过(1)/驳回(2)」 | +| **BR-12** | 新建管理角色必须填写角色名称并至少分配一项权限节点 | `POST /admin/role` 报「请填写角色名称」/「请至少分配一项权限」 | +| **BR-13** | 发布计费受控:套餐额度 → 每日免费条数 → 单条付费,三者皆无拒绝发布 | 免费模式全免;付费模式逐级核销扣除 | +| **BR-14** | 发布金额服务端定价,客户端传入的 amount/paid 被忽略,防篡改 | `POST /post/create` 金额强制由后台 `post.*` 配置计算 | +| **BR-15** | 置顶优先:置顶(`is_top=1`)信息在首页与「我的发布」中排序绝对置顶 | 列表按 `is_top DESC, updatetime DESC, id DESC` 排序 | +| **BR-16** | 会员单条付费按折扣计算:`round(singlePrice × discountRate, 2)` | 会员享受单条发帖优惠,由服务端严格折算 | + +--- + +## 二、 核心业务闭环端到端测试(E2E Flows) + +### E2E-01:同城信息发布与全链路审核流转测试 + +```mermaid +flowchart TD + A[用户填写发布内容] --> B[选择服务区域与分类] + B --> C{系统发布模式} + C -->|free 免费模式| D[生成待审核信息 audit=0] + C -->|paid 付费模式| E{是否扣减额度/支付} + E -->|扣减会员条数/单条付款| D + D --> F[管理后台待审列表 AU1] + F -->|管理员审核通过| G[状态变更为 audit=1, status=1] + G --> H[分类 post_count +1] + G --> I[发布者收到系统审核通过通知] + G --> J[前台首页/分类信息流可见] + F -->|管理员驳回并填写原因| K[状态变更为 audit=2] + K --> L[发布者收到驳回通知及原因] +``` + +- **用例编号**:`TC-E2E-001` +- **优先级**:P0 +- **测试步骤**: + 1. 普通用户登录小程序,进入发布页面 `pages/post/create`。 + 2. 填写标题《九成新家用洗衣机转让》,选择分类「二手闲置」,填写价格 450 元,上传 2 张实物图,选择所在服务区域「云岩区」,填写联系电话。 + 3. 点击提交,验证前端防重复提交状态,请求 `POST /api/v1/post/create`。 + 4. 检查响应数据中 `auditStatus` 是否为 0(待审核),信息不出现在小程序公共列表。 + 5. 登录 PC 管理端,进入「信息管理 → 信息列表」或调用 `GET /api/v1/admin/posts/pending`,确认该记录在待审核列表中。 + 6. 管理员点击「审核通过」(`POST /api/v1/admin/post/:id/audit`,`auditStatus=1`)。 + 7. 刷新小程序首页信息流 `GET /api/v1/home/feed`,验证新发布信息正确展示在信息流顶部;进入通知中心,验证收到「信息审核通过」系统通知。 + 8. 测试驳回分支:发布另一条信息,后台选择驳回并输入原因「含违规引流广告」,验证发布者收到包含驳回原因的站内通知。 + +--- + +### E2E-02:电话脱敏与付费查看联系方式闭环 + +- **用例编号**:`TC-E2E-002` +- **优先级**:P0 +- **测试步骤**: + 1. 用户 A 发布一条信息,联系电话为 `13800138000`。 + 2. 用户 B 未登录访问该信息详情页 `GET /api/v1/post/:id`,断言返回的 contact 为脱敏手机号(例如 `138****8000`),无一键拨号明文。 + 3. 用户 B 登录,点击「查看完整联系方式」,弹出付费确认窗口(单次查看金额 1.00 元)。 + 4. 用户 B 选择微信支付或账户余额支付,调用 `POST /api/v1/post/:id/pay-view`。 + 5. 支付成功后,数据库 `fa_fc_pay_view` 写入解锁记录,扣除用户相应金额并记入 `fa_fc_finance_flow`。 + 6. 再次进入该信息详情页,断言接口返回 `unlocked: true`,页面直接展示完整明文电话并支持一键拨打,无需重复扣费。 + +--- + +### E2E-03:会员开通与发布额度核销闭环 + +- **用例编号**:`TC-E2E-003` +- **优先级**:P0 +- **测试步骤**: + 1. 用户进入「会员中心」`pages/member/index`,拉取套餐列表 `GET /api/v1/member/plans`。 + 2. 选择「月卡会员(含 30 条发布额度)」,点击开通 `POST /api/v1/member/open`。 + 3. 模拟微信支付成功回调 `POST /api/v1/pay/notify`。 + 4. 验证用户扩展表 `fa_fc_user_ext` 中 `is_member=1`、`member_expiretime` 增加 30 天,`post_quota_left` 增加 30 条。 + 5. 切换系统发布模式为付费模式(`post.mode=paid`)。 + 6. 用户发布新信息,系统自动匹配并扣除套餐额度(`post_quota_left` 变为 29),无需额外唤起支付。 + +--- + +### E2E-04:二级分销绑定与裂变佣金提现流转 + +- **用例编号**:`TC-E2E-004` +- **优先级**:P0 +- **测试步骤**: + 1. 用户 A 分享专属小程序邀请码 / 邀请链接给新用户 B。 + 2. 用户 B 通过带参数的场景值扫码登录,系统自动在 `fa_fc_dist_relation` 建立关系(A 为 B 的一级上线)。 + 3. 用户 B 在平台开通会员套餐(实付金额 100 元)。 + 4. 系统触发分销结算,根据后台配置的分佣比例(假设一级 20%),为用户 A 生成佣金明细 `fa_fc_commission`,金额 20 元,并增加 A 的可提现余额。 + 5. 用户 A 进入「分销中心」提交提现申请 `POST /api/v1/distribution/withdraw`,申请提现 20 元。 + 6. 管理后台「交易财务 → 提现审核」显示该笔申请(`status=auditing`)。 + 7. 管理员点击打款通过,调用微信商家转账接口完成转账,状态更新为 `paid`,记录资金流水。 + +--- + +## 三、 用户端模块测试用例(Uni-app 小程序) + +### 3.1 认证与账号模块(Module-AUTH) + +| 用例编号 | 功能点 | 测试场景与输入 | 预期输出与断言 | 优先级 | +| :--- | :--- | :--- | :--- | :--- | +| `TC-AUTH-01` | 微信授权登录 | 用户首次打开小程序授权登录,携带有效 `code` | 返回 JWT Token、用户信息(`userInfo` 结构对齐 §四),`fa_fc_user_ext` 自动生成扩展行 | P0 | +| `TC-AUTH-02` | 登录入参校验 | 调用 `POST /auth/wx-login`,传入空参数 `{}` | HTTP 200,返回业务失败 `{"code":1, "message":"缺少微信授权 code"}` | P1 | +| `TC-AUTH-03` | 手机号快捷获取 | 点击 `'; + }).join('') + + '' + + '' + + ''; + + Layer.open({ + type: 1, + title: options.title || '填写原因', + area: ['460px', 'auto'], + content: html, + btn: [options.okText || '确定', '取消'], + yes: function (index, layero) { + var preset = $.trim(layero.find('.fc-reason__item.active').data('reason') || ''); + var extra = $.trim(layero.find('.fc-reason__text').val()); + var reason = preset ? (extra ? preset + ':' + extra : preset) : extra; + if (!reason) { + Toastr.warning('请选择或填写原因'); + return; + } + Layer.close(index); + callback(reason); + }, + success: function (layero) { + layero.find('.fc-reason__item').on('click', function () { + layero.find('.fc-reason__item').removeClass('active btn-success').addClass('btn-default'); + $(this).addClass('active btn-success').removeClass('btn-default'); + layero.find('.fc-reason__text').focus(); + }); + } + }); + }, + bindevent: function () { Form.api.bindevent($("form[role=form]")); } diff --git a/public/assets/js/backend/fc/postaudit.js b/public/assets/js/backend/fc/postaudit.js new file mode 100644 index 0000000..4f80940 --- /dev/null +++ b/public/assets/js/backend/fc/postaudit.js @@ -0,0 +1,344 @@ +define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], function ($, undefined, Backend, Table, Form, Format) { + + var Controller = { + /** + * 信息审核列表页面逻辑 + * + * 专职负责同城待审信息的核对、单条审核、一键通过/驳回与批量审核处理 + */ + index: function () { + // 初始化表格参数配置 + Table.api.init({ + extend: { + index_url: 'fc/postaudit/index' + location.search, + audit_url: 'fc/postaudit/audit', + table: 'fc_post', + } + }); + + var table = $("#table"); + var esc = Controller.api.esc; + var canAudit = table.data('operate-audit'); + + /** + * 打开审核工作台 + * + * @param {Object} row 行数据 + */ + function openAudit(row) { + Fast.api.open('fc/postaudit/detail?ids=' + row.id + '&mode=audit', '审核:' + esc(row.title), {area: ['860px', '88%']}); + } + + /** + * 打开只读详情 + * + * @param {Object} row 行数据 + */ + function openDetail(row) { + Fast.api.open('fc/postaudit/detail?ids=' + row.id + '&mode=view', '详情:' + esc(row.title), {area: ['860px', '88%']}); + } + + // 初始化表格 + table.bootstrapTable({ + url: $.fn.bootstrapTable.defaults.extend.index_url, + pk: 'id', + sortName: 'id', + sortOrder: 'desc', + escape: false, + clickToSelect: false, + commonSearch: true, + searchFormVisible: false, + fixedColumns: true, + fixedRightNumber: 1, + columns: [ + [ + {checkbox: true}, + { + field: 'id', + title: '序号', + operate: false, + sortable: false, + align: 'center', + width: '60px', + class: 'fc-serial', + table: table, + formatter: Format.serial + }, + { + field: 'cover', + title: '封面', + operate: false, + align: 'center', + width: '65px', + events: Table.api.events.image, + formatter: function (value, row) { + var img = value; + if (!img && row.media) { + try { + var raw = typeof row.media === 'string' ? row.media.trim() : ''; + if (raw.indexOf('[') === 0) { + var parsed = JSON.parse(raw); + img = parsed && parsed.length > 0 ? parsed[0] : ''; + } else if (raw) { + img = raw.split(',')[0]; + } + } catch (e) { + img = ''; + } + } + if (img) { + var fullUrl = Fast.api.cdnurl(img, true); + return ''; + } + return '无图'; + } + }, + { + field: 'title', + title: '标题', + operate: 'LIKE', + align: 'left', + events: { + 'click .btn-view-audit': function (e, value, row) { + e.stopPropagation(); + e.preventDefault(); + if (canAudit) { + openAudit(row); + } else { + openDetail(row); + } + } + }, + formatter: function (value, row) { + return '' + esc(value) + ''; + } + }, + { + field: 'category_id', + title: '分类', + addClass: 'selectpage', + extend: "data-source='fc/category/index' data-field='name'", + formatter: function (value, row) { + return row.category_name ? '' + esc(row.category_name) + '' : '-'; + } + }, + { + field: 'price', + title: '价格', + operate: 'BETWEEN', + align: 'right', + formatter: function (value, row) { + var unit = row.price_unit ? esc(row.price_unit) : ''; + if (value === null || value === '' || value === undefined || Number(value) === 0) { + return unit === '面议' + ? '面议' + : '免费'; + } + var num = Number(value).toLocaleString('zh-CN', {minimumFractionDigits: 2, maximumFractionDigits: 2}); + var suffix = (unit && unit !== '元') ? ' ' + unit + '' : ''; + return '¥' + num + '' + suffix; + } + }, + { + field: 'area', + title: '区域', + operate: 'LIKE', + formatter: function (value) { + return value ? esc(value) : '-'; + } + }, + { + field: 'user_id', + title: '发布用户', + addClass: 'selectpage', + extend: "data-source='user/user/index' data-field='nickname'", + formatter: function (value, row) { + return row.user_name ? ' ' + esc(row.user_name) : '-'; + } + }, + { + field: 'phone', + title: '联系电话', + operate: 'LIKE', + formatter: function (value, row) { + var contact = row.contact ? esc(row.contact) + ' ' : ''; + return value ? contact + esc(value) : '-'; + } + }, + { + field: 'audit_status', + title: '审核状态', + searchList: {0: '待审核', 1: '已通过', 2: '已驳回'}, + formatter: function (value) { + var map = { + 0: '待审核', + 1: '已通过', + 2: '已驳回' + }; + return map[value] || '未知'; + } + }, + { + field: 'createtime', + title: '提交时间', + operate: 'RANGE', + addclass: 'datetimerange', + autocomplete: false, + formatter: Table.api.formatter.datetime + }, + { + field: 'operate', + title: '操作', + align: 'center', + width: '100px', + table: table, + events: Table.api.events.operate, + formatter: Table.api.formatter.operate, + buttons: [ + { + name: 'audit', + text: '审核', + title: '进入审核工作台', + icon: '', + classname: 'btn btn-xs btn-success btn-click', + visible: function (row) { + return Number(row.audit_status) === 0 && canAudit; + }, + click: function (options, row) { + openAudit(row); + } + }, + { + name: 'detail', + text: '详情', + title: '查看详情', + icon: '', + classname: 'btn btn-xs btn-info btn-click', + click: function (options, row) { + openDetail(row); + } + } + ] + } + ] + ] + }); + + // 批量通过操作 + $('.toolbar').on('click', '.btn-batch-pass', function () { + var ids = Table.api.selectedids(table); + if (ids.length === 0) { + Toastr.warning('请先勾选要审核的信息'); + return; + } + Layer.confirm('确认批量通过选中的 ' + ids.length + ' 条信息并上架?', {title: '批量通过', btn: ['确认通过', '取消']}, function (index) { + Fast.api.ajax({ + url: 'fc/postaudit/pass', + data: {ids: ids.join(',')} + }, function () { + table.bootstrapTable('refresh'); + return false; + }); + Layer.close(index); + }); + }); + + // 批量驳回操作 + $('.toolbar').on('click', '.btn-batch-reject', function () { + var ids = Table.api.selectedids(table); + if (ids.length === 0) { + Toastr.warning('请先勾选要驳回的信息'); + return; + } + Controller.api.askReason({ + title: '批量驳回', + tip: '请选择或填写驳回原因,所选 ' + ids.length + ' 条信息发布者均会收到该通知。', + presets: ['内容不合规', '虚假信息', '违规联系方式', '重复发布', '类目选择错误'], + okText: '确认批量驳回' + }, function (reason) { + Fast.api.ajax({ + url: 'fc/postaudit/reject', + data: {ids: ids.join(','), reason: reason} + }, function () { + table.bootstrapTable('refresh'); + return false; + }); + }); + }); + + // 为表格绑定通用事件 + Table.api.bindevent(table); + + // 双击行直接打开审核工作台 + table.on('dbl-click-row.bs.table', function (e, row) { + if (canAudit) { + openAudit(row); + } else { + openDetail(row); + } + }); + }, + + api: { + /** + * HTML 转义防注入 + * + * @param {string} value + * @return {string} + */ + esc: function (value) { + return String(value === null || value === undefined ? '' : value).replace(/[&<>"']/g, function (c) { + return {'&': '&', '<': '<', '>': '>', '"': '"', "'": '''}[c]; + }); + }, + + /** + * 填写原因弹窗组件(驳回共用) + * + * @param {Object} options {title, tip, presets, okText} + * @param {Function} callback function(reason) + */ + askReason: function (options, callback) { + var presets = options.presets || []; + var esc = Controller.api.esc; + var html = '
' + + '

' + esc(options.tip || '请选择或填写原因') + '

' + + '
' + + presets.map(function (item) { + return ''; + }).join('') + + '
' + + '' + + '
'; + + Layer.open({ + type: 1, + title: options.title || '填写原因', + area: ['460px', 'auto'], + content: html, + btn: [options.okText || '确定', '取消'], + yes: function (index, layero) { + var preset = $.trim(layero.find('.fc-reason__item.active').data('reason') || ''); + var extra = $.trim(layero.find('.fc-reason__text').val()); + var reason = preset ? (extra ? preset + ':' + extra : preset) : extra; + if (!reason) { + Toastr.warning('请选择或填写原因'); + return; + } + Layer.close(index); + callback(reason); + }, + success: function (layero) { + layero.find('.fc-reason__item').on('click', function () { + layero.find('.fc-reason__item').removeClass('active btn-success').addClass('btn-default'); + $(this).addClass('active btn-success').removeClass('btn-default'); + layero.find('.fc-reason__text').focus(); + }); + } + }); + } + } + }; + + return Controller; +}); diff --git a/public/assets/js/backend/fc/userext.js b/public/assets/js/backend/fc/userext.js index bc6e178..4317dc6 100644 --- a/public/assets/js/backend/fc/userext.js +++ b/public/assets/js/backend/fc/userext.js @@ -70,7 +70,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], fu buttons: [ { name: 'recharge', - text: '余额充值', + text: '充值', title: '余额充值', classname: 'btn btn-xs btn-warning btn-click', click: function (options, row) { diff --git a/public/assets/js/backend/general/attachment.js b/public/assets/js/backend/general/attachment.js index a897ec0..f92e190 100755 --- a/public/assets/js/backend/general/attachment.js +++ b/public/assets/js/backend/general/attachment.js @@ -170,7 +170,7 @@ define(['jquery', 'bootstrap', 'backend', 'form', 'table', 'backend/format'], fu Fast.api.close($.extend({multiple: multiple}, row)); }, }, formatter: function () { - return ' ' + __('Choose') + ''; + return '' + __('Choose') + ''; } } ] diff --git a/public/assets/js/backend/wechat/response.js b/public/assets/js/backend/wechat/response.js index 389a7b7..b8b7152 100755 --- a/public/assets/js/backend/wechat/response.js +++ b/public/assets/js/backend/wechat/response.js @@ -63,7 +63,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'adminlte', 'backend/ Fast.api.close(row); }, }, formatter: function () { - return ' ' + __('Choose') + ''; + return '' + __('Choose') + ''; } } ] diff --git a/public/assets/js/require-backend.min.js b/public/assets/js/require-backend.min.js index 9e5e41d..f0f7757 100755 --- a/public/assets/js/require-backend.min.js +++ b/public/assets/js/require-backend.min.js @@ -71,7 +71,7 @@ this.$selectItem.filter(":enabled").prop("checked",t),this.updateRows(),t&&(e=th return"function"!=typeof this.options.renameFile?t.name:this.options.renameFile(t)}},{key:"getFallbackForm",value:function(){var t,i;if(t=this.getExistingFallback())return t;var n='
';this.options.dictFallbackText&&(n+="

".concat(this.options.dictFallbackText,"

")),n+='
');var o=e.createElement(n);return"FORM"!==this.element.tagName?(i=e.createElement('')),i.appendChild(o)):(this.element.setAttribute("enctype","multipart/form-data"),this.element.setAttribute("method",this.options.method)),null!=i?i:o}},{key:"getExistingFallback",value:function(){for(var t=0,e=["div","form"];t0){for(var n=["tb","gb","mb","kb","b"],o=0;o=Math.pow(this.options.filesizeBase,4-o)/10){e=t/Math.pow(this.options.filesizeBase,4-o),i=a;break}}e=Math.round(10*e)/10}return"".concat(e," ").concat(this.options.dictFileSizeUnits[i])}},{key:"_updateMaxFilesReachedClass",value:function(){return null!=this.options.maxFiles&&this.getAcceptedFiles().length>=this.options.maxFiles?(this.getAcceptedFiles().length===this.options.maxFiles&&this.emit("maxfilesreached",this.files),this.element.classList.add("dz-max-files-reached")):this.element.classList.remove("dz-max-files-reached")}},{key:"drop",value:function(t){if(t.dataTransfer){this.emit("drop",t);for(var e=[],i=0;i0){var o=!0,a=!1,s=void 0;try{for(var r,l=n[Symbol.iterator]();!(o=(r=l.next()).done);o=!0){var c=r.value;c.isFile?c.file(function(t){if(!i.options.ignoreHiddenFiles||"."!==t.name.substring(0,1))return t.fullPath="".concat(e,"/").concat(t.name),i.addFile(t)}):c.isDirectory&&i._addFilesFromDirectory(c,"".concat(e,"/").concat(c.name))}}catch(t){a=!0,s=t}finally{try{o||null==l.return||l.return()}finally{if(a)throw s}}t()}return null},o)}()}},{key:"accept",value:function(t,i){this.options.maxFilesize&&t.size>1024*this.options.maxFilesize*1024?i(this.options.dictFileTooBig.replace("{{filesize}}",Math.round(t.size/1024/10.24)/100).replace("{{maxFilesize}}",this.options.maxFilesize)):e.isValidFile(t,this.options.acceptedFiles)?null!=this.options.maxFiles&&this.getAcceptedFiles().length>=this.options.maxFiles?(i(this.options.dictMaxFilesExceeded.replace("{{maxFiles}}",this.options.maxFiles)),this.emit("maxfilesexceeded",t)):this.options.accept.call(this,t,i):i(this.options.dictInvalidFileType)}},{key:"addFile",value:function(t){var i=this;t.upload={uuid:e.uuidv4(),progress:0,total:t.size,bytesSent:0,filename:this._renameFile(t)},this.files.push(t),t.status=e.ADDED,this.emit("addedfile",t),this._enqueueThumbnail(t),this.accept(t,function(e){e?(t.accepted=!1,i._errorProcessing([t],e)):(t.accepted=!0,i.options.autoQueue&&i.enqueueFile(t)),i._updateMaxFilesReachedClass()})}},{key:"enqueueFiles",value:function(t){var e=!0,i=!1,n=void 0;try{for(var o,a=t[Symbol.iterator]();!(e=(o=a.next()).done);e=!0){var s=o.value;this.enqueueFile(s)}}catch(t){i=!0,n=t}finally{try{e||null==a.return||a.return()}finally{if(i)throw n}}return null}},{key:"enqueueFile",value:function(t){var i=this;if(t.status!==e.ADDED||!0!==t.accepted)throw new Error("This file can't be queued because it has already been processed or was rejected.");if(t.status=e.QUEUED,this.options.autoProcessQueue)return setTimeout(function(){return i.processQueue()},0)}},{key:"_enqueueThumbnail",value:function(t){var e=this;if(this.options.createImageThumbnails&&t.type.match(/image.*/)&&t.size<=1024*this.options.maxThumbnailFilesize*1024)return this._thumbnailQueue.push(t),setTimeout(function(){return e._processThumbnailQueue()},0)}},{key:"_processThumbnailQueue",value:function(){var t=this;if(!this._processingThumbnail&&0!==this._thumbnailQueue.length){this._processingThumbnail=!0;var e=this._thumbnailQueue.shift();return this.createThumbnail(e,this.options.thumbnailWidth,this.options.thumbnailHeight,this.options.thumbnailMethod,!0,function(i){return t.emit("thumbnail",e,i),t._processingThumbnail=!1,t._processThumbnailQueue()})}}},{key:"removeFile",value:function(t){if(t.status===e.UPLOADING&&this.cancelUpload(t),this.files=m(this.files,t),this.emit("removedfile",t),0===this.files.length)return this.emit("reset")}},{key:"removeAllFiles",value:function(t){null==t&&(t=!1);var i=!0,n=!1,o=void 0;try{for(var a,s=this.files.slice()[Symbol.iterator]();!(i=(a=s.next()).done);i=!0){var r=a.value;(r.status!==e.UPLOADING||t)&&this.removeFile(r)}}catch(t){n=!0,o=t}finally{try{i||null==s.return||s.return()}finally{if(n)throw o}}return null}},{key:"resizeImage",value:function(t,i,n,o,a){var s=this;return this.createThumbnail(t,i,n,o,!0,function(i,n){if(null==n)return a(t);var o=s.options.resizeMimeType;null==o&&(o=t.type);var r=n.toDataURL(o,s.options.resizeQuality);return"image/jpeg"!==o&&"image/jpg"!==o||(r=b.restore(t.dataURL,r)),a(e.dataURItoBlob(r))})}},{key:"createThumbnail",value:function(t,e,i,n,o,a){var s=this,r=new FileReader;r.onload=function(){if(t.dataURL=r.result,"image/svg+xml"===t.type)return void(null!=a&&a(r.result));s.createThumbnailFromUrl(t,e,i,n,o,a)},r.readAsDataURL(t)}},{key:"displayExistingFile",value:function(t,e,i,n){var o=this,a=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];if(this.emit("addedfile",t),this.emit("complete",t),a){var s=function(e){o.emit("thumbnail",t,e),i&&i()};t.dataURL=e,this.createThumbnailFromUrl(t,this.options.thumbnailWidth,this.options.thumbnailHeight,this.options.resizeMethod,this.options.fixOrientation,s,n)}else this.emit("thumbnail",t,e),i&&i()}},{key:"createThumbnailFromUrl",value:function(t,e,i,n,o,a,s){var r=this,l=document.createElement("img");return s&&(l.crossOrigin=s),l.onload=function(){var s=function(t){return t(1)};return"undefined"!=typeof EXIF&&null!==EXIF&&o&&(s=function(t){return EXIF.getData(l,function(){return t(EXIF.getTag(this,"Orientation"))})}),s(function(o){t.width=l.width,t.height=l.height;var s=r.options.resize.call(r,t,e,i,n),c=document.createElement("canvas"),d=c.getContext("2d");switch(c.width=s.trgWidth,c.height=s.trgHeight,o>4&&(c.width=s.trgHeight,c.height=s.trgWidth),o){case 2:d.translate(c.width,0),d.scale(-1,1);break;case 3:d.translate(c.width,c.height),d.rotate(Math.PI);break;case 4:d.translate(0,c.height),d.scale(1,-1);break;case 5:d.rotate(.5*Math.PI),d.scale(1,-1);break;case 6:d.rotate(.5*Math.PI),d.translate(0,-c.width);break;case 7:d.rotate(.5*Math.PI),d.translate(c.height,-c.width),d.scale(-1,1);break;case 8:d.rotate(-.5*Math.PI),d.translate(-c.height,0)}y(d,l,null!=s.srcX?s.srcX:0,null!=s.srcY?s.srcY:0,s.srcWidth,s.srcHeight,null!=s.trgX?s.trgX:0,null!=s.trgY?s.trgY:0,s.trgWidth,s.trgHeight);var u=c.toDataURL("image/png");if(null!=a)return a(u,c)})},null!=a&&(l.onerror=a),l.src=t.dataURL}},{key:"processQueue",value:function(){var t=this.options.parallelUploads,e=this.getUploadingFiles().length,i=e;if(!(e>=t)){var n=this.getQueuedFiles();if(n.length>0){if(this.options.uploadMultiple)return this.processFiles(n.slice(0,t-e));for(;i1?e-1:0),n=1;ni.options.chunkSize),t[0].upload.totalChunkCount=Math.ceil(o.size/i.options.chunkSize)}if(t[0].upload.chunked){var a=t[0],s=n[0],r=0;a.upload.chunks=[];var l=function(){for(var n=0;void 0!==a.upload.chunks[n];)n++;if(!(n>=a.upload.totalChunkCount)){r++;var o=n*i.options.chunkSize,l=Math.min(o+i.options.chunkSize,a.size),c={name:i._getParamName(0),data:s.webkitSlice?s.webkitSlice(o,l):s.slice(o,l),filename:a.upload.filename,chunkIndex:n};a.upload.chunks[n]={file:a,index:n,dataBlock:c,status:e.UPLOADING,progress:0,retries:0},i._uploadData(t,[c])}};if(a.upload.finishedChunkUpload=function(n,o){var s=!0;n.status=e.SUCCESS,i.options.chunkSuccess.call(i,n,a,o),n.dataBlock=null,n.xhr=null;for(var r=0;r=s;r?a++:a--)o[a]=e.charCodeAt(a);return new Blob([n],{type:i})};var m=function(t,e){return t.filter(function(t){return t!==e}).map(function(t){return t})},g=function(t){return t.replace(/[\-_](\w)/g,function(t){return t.charAt(1).toUpperCase()})};f.createElement=function(t){var e=document.createElement("div");return e.innerHTML=t,e.childNodes[0]},f.elementInside=function(t,e){if(t===e)return!0;for(;t=t.parentNode;)if(t===e)return!0;return!1},f.getElement=function(t,e){var i;if("string"==typeof t?i=document.querySelector(t):null!=t.nodeType&&(i=t),null==i)throw new Error("Invalid `".concat(e,"` option provided. Please provide a CSS selector or a plain HTML element."));return i},f.getElements=function(t,e){var i,n;if(t instanceof Array){n=[];try{var o=!0,a=!1,s=void 0;try{for(var r,l=t[Symbol.iterator]();!(o=(r=l.next()).done);o=!0)i=r.value,n.push(this.getElement(i,e))}catch(t){a=!0,s=t}finally{try{o||null==l.return||l.return()}finally{if(a)throw s}}}catch(t){n=null}}else if("string"==typeof t){n=[];var c=!0,d=!1,u=void 0;try{for(var h,p=document.querySelectorAll(t)[Symbol.iterator]();!(c=(h=p.next()).done);c=!0)i=h.value,n.push(i)}catch(t){d=!0,u=t}finally{try{c||null==p.return||p.return()}finally{if(d)throw u}}}else null!=t.nodeType&&(n=[t]);if(null==n||!n.length)throw new Error("Invalid `".concat(e,"` option provided. Please provide a CSS selector, a plain HTML element or a list of those."));return n},f.confirm=function(t,e,i){return window.confirm(t)?e():null!=i?i():void 0},f.isValidFile=function(t,e){if(!e)return!0;e=e.split(",");var i=t.type,n=i.replace(/\/.*$/,""),o=!0,a=!1,s=void 0;try{for(var r,l=e[Symbol.iterator]();!(o=(r=l.next()).done);o=!0){var c=r.value;if(c=c.trim(),"."===c.charAt(0)){if(-1!==t.name.toLowerCase().indexOf(c.toLowerCase(),t.name.length-c.length))return!0}else if(/\/\*$/.test(c)){if(n===c.replace(/\/.*$/,""))return!0}else if(i===c)return!0}}catch(t){a=!0,s=t}finally{try{o||null==l.return||l.return()}finally{if(a)throw s}}return!1},void 0!==t&&null!==t&&(t.fn.dropzone=function(t){return this.each(function(){return new f(this,t)})}),void 0!==h&&null!==h?h.exports=f:window.Dropzone=f,f.ADDED="added",f.QUEUED="queued",f.ACCEPTED=f.QUEUED,f.UPLOADING="uploading",f.PROCESSING=f.UPLOADING,f.CANCELED="canceled",f.ERROR="error",f.SUCCESS="success";var v=function(t){var e=(t.naturalWidth,t.naturalHeight),i=document.createElement("canvas");i.width=1,i.height=e;var n=i.getContext("2d");n.drawImage(t,0,0);for(var o=n.getImageData(1,0,1,e),a=o.data,s=0,r=e,l=e;l>s;){0===a[4*(l-1)+3]?r=l:s=l,l=r+s>>1}var c=l/e;return 0===c?1:c},y=function(t,e,i,n,o,a,s,r,l,c){var d=v(e);return t.drawImage(e,i,n,o,a,s,r,l,c/d)},b=function(){function t(){r(this,t)}return c(t,null,[{key:"initClass",value:function(){this.KEY_STR="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}},{key:"encode64",value:function(t){for(var e="",i=void 0,n=void 0,o="",a=void 0,s=void 0,r=void 0,l="",c=0;;)if(i=t[c++],n=t[c++],o=t[c++],a=i>>2,s=(3&i)<<4|n>>4,r=(15&n)<<2|o>>6,l=63&o,isNaN(n)?r=l=64:isNaN(o)&&(l=64),e=e+this.KEY_STR.charAt(a)+this.KEY_STR.charAt(s)+this.KEY_STR.charAt(r)+this.KEY_STR.charAt(l),i=n=o="",a=s=r=l="",!(ct.length)break}return i}},{key:"decode64",value:function(t){var e=void 0,i=void 0,n="",o=void 0,a=void 0,s=void 0,r="",l=0,c=[],d=/[^A-Za-z0-9\+\/\=]/g;for(d.exec(t)&&console.warn("There were invalid base64 characters in the input text.\nValid base64 characters are A-Z, a-z, 0-9, '+', '/',and '='\nExpect errors in decoding."),t=t.replace(/[^A-Za-z0-9\+\/\=]/g,"");;)if(o=this.KEY_STR.indexOf(t.charAt(l++)),a=this.KEY_STR.indexOf(t.charAt(l++)),s=this.KEY_STR.indexOf(t.charAt(l++)),r=this.KEY_STR.indexOf(t.charAt(l++)),e=o<<2|a>>4,i=(15&a)<<4|s>>2,n=(3&s)<<6|r,c.push(e),64!==s&&c.push(i),64!==r&&c.push(n),e=i=n="",o=a=s=r="",!(l\';this.onerror=null;" class="img-responsive">'},events:{onInit:function(){},onUploadSuccess:function(e,i,n){var a=e.element,s=e.options.onUploadSuccess,r=void 0!==i.data?i.data:null;if(a){var l=t(a).data("input-id")?t(a).data("input-id"):"";if(l){var c=[],d=t("#"+l);t(a).data("multiple")&&""!==d.val()&&c.push(d.val());var u=Config.upload.fullmode?r.fullurl?r.fullurl:Fast.api.cdnurl(r.url):r.url;c.push(u),d.val(c.join(",")).trigger("change").trigger("validate")}var h=t(a).data("upload-success");if(h&&("function"!=typeof h&&"function"==typeof o.api.custom[h]&&(h=o.api.custom[h]),"function"==typeof h)){var p=h.call(a,r,i,e,n);if(!1===p)return}}if("function"==typeof s){var p=s.call(a,r,i,e,n);if(!1===p)return}},onUploadError:function(e,i,n){var a=e.element,s=e.options.onUploadError,r=void 0!==i.data?i.data:null;if(a){var l=t(a).data("upload-error");if(l&&("function"!=typeof l&&"function"==typeof o.api.custom[l]&&(l=o.api.custom[l]),"function"==typeof l)){var c=l.call(a,r,i,e,n);if(!1===c)return}}if("function"==typeof s){var c=s.call(a,r,i,e,n);if(!1===c)return}Toastr.error(i.msg.toString().replace(/(<([^>]+)>)/gi,"")+"(code:"+i.code+")")},onUploadResponse:function(e,i,n){try{var o="object"==typeof e?e:JSON.parse(e);o.hasOwnProperty("code")||t.extend(o,{code:-2,msg:e,data:null})}catch(t){var o={code:-1,msg:t.message,data:null}}return o},onUploadComplete:function(e,i){var n=e.element,a=e.options.onUploadComplete;if(n){var s=t(n).data("upload-complete");if(s&&("function"!=typeof s&&"function"==typeof o.api.custom[s]&&(s=o.api.custom[s]),"function"==typeof s)){var r=s.call(n,i);if(!1===r)return}}if("function"==typeof a){var r=a.call(n,i);if(!1===r)return}}},api:{upload:function(e,a,s,r){e=void 0===e?o.config.classname:e,t(e,o.config.container).each(function(){if(t(this).attr("initialized"))return!0;t(this).attr("initialized",!0);var e=this,l=t(this).prop("id")||t(this).prop("name")||i.uuidv4(),c=t(this).data("url"),d=t(this).data("maxsize"),u=t(this).data("maxcount"),h=t(this).data("mimetype"),p=t(this).data("multipart"),f=t(this).data("multiple"),m=t(e).data("input-id")?t(e).data("input-id"):"",g=t(e).data("preview-id")?t(e).data("preview-id"):"";c=c||Config.upload.uploadurl,c=Fast.api.fixurl(c);var v=Config.upload.chunksize||2097152,y=Config.upload.timeout||6e5;d=void 0!==d?d:Config.upload.maxsize,h=void 0!==h?h:Config.upload.mimetype,p=void 0!==p?p:Config.upload.multipart,f=void 0!==f?f:Config.upload.multiple,h=h.split(",").map(function(t){return t.indexOf("/")>-1?t:t&&"*"!==t&&"."!==t.charAt(0)?"."+t:t}).join(","),h="*"===h?null:h;var b=function(t){var e=t.toString().match(/^([0-9\.]+)(\w+)$/),i=e?parseFloat(e[1]):parseFloat(t),n=e?e[2].toLowerCase():"b",o={b:0,k:1,kb:1,m:2,mb:2,gb:3,g:3,tb:4,t:4},a=void 0!==o[n]?o[n]:0;return i*Math.pow(1024,a)/Math.pow(1024,2)}(d),w=t(this).data()||{};w=t.extend(!0,{},w,t(this).data("upload-options")||{}),delete w.success,delete w.url,p=t.isArray(p)?{}:p;var x=t(this).data("params")||{};void 0!==x.category||t(this).data("category");o.list[l]=new i(this,t.extend({url:c,params:function(e,i,n){var o=p;return n?t.extend({},o,{filesize:n.file.size,filename:n.file.name,chunkid:n.file.upload.uuid,chunkindex:n.index,chunkcount:n.file.upload.totalChunkCount,chunksize:this.options.chunkSize,chunkfilesize:n.dataBlock.data.size,width:n.file.width||0,height:n.file.height||0,type:n.file.type}):o},chunking:!1,chunkSize:v,maxFilesize:b,acceptedFiles:h,maxFiles:u&&parseInt(u)>1?u:f?null:1,timeout:y,parallelUploads:1,previewsContainer:!1,dictDefaultMessage:__("Drop files here to upload"),dictFallbackMessage:__("Your browser does not support drag'n'drop file uploads"),dictFallbackText:__("Please use the fallback form below to upload your files like in the olden days"),dictFileTooBig:__("File is too big (%sMiB), Max filesize: %sMiB","{{filesize}}","{{maxFilesize}}"),dictInvalidFileType:__("You can't upload files of this type"),dictResponseError:__("Server responded with %s code.","{{statusCode}}"),dictCancelUpload:__("Cancel upload"),dictUploadCanceled:__("Upload canceled"),dictCancelUploadConfirmation:__("Are you sure you want to cancel this upload?"),dictRemoveFile:__("Remove file"),dictMaxFilesExceeded:__("You can only upload a maximum of %s files","{{maxFiles}}"),init:function(){o.events.onInit.call(this),t(">i",this.element).addClass("dz-message"),this.options.elementHtml=t(this.element).html()},sending:function(t,e,i){void 0!==t.category&&i.append("category",t.category)},addedfile:function(e){ var i=t(this.element).data("params")||{},n=void 0!==i.category?i.category:t(this.element).data("category")||"";e.category="function"==typeof n?n.call(this,e):n},addedfiles:function(e){if(this.options.maxFiles&&(!this.options.maxFiles||this.options.maxFiles>1)&&this.options.inputId){var i=t("#"+this.options.inputId);if(i.length>0){var n=t.trim(i.val()),o=""===n?0:n.split(/\,/).length,a=this.options.maxFiles-o;if(0===a||e.length>a){e=Array.prototype.slice.call(e,a);for(var s=0;s"+(n&&void 0!==n.responseText?n.responseText:i)+"");a.find("style, title, script").remove();var s=a.text()||__("Network error"),r={code:0,data:null,msg:s};o.events.onUploadError(this,r,e)},uploadprogress:function(e,i,n){e.upload.chunked&&t(this.element).prop("disabled",!0).html(" "+__("Upload")+Math.floor(e.upload.bytesSent/e.size*100)+"%")},totaluploadprogress:function(e,i){this.getActiveFiles().length>0&&!this.options.chunking&&t(this.element).prop("disabled",!0).html(" "+__("Upload")+Math.floor(e)+"%")},queuecomplete:function(){o.events.onUploadComplete(this,this.files),this.removeAllFiles(!0),t(this.element).prop("disabled",!1).html(this.options.elementHtml)},chunkSuccess:function(t,e,i){},chunksUploaded:function(e,i){var n=this;Fast.api.ajax({url:this.options.url,data:t.extend({},p,{action:"merge",filesize:e.size,filename:e.name,chunkid:e.upload.uuid,chunkcount:e.upload.totalChunkCount})},function(t,e){return i(JSON.stringify(e)),!1},function(t,i){e.accepted=!1,n._errorProcessing([e],i.msg)})},onUploadSuccess:a,onUploadError:s,onUploadComplete:r},o.options,w)),g&&f&&require(["dragsort"],function(){t("#"+g).dragsort({dragSelector:"li a:not(.btn-trash)",dragEnd:function(){t("#"+g).trigger("fa.preview.change")},placeHolderTemplate:'
  • '})});var k=function(e){var i={},n=t("textarea[name='"+e+"']"),o=n.prev("ul");t.each(t("input,select,textarea",o).serializeArray(),function(t,e){var n=/\[?(\w+)\]?\[(\w+)\]$/g,o=n.exec(e.name);if(!o)return!0;isNaN(o[2])?(o[1]="x"+parseInt(o[1]),void 0===i[o[1]]&&(i[o[1]]={}),i[o[1]][o[2]]=e.value):i[t]=e.value});var a=[];t.each(i,function(t,e){a.push(e)}),n.val(JSON.stringify(a))};g&&m&&(t(document.body).on("keyup change","#"+m,function(i){var a=t("#"+m).val(),s=a.split(/\,/),r=t("#"+g);r.empty();var l=r.data("template")?r.data("template"):"",c=r.next().is("textarea")?r.next("textarea").val():"{}",d={};try{d=JSON.parse(c)}catch(i){}t.each(s,function(i,a){if(!a)return!0;var s=/[\.]?([a-zA-Z0-9]+)$/.exec(a);s=s?s[1]:"file";var c=t(e).data(),u=void 0!==c.cdnurl?Fast.api.cdnurl(a,c.cdnurl):Fast.api.cdnurl(a);a=Config.upload.fullmode?u:a;var h=d&&void 0!==d[i]?d[i]:null,p={url:a,fullurl:u,data:c,key:i,index:i,value:h,row:h,suffix:s},f=l?n(l,p):n.render(o.config.previewtpl,p);r.append(f)}),k(r.data("name"))}),t("#"+m).trigger("change")),g&&(t("#"+g).on("change keyup","input,textarea,select",function(){k(t(this).closest("ul").data("name"))}),t(document.body).on("fa.preview.change","#"+g,function(){var e=[];t("#"+g+" [data-url]").each(function(i,n){e.push(t(this).data("url"))}),m&&t("#"+m).val(e.join(",")),k(t("#"+g).data("name"))}),t(document.body).on("click","#"+g+" .btn-trash",function(){t(this).closest("li").remove(),t("#"+g).trigger("fa.preview.change")})),m&&(t("#"+m).closest("form").on("reset",function(){setTimeout(t.proxy(function(){t("#"+m,this).trigger("change")},this),0)}),t("body").on("paste drop","#"+m,function(e){var i=e.originalEvent,n=t(".plupload[data-input-id='"+t(this).attr("id")+"'],.faupload[data-input-id='"+t(this).attr("id")+"']");if("paste"===e.type&&i.clipboardData&&i.clipboardData.items){var a=i.clipboardData.items;if(!(1===a.length&&a[0].type.indexOf("text")>-1||2===a.length&&a[1].type.indexOf("text")>-1))return o.list[n.attr("id")].paste(i),!1}if("drop"===e.type&&i.dataTransfer&&i.dataTransfer.files)return o.list[n.attr("id")].drop(i),!1}))})},plupload:function(t,e,i,n){return o.api.upload(t,e,i,n)},faupload:function(t,e,i,n){return o.api.upload(t,e,i,n)},send:function(e,n,a,s){var r=Layer.msg(__("Uploading"),{offset:"t",time:0}),l="dropzone-"+i.uuidv4();t(' ',n)),e.push(i(' ',o)),e.push(""),e},s=function(e,n,o){var a=e.constructor===Array,s=[];return s.push(i('',o.options.formatCommonChoose())),t.each(e,function(t,e){e.constructor===Object?(t=e.id,e=e.name):t=a?e:t,s.push(i("",t==n.defaultValue?"selected":""))}),s},r=function(t){return!(!t.options.commonSearch||"server"!=t.options.sidePagination||!t.options.url)},l=function(i,n){var o={},a={},s="";return t("form.form-commonsearch .operate",i.$commonsearch).each(function(r){var l=t(this).data("name"),c=t(this).is("select")?t("option:selected",this).val():t(this).val().toUpperCase(),d=t("[name='"+l+"']",i.$commonsearch);if(0==d.length)return!0;var u=e[r],h=!i.options.searchFormTemplate&&u&&"function"==typeof u.process?u.process:null;if(d.length>1)if(/BETWEEN$/.test(c)){var p=t.trim(t("[name='"+l+"']:first",i.$commonsearch).val()),f=t.trim(t("[name='"+l+"']:last",i.$commonsearch).val());p.length||f.length?(h&&(p=h(p,"begin"),f=h(f,"end")),s=p+","+f):s="",t("[name='"+l+"']:first",i.$commonsearch).hasClass("datetimepicker")&&(c="RANGE")}else s=t("[name='"+l+"']:checked",i.$commonsearch).val(),s=h?h(s):s;else s=h?h(d.val()):d.val();if(n&&(""===s||null==s||t.isArray(s)&&0===s.length)&&!c.match(/null/i))return!0;o[l]=c,a[l]=s}),{op:o,filter:a}},c=function(e,i,n){return e.filter="Object"==typeof e.filter?e.filter:e.filter?JSON.parse(e.filter):{},e.op="Object"==typeof e.op?e.op:e.op?JSON.parse(e.op):{},e.filter=t.extend({},e.filter,i.filter),e.op=t.extend({},e.op,i.op),n&&t.each(e.filter,function(i,n){(""==n||null==n||t.isArray(n)&&0==n.length)&&!e.op[i].match(/null/i)&&(delete e.filter[i],delete e.op[i])}),e.filter=JSON.stringify(e.filter),e.op=JSON.stringify(e.op),e};t.extend(t.fn.bootstrapTable.defaults,{commonSearch:!1,titleForm:"Common search",actionForm:"",searchFormTemplate:"",searchFormVisible:!0,searchClass:"searchit",showSearch:!0,renderDefault:!0,onCommonSearch:function(t,e){return!1},onPostCommonSearch:function(t){return!1}}),t.extend(t.fn.bootstrapTable.defaults.icons,{commonSearchIcon:"glyphicon-search"}),t.extend(t.fn.bootstrapTable.Constructor.EVENTS,{"common-search.bs.table":"onCommonSearch","post-common-search.bs.table":"onPostCommonSearch"}),t.extend(t.fn.bootstrapTable.locales[t.fn.bootstrapTable.defaults.locale],{formatCommonSearch:function(){return"Common search"},formatCommonSubmitButton:function(){return"Search"},formatCommonResetButton:function(){return"Reset"},formatCommonCloseButton:function(){return"Close"},formatCommonChoose:function(){return"Choose"}}),t.extend(t.fn.bootstrapTable.defaults,t.fn.bootstrapTable.locales);var d=t.fn.bootstrapTable.Constructor,u=d.prototype.initHeader,h=d.prototype.initToolbar,p=d.prototype.load,f=d.prototype.initSearch;d.prototype.initHeader=function(){u.apply(this,Array.prototype.slice.apply(arguments)),this.$header.find("th[data-field]").each(function(e){var i=t(this).data();void 0!==i.width&&-1===i.width.toString().indexOf("%")&&(t(".th-inner",this).outerWidth(i.width),t(this).css("max-width",i.width))}),this.options.stateField=this.header.stateField},d.prototype.initToolbar=function(){if(h.apply(this,Array.prototype.slice.apply(arguments)),r(this)){var e=this,o=[];e.options.showSearch&&(o.push(i('
    ',this.options.buttonsAlign,this.options.buttonsAlign)),o.push(i('
    ")),e.$toolbar.find(".pull-right").length>0?t(o.join("")).insertBefore(e.$toolbar.find(".pull-right:first")):e.$toolbar.append(o.join("")),n(e.columns,e),e.$toolbar.find('button[name="commonSearch"]').off("click").on("click",function(){e.$commonsearch.toggleClass("hidden")}),e.$container.on("click","."+e.options.searchClass,function(){var i=t(this).data("value"),n=t(this).data("field"),o=e.$container.closest(".panel-intro").find("ul[data-field='"+n+"']");if(o.length>0)return void t('li a[data-value="'+i+'"][data-toggle="tab"]',o).trigger("click");var a=t("form [name='"+n+"']",e.$commonsearch);a.length>0&&(a.is("select")?t("option[value='"+i+"']",a).prop("selected",!0):a.length>1?t("form [name='"+n+"'][value='"+i+"']",e.$commonsearch).prop("checked",!0):a.val(i+""),a.trigger("change"),t("form",e.$commonsearch).trigger("submit"))});var a=e.options.queryParams;this.options.queryParams=function(t){return a(c(t,l(e,!0)))},this.trigger("post-common-search",e)}},d.prototype.onCommonSearch=function(){var t=l(this);this.trigger("common-search",this,t),this.options.pageNumber=1,this.refresh({})},d.prototype.load=function(t){p.apply(this,Array.prototype.slice.apply(arguments)),r(this)},d.prototype.initSearch=function(){if(f.apply(this,Array.prototype.slice.apply(arguments)),r(this)){var e=this,i=t.isEmptyObject(this.filterColumnsPartial)?null:this.filterColumnsPartial;this.data=i?t.grep(this.data,function(n,o){for(var a in i){var s=i[a].toLowerCase(),r=n[a];if(r=t.fn.bootstrapTable.utils.calculateObjectValue(e.header,e.header.formatters[t.inArray(a,e.header.fields)],[r,n,o],r),-1===t.inArray(a,e.header.fields)||"string"!=typeof r&&"number"!=typeof r||-1===(r+"").toLowerCase().indexOf(s))return!1}return!0}):this.data}}}(jQuery),define("bootstrap-table-commonsearch",["bootstrap-table"],function(t){return function(){return t.$.fn.bootstrapTable.defaults}}(this)),function(t){"use strict";t.extend(t.fn.bootstrapTable.defaults,{templateView:!1,templateFormatter:"itemtpl",templateParentClass:"row row-flex",templateTableClass:"table-template"});var e=t.fn.bootstrapTable.Constructor,i=e.prototype.initContainer,n=e.prototype.initBody,o=e.prototype.initRow;e.prototype.initContainer=function(){i.apply(this,Array.prototype.slice.apply(arguments));var t=this;t.options.templateView&&(t.options.cardView=!0)},e.prototype.initBody=function(){var e=this;t.extend(e.options,{showHeader:!e.options.templateView&&t.fn.bootstrapTable.defaults.showHeader,showFooter:!e.options.templateView&&t.fn.bootstrapTable.defaults.showFooter}),t(e.$el).toggleClass(e.options.templateTableClass,e.options.templateView),n.apply(this,Array.prototype.slice.apply(arguments)),e.options.templateView&&t("> *:not(.no-records-found)",e.$body).wrapAll(t("
    ").addClass(e.options.templateParentClass))},e.prototype.initRow=function(t,e,i,n){var a=this;if(!a.options.templateView)return o.apply(a,Array.prototype.slice.apply(arguments));var s="";if("function"==typeof a.options.templateFormatter)s=a.options.templateFormatter.call(a,t,e,i);else{s=require("template")(a.options.templateFormatter,{item:t,i:e,data:i})}return s}}(jQuery),define("bootstrap-table-template",["bootstrap-table","template"],function(t){return function(){return t.$.fn.bootstrapTable.defaults}}(this)),function(t){"use strict";var e=t.fn.bootstrapTable.utils.sprintf;t.extend(t.fn.bootstrapTable.defaults,{showJumpto:!1,exportOptions:{}}),t.extend(t.fn.bootstrapTable.locales,{formatJumpto:function(){return"GO"}}),t.extend(t.fn.bootstrapTable.defaults,t.fn.bootstrapTable.locales);var i=t.fn.bootstrapTable.Constructor,n=i.prototype.initPagination;i.prototype.initPagination=function(){if(this.showToolbar=this.options.showExport,n.apply(this,Array.prototype.slice.apply(arguments)),this.options.showJumpto){var i=this,o=this.$pagination.find("ul.pagination"),a=o.find("li.jumpto");a.length||(a=t(['
  • ','','","
  • "].join("")).appendTo(o),a.find("button").click(function(){i.selectPage(parseInt(a.find("input").val()))}))}}}(jQuery),define("bootstrap-table-jumpto",["bootstrap-table"],function(t){return function(){return t.$.fn.bootstrapTable.defaults}}(this)),function(t){"use strict";function e(t){var e=0,a=0,s=0,r=0;return"detail"in t&&(a=t.detail),"wheelDelta"in t&&(a=-t.wheelDelta/120),"wheelDeltaY"in t&&(a=-t.wheelDeltaY/120),"wheelDeltaX"in t&&(e=-t.wheelDeltaX/120),"axis"in t&&t.axis===t.HORIZONTAL_AXIS&&(e=a,a=0),s=e*i,r=a*i,"deltaY"in t&&(r=t.deltaY),"deltaX"in t&&(s=t.deltaX),(s||r)&&t.deltaMode&&(1===t.deltaMode?(s*=n,r*=n):(s*=o,r*=o)),s&&!e&&(e=s<1?-1:1),r&&!a&&(a=r<1?-1:1),{spinX:e,spinY:a,pixelX:s,pixelY:r}}var i=10,n=40,o=800,a=null,s=function(){if(null===a){var e=t("

    ").addClass("fixed-table-scroll-inner"),i=t("

    ").addClass("fixed-table-scroll-outer"),n=void 0,o=void 0;i.append(e),t("body").append(i),n=e[0].offsetWidth,i.css("overflow","scroll"),o=e[0].offsetWidth,n===o&&(o=i[0].clientWidth),i.remove(),a=n-o}return a},r=function(t){return t[0].scrollHeight>t[0].clientHeight?15:0};t.extend(t.fn.bootstrapTable.defaults,{fixedColumns:!1,fixedNumber:0,fixedRightNumber:0});var l=t.fn.bootstrapTable.Constructor,c=l.prototype.initBody,d=l.prototype.initContainer,u=l.prototype.trigger,h=l.prototype.hideLoading,p=l.prototype.updateSelected;l.prototype.fixedColumnsSupported=function(){var t=this;return t.options.fixedColumns&&!t.options.detailView&&!t.options.cardView},l.prototype.initFixedContainer=function(){this.options.fixedNumber&&(0==this.$tableContainer.find(".fixed-columns").length&&this.$tableContainer.append('
    '),this.$fixedColumns=this.$tableContainer.find(".fixed-columns")),this.options.fixedRightNumber&&(0==this.$tableContainer.find(".fixed-columns-right").length&&this.$tableContainer.append('
    '),this.$fixedColumnsRight=this.$tableContainer.find(".fixed-columns-right"))},l.prototype.initContainer=function(){d.apply(this,Array.prototype.slice.apply(arguments)),this.initFixedContainer()},l.prototype.initBody=function(){c.apply(this,Array.prototype.slice.apply(arguments)),this.fixedColumnsSupported()&&(this.options.showHeader&&this.options.height||(this.initFixedColumnsBody(),this.initFixedColumnsEvents()))},l.prototype.trigger=function(){var t=this;u.apply(this,Array.prototype.slice.apply(arguments)),"pre-body"===arguments[0]&&this.options.cardView&&this.$tableBody.css("height","auto"),"toggle"===arguments[0]&&(arguments[1]?(this.$tableBody.css("height","auto"),this.$fixedColumns&&this.$fixedColumns.hide(),this.$fixedColumnsRight&&this.$fixedColumnsRight.hide()):(this.$tableBody.css("height","100%"),this.$fixedColumns&&this.$fixedColumns.show(),this.$fixedColumnsRight&&this.$fixedColumnsRight.show(),this.$fixedHeaderRight&&this.$fixedHeaderRight.scrollLeft(this.$tableBody.find("table").width()),this.$fixedBodyRight&&this.$fixedBodyRight.scrollLeft(this.$tableBody.find("table").width()))),t.fixedColumnsSupported()&&("post-header"===arguments[0]?this.initFixedColumnsHeader():"scroll-body"===arguments[0]?(this.needFixedColumns&&this.options.fixedNumber&&this.$fixedBody&&this.$fixedBody.scrollTop(this.$tableBody.scrollTop()),this.needFixedColumns&&this.options.fixedRightNumber&&this.$fixedBodyRight&&this.$fixedBodyRight.scrollTop(this.$tableBody.scrollTop())):"load-success"===arguments[0]&&this.hideLoading())},l.prototype.updateSelected=function(){var e=this;p.apply(this,Array.prototype.slice.apply(arguments)),this.fixedColumnsSupported()&&this.$tableBody.find("tr").each(function(i,n){var o=t(n),a=o.data("index"),s=o.attr("class"),r='[name="'+e.options.selectItemName+'"]',l=o.find(r);if(void 0!==a){var c=function(t,i){var n=i.find('tr[data-index="'+a+'"]');n.attr("class",s),l.length&&n.find(r).prop("checked",l.prop("checked")),e.$selectAll.length&&t.add(i).find('[name="btSelectAll"]').prop("checked",e.$selectAll.prop("checked"))};e.$fixedBody&&e.options.fixedNumber&&c(e.$fixedHeader,e.$fixedBody),e.$fixedBodyRight&&e.options.fixedRightNumber&&c(e.$fixedHeaderRight,e.$fixedBodyRight)}})},l.prototype.hideLoading=function(){h.apply(this,Array.prototype.slice.apply(arguments)),this.needFixedColumns&&this.options.fixedNumber&&this.$fixedColumns.find(".fixed-table-loading").hide(),this.needFixedColumns&&this.options.fixedRightNumber&&this.$fixedColumnsRight.find(".fixed-table-loading").hide()},l.prototype.initFixedColumnsHeader=function(){var t=this;this.options.height?this.needFixedColumns=this.$tableHeader.outerWidth(!0)a.clientWidth?s():0,l=t(".fixed-table-pagination",e.$tableContainer).height();void 0!==e.options.height&&(l=0),i.css({height:"calc(100% - "+(l+r)+"px)"}),o.css({height:"calc(100% - "+n.height()+"px)",overflow:"hidden"})};return t(window).on("resize",r),r(),o};this.needFixedColumns&&this.options.fixedNumber&&(this.$fixedBody=i(this.$fixedColumns,this.$fixedHeader)),this.needFixedColumns&&this.options.fixedRightNumber&&(this.$fixedBodyRight=i(this.$fixedColumnsRight,this.$fixedHeaderRight),this.$fixedBodyRight.scrollLeft(this.$fixedBodyRight.find("table").width()),this.$fixedBodyRight.css("overflow-y","hidden"))},l.prototype.getFixedColumnsWidth=function(t){var e=this.getVisibleFields(),i=0,n=this.options.fixedNumber;t&&(e=e.reverse(),n=this.options.fixedRightNumber,this.$fixedColumnsRight.css("right",r(this.$tableBody)));for(var o=0;o-1,a=o?"DOMMouseScroll":"mousewheel",s=function(t,n){var o=e(t),a=Math.ceil(o.pixelY),s=i.$tableBody.scrollTop()+a;(a<0&&s>0||a>0&&s table > tbody > tr[data-index] > td").off("click dblclick").on("click dblclick",function(e){var n=t(this).closest("tr[data-index]").data("index");t(i.$selectItem[n]).closest("tr[data-index]").find(">td:eq("+t(this).index()+")").trigger("click")})),t("div.fixed-table-body").off("scroll"),this.$tableBody.off("scroll").on("scroll",function(t){i.$tableHeader.scrollLeft(0),i.$tableBody.scrollLeft()>0&&(i.$tableHeader.scrollLeft(i.$tableBody.scrollLeft()),i.options.showFooter&&!i.options.cardView&&i.$tableFooter.scrollLeft(i.$tableBody.scrollLeft()));var e=i.$tableBody.scrollTop();i.$fixedBody&&i.$fixedBody.scrollTop(e),i.$fixedBodyRight&&i.$fixedBodyRight.scrollTop(e)}), -this.needFixedColumns&&this.options.fixedRightNumber&&(this.$fixedBodyRight.find("tr").hover(function(t){n(t,!0)},function(t){n(t,!1)}),this.$fixedBodyRight[0].addEventListener(a,function(t){s(t,i.$fixedBodyRight[0])}),this.$fixedBodyRight.find('input[name="'+this.options.selectItemName+'"]').off("click").on("click",function(e){e.stopImmediatePropagation();var n=t(e.target).data("index");t(i.$selectItem[n]).trigger("click")}),this.$fixedBodyRight.find("> table > tbody > tr[data-index] > td").off("click dblclick").on("click dblclick",function(e){var n=t(this).closest("tr[data-index]").data("index");t(i.$selectItem[n]).closest("tr[data-index]").find(">td:eq("+t(this).index()+")").trigger("click")})),this.options.filterControl&&t(this.$fixedColumns).off("keyup change").on("keyup change",function(e){var n=t(e.target),o=n.val(),a=n.parents("th").data("field"),s=i.$header.find('th[data-field="'+a+'"]');if(n.is("input"))s.find("input").val(o);else if(n.is("select")){var r=s.find("select");r.find("option[selected]").removeAttr("selected"),r.find('option[value="'+o+'"]').attr("selected",!0)}i.triggerSearch()})}}(jQuery),define("bootstrap-table-fixed-columns",["bootstrap-table"],function(t){return function(){return t.$.fn.bootstrapTable.defaults}}(this)),define("table",["jquery","bootstrap","moment","moment/locale/zh-cn","bootstrap-table","bootstrap-table-lang","bootstrap-table-export","bootstrap-table-commonsearch","bootstrap-table-template","bootstrap-table-jumpto","bootstrap-table-fixed-columns"],function(t,e,i){var n={list:{},defaults:{url:"",sidePagination:"server",method:"get",toolbar:".toolbar",search:!0,cache:!1,commonSearch:!0,searchFormVisible:!1,titleForm:"",idTable:"commonTable",showExport:!0,exportDataType:"auto",exportTypes:["json","xml","csv","txt","doc","excel"],exportOptions:{fileName:"export_"+i().format("YYYY-MM-DD"),preventInjection:!1,mso:{onMsoNumberFormat:function(e,i,n){return isNaN(t(e).text())?"":"\\@"}},ignoreColumn:[0,"operate"]},pageSize:Config.pagesize||localStorage.getItem("pagesize")||10,pageList:[10,15,20,25,50,"All"],pagination:!0,clickToSelect:!0,dblClickToEdit:!0,singleSelect:!1,showRefresh:!1,showJumpto:!0,locale:"zh-cn"===Config.language?"zh-CN":"en-US",showToggle:!0,showColumns:!0,pk:"id",sortName:"id",sortOrder:"desc",paginationFirstText:__("First"),paginationPreText:__("Previous"),paginationNextText:__("Next"),paginationLastText:__("Last"),cardView:!1,iosCardView:!0,checkOnInit:!0,escape:!0,fixDropdownPosition:!0,dragCheckboxMultiselect:!0,selectedIds:[],selectedData:[],extend:{index_url:"",add_url:"",edit_url:"",del_url:"",import_url:"",multi_url:"",dragsort_url:"ajax/weigh"}},columnDefaults:{align:"center",valign:"middle"},config:{checkboxtd:"tbody>tr>td.bs-checkbox",toolbar:".toolbar",refreshbtn:".btn-refresh",addbtn:".btn-add",editbtn:".btn-edit",delbtn:".btn-del",importbtn:".btn-import",multibtn:".btn-multi",disabledbtn:".btn-disabled",editonebtn:".btn-editone",restoreonebtn:".btn-restoreone",destroyonebtn:".btn-destroyone",restoreallbtn:".btn-restoreall",destroyallbtn:".btn-destroyall",dragsortfield:"weigh"},button:{edit:{name:"edit",icon:"fa fa-pencil",title:__("Edit"),extend:'data-toggle="tooltip" data-container="body"',classname:"btn btn-xs btn-success btn-editone"},del:{name:"del",icon:"fa fa-trash",title:__("Del"),extend:'data-toggle="tooltip" data-container="body"',classname:"btn btn-xs btn-danger btn-delone"},dragsort:{name:"dragsort",icon:"fa fa-arrows",title:__("Drag to sort"),extend:'data-toggle="tooltip"',classname:"btn btn-xs btn-primary btn-dragsort"}},api:{init:function(e,i,o){e=e||{},i=i||{},o=o||{},t.fn.bootstrapTable.Constructor.prototype.getSelectItem=function(){return this.$selectItem};var a=t.fn.bootstrapTable.Constructor.prototype.onPageListChange;t.fn.bootstrapTable.Constructor.prototype.onPageListChange=function(){return a.apply(this,Array.prototype.slice.apply(arguments)),localStorage.setItem("pagesize",this.options.pageSize),!1},t.extend(!0,t.fn.bootstrapTable.defaults,n.defaults,e),t.extend(t.fn.bootstrapTable.columnDefaults,n.columnDefaults,i),t.extend(t.fn.bootstrapTable.locales[n.defaults.locale],{formatCommonSearch:function(){return __("Common search")},formatCommonSubmitButton:function(){return __("Search")},formatCommonResetButton:function(){return __("Reset")},formatCommonCloseButton:function(){return __("Close")},formatCommonChoose:function(){return __("Choose")},formatJumpto:function(){return __("Go")}},o),t.fn.bootstrapTable.defaults.iosCardView&&navigator.userAgent.match(/(iPod|iPhone|iPad)/)&&(n.defaults.cardView=!0,t.fn.bootstrapTable.defaults.cardView=!0),void 0!==e.exportTypes&&(t.fn.bootstrapTable.defaults.exportTypes=e.exportTypes)},bindevent:function(e){var i=e.closest(".bootstrap-table"),o=e.bootstrapTable("getOptions"),a=t(o.toolbar,i),s=t(".btn-selected-tips",i);0===s.length&&(s=t(' '+__("Multiple selection mode: %s checked","0")+"").appendTo(a)),s.off("click").on("click",function(t){e.trigger("uncheckbox"),e.bootstrapTable("refresh")}),e.on("uncheckbox",function(t,e,i){o.selectedIds=[],o.selectedData=[],s.tooltip("hide"),s.addClass("hide")}),e.on("load-error.bs.table",function(t,e,i){0!==i.status&&Toastr.error(__("Unknown data format"))}),e.on("load-success.bs.table",function(t,e){void 0===e.rows&&void 0!==e.code&&Toastr.error(e.msg)}),e.on("refresh.bs.table",function(e,i,o){t(n.config.refreshbtn,a).find(".fa").addClass("fa-spin"),t(".layui-layer-autocontent").remove()}),e.on("search.bs.table common-search.bs.table",function(t,i,n){e.trigger("uncheckbox")}),o.dblClickToEdit&&e.on("dbl-click-row.bs.table",function(e,i,o,a){t(n.config.editonebtn,o).trigger("click")}),e.on("pre-body.bs.table",function(e,i){o.maintainSelected&&t.each(i,function(e,i){i[o.stateField]=t.inArray(i[o.pk],o.selectedIds)>-1})}),e.on("post-body.bs.table",function(i,s){if(t(n.config.refreshbtn,a).find(".fa").removeClass("fa-spin"),t(n.config.checkboxtd+":first",e).find("input[type='checkbox'][data-index]").length>0){var r,l,c,d=!1,u=!1,h=function(i){if(d){var o=Math.min(i.pageX,r),a=Math.min(i.pageY,l),s=Math.abs(r-i.pageX),u=Math.abs(l-i.pageY);c.css({left:o+"px",top:a+"px",width:s+"px",height:u+"px"});var h={x:o,y:a,width:s,height:u};t(n.config.checkboxtd,e).each(function(){var e=t("input:checkbox",this),i=this.getBoundingClientRect();i.x+=document.documentElement.scrollLeft,i.y+=document.documentElement.scrollTop;var n=i.x,o=i.y,a=i.x+i.width,s=i.y+i.height,r=h.x,l=h.y,c=h.x+h.width,d=h.y+h.height;n<=c&&a>=r&&o<=d&&s>=l?t(this).hasClass("overlaped")||(t(this).addClass("overlaped"),e.trigger("click")):t(this).hasClass("overlaped")&&(t(this).removeClass("overlaped"),e.trigger("click"))})}},p=function(){return!1},f=function(){d&&(t(document).off("mousemove",h),t(document).off("selectstart",p),c.remove()),d=!1,u=!1,t(document.body).css({MozUserSelect:"",webkitUserSelect:""}).attr("unselectable","off")};t(n.config.checkboxtd,e).on("mousedown",function(e){if(2===e.button||t(e.target).is("input"))return!1;r=e.pageX,l=e.pageY,u=!0}).on("mousemove",function(i){u&&!d&&(d=!0,c=t("
    "),c.css({position:"absolute",width:0,height:0,border:"1px dashed blue",background:"#0029ff",left:i.pageX+"px",top:i.pageY+"px",opacity:.1}),c.appendTo(document.body),t(document.body).css({MozUserSelect:"none",webkitUserSelect:"none"}).attr("unselectable","on"),t(document).on("mousemove",h).on("mouseup",f).on("selectstart",p),o.dragCheckboxMultiselect&&t(n.config.checkboxtd,e).removeClass("overlaped"))})}});var r=o.exportDataType;if(e.on("check.bs.table uncheck.bs.table check-all.bs.table uncheck-all.bs.table post-body.bs.table",function(i){var l=[];t.each(e.bootstrapTable("getData"),function(t,e){l.push(void 0!==e[o.pk]?e[o.pk]:"")});var c=n.api.selectedids(e,!0),d=n.api.selecteddata(e,!0);o.maintainSelected?(o.selectedIds=o.selectedIds.filter(function(e,i,n){return-1===t.inArray(e,l)}).concat(c),o.selectedData=o.selectedData.filter(function(e,i,n){return-1===t.inArray(e[o.pk],l)}).concat(d),o.selectedIds.length>c.length?(t("b",s).text(o.selectedIds.length),s.removeClass("hide")):s.addClass("hide")):(o.selectedIds=c,o.selectedData=d),"auto"===r&&(o.exportDataType=c.length>0?"selected":"all",0===t(".export .exporttips").length&&t(".export .dropdown-menu").prepend("
  • "),t(".export .exporttips").html("导出记录:"+(c.length>0?"选中":"全部"))),t(n.config.disabledbtn,a).toggleClass("disabled",!o.selectedIds.length)}),e.on("common-search.bs.table",function(i,n,o){var a=t(".panel-heading [data-field]",e.closest(".panel-intro")),s=a.data("field"),r=t("li.active > a",a).data("value");o.filter&&void 0!==o.filter[s]&&o.filter[s]!=r&&(t("li",a).removeClass("active"),t("li > a[data-value='"+o.filter[s]+"']",a).parent().addClass("active"))}),t('.panel-heading [data-field] a[data-toggle="tab"]',e.closest(".panel-intro")).on("shown.bs.tab",function(i){var n=t(this).closest("[data-field]").data("field"),o=t(this).data("value"),a=t("[name='"+n+"']",e.closest(".bootstrap-table").find(".commonsearch-table"));return"SELECT"===a.prop("tagName")?t("option[value='"+o+"']",a).prop("selected",!0):a.val(o),e.trigger("uncheckbox"),e.bootstrapTable("getOptions").totalRows=0,e.bootstrapTable("refresh",{pageNumber:1}),!1}),t("form",e.closest(".bootstrap-table").find(".commonsearch-table")).on("reset",function(){setTimeout(function(){},0),t(".panel-heading [data-field] li",e.closest(".panel-intro")).removeClass("active"),t(".panel-heading [data-field] li:first",e.closest(".panel-intro")).addClass("active")}),a.on("click",n.config.refreshbtn,function(){e.bootstrapTable("refresh")}),a.on("click",n.config.addbtn,function(){var i=n.api.selectedids(e),a=o.extend.add_url;-1!==a.indexOf("{ids}")&&(a=n.api.replaceurl(a,{ids:i.length>0?i.join(","):0},e)),Fast.api.open(a,t(this).data("original-title")||t(this).attr("title")||__("Add"),t(this).data()||{})}),t(n.config.importbtn,a).length>0&&require(["upload"],function(i){i.api.upload(t(n.config.importbtn,a),function(t,i){Fast.api.ajax({url:o.extend.import_url,data:{file:t.url}},function(t,i){e.trigger("uncheckbox"),e.bootstrapTable("refresh")})})}),a.on("click",n.config.editbtn,function(){var i=this;if(!(n.api.selectedids(e).length>10)){var a=t(i).data("title")||t(i).attr("title")||__("Edit"),s=t(i).data()||{};delete s.title,t.each(n.api.selecteddata(e),function(i,r){var l=o.extend.edit_url;r=t.extend({},r||{},{ids:r[o.pk]}),l=n.api.replaceurl(l,r,e),Fast.api.open(l,"function"==typeof a?a.call(e,r):a,s)})}}),t(document).on("click",n.config.destroyallbtn,function(){var i=this;return Layer.confirm(__("Are you sure you want to truncate?"),function(){var n=t(i).data("url")?t(i).data("url"):t(i).attr("href");Fast.api.ajax(n,function(){Layer.closeAll(),e.trigger("uncheckbox"),e.bootstrapTable("refresh")},function(){Layer.closeAll()})}),!1}),t(document).on("click",n.config.restoreallbtn,function(){var i=this,n=t(i).data("url")?t(i).data("url"):t(i).attr("href");return Fast.api.ajax(n,function(){Layer.closeAll(),e.trigger("uncheckbox"),e.bootstrapTable("refresh")},function(){Layer.closeAll()}),!1}),t(document).on("click",n.config.restoreonebtn+","+n.config.destroyonebtn,function(){var i=this,a=t(i).data("url")?t(i).data("url"):t(i).attr("href"),s=n.api.getrowbyindex(e,t(i).data("row-index"));return Fast.api.ajax({url:a,data:{ids:s[o.pk]}},function(){e.trigger("uncheckbox"),e.bootstrapTable("refresh")}),!1}),a.on("click",n.config.multibtn,function(){var i=n.api.selectedids(e);n.api.multi(t(this).data("action"),i,e,this)}),a.on("click",n.config.delbtn,function(){var t=this,i=n.api.selectedids(e);Layer.confirm(__("Are you sure you want to delete the %s selected item?",i.length),{icon:3,title:__("Warning"),offset:0,shadeClose:!0,btn:[__("OK"),__("Cancel")]},function(o){n.api.multi("del",i,e,t),Layer.close(o)})}),require(["dragsort"],function(){t("tbody",e).dragsort({itemSelector:"tr:visible",dragSelector:"a.btn-dragsort",dragEnd:function(i,o){var a=t("a.btn-dragsort",this),s=e.bootstrapTable("getData"),r=s[parseInt(t(this).data("index"))],l=e.bootstrapTable("getOptions"),c=t.map(t("tbody tr:visible",e),function(e){return s[parseInt(t(e).data("index"))][l.pk]}),d=r[l.pk],u=void 0!==r.pid?r.pid:"",h={url:e.bootstrapTable("getOptions").extend.dragsort_url,data:{ids:c.join(","),changeid:d,pid:u,field:n.config.dragsortfield,orderway:l.sortOrder,table:l.extend.table,pk:l.pk}};Fast.api.ajax(h,function(i,n){var o=t(a).data("success")||t.noop;if("function"==typeof o&&!1===o.call(a,i,n))return!1;e.bootstrapTable("refresh")},function(i,n){var o=t(a).data("error")||t.noop;if("function"==typeof o&&!1===o.call(a,i,n))return!1;e.bootstrapTable("refresh")})},placeHolderTemplate:""})}),e.on("click","input[data-id][name='checkbox']",function(i){var n=t(this).data("id");e.bootstrapTable(t(this).prop("checked")?"checkBy":"uncheckBy",{field:o.pk,values:[n]})}),e.on("click","[data-id].btn-change",function(i){i.preventDefault();var o=t.proxy(function(){n.api.multi(t(this).data("action")?t(this).data("action"):"",[t(this).data("id")],e,this)},this);void 0!==t(this).data("confirm")?Layer.confirm(t(this).data("confirm"),function(t){o(),Layer.close(t)}):o()}),e.on("click","[data-id].btn-edit",function(i){i.preventDefault();var a=t(this).data("id"),s=n.api.getrowbyid(e,a);s.ids=a;var r=n.api.replaceurl(o.extend.edit_url,s,e);Fast.api.open(r,t(this).data("original-title")||t(this).attr("title")||__("Edit"),t(this).data()||{})}),e.on("click","[data-id].btn-del",function(i){i.preventDefault();var o=t(this).data("id"),a=this;Layer.confirm(__("Are you sure you want to delete this item?"),{icon:3,title:__("Warning"),shadeClose:!0,btn:[__("OK"),__("Cancel")]},function(t){n.api.multi("del",o,e,a),Layer.close(t)})}),e.on("mouseenter mouseleave",".autocontent",function(e){var i=t(".autocontent-item",this).get(0);i&&("mouseenter"===e.type?i.scrollWidth>i.offsetWidth&&0===t(".autocontent-caret",this).length&&t(this).append("
    "):t(".autocontent-caret",this).remove())}),e.on("click mouseenter",".autocontent-caret",function(e){var i=t(this).prev().hasClass("autocontent-hover");if(i||"mouseenter"!==e.type){var n=t(this).prev().text(),o=t(this).parent().get(0).getBoundingClientRect(),a=Layer.open({id:"autocontent",skin:"layui-layer-fast layui-layer-autocontent",title:!1,content:n,btn:!1,anim:!1,shade:0,isOutAnim:!1,area:"auto",maxWidth:450,maxHeight:350,offset:[o.y,o.x]});i&&t(document).one("mouseleave","#layui-layer"+a,function(){Layer.close(a)});var s=function(e){0===t(e.target).closest(".layui-layer").length&&(Layer.close(a),t(document).off("mousedown",s))};t(document).off("mousedown",s).on("mousedown",s)}}),o.fixDropdownPosition){var l=e.closest(".fixed-table-body");e.on("show.bs.dropdown fa.event.refreshdropdown",".btn-group",function(e){var i,n,o,a=t(".dropdown-menu",this),s=t(this),r=a.hasClass("pull-right")||a.hasClass("dropdown-menu-right");o="fixed",n=s.offset().top-t(window).scrollTop()+s.outerHeight(),n+a.outerHeight()>t(window).height()&&(n=s.offset().top-a.outerHeight()-5),i=r?s.offset().left+s.outerWidth()-a.outerWidth():s.offset().left,(i||n)&&a.css({position:o,left:i,top:n,right:"inherit"})});var c=function(){t(".btn-group.open",e).length>0&&"fixed"==t(".btn-group.open .dropdown-menu",e).css("position")&&t(".btn-group.open",e).trigger("fa.event.refreshdropdown")};t(window).on("scroll",function(){c()}),l.on("scroll",function(){c()})}var d=e.attr("id");return n.list[d]=e,e},multi:function(e,i,n,o){var a=n.bootstrapTable("getOptions"),s=o?t(o).data():{};i=t.isArray(i)?i.join(","):i,a={url:void 0!==s.url?s.url:"del"==e?a.extend.del_url:a.extend.multi_url,data:{action:e,ids:i,params:void 0!==s.params?"object"==typeof s.params?t.param(s.params):s.params:""}},Fast.api.ajax(a,function(e,i){n.trigger("uncheckbox");var a=t(o).data("success")||t.noop;if("function"==typeof a&&!1===a.call(o,e,i))return!1;n.bootstrapTable("refresh")},function(e,i){var n=t(o).data("error")||t.noop;if("function"==typeof n&&!1===n.call(o,e,i))return!1})},events:{operate:{"click .btn-editone":function(e,i,o,a){e.stopPropagation(),e.preventDefault();var s=t(this).closest("table"),r=s.bootstrapTable("getOptions"),l=o[r.pk];o=t.extend({},o||{},{ids:l});var c=r.extend.edit_url;Fast.api.open(n.api.replaceurl(c,o,s),t(this).data("original-title")||t(this).attr("title")||__("Edit"),t(this).data()||{})},"click .btn-delone":function(i,o,a,s){i.stopPropagation(),i.preventDefault();var r=this,l=t(r).offset().top-t(window).scrollTop(),c=t(r).offset().left-t(window).scrollLeft()-260;l+154>t(window).height()&&(l-=154),t(window).width()<480&&(l=c=e),Layer.confirm(__("Are you sure you want to delete this item?"),{icon:3,title:__("Warning"),offset:[l,c],shadeClose:!0,btn:[__("OK"),__("Cancel")]},function(e){var i=t(r).closest("table"),o=i.bootstrapTable("getOptions");n.api.multi("del",a[o.pk],i,r),Layer.close(e)})}},image:{"click .img-center":function(e,i,n,o){var a=[];i=null===i?"":i.toString();var s,r=""!=i?i.split(","):[];t.each(r,function(t,e){s=Fast.api.cdnurl(e),a.push({src:s,thumb:s.match(/^(\/|data:image\\)/)?s:s+Config.upload.thumbstyle})}),Layer.photos({photos:{start:t(this).parent().index(),data:a},anim:5})}}},formatter:{icon:function(t,e,i){return t=null===t?"":t.toString(),'-1?t:"fa fa-"+t)+'"> '+t},image:function(t,e,i){return n.api.formatter.images.call(this,t,e,i)},images:function(e,i,n){e=null==e||0===e.length?"":e.toString();var o,a=void 0!==this.classname?this.classname:"img-sm img-center",s=""!==e?-1===e.indexOf("data:image/")?e.split(","):[e]:[],r=[];return t.each(s,function(t,e){e=e||"/assets/img/blank.gif",o=Fast.api.cdnurl(e,!0),o=!Config.upload.thumbstyle||o.match(/^(\/|data:image\/)/)||o.indexOf(Config.upload.thumbstyle.substring(0,1))>-1?o:o+Config.upload.thumbstyle,r.push('')}),r.join(" ")},file:function(t,e,i){return n.api.formatter.files.call(this,t,e,i)},files:function(e,i,n){e=null==e||0===e.length?"":e.toString();var o,a,s=void 0!==this.classname?this.classname:"img-sm img-center",r=""!==e?-1===e.indexOf("data:image/")?e.split(","):[e]:[],l=[];return t.each(r,function(t,e){e=Fast.api.cdnurl(e,!0),o=/[\.]?([a-zA-Z0-9]+)$/.exec(e),o=o?o[1]:"file",a=Fast.api.fixurl("ajax/icon?suffix="+o),l.push('')}),l.join(" ")},content:function(t,i,n){var o=this.width!=e?this.width.toString().match(/^\d+$/)?this.width+"px":this.width:"250px";return"
    "+t+"
    "},status:function(e,i,o){var a={normal:"success",hidden:"gray",deleted:"danger",locked:"info"};return void 0!==this.custom&&(a=t.extend(a,this.custom)),this.custom=a,this.icon="fa fa-circle",n.api.formatter.normal.call(this,e,i,o)},normal:function(e,i,n){var o=["primary","success","danger","warning","info","gray","red","yellow","aqua","blue","navy","teal","olive","lime","fuchsia","purple","maroon"],a={};void 0!==this.custom&&(a=t.extend(a,this.custom)),e=i[this.field]||e,e=null==e||0===e.length?"":e.toString();var s="object"==typeof this.searchList?Object.keys(this.searchList):[],n=s.indexOf(e),r=e&&void 0!==a[e]?a[e]:null,l=n>-1?this.searchList[e]:null,c=void 0!==this.icon?this.icon:null;r||(r=n>-1&&void 0!==o[n]?o[n]:"primary"),l||(l=__(e.charAt(0).toUpperCase()+e.slice(1))),e=Fast.api.escape(e),l=Fast.api.escape(l);var d=''+(c?' ':"")+l+"";return 0!=this.operate&&(d=''+d+""),d},toggle:function(t,e,i){var n=this.table,o=n?n.bootstrapTable("getOptions"):{},a=o.pk||"id",s=void 0!==this.color?this.color:"success",r=void 0!==this.yes?this.yes:1,l=void 0!==this.no?this.no:0,c=void 0!==this.url?this.url:"",d="",u=!1;return void 0!==this.confirm&&(d="function"==typeof this.confirm?this.confirm.call(this,t,e,i):this.confirm),void 0!==this.disable&&(u="function"==typeof this.disable?this.disable.call(this,t,e,i):this.disable),""},url:function(t,e,i){return'
    '},search:function(t,i,n){var o=this.field;if(void 0!==this.customField){var a=this.customField.split(".").reduce(function(t,i){return null===t||t===e?"":t[i]},i);t=Fast.api.escape(a),o=this.customField}return''+t+""},addtabs:function(t,e,i){var o=n.api.replaceurl(this.url||"",e,this.table),a=this.atitle?this.atitle:__("Search %s",t);return''+t+""},dialog:function(t,e,i){var o=n.api.replaceurl(this.url||"",e,this.table),a=this.atitle?this.atitle:__("View %s",t);return''+t+""},flag:function(i,n,o){var a=this;i=null==i||0===i.length?"":i.toString();var s={index:"success",hot:"warning",recommend:"danger",new:"info"};void 0!==this.custom&&(s=t.extend(s,this.custom));var r=this.field;if(void 0!==this.customField){var l=this.customField.split(".").reduce(function(t,i){return null===t||t===e?"":t[i]},n);i=Fast.api.escape(l),r=this.customField}if("object"==typeof a.searchList&&"function"==typeof a.searchList.then&&t.when(a.searchList).done(function(e){e.data&&e.data.searchlist&&t.isArray(e.data.searchlist)?a.searchList=e.data.searchlist:e.constructor!==Array&&e.constructor!==Object||(a.searchList=e)}),"object"==typeof a.searchList&&void 0===a.custom){var c=0,d=Object.values(s);t.each(a.searchList,function(t,e){void 0===s[t]&&(s[t]=d[c],c=void 0===d[c+1]?0:c+1)})}var u,h,p,f=[],m=t.isArray(i)?i:""!=i?i.split(","):[];return t.each(m,function(t,e){if(""===(e=null==e||0===e.length?"":e.toString()))return!0;u=e&&void 0!==s[e]?s[e]:"primary",h=void 0!==a.searchList&&void 0!==a.searchList[e]?a.searchList[e]:__(e.charAt(0).toUpperCase()+e.slice(1)),e=Fast.api.escape(e),h=Fast.api.escape(h),p=''+h+"",a.operate?f.push(''+p+""):f.push(p)}),f.join(" ")},label:function(t,e,i){return n.api.formatter.flag.call(this,t,e,i)},datetime:function(t,e,n){var o=void 0===this.datetimeFormat?"YYYY-MM-DD HH:mm:ss":this.datetimeFormat;return isNaN(t)?t?i(t).format(o):__("None"):t?i(1e3*parseInt(t)).format(o):__("None")},operate:function(e,i,o){var a=this.table,s=a?a.bootstrapTable("getOptions"):{},r=t.extend([],this.buttons||[]),l=[];return r.forEach(function(t){l.push(t.name)}),""!==s.extend.dragsort_url&&-1===l.indexOf("dragsort")&&r.push(n.button.dragsort),""!==s.extend.edit_url&&-1===l.indexOf("edit")&&(n.button.edit.url=s.extend.edit_url,r.push(n.button.edit)),""!==s.extend.del_url&&-1===l.indexOf("del")&&r.push(n.button.del),n.api.buttonlink(this,r,e,i,o,"operate")},buttons:function(e,i,o){var a=t.extend([],this.buttons||[]);return n.api.buttonlink(this,a,e,i,o,"buttons")}},buttonlink:function(e,i,o,a,s,r){var l=e.table;e.clickToSelect=!1,r=void 0===r?"buttons":r;var c,d,u,h,p,f,m,g,v,y,b,w,x,k=l?l.bootstrapTable("getOptions"):{},_=[],C=e.fieldIndex,S={};if(t.each(i,function(t,e){if("operate"===r){if("dragsort"===e.name&&void 0===a[n.config.dragsortfield])return!0;if(["add","edit","del","multi","dragsort"].indexOf(e.name)>-1&&!k.extend[e.name+"_url"])return!0}var i=l.data(r+"-"+e.name);if(void 0===i||i){if(c="function"==typeof e.hidden?e.hidden.call(l,a,e):void 0!==e.hidden&&e.hidden)return!0;if(!(d="function"==typeof e.visible?e.visible.call(l,a,e):void 0===e.visible||e.visible))return!0;w=e.dropdown?e.dropdown:"",h=e.url?e.url:"",h="function"==typeof h?h.call(l,a,e):h?Fast.api.fixurl(n.api.replaceurl(h,a,l)):"javascript:;",p=e.classname?e.classname:w?"btn-"+name+"one":"btn-primary btn-"+name+"one",f=e.icon?e.icon:"",m="function"==typeof e.text?e.text.call(l,a,e):e.text?e.text:"",g="function"==typeof e.title?e.title.call(l,a,e):e.title?e.title:m,v=e.refresh?'data-refresh="'+e.refresh+'"':"",y="function"==typeof e.confirm?e.confirm.call(l,a,e):void 0!==e.confirm&&e.confirm,y=y?'data-confirm="'+y+'"':"",b="function"==typeof e.extend?e.extend.call(l,a,e):void 0!==e.extend?e.extend:"",u="function"==typeof e.disable?e.disable.call(l,a,e):void 0!==e.disable&&e.disable,u&&(p+=" disabled"),x=''+(m?" "+m:"")+"",w?(void 0===S[w]&&(S[w]=[]),S[w].push(x)):_.push(x)}}),!t.isEmptyObject(S)){var T=[];t.each(S,function(t,e){T.push('
    ")}),_.unshift(T.join(" "))}return _.join(" ")},replaceurl:function(t,i,n){var o=n?n.bootstrapTable("getOptions"):null,a=o?i[o.pk]:0;return i.ids=a||(void 0!==i.ids?i.ids:0),t=null==t||0===t.length?"":t.toString(),t=t.match(/(?=([?&]ids=)|(\/ids\/)|(\{ids}))/i)?t:t+(t.match(/(\?|&)+/)?"&ids=":"/ids/")+"{ids}",t=t.replace(/\{(.*?)\}/gi,function(t){t=t.substring(1,t.length-1);var n=t.split(".").reduce(function(t,i){return null===t||t===e?"":t[i]},i);return n=Fast.api.escape(n)})},selectedids:function(e,i){var n=e.bootstrapTable("getOptions");return!i&&n.maintainSelected?n.selectedIds:t.map(e.bootstrapTable("getSelections"),function(t){return t[n.pk]})},selecteddata:function(t,e){var i=t.bootstrapTable("getOptions");return!e&&i.maintainSelected?i.selectedData:t.bootstrapTable("getSelections")},toggleattr:function(e){t("input[type='checkbox']",e).trigger("click")},getrowdata:function(t,e){e=parseInt(e);var i=t.bootstrapTable("getData");return void 0!==i[e]?i[e]:null},getrowbyindex:function(t,e){return n.api.getrowdata(t,e)},getrowbyid:function(e,i){var o={},a=e.bootstrapTable("getOptions");return t.each(n.api.selecteddata(e),function(t,e){if(e[a.pk]==i)return o=e,!1}),o}}};return n}),function(t){t.fn.dragsort=function(e){if("destroy"==e)return void t(this.selector).trigger("dragsort-uninit");var i=t.extend({},t.fn.dragsort.defaults,e),n=[],o=null,a=null;return this.each(function(e,s){t(s).is("table")&&1==t(s).children().length&&t(s).children().is("tbody")&&(s=t(s).children().get(0));var r={draggedItem:null,placeHolderItem:null,pos:null,offset:null,offsetLimit:null,scroll:null,container:s,init:function(){i.tagName=""==i.tagName?0==t(this.container).children().length?"li":t(this.container).children().get(0).tagName.toLowerCase():i.tagName,""==i.itemSelector&&(i.itemSelector=i.tagName),""==i.dragSelector&&(i.dragSelector=i.tagName),""==i.placeHolderTemplate&&(i.placeHolderTemplate="<"+i.tagName+"> "),t(this.container).attr("data-listidx",e).mousedown(this.grabItem).bind("dragsort-uninit",this.uninit),this.styleDragHandlers(!0)},uninit:function(){var e=n[t(this).attr("data-listidx")];t(e.container).unbind("mousedown",e.grabItem).unbind("dragsort-uninit"),e.styleDragHandlers(!1)},getItems:function(){return t(this.container).children(i.itemSelector)},styleDragHandlers:function(e){this.getItems().map(function(){return t(this).is(i.dragSelector)?this:t(this).find(i.dragSelector).get()}).css("cursor",e?"pointer":"")},grabItem:function(e){var o=n[t(this).attr("data-listidx")],a=t(e.target).closest("[data-listidx] > "+i.tagName).get(0),s=o.getItems().filter(function(){return this==a}).length>0;if(!(1!=e.which||t(e.target).is(i.dragSelectorExclude)||t(e.target).closest(i.dragSelectorExclude).length>0)&&s&&(t(e.target).is(i.dragSelector)||t(e.target).closest(i.dragSelector).length)){e.preventDefault();for(var r=e.target;!t(r).is(i.dragSelector);){if(r==this)return;r=r.parentNode}t(r).attr("data-cursor",t(r).css("cursor")),t(r).css("cursor","move");var l=this,c=function(){o.dragStart.call(l,e),t(o.container).unbind("mousemove",c)};t(o.container).mousemove(c).mouseup(function(){t(o.container).unbind("mousemove",c),t(r).css("cursor",t(r).attr("data-cursor"))})}},dragStart:function(e){null!=o&&null!=o.draggedItem&&o.dropItem(),o=n[t(this).attr("data-listidx")],o.draggedItem=t(e.target).closest("[data-listidx] > "+i.tagName),o.draggedItem.attr("data-origpos",t(this).attr("data-listidx")+"-"+t(o.container).children().index(o.draggedItem));var a=parseInt(o.draggedItem.css("marginTop")),s=parseInt(o.draggedItem.css("marginLeft"));if(o.offset=o.draggedItem.offset(),o.offset.top=e.pageY-o.offset.top+(isNaN(a)?0:a)-1,o.offset.left=e.pageX-o.offset.left+(isNaN(s)?0:s)-1,!i.dragBetween){var r=0==t(o.container).outerHeight()?Math.max(1,Math.round(.5+o.getItems().length*o.draggedItem.outerWidth()/t(o.container).outerWidth()))*o.draggedItem.outerHeight():t(o.container).outerHeight();o.offsetLimit=t(o.container).offset(),o.offsetLimit.right=o.offsetLimit.left+t(o.container).outerWidth()-o.draggedItem.outerWidth(),o.offsetLimit.bottom=o.offsetLimit.top+r-o.draggedItem.outerHeight()}var l=o.draggedItem.height(),c=o.draggedItem.width();if("tr"==i.tagName?(o.draggedItem.children().each(function(){t(this).width(t(this).width())}),o.placeHolderItem=o.draggedItem.clone().attr("data-placeholder",!0),o.draggedItem.after(o.placeHolderItem),o.placeHolderItem.children().each(function(){t(this).html(" ")})):(o.draggedItem.after(i.placeHolderTemplate),o.placeHolderItem=o.draggedItem.next().css({height:l,width:c}).attr("data-placeholder",!0)),"td"==i.tagName){var d=o.draggedItem.closest("table").get(0);t("
    ").appendTo("body").children().append(o.draggedItem)}var u=o.draggedItem.attr("style");o.draggedItem.attr("data-origstyle",u||""),o.draggedItem.css({position:"absolute",opacity:.8,"z-index":999,height:l,width:c}),o.scroll={moveX:0,moveY:0,maxX:t(document).width()-t(window).width(),maxY:t(document).height()-t(window).height()},o.scroll.scrollY=window.setInterval(function(){if(i.scrollContainer!=window)return void t(i.scrollContainer).scrollTop(t(i.scrollContainer).scrollTop()+o.scroll.moveY);var e=t(i.scrollContainer).scrollTop();(o.scroll.moveY>0&&e0)&&(t(i.scrollContainer).scrollTop(e+o.scroll.moveY),o.draggedItem.css("top",o.draggedItem.offset().top+o.scroll.moveY+1))},10),o.scroll.scrollX=window.setInterval(function(){if(i.scrollContainer!=window)return void t(i.scrollContainer).scrollLeft(t(i.scrollContainer).scrollLeft()+o.scroll.moveX);var e=t(i.scrollContainer).scrollLeft() +this.needFixedColumns&&this.options.fixedRightNumber&&(this.$fixedBodyRight.find("tr").hover(function(t){n(t,!0)},function(t){n(t,!1)}),this.$fixedBodyRight[0].addEventListener(a,function(t){s(t,i.$fixedBodyRight[0])}),this.$fixedBodyRight.find('input[name="'+this.options.selectItemName+'"]').off("click").on("click",function(e){e.stopImmediatePropagation();var n=t(e.target).data("index");t(i.$selectItem[n]).trigger("click")}),this.$fixedBodyRight.find("> table > tbody > tr[data-index] > td").off("click dblclick").on("click dblclick",function(e){var n=t(this).closest("tr[data-index]").data("index");t(i.$selectItem[n]).closest("tr[data-index]").find(">td:eq("+t(this).index()+")").trigger("click")})),this.options.filterControl&&t(this.$fixedColumns).off("keyup change").on("keyup change",function(e){var n=t(e.target),o=n.val(),a=n.parents("th").data("field"),s=i.$header.find('th[data-field="'+a+'"]');if(n.is("input"))s.find("input").val(o);else if(n.is("select")){var r=s.find("select");r.find("option[selected]").removeAttr("selected"),r.find('option[value="'+o+'"]').attr("selected",!0)}i.triggerSearch()})}}(jQuery),define("bootstrap-table-fixed-columns",["bootstrap-table"],function(t){return function(){return t.$.fn.bootstrapTable.defaults}}(this)),define("table",["jquery","bootstrap","moment","moment/locale/zh-cn","bootstrap-table","bootstrap-table-lang","bootstrap-table-export","bootstrap-table-commonsearch","bootstrap-table-template","bootstrap-table-jumpto","bootstrap-table-fixed-columns"],function(t,e,i){var n={list:{},defaults:{url:"",sidePagination:"server",method:"get",toolbar:".toolbar",search:!0,cache:!1,commonSearch:!0,searchFormVisible:!1,titleForm:"",idTable:"commonTable",showExport:!0,exportDataType:"auto",exportTypes:["json","xml","csv","txt","doc","excel"],exportOptions:{fileName:"export_"+i().format("YYYY-MM-DD"),preventInjection:!1,mso:{onMsoNumberFormat:function(e,i,n){return isNaN(t(e).text())?"":"\\@"}},ignoreColumn:[0,"operate"]},pageSize:Config.pagesize||localStorage.getItem("pagesize")||10,pageList:[10,15,20,25,50,"All"],pagination:!0,clickToSelect:!0,dblClickToEdit:!0,singleSelect:!1,showRefresh:!1,showJumpto:!0,locale:"zh-cn"===Config.language?"zh-CN":"en-US",showToggle:!0,showColumns:!0,pk:"id",sortName:"id",sortOrder:"desc",paginationFirstText:__("First"),paginationPreText:__("Previous"),paginationNextText:__("Next"),paginationLastText:__("Last"),cardView:!1,iosCardView:!0,checkOnInit:!0,escape:!0,fixDropdownPosition:!0,dragCheckboxMultiselect:!0,selectedIds:[],selectedData:[],extend:{index_url:"",add_url:"",edit_url:"",del_url:"",import_url:"",multi_url:"",dragsort_url:"ajax/weigh"}},columnDefaults:{align:"center",valign:"middle"},config:{checkboxtd:"tbody>tr>td.bs-checkbox",toolbar:".toolbar",refreshbtn:".btn-refresh",addbtn:".btn-add",editbtn:".btn-edit",delbtn:".btn-del",importbtn:".btn-import",multibtn:".btn-multi",disabledbtn:".btn-disabled",editonebtn:".btn-editone",restoreonebtn:".btn-restoreone",destroyonebtn:".btn-destroyone",restoreallbtn:".btn-restoreall",destroyallbtn:".btn-destroyall",dragsortfield:"weigh"},button:{edit:{name:"edit",icon:"",text:__("Edit"),title:__("Edit"),extend:'data-toggle="tooltip" data-container="body"',classname:"btn btn-xs btn-success btn-editone"},del:{name:"del",icon:"",text:__("Del"),title:__("Del"),extend:'data-toggle="tooltip" data-container="body"',classname:"btn btn-xs btn-danger btn-delone"},dragsort:{name:"dragsort",icon:"",text:"排序",title:__("Drag to sort"),extend:'data-toggle="tooltip"',classname:"btn btn-xs btn-primary btn-dragsort"}},api:{init:function(e,i,o){e=e||{},i=i||{},o=o||{},t.fn.bootstrapTable.Constructor.prototype.getSelectItem=function(){return this.$selectItem};var a=t.fn.bootstrapTable.Constructor.prototype.onPageListChange;t.fn.bootstrapTable.Constructor.prototype.onPageListChange=function(){return a.apply(this,Array.prototype.slice.apply(arguments)),localStorage.setItem("pagesize",this.options.pageSize),!1},t.extend(!0,t.fn.bootstrapTable.defaults,n.defaults,e),t.extend(t.fn.bootstrapTable.columnDefaults,n.columnDefaults,i),t.extend(t.fn.bootstrapTable.locales[n.defaults.locale],{formatCommonSearch:function(){return __("Common search")},formatCommonSubmitButton:function(){return __("Search")},formatCommonResetButton:function(){return __("Reset")},formatCommonCloseButton:function(){return __("Close")},formatCommonChoose:function(){return __("Choose")},formatJumpto:function(){return __("Go")}},o),t.fn.bootstrapTable.defaults.iosCardView&&navigator.userAgent.match(/(iPod|iPhone|iPad)/)&&(n.defaults.cardView=!0,t.fn.bootstrapTable.defaults.cardView=!0),void 0!==e.exportTypes&&(t.fn.bootstrapTable.defaults.exportTypes=e.exportTypes)},bindevent:function(e){var i=e.closest(".bootstrap-table"),o=e.bootstrapTable("getOptions"),a=t(o.toolbar,i),s=t(".btn-selected-tips",i);0===s.length&&(s=t(' '+__("Multiple selection mode: %s checked","0")+"").appendTo(a)),s.off("click").on("click",function(t){e.trigger("uncheckbox"),e.bootstrapTable("refresh")}),e.on("uncheckbox",function(t,e,i){o.selectedIds=[],o.selectedData=[],s.tooltip("hide"),s.addClass("hide")}),e.on("load-error.bs.table",function(t,e,i){0!==i.status&&Toastr.error(__("Unknown data format"))}),e.on("load-success.bs.table",function(t,e){void 0===e.rows&&void 0!==e.code&&Toastr.error(e.msg)}),e.on("refresh.bs.table",function(e,i,o){t(n.config.refreshbtn,a).find(".fa").addClass("fa-spin"),t(".layui-layer-autocontent").remove()}),e.on("search.bs.table common-search.bs.table",function(t,i,n){e.trigger("uncheckbox")}),o.dblClickToEdit&&e.on("dbl-click-row.bs.table",function(e,i,o,a){t(n.config.editonebtn,o).trigger("click")}),e.on("pre-body.bs.table",function(e,i){o.maintainSelected&&t.each(i,function(e,i){i[o.stateField]=t.inArray(i[o.pk],o.selectedIds)>-1})}),e.on("post-body.bs.table",function(i,s){if(t(n.config.refreshbtn,a).find(".fa").removeClass("fa-spin"),t(n.config.checkboxtd+":first",e).find("input[type='checkbox'][data-index]").length>0){var r,l,c,d=!1,u=!1,h=function(i){if(d){var o=Math.min(i.pageX,r),a=Math.min(i.pageY,l),s=Math.abs(r-i.pageX),u=Math.abs(l-i.pageY);c.css({left:o+"px",top:a+"px",width:s+"px",height:u+"px"});var h={x:o,y:a,width:s,height:u};t(n.config.checkboxtd,e).each(function(){var e=t("input:checkbox",this),i=this.getBoundingClientRect();i.x+=document.documentElement.scrollLeft,i.y+=document.documentElement.scrollTop;var n=i.x,o=i.y,a=i.x+i.width,s=i.y+i.height,r=h.x,l=h.y,c=h.x+h.width,d=h.y+h.height;n<=c&&a>=r&&o<=d&&s>=l?t(this).hasClass("overlaped")||(t(this).addClass("overlaped"),e.trigger("click")):t(this).hasClass("overlaped")&&(t(this).removeClass("overlaped"),e.trigger("click"))})}},p=function(){return!1},f=function(){d&&(t(document).off("mousemove",h),t(document).off("selectstart",p),c.remove()),d=!1,u=!1,t(document.body).css({MozUserSelect:"",webkitUserSelect:""}).attr("unselectable","off")};t(n.config.checkboxtd,e).on("mousedown",function(e){if(2===e.button||t(e.target).is("input"))return!1;r=e.pageX,l=e.pageY,u=!0}).on("mousemove",function(i){u&&!d&&(d=!0,c=t("
    "),c.css({position:"absolute",width:0,height:0,border:"1px dashed blue",background:"#0029ff",left:i.pageX+"px",top:i.pageY+"px",opacity:.1}),c.appendTo(document.body),t(document.body).css({MozUserSelect:"none",webkitUserSelect:"none"}).attr("unselectable","on"),t(document).on("mousemove",h).on("mouseup",f).on("selectstart",p),o.dragCheckboxMultiselect&&t(n.config.checkboxtd,e).removeClass("overlaped"))})}});var r=o.exportDataType;if(e.on("check.bs.table uncheck.bs.table check-all.bs.table uncheck-all.bs.table post-body.bs.table",function(i){var l=[];t.each(e.bootstrapTable("getData"),function(t,e){l.push(void 0!==e[o.pk]?e[o.pk]:"")});var c=n.api.selectedids(e,!0),d=n.api.selecteddata(e,!0);o.maintainSelected?(o.selectedIds=o.selectedIds.filter(function(e,i,n){return-1===t.inArray(e,l)}).concat(c),o.selectedData=o.selectedData.filter(function(e,i,n){return-1===t.inArray(e[o.pk],l)}).concat(d),o.selectedIds.length>c.length?(t("b",s).text(o.selectedIds.length),s.removeClass("hide")):s.addClass("hide")):(o.selectedIds=c,o.selectedData=d),"auto"===r&&(o.exportDataType=c.length>0?"selected":"all",0===t(".export .exporttips").length&&t(".export .dropdown-menu").prepend("
  • "),t(".export .exporttips").html("导出记录:"+(c.length>0?"选中":"全部"))),t(n.config.disabledbtn,a).toggleClass("disabled",!o.selectedIds.length)}),e.on("common-search.bs.table",function(i,n,o){var a=t(".panel-heading [data-field]",e.closest(".panel-intro")),s=a.data("field"),r=t("li.active > a",a).data("value");o.filter&&void 0!==o.filter[s]&&o.filter[s]!=r&&(t("li",a).removeClass("active"),t("li > a[data-value='"+o.filter[s]+"']",a).parent().addClass("active"))}),t('.panel-heading [data-field] a[data-toggle="tab"]',e.closest(".panel-intro")).on("shown.bs.tab",function(i){var n=t(this).closest("[data-field]").data("field"),o=t(this).data("value"),a=t("[name='"+n+"']",e.closest(".bootstrap-table").find(".commonsearch-table"));return"SELECT"===a.prop("tagName")?t("option[value='"+o+"']",a).prop("selected",!0):a.val(o),e.trigger("uncheckbox"),e.bootstrapTable("getOptions").totalRows=0,e.bootstrapTable("refresh",{pageNumber:1}),!1}),t("form",e.closest(".bootstrap-table").find(".commonsearch-table")).on("reset",function(){setTimeout(function(){},0),t(".panel-heading [data-field] li",e.closest(".panel-intro")).removeClass("active"),t(".panel-heading [data-field] li:first",e.closest(".panel-intro")).addClass("active")}),a.on("click",n.config.refreshbtn,function(){e.bootstrapTable("refresh")}),a.on("click",n.config.addbtn,function(){var i=n.api.selectedids(e),a=o.extend.add_url;-1!==a.indexOf("{ids}")&&(a=n.api.replaceurl(a,{ids:i.length>0?i.join(","):0},e)),Fast.api.open(a,t(this).data("original-title")||t(this).attr("title")||__("Add"),t(this).data()||{})}),t(n.config.importbtn,a).length>0&&require(["upload"],function(i){i.api.upload(t(n.config.importbtn,a),function(t,i){Fast.api.ajax({url:o.extend.import_url,data:{file:t.url}},function(t,i){e.trigger("uncheckbox"),e.bootstrapTable("refresh")})})}),a.on("click",n.config.editbtn,function(){var i=this;if(!(n.api.selectedids(e).length>10)){var a=t(i).data("title")||t(i).attr("title")||__("Edit"),s=t(i).data()||{};delete s.title,t.each(n.api.selecteddata(e),function(i,r){var l=o.extend.edit_url;r=t.extend({},r||{},{ids:r[o.pk]}),l=n.api.replaceurl(l,r,e),Fast.api.open(l,"function"==typeof a?a.call(e,r):a,s)})}}),t(document).on("click",n.config.destroyallbtn,function(){var i=this;return Layer.confirm(__("Are you sure you want to truncate?"),function(){var n=t(i).data("url")?t(i).data("url"):t(i).attr("href");Fast.api.ajax(n,function(){Layer.closeAll(),e.trigger("uncheckbox"),e.bootstrapTable("refresh")},function(){Layer.closeAll()})}),!1}),t(document).on("click",n.config.restoreallbtn,function(){var i=this,n=t(i).data("url")?t(i).data("url"):t(i).attr("href");return Fast.api.ajax(n,function(){Layer.closeAll(),e.trigger("uncheckbox"),e.bootstrapTable("refresh")},function(){Layer.closeAll()}),!1}),t(document).on("click",n.config.restoreonebtn+","+n.config.destroyonebtn,function(){var i=this,a=t(i).data("url")?t(i).data("url"):t(i).attr("href"),s=n.api.getrowbyindex(e,t(i).data("row-index"));return Fast.api.ajax({url:a,data:{ids:s[o.pk]}},function(){e.trigger("uncheckbox"),e.bootstrapTable("refresh")}),!1}),a.on("click",n.config.multibtn,function(){var i=n.api.selectedids(e);n.api.multi(t(this).data("action"),i,e,this)}),a.on("click",n.config.delbtn,function(){var t=this,i=n.api.selectedids(e);Layer.confirm(__("Are you sure you want to delete the %s selected item?",i.length),{icon:3,title:__("Warning"),offset:0,shadeClose:!0,btn:[__("OK"),__("Cancel")]},function(o){n.api.multi("del",i,e,t),Layer.close(o)})}),require(["dragsort"],function(){t("tbody",e).dragsort({itemSelector:"tr:visible",dragSelector:"a.btn-dragsort",dragEnd:function(i,o){var a=t("a.btn-dragsort",this),s=e.bootstrapTable("getData"),r=s[parseInt(t(this).data("index"))],l=e.bootstrapTable("getOptions"),c=t.map(t("tbody tr:visible",e),function(e){return s[parseInt(t(e).data("index"))][l.pk]}),d=r[l.pk],u=void 0!==r.pid?r.pid:"",h={url:e.bootstrapTable("getOptions").extend.dragsort_url,data:{ids:c.join(","),changeid:d,pid:u,field:n.config.dragsortfield,orderway:l.sortOrder,table:l.extend.table,pk:l.pk}};Fast.api.ajax(h,function(i,n){var o=t(a).data("success")||t.noop;if("function"==typeof o&&!1===o.call(a,i,n))return!1;e.bootstrapTable("refresh")},function(i,n){var o=t(a).data("error")||t.noop;if("function"==typeof o&&!1===o.call(a,i,n))return!1;e.bootstrapTable("refresh")})},placeHolderTemplate:""})}),e.on("click","input[data-id][name='checkbox']",function(i){var n=t(this).data("id");e.bootstrapTable(t(this).prop("checked")?"checkBy":"uncheckBy",{field:o.pk,values:[n]})}),e.on("click","[data-id].btn-change",function(i){i.preventDefault();var o=t.proxy(function(){n.api.multi(t(this).data("action")?t(this).data("action"):"",[t(this).data("id")],e,this)},this);void 0!==t(this).data("confirm")?Layer.confirm(t(this).data("confirm"),function(t){o(),Layer.close(t)}):o()}),e.on("click","[data-id].btn-edit",function(i){i.preventDefault();var a=t(this).data("id"),s=n.api.getrowbyid(e,a);s.ids=a;var r=n.api.replaceurl(o.extend.edit_url,s,e);Fast.api.open(r,t(this).data("original-title")||t(this).attr("title")||__("Edit"),t(this).data()||{})}),e.on("click","[data-id].btn-del",function(i){i.preventDefault();var o=t(this).data("id"),a=this;Layer.confirm(__("Are you sure you want to delete this item?"),{icon:3,title:__("Warning"),shadeClose:!0,btn:[__("OK"),__("Cancel")]},function(t){n.api.multi("del",o,e,a),Layer.close(t)})}),e.on("mouseenter mouseleave",".autocontent",function(e){var i=t(".autocontent-item",this).get(0);i&&("mouseenter"===e.type?i.scrollWidth>i.offsetWidth&&0===t(".autocontent-caret",this).length&&t(this).append("
    "):t(".autocontent-caret",this).remove())}),e.on("click mouseenter",".autocontent-caret",function(e){var i=t(this).prev().hasClass("autocontent-hover");if(i||"mouseenter"!==e.type){var n=t(this).prev().text(),o=t(this).parent().get(0).getBoundingClientRect(),a=Layer.open({id:"autocontent",skin:"layui-layer-fast layui-layer-autocontent",title:!1,content:n,btn:!1,anim:!1,shade:0,isOutAnim:!1,area:"auto",maxWidth:450,maxHeight:350,offset:[o.y,o.x]});i&&t(document).one("mouseleave","#layui-layer"+a,function(){Layer.close(a)});var s=function(e){0===t(e.target).closest(".layui-layer").length&&(Layer.close(a),t(document).off("mousedown",s))};t(document).off("mousedown",s).on("mousedown",s)}}),o.fixDropdownPosition){var l=e.closest(".fixed-table-body");e.on("show.bs.dropdown fa.event.refreshdropdown",".btn-group",function(e){var i,n,o,a=t(".dropdown-menu",this),s=t(this),r=a.hasClass("pull-right")||a.hasClass("dropdown-menu-right");o="fixed",n=s.offset().top-t(window).scrollTop()+s.outerHeight(),n+a.outerHeight()>t(window).height()&&(n=s.offset().top-a.outerHeight()-5),i=r?s.offset().left+s.outerWidth()-a.outerWidth():s.offset().left,(i||n)&&a.css({position:o,left:i,top:n,right:"inherit"})});var c=function(){t(".btn-group.open",e).length>0&&"fixed"==t(".btn-group.open .dropdown-menu",e).css("position")&&t(".btn-group.open",e).trigger("fa.event.refreshdropdown")};t(window).on("scroll",function(){c()}),l.on("scroll",function(){c()})}var d=e.attr("id");return n.list[d]=e,e},multi:function(e,i,n,o){var a=n.bootstrapTable("getOptions"),s=o?t(o).data():{};i=t.isArray(i)?i.join(","):i,a={url:void 0!==s.url?s.url:"del"==e?a.extend.del_url:a.extend.multi_url,data:{action:e,ids:i,params:void 0!==s.params?"object"==typeof s.params?t.param(s.params):s.params:""}},Fast.api.ajax(a,function(e,i){n.trigger("uncheckbox");var a=t(o).data("success")||t.noop;if("function"==typeof a&&!1===a.call(o,e,i))return!1;n.bootstrapTable("refresh")},function(e,i){var n=t(o).data("error")||t.noop;if("function"==typeof n&&!1===n.call(o,e,i))return!1})},events:{operate:{"click .btn-editone":function(e,i,o,a){e.stopPropagation(),e.preventDefault();var s=t(this).closest("table"),r=s.bootstrapTable("getOptions"),l=o[r.pk];o=t.extend({},o||{},{ids:l});var c=r.extend.edit_url;Fast.api.open(n.api.replaceurl(c,o,s),t(this).data("original-title")||t(this).attr("title")||__("Edit"),t(this).data()||{})},"click .btn-delone":function(i,o,a,s){i.stopPropagation(),i.preventDefault();var r=this,l=t(r).offset().top-t(window).scrollTop(),c=t(r).offset().left-t(window).scrollLeft()-260;l+154>t(window).height()&&(l-=154),t(window).width()<480&&(l=c=e),Layer.confirm(__("Are you sure you want to delete this item?"),{icon:3,title:__("Warning"),offset:[l,c],shadeClose:!0,btn:[__("OK"),__("Cancel")]},function(e){var i=t(r).closest("table"),o=i.bootstrapTable("getOptions");n.api.multi("del",a[o.pk],i,r),Layer.close(e)})}},image:{"click .img-center":function(e,i,n,o){var a=[];i=null===i?"":i.toString();var s,r=""!=i?i.split(","):[];t.each(r,function(t,e){s=Fast.api.cdnurl(e),a.push({src:s,thumb:s.match(/^(\/|data:image\\)/)?s:s+Config.upload.thumbstyle})}),Layer.photos({photos:{start:t(this).parent().index(),data:a},anim:5})}}},formatter:{icon:function(t,e,i){return t=null===t?"":t.toString(),'-1?t:"fa fa-"+t)+'"> '+t},image:function(t,e,i){return n.api.formatter.images.call(this,t,e,i)},images:function(e,i,n){e=null==e||0===e.length?"":e.toString();var o,a=void 0!==this.classname?this.classname:"img-sm img-center",s=""!==e?-1===e.indexOf("data:image/")?e.split(","):[e]:[],r=[];return t.each(s,function(t,e){e=e||"/assets/img/blank.gif",o=Fast.api.cdnurl(e,!0),o=!Config.upload.thumbstyle||o.match(/^(\/|data:image\/)/)||o.indexOf(Config.upload.thumbstyle.substring(0,1))>-1?o:o+Config.upload.thumbstyle,r.push('')}),r.join(" ")},file:function(t,e,i){return n.api.formatter.files.call(this,t,e,i)},files:function(e,i,n){e=null==e||0===e.length?"":e.toString();var o,a,s=void 0!==this.classname?this.classname:"img-sm img-center",r=""!==e?-1===e.indexOf("data:image/")?e.split(","):[e]:[],l=[];return t.each(r,function(t,e){e=Fast.api.cdnurl(e,!0),o=/[\.]?([a-zA-Z0-9]+)$/.exec(e),o=o?o[1]:"file",a=Fast.api.fixurl("ajax/icon?suffix="+o),l.push('')}),l.join(" ")},content:function(t,i,n){var o=this.width!=e?this.width.toString().match(/^\d+$/)?this.width+"px":this.width:"250px";return"
    "+t+"
    "},status:function(e,i,o){var a={normal:"success",hidden:"gray",deleted:"danger",locked:"info"};return void 0!==this.custom&&(a=t.extend(a,this.custom)),this.custom=a,this.icon="fa fa-circle",n.api.formatter.normal.call(this,e,i,o)},normal:function(e,i,n){var o=["primary","success","danger","warning","info","gray","red","yellow","aqua","blue","navy","teal","olive","lime","fuchsia","purple","maroon"],a={};void 0!==this.custom&&(a=t.extend(a,this.custom)),e=i[this.field]||e,e=null==e||0===e.length?"":e.toString();var s="object"==typeof this.searchList?Object.keys(this.searchList):[],n=s.indexOf(e),r=e&&void 0!==a[e]?a[e]:null,l=n>-1?this.searchList[e]:null,c=void 0!==this.icon?this.icon:null;r||(r=n>-1&&void 0!==o[n]?o[n]:"primary"),l||(l=__(e.charAt(0).toUpperCase()+e.slice(1))),e=Fast.api.escape(e),l=Fast.api.escape(l);var d=''+(c?' ':"")+l+"";return 0!=this.operate&&(d=''+d+""),d},toggle:function(t,e,i){var n=this.table,o=n?n.bootstrapTable("getOptions"):{},a=o.pk||"id",s=void 0!==this.color?this.color:"success",r=void 0!==this.yes?this.yes:1,l=void 0!==this.no?this.no:0,c=void 0!==this.url?this.url:"",d="",u=!1;return void 0!==this.confirm&&(d="function"==typeof this.confirm?this.confirm.call(this,t,e,i):this.confirm),void 0!==this.disable&&(u="function"==typeof this.disable?this.disable.call(this,t,e,i):this.disable),""},url:function(t,e,i){return'
    '},search:function(t,i,n){var o=this.field;if(void 0!==this.customField){var a=this.customField.split(".").reduce(function(t,i){return null===t||t===e?"":t[i]},i);t=Fast.api.escape(a),o=this.customField}return''+t+""},addtabs:function(t,e,i){var o=n.api.replaceurl(this.url||"",e,this.table),a=this.atitle?this.atitle:__("Search %s",t);return''+t+""},dialog:function(t,e,i){var o=n.api.replaceurl(this.url||"",e,this.table),a=this.atitle?this.atitle:__("View %s",t);return''+t+""},flag:function(i,n,o){var a=this;i=null==i||0===i.length?"":i.toString();var s={index:"success",hot:"warning",recommend:"danger",new:"info"};void 0!==this.custom&&(s=t.extend(s,this.custom));var r=this.field;if(void 0!==this.customField){var l=this.customField.split(".").reduce(function(t,i){return null===t||t===e?"":t[i]},n);i=Fast.api.escape(l),r=this.customField}if("object"==typeof a.searchList&&"function"==typeof a.searchList.then&&t.when(a.searchList).done(function(e){e.data&&e.data.searchlist&&t.isArray(e.data.searchlist)?a.searchList=e.data.searchlist:e.constructor!==Array&&e.constructor!==Object||(a.searchList=e)}),"object"==typeof a.searchList&&void 0===a.custom){var c=0,d=Object.values(s);t.each(a.searchList,function(t,e){void 0===s[t]&&(s[t]=d[c],c=void 0===d[c+1]?0:c+1)})}var u,h,p,f=[],m=t.isArray(i)?i:""!=i?i.split(","):[];return t.each(m,function(t,e){if(""===(e=null==e||0===e.length?"":e.toString()))return!0;u=e&&void 0!==s[e]?s[e]:"primary",h=void 0!==a.searchList&&void 0!==a.searchList[e]?a.searchList[e]:__(e.charAt(0).toUpperCase()+e.slice(1)),e=Fast.api.escape(e),h=Fast.api.escape(h),p=''+h+"",a.operate?f.push(''+p+""):f.push(p)}),f.join(" ")},label:function(t,e,i){return n.api.formatter.flag.call(this,t,e,i)},datetime:function(t,e,n){var o=void 0===this.datetimeFormat?"YYYY-MM-DD HH:mm:ss":this.datetimeFormat;return isNaN(t)?t?i(t).format(o):__("None"):t?i(1e3*parseInt(t)).format(o):__("None")},operate:function(e,i,o){var a=this.table,s=a?a.bootstrapTable("getOptions"):{},r=t.extend([],this.buttons||[]),l=[];return r.forEach(function(t){l.push(t.name)}),""!==s.extend.dragsort_url&&-1===l.indexOf("dragsort")&&r.push(n.button.dragsort),""!==s.extend.edit_url&&-1===l.indexOf("edit")&&(n.button.edit.url=s.extend.edit_url,r.push(n.button.edit)),""!==s.extend.del_url&&-1===l.indexOf("del")&&r.push(n.button.del),n.api.buttonlink(this,r,e,i,o,"operate")},buttons:function(e,i,o){var a=t.extend([],this.buttons||[]);return n.api.buttonlink(this,a,e,i,o,"buttons")}},buttonlink:function(e,i,o,a,s,r){var l=e.table;e.clickToSelect=!1,r=void 0===r?"buttons":r;var c,d,u,h,p,f,m,g,v,y,b,w,x,k=l?l.bootstrapTable("getOptions"):{},_=[],C=e.fieldIndex,S={};if(t.each(i,function(t,e){if("operate"===r){if("dragsort"===e.name&&void 0===a[n.config.dragsortfield])return!0;if(["add","edit","del","multi","dragsort"].indexOf(e.name)>-1&&!k.extend[e.name+"_url"])return!0}var i=l.data(r+"-"+e.name);if(void 0===i||i){if(c="function"==typeof e.hidden?e.hidden.call(l,a,e):void 0!==e.hidden&&e.hidden)return!0;if(!(d="function"==typeof e.visible?e.visible.call(l,a,e):void 0===e.visible||e.visible))return!0;w=e.dropdown?e.dropdown:"",h=e.url?e.url:"",h="function"==typeof h?h.call(l,a,e):h?Fast.api.fixurl(n.api.replaceurl(h,a,l)):"javascript:;",p=e.classname?e.classname:w?"btn-"+name+"one":"btn-primary btn-"+name+"one",f=e.icon?e.icon:"",m="function"==typeof e.text?e.text.call(l,a,e):e.text?e.text:"",g="function"==typeof e.title?e.title.call(l,a,e):e.title?e.title:m,v=e.refresh?'data-refresh="'+e.refresh+'"':"",y="function"==typeof e.confirm?e.confirm.call(l,a,e):void 0!==e.confirm&&e.confirm,y=y?'data-confirm="'+y+'"':"",b="function"==typeof e.extend?e.extend.call(l,a,e):void 0!==e.extend?e.extend:"",u="function"==typeof e.disable?e.disable.call(l,a,e):void 0!==e.disable&&e.disable,u&&(p+=" disabled"),x=''+(f?'':"")+(m?(f?" ":"")+m:"")+"",w?(void 0===S[w]&&(S[w]=[]),S[w].push(x)):_.push(x)}}),!t.isEmptyObject(S)){var T=[];t.each(S,function(t,e){T.push('
    ")}),_.unshift(T.join(" "))}return _.join(" ")},replaceurl:function(t,i,n){var o=n?n.bootstrapTable("getOptions"):null,a=o?i[o.pk]:0;return i.ids=a||(void 0!==i.ids?i.ids:0),t=null==t||0===t.length?"":t.toString(),t=t.match(/(?=([?&]ids=)|(\/ids\/)|(\{ids}))/i)?t:t+(t.match(/(\?|&)+/)?"&ids=":"/ids/")+"{ids}",t=t.replace(/\{(.*?)\}/gi,function(t){t=t.substring(1,t.length-1);var n=t.split(".").reduce(function(t,i){return null===t||t===e?"":t[i]},i);return n=Fast.api.escape(n)})},selectedids:function(e,i){var n=e.bootstrapTable("getOptions");return!i&&n.maintainSelected?n.selectedIds:t.map(e.bootstrapTable("getSelections"),function(t){return t[n.pk]})},selecteddata:function(t,e){var i=t.bootstrapTable("getOptions");return!e&&i.maintainSelected?i.selectedData:t.bootstrapTable("getSelections")},toggleattr:function(e){t("input[type='checkbox']",e).trigger("click")},getrowdata:function(t,e){e=parseInt(e);var i=t.bootstrapTable("getData");return void 0!==i[e]?i[e]:null},getrowbyindex:function(t,e){return n.api.getrowdata(t,e)},getrowbyid:function(e,i){var o={},a=e.bootstrapTable("getOptions");return t.each(n.api.selecteddata(e),function(t,e){if(e[a.pk]==i)return o=e,!1}),o}}};return n}),function(t){t.fn.dragsort=function(e){if("destroy"==e)return void t(this.selector).trigger("dragsort-uninit");var i=t.extend({},t.fn.dragsort.defaults,e),n=[],o=null,a=null;return this.each(function(e,s){t(s).is("table")&&1==t(s).children().length&&t(s).children().is("tbody")&&(s=t(s).children().get(0));var r={draggedItem:null,placeHolderItem:null,pos:null,offset:null,offsetLimit:null,scroll:null,container:s,init:function(){i.tagName=""==i.tagName?0==t(this.container).children().length?"li":t(this.container).children().get(0).tagName.toLowerCase():i.tagName,""==i.itemSelector&&(i.itemSelector=i.tagName),""==i.dragSelector&&(i.dragSelector=i.tagName),""==i.placeHolderTemplate&&(i.placeHolderTemplate="<"+i.tagName+"> "),t(this.container).attr("data-listidx",e).mousedown(this.grabItem).bind("dragsort-uninit",this.uninit),this.styleDragHandlers(!0)},uninit:function(){var e=n[t(this).attr("data-listidx")];t(e.container).unbind("mousedown",e.grabItem).unbind("dragsort-uninit"),e.styleDragHandlers(!1)},getItems:function(){return t(this.container).children(i.itemSelector)},styleDragHandlers:function(e){this.getItems().map(function(){return t(this).is(i.dragSelector)?this:t(this).find(i.dragSelector).get()}).css("cursor",e?"pointer":"")},grabItem:function(e){var o=n[t(this).attr("data-listidx")],a=t(e.target).closest("[data-listidx] > "+i.tagName).get(0),s=o.getItems().filter(function(){return this==a}).length>0;if(!(1!=e.which||t(e.target).is(i.dragSelectorExclude)||t(e.target).closest(i.dragSelectorExclude).length>0)&&s&&(t(e.target).is(i.dragSelector)||t(e.target).closest(i.dragSelector).length)){e.preventDefault();for(var r=e.target;!t(r).is(i.dragSelector);){if(r==this)return;r=r.parentNode}t(r).attr("data-cursor",t(r).css("cursor")),t(r).css("cursor","move");var l=this,c=function(){o.dragStart.call(l,e),t(o.container).unbind("mousemove",c)};t(o.container).mousemove(c).mouseup(function(){t(o.container).unbind("mousemove",c),t(r).css("cursor",t(r).attr("data-cursor"))})}},dragStart:function(e){null!=o&&null!=o.draggedItem&&o.dropItem(),o=n[t(this).attr("data-listidx")],o.draggedItem=t(e.target).closest("[data-listidx] > "+i.tagName),o.draggedItem.attr("data-origpos",t(this).attr("data-listidx")+"-"+t(o.container).children().index(o.draggedItem));var a=parseInt(o.draggedItem.css("marginTop")),s=parseInt(o.draggedItem.css("marginLeft"));if(o.offset=o.draggedItem.offset(),o.offset.top=e.pageY-o.offset.top+(isNaN(a)?0:a)-1,o.offset.left=e.pageX-o.offset.left+(isNaN(s)?0:s)-1,!i.dragBetween){var r=0==t(o.container).outerHeight()?Math.max(1,Math.round(.5+o.getItems().length*o.draggedItem.outerWidth()/t(o.container).outerWidth()))*o.draggedItem.outerHeight():t(o.container).outerHeight();o.offsetLimit=t(o.container).offset(),o.offsetLimit.right=o.offsetLimit.left+t(o.container).outerWidth()-o.draggedItem.outerWidth(),o.offsetLimit.bottom=o.offsetLimit.top+r-o.draggedItem.outerHeight()}var l=o.draggedItem.height(),c=o.draggedItem.width();if("tr"==i.tagName?(o.draggedItem.children().each(function(){t(this).width(t(this).width())}),o.placeHolderItem=o.draggedItem.clone().attr("data-placeholder",!0),o.draggedItem.after(o.placeHolderItem),o.placeHolderItem.children().each(function(){t(this).html(" ")})):(o.draggedItem.after(i.placeHolderTemplate),o.placeHolderItem=o.draggedItem.next().css({height:l,width:c}).attr("data-placeholder",!0)),"td"==i.tagName){var d=o.draggedItem.closest("table").get(0);t("
    ").appendTo("body").children().append(o.draggedItem)}var u=o.draggedItem.attr("style");o.draggedItem.attr("data-origstyle",u||""),o.draggedItem.css({position:"absolute",opacity:.8,"z-index":999,height:l,width:c}),o.scroll={moveX:0,moveY:0,maxX:t(document).width()-t(window).width(),maxY:t(document).height()-t(window).height()},o.scroll.scrollY=window.setInterval(function(){if(i.scrollContainer!=window)return void t(i.scrollContainer).scrollTop(t(i.scrollContainer).scrollTop()+o.scroll.moveY);var e=t(i.scrollContainer).scrollTop();(o.scroll.moveY>0&&e0)&&(t(i.scrollContainer).scrollTop(e+o.scroll.moveY),o.draggedItem.css("top",o.draggedItem.offset().top+o.scroll.moveY+1))},10),o.scroll.scrollX=window.setInterval(function(){if(i.scrollContainer!=window)return void t(i.scrollContainer).scrollLeft(t(i.scrollContainer).scrollLeft()+o.scroll.moveX);var e=t(i.scrollContainer).scrollLeft() ;(o.scroll.moveX>0&&e0)&&(t(i.scrollContainer).scrollLeft(e+o.scroll.moveX),o.draggedItem.css("left",o.draggedItem.offset().left+o.scroll.moveX+1))},10),t(n).each(function(t,e){e.createDropTargets(),e.buildPositionTable()}),o.setPos(e.pageX,e.pageY),t(document).bind("mousemove",o.swapItems),t(document).bind("mouseup",o.dropItem),i.scrollContainer!=window&&t(window).bind("wheel",o.wheel)},setPos:function(e,n){var a=n-this.offset.top,s=e-this.offset.left;i.dragBetween||(a=Math.min(this.offsetLimit.bottom,Math.max(a,this.offsetLimit.top)),s=Math.min(this.offsetLimit.right,Math.max(s,this.offsetLimit.left)));var r=this.draggedItem.offsetParent().not("body").offset();if(null!=r&&(a-=r.top,s-=r.left),i.scrollContainer==window)n-=t(window).scrollTop(),e-=t(window).scrollLeft(),n=Math.max(0,n-t(window).height()+5)+Math.min(0,n-5),e=Math.max(0,e-t(window).width()+5)+Math.min(0,e-5);else{var l=t(i.scrollContainer),c=l.offset();n=Math.max(0,n-l.height()-c.top)+Math.min(0,n-c.top),e=Math.max(0,e-l.width()-c.left)+Math.min(0,e-c.left)}o.scroll.moveX=0==e?0:e*i.scrollSpeed/Math.abs(e),o.scroll.moveY=0==n?0:n*i.scrollSpeed/Math.abs(n),this.draggedItem.css({top:a,left:s})},wheel:function(e){if(o&&i.scrollContainer!=window){var n=t(i.scrollContainer),a=n.offset();if(e=e.originalEvent,e.clientX>a.left&&e.clientXa.top&&e.clientY0?s.before(o.draggedItem):0==a[1]?t(n[a[0]].container).prepend(o.draggedItem):t(n[a[0]].container).append(o.draggedItem)}return o.draggedItem.removeAttr("data-origpos"),o.draggedItem=null,t(document).unbind("mousemove",o.swapItems),t(document).unbind("mouseup",o.dropItem),i.scrollContainer!=window&&t(window).unbind("wheel",o.wheel),!1}},swapItems:function(e){if(null==o.draggedItem)return!1;o.setPos(e.pageX,e.pageY);for(var s=o.findPos(e.pageX,e.pageY),r=o,l=0;-1==s&&i.dragBetween&&lo.draggedItem.offset().top||a.left>o.draggedItem.offset().left?t(r.pos[s].elm).before(o.placeHolderItem):t(r.pos[s].elm).after(o.placeHolderItem),d.each(function(){var e=c().eq(this.idx).get(0);this!=e&&c().index(this)t&&this.pos[i].tope)return i;return-1},createDropTargets:function(){i.dragBetween&&t(n).each(function(){var e=t(this.container).find("[data-placeholder]"),n=t(this.container).find("[data-droptarget]");e.length>0&&n.length>0?n.remove():0==e.length&&0==n.length&&("td"==i.tagName?t(i.placeHolderTemplate).attr("data-droptarget",!0).appendTo(this.container):t(this.container).append(o.placeHolderItem.removeAttr("data-placeholder").clone().attr("data-droptarget",!0)),o.placeHolderItem.attr("data-placeholder",!0))})}};r.init(),n.push(r)}),this},t.fn.dragsort.defaults={tagName:"",itemSelector:"",dragSelector:"",dragSelectorExclude:"input, textarea",dragEnd:function(){},dragBetween:!1,placeHolderTemplate:"",scrollContainer:window,scrollSpeed:5}}(jQuery),define("dragsort",function(){}),function(t){t.fn.addtabs=function(e){var i=t(this);e=t.extend({content:"",close:!0,monitor:"body",nav:".nav-addtabs",tab:".tab-addtabs",iframeUse:!0,simple:!1,iframeHeight:t(window).height()-50,iframeForceRefresh:!1,iframeForceRefreshTable:!1,callback:function(){}},e||{});var n=t(e.nav),o=t(e.tab);history.pushState&&t(window).on("popstate",function(i){var n=i.originalEvent.state;n&&t("a[addtabs="+n.id+"]",e.monitor).data("pushstate",!0).trigger("click")}),t(e.monitor).on("click","[addtabs]",function(i){if(0!==t(this).attr("url").indexOf("javascript:")){t(this).is("a")&&i.preventDefault();var n=t(this).attr("addtabs"),o=t(this).attr("title")?t(this).attr("title"):t.trim(t(this).text()),s=t(this).attr("url"),r=e.content?e.content:t(this).attr("content"),l="1"===t(this).attr("ajax")||"true"===t(this).attr("ajax"),c={url:s,title:o,id:n,content:r,ajax:l};if(document.title=o,history.pushState&&!t(this).data("pushstate")){var d=-1===s.indexOf("ref=addtabs")?s+(s.indexOf("?")>-1?"&":"?")+"ref=addtabs":s;try{window.history.pushState(c,o,d)}catch(i){}}t(this).data("pushstate",null),a.call(this,{id:n,title:t(this).attr("title")?t(this).attr("title"):t(this).html(),content:r,url:s,ajax:l})}}),n.on("click",".close-tab",function(){var e=t(this).prev("a").attr("aria-controls");return s(e),!1}),n.on("dblclick","li[role=presentation]",function(){t(this).find(".close-tab").trigger("click")}),n.on("click","li[role=presentation]",function(){t("a[addtabs="+t("a",this).attr("node-id")+"]").trigger("click")}),t(window).resize(function(){if("object"==typeof e.nav){var i=0;n.siblings().each(function(){i+=t(this).outerWidth()}),n.width(n.parent().width()-i)}else t("#nav").width(t("#header").find("> .navbar").width()-t(".sidebar-toggle").outerWidth()-t(".navbar-custom-menu").outerWidth()-20);r()});var a=function(i){var a,s,l,c;a=i.id,s="tab_"+i.id,l="con_"+i.id,c=i.url,c+=i.url.indexOf("?")>-1?"&addtabs=1":"?addtabs=1",e.simple&&(n.find("[role='presentation']").remove(),o.find("[role='tabpanel']").remove());var d=t("#"+s,n),u=t("#"+l,o);if(n.find("[role='presentation']").removeClass("active"),o.find("[role='tabpanel']").removeClass("active"),0===d.length){if(d=t('"),e.close&&t("li",n).length>0&&d.append(' '),0===u.length){if(u=t('
    '),i.content)u.append(i.content);else if(e.iframeUse&&!i.ajax){var h=e.iframeHeight;u.append('
    ')}else t.get(c,function(t){u.append(t)});o.append(u)}e.simple||(t(".tabdrop li",n).length>0?t(".tabdrop ul",n).append(d):n.append(d))}else if(e.iframeForceRefresh)t("#"+l+" iframe").attr("src",function(t,e){return e});else if(e.iframeForceRefreshTable)try{t("#"+l+" iframe").contents().find(".btn-refresh:not([data-force-refresh=false])").length>0&&t("#"+l+" iframe")[0].contentWindow.$(".btn-refresh:not([data-force-refresh=false])").trigger("click")}catch(t){}sessionStorage.setItem("addtabs",t(this).prop("outerHTML")),d.addClass("active"),u.addClass("active"),r()},s=function(a){var s="tab_"+a,l="con_"+a,c=t("#"+s,n),d=t("#"+l,o);if(i.find("li.active").not(".tabdrop").attr("id")===s){var u=c.prev().not(".tabdrop"),h=c.next().not(".tabdrop");u.length>0?u.find("a").trigger("click"):h.length>0?h.find("a").trigger("click"):t(">li:not(.tabdrop):last > a",n).trigger("click")}c.remove(),d.remove(),r(),e.callback()},r=function(){n.refreshAddtabs()}},t.fn.refreshAddtabs=function(){var e=t(this),i=t(".tabdrop",e);0===i.length&&(i=t(''),i.prependTo(e)),e.parent().is(".tabs-below")&&i.addClass("dropup");var n=0,o=e.width()-65,a=0,s=e.append(i.find("li")).find(">li").not(".tabdrop"),r=0;s.each(function(){r+=t(this).outerWidth(!0)}),e.width()o&&(i.find("ul").append(t(this)),n++)}),n>0&&(i.removeClass("hide"),1===i.find(".active").length?i.addClass("active"):i.removeClass("active"))):i.addClass("hide")}}(jQuery),define("addtabs",function(){}),function(t){"use strict";function e(e){return this.each(function(){var i=t(this),n=i.data(d.dataKey),o=t.extend({},c,i.data(),n&&n.option,"object"==typeof e&&e);n||i.data(d.dataKey,n=new d(this,o))})}function i(e){return t(e).closest("div.sp_container").find("input.sp_input")}function n(){return this.each(function(){var t=i(this),e=t.data(d.dataKey);e&&(e.prop.init_set=!0,e.clearAll(e),e.prop.init_set=!1)})}function o(){return this.each(function(){var t=i(this),e=t.data(d.dataKey);e&&e.elem.hidden.val()&&e.setInitRecord(!0)})}function a(e){return this.each(function(){if(e&&t.isArray(e)){var n=i(this),o=n.data(d.dataKey);o&&(o.clearAll(o),o.option.data=e)}})}function s(e){var n=!1;return this.each(function(){var o=i(this),a=o.data(d.dataKey);a&&("undefined"!==t.type(e)?a.disabled(a,e):n=a.disabled(a))}),n}function r(){var e="";return this.each(function(){var n=i(this),o=n.data(d.dataKey);if(o)if(o.option.multiple){var a=[];o.elem.element_box.find("li.selected_tag").each(function(e,i){a.push(t(i).text())}),e+=a.toString()}else e+=o.elem.combo_input.val()}),e}function l(){var e=[];return this.each(function(){var n=i(this),o=n.data(d.dataKey);if(o)if(o.option.multiple)o.elem.element_box.find("li.selected_tag").each(function(i,n){e.push(t(n).data("dataObj"))});else{var a=o.elem.combo_input.data("dataObj");a&&e.push(a)}}),e}var c={data:void 0,lang:"cn",multiple:!1,pagination:!0,dropButton:!0,listSize:10,multipleControlbar:!0,maxSelectLimit:0,selectToCloseList:!1,initRecord:void 0,dbTable:"tbl",keyField:"id",showField:"name",searchField:void 0,escape:!0,andOr:"OR",separator:",",orderBy:void 0,pageSize:10,params:void 0,formatItem:void 0,autoFillResult:!1,autoSelectFirst:!1,noResultClean:!0,selectOnly:!1,inputDelay:.5,eSelect:void 0,eOpen:void 0,eAjaxSuccess:void 0,eTagRemove:void 0,eClear:void 0},d=function(e,i){t.each({data:"source",keyField:"primaryKey",showField:"field",pageSize:"perPage"},function(t,e){void 0!==i[e]&&(i[t]=i[e],delete i[e])}),this.setOption(i),this.setLanguage(),this.setCssClass(),this.setProp(),this.setElem(e),this.setButtonAttrDefault(),this.setInitRecord(),this.eDropdownButton(),this.eInput(),this.eWhole()};d.version="2.19",d.dataKey="selectPageObject",d.prototype.setOption=function(e){e.searchField=e.searchField||e.showField,e.andOr=e.andOr.toUpperCase(),"AND"!==e.andOr&&"OR"!==e.andOr&&(e.andOr="AND");for(var i=["searchField"],n=0;n/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/`/g,"`"):t},d.prototype.strToArray=function(t){return t?t.replace(/[\s ]+/g,"").split(","):""},d.prototype.setOrderbyOption=function(e,i){var n=[],o=[];if("object"==typeof e)for(var a=0;a#item_text#',textKey:"#item_text#",valueKey:"#item_value#"},page:{current:"page_num",total:"page_count"},msg:{maxSelectLimit:"max_selected_limit"}}},d.prototype.elementRealSize=function(e,i){var n,o,a,s={absolute:!1,clone:!1,includeMargin:!1,display:"block"},r=s,l=e.eq(0),c=[],d="";n=function(){a=l.parents().addBack().filter(":hidden"),d+="visibility: hidden !important; display: "+r.display+" !important; ",!0===r.absolute&&(d+="position: absolute !important;"),a.each(function(){var e=t(this),i=e.attr("style");c.push(i),e.attr("style",i?i+";"+d:d)})},o=function(){a.each(function(e){var i=t(this),n=c[e];void 0===n?i.removeAttr("style"):i.attr("style",n)})},n();var u=/(outer)/.test(i)?l[i](r.includeMargin):l[i]();return o(),u},d.prototype.setElem=function(e){var i={},n=this.option,o=this.css_class,a=this.message,s=t(e),r=s.css("width"),l=s.outerWidth();r.indexOf("%")>-1||s.parent().length>0&&s.parent().width()==l?l="100%":(l<=0&&(l=this.elementRealSize(s,"outerWidth")),l<150&&(l=150)),i.combo_input=s.attr({autocomplete:"off"}).addClass(o.input).wrap("
    "),n.selectOnly&&i.combo_input.prop("readonly",!0),i.container=i.combo_input.parent().addClass(o.container),i.combo_input.prop("disabled")&&(n.multiple?i.container.addClass(o.disabled):i.combo_input.addClass(o.input_off)),i.container.width(l),i.button=t("
    ").addClass(o.button),i.dropdown=t(''),i.clear_btn=t("
    ").html(t("").addClass("spfont sp-close")).addClass(o.clear_btn).attr("title",a.clear),n.dropButton||i.clear_btn.addClass(o.align_right),i.element_box=t("
      ").addClass(o.element_box),n.multiple&&n.multipleControlbar&&(i.control=t("
      ").addClass(o.control_box)),i.result_area=t("
      ").addClass(o.re_area),n.pagination&&(i.navi=t("
      ").addClass("sp_pagination").append("
        ")),i.results=t("
          ").addClass(o.results);var c=i.combo_input.attr("id")||i.combo_input.attr("name"),d=i.combo_input.attr("name")||"selectPage",u=d,h=c;if(i.hidden=t('').attr({name:u,id:h}).val(""),i.combo_input.attr({name:void 0!==s.data("name")?s.data("name"):d+"_text",id:c+"_text"}),i.hidden.attr("data-rule",i.combo_input.data("rule")||""),i.combo_input.attr("novalidate","novalidate"),i.container.append(i.hidden),n.dropButton&&(i.container.append(i.button),i.button.append(i.dropdown)),t(document.body).append(i.result_area),i.result_area.append(i.results),n.pagination&&i.result_area.append(i.navi),n.multiple){n.multipleControlbar&&(i.control.append(''),i.control.append(''),i.control.append(''),i.control_text=t("

          "),i.control.append(i.control_text),i.result_area.prepend(i.control)),i.container.addClass("sp_container_combo"),i.combo_input.addClass("sp_combo_input").before(i.element_box);var p=t("

        • ").addClass("input_box");p.append(i.combo_input),i.element_box.append(p),i.combo_input.attr("placeholder")&&i.combo_input.attr("placeholder_bak",i.combo_input.attr("placeholder"))}this.elem=i},d.prototype.setButtonAttrDefault=function(){this.option.dropButton&&this.elem.button.attr("title",this.message.close_btn)},d.prototype.setInitRecord=function(e){var i=this,n=i.option,o=i.elem,a="";if("undefined"!=t.type(o.combo_input.data("init"))&&(n.initRecord=String(o.combo_input.data("init"))),e||n.initRecord||!o.combo_input.val()||(n.initRecord=o.combo_input.val()),o.combo_input.val(""),e||o.hidden.val(n.initRecord),a=e&&o.hidden.val()?o.hidden.val():n.initRecord)if("object"==typeof n.data){var s=new Array,r=a.split(",");t.each(r,function(t,e){for(var i=0;i1&&(s=[s[0]]),i.afterInit(i,s)}else{var l=n.params,c={},d=(n.searchField,{searchTable:n.dbTable,searchKey:n.keyField,searchValue:a,orderBy:n.orderBy,showField:n.showField,keyField:n.keyField,keyValue:a,searchField:n.searchField});if(l){var u=t.isFunction(l)?l(i):l;c=u&&t.isPlainObject(u)?t.extend({},d,u):d}else c=d;t.ajax({dataType:"json",type:"POST",url:n.data,data:c,success:function(e){var o=null;n.eAjaxSuccess&&t.isFunction(n.eAjaxSuccess)&&(o=n.eAjaxSuccess(e)),i.afterInit(i,o.list)},error:function(t,e,n){i.ajaxErrorNotify(i,n)}})}},d.prototype.afterInit=function(e,i){if(i&&(!t.isArray(i)||0!==i.length)){t.isArray(i)||(i=[i]);var n=e.option,o=e.css_class;if(e.data=i,n.multiple)e.prop.init_set=!0,e.clearAll(e),t.each(i,function(t,i){var o=n.escape?e.escapeHTML(i[n.keyField]):i[n.keyField],a=n.escape?e.escapeHTML(i[n.showField]):i[n.showField],s={text:a,value:o};e.isAlreadySelected(e,s)||e.addNewTag(e,i,s)}),e.tagValuesSet(e),e.inputResize(e),e.elem.hidden.blur(),e.prop.init_set=!1;else{var a=i[0],s=n.escape?e.escapeHTML(a[n.keyField]):a[n.keyField],r=n.escape?e.escapeHTML(a[n.showField]):a[n.showField];e.elem.combo_input.val(r),e.elem.hidden.val(s),e.prop.prev_value=r,e.prop.selected_text=r,n.selectOnly&&e.elem.combo_input.attr("title",e.message.select_ok).removeClass(o.select_ng).addClass(o.select_ok),e.putClearButton()}}},d.prototype.eDropdownButton=function(){var t=this;t.option.dropButton&&t.elem.button.mouseup(function(e){e.stopPropagation(),t.elem.result_area.is(":hidden")&&!t.elem.combo_input.prop("disabled")?t.elem.combo_input.focus():t.hideResults(t)})},d.prototype.eInput=function(){var e=this,i=e.option,n=e.elem,o=e.message,a=function(){e.prop.page_move=!1,e.suggest(e),e.setCssFocusedInput(e)};n.combo_input.keyup(function(t){e.processKey(e,t)}).keydown(function(t){e.processControl(e,t)}).focus(function(t){n.result_area.is(":hidden")&&(t.stopPropagation(),e.prop.first_show=!0,a())}),n.container.on("click.SelectPage","div."+e.css_class.clear_btn,function(n){n.stopPropagation(),e.disabled(e)||(e.clearAll(e,!0),e.elem.hidden.change(),i.eClear&&t.isFunction(i.eClear)&&i.eClear(e))}),n.result_area.on("mousedown.SelectPage",function(t){t.stopPropagation()}),i.multiple&&(i.multipleControlbar&&(n.control.find(".sp_select_all").on("click.SelectPage",function(t){e.selectAllLine(e)}).hover(function(){n.control_text.html(o.select_all)},function(){n.control_text.html("")}),n.control.find(".sp_unselect_all").on("click.SelectPage",function(t){e.unSelectAllLine(e)}).hover(function(){n.control_text.html(o.unselect_all)},function(){n.control_text.html("")}),n.control.find(".sp_clear_all").on("click.SelectPage",function(t){e.clearAll(e,!0)}).hover(function(){n.control_text.html(o.clear_all)},function(){n.control_text.html("")})),n.element_box.on("click.SelectPage",function(e){var i=e.target||e.srcElement;t(i).is("ul")&&n.combo_input.focus()}),n.element_box.on("click.SelectPage","span.tag_close",function(){var n=t(this).closest("li"),o=n.data("dataObj");e.removeTag(e,n),a(),i.eTagRemove&&t.isFunction(i.eTagRemove)&&i.eTagRemove([o])}),e.inputResize(e))},d.prototype.eWhole=function(){var e=this,i=e.css_class,n=function(t){t.elem.combo_input.val(""),t.option.multiple||t.elem.hidden.val(""),t.prop.selected_text=""};t(document.body).off("mousedown.selectPage").on("mousedown.selectPage",function(e){var o=e.target||e.srcElement,a=t(o).closest("div."+i.container);t("div."+i.container+"."+i.container_open).each(function(){if(this!=a[0]){var e=t(this),o=e.find("input."+i.input).data(d.dataKey);if(!o.elem.combo_input.val()&&o.elem.hidden.val()&&!o.option.multiple)return o.prop.current_page=1,n(o),o.hideResults(o),!0;o.elem.results.find("li").not("."+i.message_box).length?o.option.autoFillResult?o.elem.hidden.val()?o.hideResults(o):o.elem.results.find("li.sp_over").length?o.selectCurrentLine(o,!0):o.option.autoSelectFirst?(o.nextLine(o),o.selectCurrentLine(o,!0)):o.hideResults(o):o.hideResults(o):(o.option.noResultClean?n(o):o.option.multiple||o.elem.hidden.val(""),o.hideResults(o))}})})},d.prototype.eResultList=function(){var e=this,i=this.css_class;e.elem.results.children("li").hover(function(){if(e.prop.key_select)return void(e.prop.key_select=!1);t(this).hasClass(i.selected)||t(this).hasClass(i.message_box)||(t(this).addClass(i.select),e.setCssFocusedResults(e))},function(){t(this).removeClass(i.select)}).click(function(n){if(e.prop.key_select)return void(e.prop.key_select=!1);n.preventDefault(),n.stopPropagation(),t(this).hasClass(i.selected)||e.selectCurrentLine(e,!1)})},d.prototype.eScroll=function(){var e=this.css_class;t(window).on("scroll.SelectPage",function(i){t("div."+e.container+"."+e.container_open).each(function(){var i=t(this),n=i.find("input."+e.input).data(d.dataKey),o=n.elem.result_area.offset(),a=t(window).scrollTop(),s=t(document).height(),r=t(window).height(),l=n.elem.result_area.outerHeight(),c=o.top+l,u=s>r,h=n.elem.result_area.hasClass("shadowDown");u&&(h?c>r+a&&n.calcResultsSize(n):o.top '+e+"
        • ";t.elem.results.empty().append(i).show(),t.calcResultsSize(t),t.setOpenStatus(t,!0),t.elem.control&&t.elem.control.hide(),t.option.pagination&&t.elem.navi.hide()}},d.prototype.scrollWindow=function(e,i){var n,o=e.getCurrentLine(e),a=o&&!i?o.offset().top:e.elem.container.offset().top;e.prop.size_li=e.elem.results.children("li:first").outerHeight(),n=e.prop.size_li;var s,r=t(window).height(),l=t(window).scrollTop(),c=l+r-n;if(o.length)if(ar)s=a-l;else{if(!(a>c))return;s=a-c}else a-1&&e.elem.result_area.is(":visible")||t.inArray(i.keyCode,[13,9])>-1&&e.getCurrentLine(e))switch(i.preventDefault(),i.stopPropagation(),i.cancelBubble=!0,i.returnValue=!1,i.keyCode){case 37:i.shiftKey?e.firstPage(e):e.prevPage(e);break;case 38:e.prop.key_select=!0,e.prevLine(e);break;case 39:i.shiftKey?e.lastPage(e):e.nextPage(e);break;case 40:e.elem.results.children("li").length?(e.prop.key_select=!0,e.nextLine(e)):e.suggest(e);break;case 9:e.prop.key_paging=!0,e.selectCurrentLine(e,!0);break;case 13:e.selectCurrentLine(e,!0);break;case 27:e.prop.key_paging=!0,e.hideResults(e)}},d.prototype.abortAjax=function(t){t.prop.xhr&&(t.prop.xhr.abort(),t.prop.xhr=!1)},d.prototype.suggest=function(e){var i,n=t.trim(e.elem.combo_input.val());i=e.option.multiple?n:n&&n==e.prop.selected_text?"":n,i=i.split(e.option.separator),e.option.eOpen&&t.isFunction(e.option.eOpen)&&e.option.eOpen.call(e),e.abortAjax(e);var o=e.prop.current_page||1;"object"==typeof e.option.data?e.searchForJson(e,i,o):e.searchForDb(e,i,o)},d.prototype.setLoading=function(t){""===t.elem.results.html()&&t.setOpenStatus(t,!0)},d.prototype.searchForDb=function(e,i,n){var o=e.option;o.eAjaxSuccess&&t.isFunction(o.eAjaxSuccess)||e.hideResults(e);var a=o.params,s={},r=o.searchField;i.length&&i[0]&&i.join(e.option.separator)!==e.prop.prev_value&&(n=1);var l={q_word:i,pageNumber:n,pageSize:o.pageSize,andOr:o.andOr,orderBy:o.orderBy,searchTable:o.dbTable,showField:e.option.showField,keyField:e.option.keyField,searchField:e.option.searchField};if(!1!==o.orderBy&&(l.orderBy=o.orderBy),l[r]=i[0],a){var c=t.isFunction(a)?a(e):a;s=c&&t.isPlainObject(c)?t.extend({},l,c):l}else s=l;e.prop.xhr=t.ajax({dataType:"json",url:o.data,type:"POST",data:s,success:function(a){if(!a||!t.isPlainObject(a))return e.hideResults(e),void e.ajaxErrorNotify(e,errorThrown);var s={},r={};try{s=o.eAjaxSuccess(a),r.originalResult=s.list,r.cnt_whole=s.totalRow}catch(t){return void e.showMessage(e,e.message.ajax_error)}if(e.elem.navi&&t(e.elem.navi).toggleClass("hide",r.cnt_whole<=r.originalResult.length),r.candidate=[],r.keyField=[],"object"!=typeof r.originalResult)return e.prop.xhr=null,void e.notFoundSearch(e);r.cnt_page=r.originalResult.length;for(var l=0;l '),e.append('
        • '),e.append('
        • '+a()+"
        • "), e.append('
        • '),e.append('
        • '),e.show()}else e.find("li.pageInfoBox a").html(a())}(t,a,n,s);var r="disabled",l=a.find("li.csFirstPage"),c=a.find("li.csPreviousPage"),d=a.find("li.csNextPage"),u=a.find("li.csLastPage");1===n||0===n?(l.hasClass(r)||l.addClass(r),c.hasClass(r)||c.addClass(r)):(l.hasClass(r)&&l.removeClass(r),c.hasClass(r)&&c.removeClass(r)),n===s||0===s?(d.hasClass(r)||d.addClass(r),u.hasClass(r)||u.addClass(r)):(d.hasClass(r)&&d.removeClass(r),u.hasClass(r)&&u.removeClass(r)),s>1&&t.ePaging()},d.prototype.displayResults=function(e,i,n){var o=e.option,a=e.elem;if(a.results.hide().empty(),o.multiple&&"number"===t.type(o.maxSelectLimit)&&o.maxSelectLimit>0){var s=a.element_box.find("li.selected_tag").length;if(s>0&&s>=o.maxSelectLimit){var r=e.message.max_selected;return void e.showMessage(e,r.replace(e.template.msg.maxSelectLimit,o.maxSelectLimit))}}if(i.candidate.length)for(var l=i.candidate,c=i.keyField,d=a.hidden.val(),u=d?d.split(","):[],h="",p=0;p").html(h).attr({pkey:c[p],index:p});o.formatItem||f.attr("title",h),-1!==t.inArray(c[p].toString(),u)&&f.addClass(e.css_class.selected),f.data("dataObj",i.originalResult[p]),a.results.append(f)}else{var m='
        • '+e.message.not_found+"
        • ";a.results.append(m)}a.results.show(),o.multiple&&o.multipleControlbar&&a.control.show(),o.pagination&&a.navi.show(),e.calcResultsSize(e),e.setOpenStatus(e,!0),e.eResultList(),e.eScroll(),n&&i.candidate.length&&o.autoSelectFirst&&e.nextLine(e)},d.prototype.calcResultsSize=function(e){var i=e.option,n=e.elem,o=function(){if("static"!==n.container.css("position")){if(!i.pagination){var e=n.results.find("li:first").outerHeight(!0),o=e*i.listSize;n.results.css({"max-height":o,"overflow-y":"auto"})}var a=t(document).width(),s=t(document).height(),r=t(window).height(),l=n.container.offset(),c=t(window).scrollTop(),d=n.result_area.outerWidth(),o=n.result_area.outerHeight(),u=l.left,h=n.container.outerHeight(),p=l.left+d>a?u-(d-n.container.outerWidth()):u,f=l.top,m=0,g=f+h+o+5,v=f+o+5,y=s>r;return f-c-5>o&&y&&g>r+c||!y&&g>r&&f>=v?(m=l.top-o-5,n.result_area.removeClass("shadowUp shadowDown").addClass("shadowUp")):(m=l.top+(i.multiple?n.container.outerHeight():h),n.result_area.removeClass("shadowUp shadowDown").addClass("shadowDown"),m+=5),{top:m+"px",left:p+"px"}}var l=n.combo_input.offset();n.result_area.css({top:l.top+n.combo_input.outerHeight()+"px",left:l.left+"px"})};if(n.result_area.is(":visible"))n.result_area.css(o());else{var a=o();n.result_area.css(a).show(1,function(){var t=o();a.top===t.top&&a.left===t.left||n.result_area.css(t)})}},d.prototype.hideResults=function(e){e.prop.key_paging&&(e.scrollWindow(e,!0),e.prop.key_paging=!1),e.setCssFocusedInput(e),e.option.autoFillResult,e.elem.results.empty(),e.elem.result_area.hide(),e.setOpenStatus(e,!1),t(window).off("scroll.SelectPage"),e.abortAjax(e),e.setButtonAttrDefault()},d.prototype.disabled=function(e,i){var n=(e.option,e.elem);if("undefined"===t.type(i))return n.combo_input.prop("disabled");"boolean"===t.type(i)&&(n.combo_input.prop("disabled",i),i?n.container.addClass(e.css_class.disabled):n.container.removeClass(e.css_class.disabled))},d.prototype.firstPage=function(t){t.prop.current_page>1&&(t.prop.current_page=1,t.prop.page_move=!0,t.suggest(t))},d.prototype.prevPage=function(t){t.prop.current_page>1&&(t.prop.current_page--,t.prop.page_move=!0,t.suggest(t))},d.prototype.nextPage=function(t){t.prop.current_page0&&i.maxSelectLimit===e.elem.element_box.find("li.selected_tag").length)return!1}),i.eSelect&&t.isFunction(i.eSelect)&&i.eSelect(n,e),e.afterAction(e,!0)},d.prototype.unSelectAllLine=function(e){var i=e.option,n=(e.elem.results.find("li").length,[]);e.elem.results.find("li").each(function(i,o){var a=t(o).attr("pkey"),s=e.elem.element_box.find('li.selected_tag[itemvalue="'+a+'"]');s.length&&n.push(s.data("dataObj")),e.removeTag(e,s)}),e.afterAction(e,!0),i.eTagRemove&&t.isFunction(i.eTagRemove)&&i.eTagRemove(n)},d.prototype.clearAll=function(e,i){var n=e.option,o=[];n.multiple&&(e.elem.element_box.find("li.selected_tag").each(function(e,i){o.push(t(i).data("dataObj")),i.remove()}),e.elem.element_box.find("li.selected_tag").remove()),e.reset(e),e.afterAction(e,i),n.multiple?n.eTagRemove&&t.isFunction(n.eTagRemove)&&n.eTagRemove(o):e.elem.clear_btn.remove()},d.prototype.reset=function(t){t.elem.combo_input.val(""),t.elem.hidden.val(""),t.prop.prev_value="",t.prop.selected_text="",t.prop.current_page=1},d.prototype.getCurrentLine=function(t){if(t.elem.result_area.is(":hidden"))return!1;var e=t.elem.results.find("li."+t.css_class.select);return!!e.length&&e},d.prototype.isAlreadySelected=function(e,i){var n=!1;if(i.value){var o=e.elem.hidden.val();if(o){var a=o.split(",");a&&a.length&&-1!=t.inArray(i.value,a)&&(n=!0)}}return n},d.prototype.addNewTag=function(e,i,n){if(e.option.multiple&&i&&n){var o,a=e.template.tag.content;a=a.replace(e.template.tag.textKey,n.text),a=a.replace(e.template.tag.valueKey,n.value),o=t(a),o.data("dataObj",i),e.elem.combo_input.prop("disabled")&&o.find("span.tag_close").hide(),e.elem.combo_input.closest("li").before(o)}},d.prototype.removeTag=function(e,i){var n=t(i).attr("itemvalue"),o=e.elem.hidden.val();if("undefined"!=t.type(n)&&o){var a=o.split(","),s=t.inArray(n.toString(),a);-1!=s&&(a.splice(s,1),e.elem.hidden.val(a.toString()).trigger("change"))}t(i).remove(),e.inputResize(e)},d.prototype.tagValuesSet=function(e){if(e.option.multiple){var i=e.elem.element_box.find("li.selected_tag");if(i&&i.length){var n=new Array;t.each(i,function(e,i){var o=t(i).attr("itemvalue");"undefined"!==t.type(o)&&n.push(o)}),n.length&&e.elem.hidden.val(n.join(",")).trigger("change")}}},d.prototype.inputResize=function(t){if(t.option.multiple){var e=t.elem.combo_input.closest("li");0===t.elem.element_box.find("li.selected_tag").length?(e.hasClass("full_width")||e.addClass("full_width"),t.elem.combo_input.attr("placeholder_bak")&&t.elem.combo_input.attr("placeholder",t.elem.combo_input.attr("placeholder_bak")).removeAttr("style")):function(t,e){e.removeClass("full_width");var i=t.elem.combo_input.val().length+1,n=.75*i+"em";t.elem.combo_input.css("width",n).removeAttr("placeholder")}(t,e)}},d.prototype.nextLine=function(t){var e,i=t.getCurrentLine(t);if(i?(e=t.elem.results.children("li").index(i),i.removeClass(t.css_class.select)):e=-1,++e-1){t.elem.results.children("li").eq(e).addClass(t.css_class.select),t.setCssFocusedResults(t)}else t.setCssFocusedInput(t);t.scrollWindow(t,!1)};var u=t.fn.selectPage;t.fn.selectPage=e,t.fn.selectPage.Constructor=d,t.fn.selectPageClear=n,t.fn.selectPageRefresh=o,t.fn.selectPageData=a,t.fn.selectPageDisabled=s,t.fn.selectPageText=r,t.fn.selectPageSelectedData=l,t.fn.selectPage.noConflict=function(){return t.fn.selectPage=u,this}}(window.jQuery),define("selectpage",function(){}),function(t,e){if("function"==typeof define&&define.amd)define("bootstrap-daterangepicker",["moment","jquery"],function(t,i){return i.fn||(i.fn={}),e(t,i)});else if("object"==typeof module&&module.exports){var i="undefined"!=typeof window?window.jQuery:void 0;i||(i=require("jquery"),i.fn||(i.fn={}));var n="undefined"!=typeof window&&void 0!==window.moment?window.moment:require("moment");module.exports=e(n,i)}else t.daterangepicker=e(t.moment,t.jQuery)}(this,function(t,e){var i=function(i,n,o){if(this.parentEl="body",this.element=e(i),this.startDate=t().startOf("day"),this.endDate=t().endOf("day"),this.minDate=!1,this.maxDate=!1,this.dateLimit=!1,this.autoApply=!1,this.singleDatePicker=!1,this.showDropdowns=!1,this.showWeekNumbers=!1,this.showISOWeekNumbers=!1,this.showCustomRangeLabel=!0,this.timePicker=!1,this.timePicker24Hour=!1,this.timePickerIncrement=1,this.timePickerSeconds=!1,this.linkedCalendars=!0,this.autoUpdateInput=!0,this.alwaysShowCalendars=!1,this.ranges={},this.opens="right",this.element.hasClass("pull-right")&&(this.opens="left"),this.drops="down",this.element.hasClass("dropup")&&(this.drops="up"),this.buttonClasses="btn btn-sm",this.applyClass="btn-success",this.cancelClass="btn-default",this.locale={direction:"ltr",format:t.localeData().longDateFormat("L"),separator:" - ",applyLabel:"Apply",cancelLabel:"Cancel",weekLabel:"W",customRangeLabel:"Custom Range",daysOfWeek:t.weekdaysMin(),monthNames:t.monthsShort(),firstDay:t.localeData().firstDayOfWeek()},this.callback=function(){},this.isShowing=!1,this.leftCalendar={},this.rightCalendar={},"object"==typeof n&&null!==n||(n={}),n=e.extend(this.element.data(),n),"string"==typeof n.template||n.template instanceof e||(n.template=''),this.parentEl=e(n.parentEl&&e(n.parentEl).length?n.parentEl:this.parentEl),this.container=e(n.template).appendTo(this.parentEl),"object"==typeof n.locale&&("string"==typeof n.locale.direction&&(this.locale.direction=n.locale.direction),"string"==typeof n.locale.format&&(this.locale.format=n.locale.format),"string"==typeof n.locale.separator&&(this.locale.separator=n.locale.separator),"object"==typeof n.locale.daysOfWeek&&(this.locale.daysOfWeek=n.locale.daysOfWeek.slice()),"object"==typeof n.locale.monthNames&&(this.locale.monthNames=n.locale.monthNames.slice()),"number"==typeof n.locale.firstDay&&(this.locale.firstDay=n.locale.firstDay),"string"==typeof n.locale.applyLabel&&(this.locale.applyLabel=n.locale.applyLabel),"string"==typeof n.locale.cancelLabel&&(this.locale.cancelLabel=n.locale.cancelLabel),"string"==typeof n.locale.weekLabel&&(this.locale.weekLabel=n.locale.weekLabel),"string"==typeof n.locale.customRangeLabel)){var a=document.createElement("textarea");a.innerHTML=n.locale.customRangeLabel;var s=a.value;this.locale.customRangeLabel=s}if(this.container.addClass(this.locale.direction),"string"==typeof n.startDate&&(this.startDate=t(n.startDate,this.locale.format)),"string"==typeof n.endDate&&(this.endDate=t(n.endDate,this.locale.format)),"string"==typeof n.minDate&&(this.minDate=t(n.minDate,this.locale.format)),"string"==typeof n.maxDate&&(this.maxDate=t(n.maxDate,this.locale.format)),"object"==typeof n.startDate&&(this.startDate=t(n.startDate)),"object"==typeof n.endDate&&(this.endDate=t(n.endDate)),"object"==typeof n.minDate&&(this.minDate=t(n.minDate)),"object"==typeof n.maxDate&&(this.maxDate=t(n.maxDate)),this.minDate&&this.startDate.isBefore(this.minDate)&&(this.startDate=this.minDate.clone()),this.maxDate&&this.endDate.isAfter(this.maxDate)&&(this.endDate=this.maxDate.clone()),"string"==typeof n.applyClass&&(this.applyClass=n.applyClass),"string"==typeof n.cancelClass&&(this.cancelClass=n.cancelClass),"object"==typeof n.dateLimit&&(this.dateLimit=n.dateLimit),"string"==typeof n.opens&&(this.opens=n.opens),"string"==typeof n.drops&&(this.drops=n.drops),"boolean"==typeof n.showWeekNumbers&&(this.showWeekNumbers=n.showWeekNumbers),"boolean"==typeof n.showISOWeekNumbers&&(this.showISOWeekNumbers=n.showISOWeekNumbers),"string"==typeof n.buttonClasses&&(this.buttonClasses=n.buttonClasses),"object"==typeof n.buttonClasses&&(this.buttonClasses=n.buttonClasses.join(" ")),"boolean"==typeof n.showDropdowns&&(this.showDropdowns=n.showDropdowns),"boolean"==typeof n.showCustomRangeLabel&&(this.showCustomRangeLabel=n.showCustomRangeLabel),"boolean"==typeof n.singleDatePicker&&(this.singleDatePicker=n.singleDatePicker,this.singleDatePicker&&(this.endDate=this.startDate.clone())),"boolean"==typeof n.timePicker&&(this.timePicker=n.timePicker),"boolean"==typeof n.timePickerSeconds&&(this.timePickerSeconds=n.timePickerSeconds),"number"==typeof n.timePickerIncrement&&(this.timePickerIncrement=n.timePickerIncrement),"boolean"==typeof n.timePicker24Hour&&(this.timePicker24Hour=n.timePicker24Hour),"boolean"==typeof n.autoApply&&(this.autoApply=n.autoApply),"boolean"==typeof n.autoUpdateInput&&(this.autoUpdateInput=n.autoUpdateInput),"boolean"==typeof n.linkedCalendars&&(this.linkedCalendars=n.linkedCalendars),"function"==typeof n.isInvalidDate&&(this.isInvalidDate=n.isInvalidDate),"function"==typeof n.isCustomDate&&(this.isCustomDate=n.isCustomDate),"boolean"==typeof n.alwaysShowCalendars&&(this.alwaysShowCalendars=n.alwaysShowCalendars),0!=this.locale.firstDay)for(var r=this.locale.firstDay;r>0;)this.locale.daysOfWeek.push(this.locale.daysOfWeek.shift()),r--;var l,c,d;if(void 0===n.startDate&&void 0===n.endDate&&e(this.element).is("input[type=text]")){var u=e(this.element).val(),h=u.split(this.locale.separator);l=c=null,2==h.length?(l=t(h[0],this.locale.format),c=t(h[1],this.locale.format)):this.singleDatePicker&&""!==u&&(l=t(u,this.locale.format),c=t(u,this.locale.format)),null!==l&&null!==c&&(this.setStartDate(l),this.setEndDate(c))}if("object"==typeof n.ranges){for(d in n.ranges){l="string"==typeof n.ranges[d][0]?t(n.ranges[d][0],this.locale.format):t(n.ranges[d][0]),c="string"==typeof n.ranges[d][1]?t(n.ranges[d][1],this.locale.format):t(n.ranges[d][1]),this.minDate&&l.isBefore(this.minDate)&&(l=this.minDate.clone());var p=this.maxDate;if(this.dateLimit&&p&&l.clone().add(this.dateLimit).isAfter(p)&&(p=l.clone().add(this.dateLimit)),p&&c.isAfter(p)&&(c=p.clone()),!(this.minDate&&c.isBefore(this.minDate,this.timepicker?"minute":"day")||p&&l.isAfter(p,this.timepicker?"minute":"day"))){var a=document.createElement("textarea");a.innerHTML=d;var s=a.value;this.ranges[s]=[l,c]}}var f="
            ";for(d in this.ranges)f+='
          • '+d+"
          • ";this.showCustomRangeLabel&&(f+='
          • '+this.locale.customRangeLabel+"
          • "),f+="
          ",this.container.find(".ranges").prepend(f)}"function"==typeof o&&(this.callback=o),this.timePicker||(this.startDate=this.startDate.startOf("day"),this.endDate=this.endDate.endOf("day"),this.container.find(".calendar-time").hide()),this.timePicker&&this.autoApply&&(this.autoApply=!1),this.autoApply&&"object"!=typeof n.ranges?this.container.find(".ranges").hide():this.autoApply&&this.container.find(".applyBtn, .cancelBtn").addClass("hide"),this.singleDatePicker&&(this.container.addClass("single"),this.container.find(".calendar.left").addClass("single"),this.container.find(".calendar.left").show(),this.container.find(".calendar.right").hide(),this.container.find(".daterangepicker_input input, .daterangepicker_input > i").hide(),this.timePicker?this.container.find(".ranges ul").hide():this.container.find(".ranges").hide()),(void 0===n.ranges&&!this.singleDatePicker||this.alwaysShowCalendars)&&this.container.addClass("show-calendar"),this.container.addClass("opens"+this.opens),void 0!==n.ranges&&"right"==this.opens&&this.container.find(".ranges").prependTo(this.container.find(".calendar.left").parent()),this.container.find(".applyBtn, .cancelBtn").addClass(this.buttonClasses),this.applyClass.length&&this.container.find(".applyBtn").addClass(this.applyClass),this.cancelClass.length&&this.container.find(".cancelBtn").addClass(this.cancelClass),this.container.find(".applyBtn").html(this.locale.applyLabel),this.container.find(".cancelBtn").html(this.locale.cancelLabel),this.container.find(".calendar").on("click.daterangepicker",".prev",e.proxy(this.clickPrev,this)).on("click.daterangepicker",".next",e.proxy(this.clickNext,this)).on("mousedown.daterangepicker","td.available",e.proxy(this.clickDate,this)).on("mouseenter.daterangepicker","td.available",e.proxy(this.hoverDate,this)).on("mouseleave.daterangepicker","td.available",e.proxy(this.updateFormInputs,this)).on("change.daterangepicker","select.yearselect",e.proxy(this.monthOrYearChanged,this)).on("change.daterangepicker","select.monthselect",e.proxy(this.monthOrYearChanged,this)).on("change.daterangepicker","select.hourselect,select.minuteselect,select.secondselect,select.ampmselect",e.proxy(this.timeChanged,this)).on("click.daterangepicker",".daterangepicker_input input",e.proxy(this.showCalendars,this)).on("focus.daterangepicker",".daterangepicker_input input",e.proxy(this.formInputsFocused,this)).on("blur.daterangepicker",".daterangepicker_input input",e.proxy(this.formInputsBlurred,this)).on("change.daterangepicker",".daterangepicker_input input",e.proxy(this.formInputsChanged,this)).on("keydown.daterangepicker",".daterangepicker_input input",e.proxy(this.formInputsKeydown,this)),this.container.find(".ranges").on("click.daterangepicker","button.applyBtn",e.proxy(this.clickApply,this)).on("click.daterangepicker","button.cancelBtn",e.proxy(this.clickCancel,this)).on("click.daterangepicker","li",e.proxy(this.clickRange,this)).on("mouseenter.daterangepicker","li",e.proxy(this.hoverRange,this)).on("mouseleave.daterangepicker","li",e.proxy(this.updateFormInputs,this)),this.element.is("input")||this.element.is("button")?this.element.on({"click.daterangepicker":e.proxy(this.show,this),"focus.daterangepicker":e.proxy(this.show,this),"keyup.daterangepicker":e.proxy(this.elementChanged,this),"keydown.daterangepicker":e.proxy(this.keydown,this)}):(this.element.on("click.daterangepicker",e.proxy(this.toggle,this)),this.element.on("keydown.daterangepicker",e.proxy(this.toggle,this))),this.element.is("input")&&!this.singleDatePicker&&this.autoUpdateInput?(this.element.val(this.startDate.format(this.locale.format)+this.locale.separator+this.endDate.format(this.locale.format)),this.element.trigger("change")):this.element.is("input")&&this.autoUpdateInput&&(this.element.val(this.startDate.format(this.locale.format)),this.element.trigger("change"))};return i.prototype={constructor:i,setStartDate:function(e){"string"==typeof e&&(this.startDate=t(e,this.locale.format)),"object"==typeof e&&(this.startDate=t(e)),this.timePicker||(this.startDate=this.startDate.startOf("day")),this.timePicker&&this.timePickerIncrement&&this.startDate.minute(Math.round(this.startDate.minute()/this.timePickerIncrement)*this.timePickerIncrement),this.minDate&&this.startDate.isBefore(this.minDate)&&(this.startDate=this.minDate.clone(),this.timePicker&&this.timePickerIncrement&&this.startDate.minute(Math.round(this.startDate.minute()/this.timePickerIncrement)*this.timePickerIncrement)),this.maxDate&&this.startDate.isAfter(this.maxDate)&&(this.startDate=this.maxDate.clone(),this.timePicker&&this.timePickerIncrement&&this.startDate.minute(Math.floor(this.startDate.minute()/this.timePickerIncrement)*this.timePickerIncrement)),this.isShowing||this.updateElement(),this.updateMonthsInView()},setEndDate:function(e){"string"==typeof e&&(this.endDate=t(e,this.locale.format)),"object"==typeof e&&(this.endDate=t(e)),this.timePicker||(this.endDate=this.endDate.add(1,"d").startOf("day").subtract(1,"second")),this.timePicker&&this.timePickerIncrement&&this.endDate.minute(Math.round(this.endDate.minute()/this.timePickerIncrement)*this.timePickerIncrement),this.endDate.isBefore(this.startDate)&&(this.endDate=this.startDate.clone()),this.maxDate&&this.endDate.isAfter(this.maxDate)&&(this.endDate=this.maxDate.clone()),this.dateLimit&&this.startDate.clone().add(this.dateLimit).isBefore(this.endDate)&&(this.endDate=this.startDate.clone().add(this.dateLimit)),this.previousRightTime=this.endDate.clone(),this.isShowing||this.updateElement(),this.updateMonthsInView()},isInvalidDate:function(){return!1},isCustomDate:function(){return!1},updateView:function(){this.timePicker&&(this.renderTimePicker("left"),this.renderTimePicker("right"),this.endDate?this.container.find(".right .calendar-time select").removeAttr("disabled").removeClass("disabled"):this.container.find(".right .calendar-time select").attr("disabled","disabled").addClass("disabled")),this.endDate?(this.container.find('input[name="daterangepicker_end"]').removeClass("active"),this.container.find('input[name="daterangepicker_start"]').addClass("active")):(this.container.find('input[name="daterangepicker_end"]').addClass("active"),this.container.find('input[name="daterangepicker_start"]').removeClass("active")),this.updateMonthsInView(),this.updateCalendars(),this.updateFormInputs()},updateMonthsInView:function(){if(this.endDate){if(!this.singleDatePicker&&this.leftCalendar.month&&this.rightCalendar.month&&(this.startDate.format("YYYY-MM")==this.leftCalendar.month.format("YYYY-MM")||this.startDate.format("YYYY-MM")==this.rightCalendar.month.format("YYYY-MM"))&&(this.endDate.format("YYYY-MM")==this.leftCalendar.month.format("YYYY-MM")||this.endDate.format("YYYY-MM")==this.rightCalendar.month.format("YYYY-MM")))return;this.leftCalendar.month=this.startDate.clone().date(2),this.linkedCalendars||this.endDate.month()==this.startDate.month()&&this.endDate.year()==this.startDate.year()?this.rightCalendar.month=this.startDate.clone().date(2).add(1,"month"):this.rightCalendar.month=this.endDate.clone().date(2)}else this.leftCalendar.month.format("YYYY-MM")!=this.startDate.format("YYYY-MM")&&this.rightCalendar.month.format("YYYY-MM")!=this.startDate.format("YYYY-MM")&&(this.leftCalendar.month=this.startDate.clone().date(2),this.rightCalendar.month=this.startDate.clone().date(2).add(1,"month"));this.maxDate&&this.linkedCalendars&&!this.singleDatePicker&&this.rightCalendar.month>this.maxDate&&(this.rightCalendar.month=this.maxDate.clone().date(2),this.leftCalendar.month=this.maxDate.clone().date(2).subtract(1,"month"))},updateCalendars:function(){if(this.timePicker){var t,e,i;if(this.endDate){if(t=parseInt(this.container.find(".left .hourselect").val(),10),e=parseInt(this.container.find(".left .minuteselect").val(),10),i=this.timePickerSeconds?parseInt(this.container.find(".left .secondselect").val(),10):0,!this.timePicker24Hour){var n=this.container.find(".left .ampmselect").val();"PM"===n&&t<12&&(t+=12),"AM"===n&&12===t&&(t=0)}}else if(t=parseInt(this.container.find(".right .hourselect").val(),10),e=parseInt(this.container.find(".right .minuteselect").val(),10),i=this.timePickerSeconds?parseInt(this.container.find(".right .secondselect").val(),10):0,!this.timePicker24Hour){var n=this.container.find(".right .ampmselect").val();"PM"===n&&t<12&&(t+=12),"AM"===n&&12===t&&(t=0)}this.leftCalendar.month.hour(t).minute(e).second(i),this.rightCalendar.month.hour(t).minute(e).second(i)}this.renderCalendar("left"),this.renderCalendar("right"),this.container.find(".ranges li").removeClass("active"),null!=this.endDate&&this.calculateChosenLabel()},renderCalendar:function(i){var n="left"==i?this.leftCalendar:this.rightCalendar,o=n.month.month(),a=n.month.year(),s=n.month.hour(),r=n.month.minute(),l=n.month.second(),c=t([a,o]).daysInMonth(),d=t([a,o,1]),u=t([a,o,c]),h=t(d).subtract(1,"month").month(),p=t(d).subtract(1,"month").year(),f=t([p,h]).daysInMonth(),m=d.day(),n=[];n.firstDay=d,n.lastDay=u;for(var g=0;g<6;g++)n[g]=[];var v=f-m+this.locale.firstDay+1;v>f&&(v-=7),m==this.locale.firstDay&&(v=f-6);for(var y,b,w=t([p,h,v,12,r,l]),g=0,y=0,b=0;g<42;g++,y++,w=t(w).add(24,"hour"))g>0&&y%7==0&&(y=0,b++),n[b][y]=w.clone().hour(s).minute(r).second(l),w.hour(12),this.minDate&&n[b][y].format("YYYY-MM-DD")==this.minDate.format("YYYY-MM-DD")&&n[b][y].isBefore(this.minDate)&&"left"==i&&(n[b][y]=this.minDate.clone()),this.maxDate&&n[b][y].format("YYYY-MM-DD")==this.maxDate.format("YYYY-MM-DD")&&n[b][y].isAfter(this.maxDate)&&"right"==i&&(n[b][y]=this.maxDate.clone());"left"==i?this.leftCalendar.calendar=n:this.rightCalendar.calendar=n;var x="left"==i?this.minDate:this.startDate,k=this.maxDate,_=("left"==i?this.startDate:this.endDate,"ltr"==this.locale.direction?{left:"chevron-left",right:"chevron-right"}:{left:"chevron-right",right:"chevron-left"}),C='';C+="",C+="",(this.showWeekNumbers||this.showISOWeekNumbers)&&(C+=""),x&&!x.isBefore(n.firstDay)||this.linkedCalendars&&"left"!=i?C+="":C+='';var S=this.locale.monthNames[n[1][1].month()]+n[1][1].format(" YYYY");if(this.showDropdowns){for(var T=n[1][1].month(),D=n[1][1].year(),$=k&&k.year()||D+5,E=x&&x.year()||D-50,A=D==E,O=D==$,F='";for(var P='",S=F+P}if(C+='",k&&!k.isAfter(n.lastDay)||this.linkedCalendars&&"right"!=i&&!this.singleDatePicker?C+="":C+='',C+="",C+="",(this.showWeekNumbers||this.showISOWeekNumbers)&&(C+='"),e.each(this.locale.daysOfWeek,function(t,e){C+=""}),C+="",C+="",C+="",null==this.endDate&&this.dateLimit){var I=this.startDate.clone().add(this.dateLimit).endOf("day");k&&!I.isBefore(k)||(k=I)}for(var b=0;b<6;b++){C+="",this.showWeekNumbers?C+='":this.showISOWeekNumbers&&(C+='");for(var y=0;y<7;y++){var N=[];n[b][y].isSame(new Date,"day")&&N.push("today"),n[b][y].isoWeekday()>5&&N.push("weekend"),n[b][y].month()!=n[1][1].month()&&N.push("off"),this.minDate&&n[b][y].isBefore(this.minDate,"day")&&N.push("off","disabled"),k&&n[b][y].isAfter(k,"day")&&N.push("off","disabled"),this.isInvalidDate(n[b][y])&&N.push("off","disabled"),n[b][y].format("YYYY-MM-DD")==this.startDate.format("YYYY-MM-DD")&&N.push("active","start-date"),null!=this.endDate&&n[b][y].format("YYYY-MM-DD")==this.endDate.format("YYYY-MM-DD")&&N.push("active","end-date"),null!=this.endDate&&n[b][y]>this.startDate&&n[b][y]'+n[b][y].date()+""}C+=""}C+="",C+="
          '+S+"
          '+this.locale.weekLabel+""+e+"
          '+n[b][0].week()+"'+n[b][0].isoWeek()+"
          ",this.container.find(".calendar."+i+" .calendar-table").html(C)},renderTimePicker:function(t){if("right"!=t||this.endDate){var e,i,n,o=this.maxDate;if(!this.dateLimit||this.maxDate&&!this.startDate.clone().add(this.dateLimit).isAfter(this.maxDate)||(o=this.startDate.clone().add(this.dateLimit)),"left"==t)i=this.startDate.clone(),n=this.minDate;else if("right"==t){i=this.endDate.clone(),n=this.startDate;var a=this.container.find(".calendar.right .calendar-time div");if(""!=a.html()&&(i.hour(a.find(".hourselect option:selected").val()||i.hour()),i.minute(a.find(".minuteselect option:selected").val()||i.minute()),i.second(a.find(".secondselect option:selected").val()||i.second()),!this.timePicker24Hour)){var s=a.find(".ampmselect option:selected").val();"PM"===s&&i.hour()<12&&i.hour(i.hour()+12),"AM"===s&&12===i.hour()&&i.hour(0)}i.isBefore(this.startDate)&&(i=this.startDate.clone()),o&&i.isAfter(o)&&(i=o.clone())}e=' ",e+=': ",this.timePickerSeconds){e+=': "}if(!this.timePicker24Hour){e+='"}this.container.find(".calendar."+t+" .calendar-time div").html(e)}},updateFormInputs:function(){this.container.find("input[name=daterangepicker_start]").is(":focus")||this.container.find("input[name=daterangepicker_end]").is(":focus")||(this.container.find("input[name=daterangepicker_start]").val(this.startDate.format(this.locale.format)),this.endDate&&this.container.find("input[name=daterangepicker_end]").val(this.endDate.format(this.locale.format)),this.singleDatePicker||this.endDate&&(this.startDate.isBefore(this.endDate)||this.startDate.isSame(this.endDate))?this.container.find("button.applyBtn").removeAttr("disabled"):this.container.find("button.applyBtn").attr("disabled","disabled"))},move:function(){var t,i={top:0,left:0},n=e(window).width();this.parentEl.is("body")||(i={top:this.parentEl.offset().top-this.parentEl.scrollTop(),left:this.parentEl.offset().left-this.parentEl.scrollLeft()},n=this.parentEl[0].clientWidth+this.parentEl.offset().left),t="up"==this.drops?this.element.offset().top-this.container.outerHeight()-i.top:this.element.offset().top+this.element.outerHeight()-i.top,this.container["up"==this.drops?"addClass":"removeClass"]("dropup"),"left"==this.opens?(this.container.css({top:t,right:n-this.element.offset().left-this.element.outerWidth(),left:"auto"}),this.container.offset().left<0&&this.container.css({right:"auto",left:9})):"center"==this.opens?(this.container.css({top:t,left:this.element.offset().left-i.left+this.element.outerWidth()/2-this.container.outerWidth()/2,right:"auto"}),this.container.offset().left<0&&this.container.css({right:"auto",left:9})):(this.container.css({top:t,left:this.element.offset().left-i.left,right:"auto"}),this.container.offset().left+this.container.outerWidth()>e(window).width()&&this.container.css({left:"auto",right:0}))},show:function(t){this.isShowing||(this._outsideClickProxy=e.proxy(function(t){this.outsideClick(t)},this),e(document).on("mousedown.daterangepicker",this._outsideClickProxy).on("touchend.daterangepicker",this._outsideClickProxy).on("click.daterangepicker","[data-toggle=dropdown]",this._outsideClickProxy).on("focusin.daterangepicker",this._outsideClickProxy),e(window).on("resize.daterangepicker",e.proxy(function(t){this.move(t)},this)),this.oldStartDate=this.startDate.clone(),this.oldEndDate=this.endDate.clone(),this.previousRightTime=this.endDate.clone(),this.updateView(),this.container.show(),this.move(),this.element.trigger("show.daterangepicker",this),this.isShowing=!0)},hide:function(t){this.isShowing&&(this.endDate||(this.startDate=this.oldStartDate.clone(),this.endDate=this.oldEndDate.clone()),this.startDate.isSame(this.oldStartDate)&&this.endDate.isSame(this.oldEndDate)||this.callback(this.startDate,this.endDate,this.chosenLabel),this.updateElement(),e(document).off(".daterangepicker"),e(window).off(".daterangepicker"),this.container.hide(),this.element.trigger("hide.daterangepicker",this),this.isShowing=!1)},toggle:function(t){this.isShowing?this.hide():this.show()},outsideClick:function(t){var i=e(t.target);"focusin"==t.type||i.closest(this.element).length||i.closest(this.container).length||i.closest(".calendar-table").length||(this.hide(),this.element.trigger("outsideClick.daterangepicker",this))},showCalendars:function(){this.container.addClass("show-calendar"),this.move(),this.element.trigger("showCalendar.daterangepicker",this)},hideCalendars:function(){this.container.removeClass("show-calendar"),this.element.trigger("hideCalendar.daterangepicker",this)},hoverRange:function(t){if(!this.container.find("input[name=daterangepicker_start]").is(":focus")&&!this.container.find("input[name=daterangepicker_end]").is(":focus")){var e=t.target.getAttribute("data-range-key");if(e==this.locale.customRangeLabel)this.updateView();else{var i=this.ranges[e];this.container.find("input[name=daterangepicker_start]").val(i[0].format(this.locale.format)),this.container.find("input[name=daterangepicker_end]").val(i[1].format(this.locale.format))}}},clickRange:function(t){var e=t.target.getAttribute("data-range-key");if(this.chosenLabel=e,e==this.locale.customRangeLabel)this.showCalendars();else{var i=this.ranges[e];this.startDate=i[0],this.endDate=i[1],this.timePicker||(this.startDate.startOf("day"),this.endDate.endOf("day")),this.alwaysShowCalendars||this.hideCalendars(),this.clickApply()}},clickPrev:function(t){e(t.target).parents(".calendar").hasClass("left")?(this.leftCalendar.month.subtract(1,"month"),this.linkedCalendars&&this.rightCalendar.month.subtract(1,"month")):this.rightCalendar.month.subtract(1,"month"),this.updateCalendars()},clickNext:function(t){e(t.target).parents(".calendar").hasClass("left")?this.leftCalendar.month.add(1,"month"):(this.rightCalendar.month.add(1,"month"),this.linkedCalendars&&this.leftCalendar.month.add(1,"month")),this.updateCalendars()},hoverDate:function(t){if(e(t.target).hasClass("available")){var i=e(t.target).attr("data-title"),n=i.substr(1,1),o=i.substr(3,1),a=e(t.target).parents(".calendar"),s=a.hasClass("left")?this.leftCalendar.calendar[n][o]:this.rightCalendar.calendar[n][o];this.endDate&&!this.container.find("input[name=daterangepicker_start]").is(":focus")?this.container.find("input[name=daterangepicker_start]").val(s.format(this.locale.format)):this.endDate||this.container.find("input[name=daterangepicker_end]").is(":focus")||this.container.find("input[name=daterangepicker_end]").val(s.format(this.locale.format));var r=this.leftCalendar,l=this.rightCalendar,c=this.startDate;this.endDate||this.container.find(".calendar tbody td").each(function(t,i){if(!e(i).hasClass("week")){var n=e(i).attr("data-title"),o=n.substr(1,1),a=n.substr(3,1),d=e(i).parents(".calendar"),u=d.hasClass("left")?r.calendar[o][a]:l.calendar[o][a];u.isAfter(c)&&u.isBefore(s)||u.isSame(s,"day")?e(i).addClass("in-range"):e(i).removeClass("in-range")}})}},clickDate:function(t){if(e(t.target).hasClass("available")){var i=e(t.target).attr("data-title"),n=i.substr(1,1),o=i.substr(3,1),a=e(t.target).parents(".calendar"),s=a.hasClass("left")?this.leftCalendar.calendar[n][o]:this.rightCalendar.calendar[n][o];if(this.endDate||s.isBefore(this.startDate,"day")){if(this.timePicker){var r=parseInt(this.container.find(".left .hourselect").val(),10);if(!this.timePicker24Hour){var l=this.container.find(".left .ampmselect").val();"PM"===l&&r<12&&(r+=12),"AM"===l&&12===r&&(r=0)}var c=parseInt(this.container.find(".left .minuteselect").val(),10),d=this.timePickerSeconds?parseInt(this.container.find(".left .secondselect").val(),10):0;s=s.clone().hour(r).minute(c).second(d)}this.endDate=null,this.setStartDate(s.clone())}else if(!this.endDate&&s.isBefore(this.startDate))this.setEndDate(this.startDate.clone());else{if(this.timePicker){var r=parseInt(this.container.find(".right .hourselect").val(),10);if(!this.timePicker24Hour){var l=this.container.find(".right .ampmselect").val();"PM"===l&&r<12&&(r+=12),"AM"===l&&12===r&&(r=0)}var c=parseInt(this.container.find(".right .minuteselect").val(),10),d=this.timePickerSeconds?parseInt(this.container.find(".right .secondselect").val(),10):0;s=s.clone().hour(r).minute(c).second(d)}this.setEndDate(s.clone()),this.autoApply&&(this.calculateChosenLabel(),this.clickApply())}this.singleDatePicker&&(this.setEndDate(this.startDate),this.timePicker||this.clickApply()),this.updateView(),t.stopPropagation()}},calculateChosenLabel:function(){var t=!0,e=0;for(var i in this.ranges){if(this.timePicker){var n=this.timePickerSeconds?"YYYY-MM-DD hh:mm:ss":"YYYY-MM-DD hh:mm";if(this.startDate.format(n)==this.ranges[i][0].format(n)&&this.endDate.format(n)==this.ranges[i][1].format(n)){t=!1,this.chosenLabel=this.container.find(".ranges li:eq("+e+")").addClass("active").html();break}}else if(this.startDate.format("YYYY-MM-DD")==this.ranges[i][0].format("YYYY-MM-DD")&&this.endDate.format("YYYY-MM-DD")==this.ranges[i][1].format("YYYY-MM-DD")){t=!1,this.chosenLabel=this.container.find(".ranges li:eq("+e+")").addClass("active").html();break}e++}t&&(this.showCustomRangeLabel?this.chosenLabel=this.container.find(".ranges li:last").addClass("active").html():this.chosenLabel=null,this.showCalendars())},clickApply:function(t){this.hide(),this.element.trigger("apply.daterangepicker",this)},clickCancel:function(t){this.startDate=this.oldStartDate,this.endDate=this.oldEndDate,this.hide(),this.element.trigger("cancel.daterangepicker",this)},monthOrYearChanged:function(t){var i=e(t.target).closest(".calendar").hasClass("left"),n=i?"left":"right",o=this.container.find(".calendar."+n),a=parseInt(o.find(".monthselect").val(),10),s=o.find(".yearselect").val();i||(sthis.maxDate.year()||s==this.maxDate.year()&&a>this.maxDate.month())&&(a=this.maxDate.month(),s=this.maxDate.year()),i?(this.leftCalendar.month.month(a).year(s),this.linkedCalendars&&(this.rightCalendar.month=this.leftCalendar.month.clone().add(1,"month"))):(this.rightCalendar.month.month(a).year(s),this.linkedCalendars&&(this.leftCalendar.month=this.rightCalendar.month.clone().subtract(1,"month"))),this.updateCalendars()},timeChanged:function(t){var i=e(t.target).closest(".calendar"),n=i.hasClass("left"),o=parseInt(i.find(".hourselect").val(),10),a=parseInt(i.find(".minuteselect").val(),10),s=this.timePickerSeconds?parseInt(i.find(".secondselect").val(),10):0;if(!this.timePicker24Hour){var r=i.find(".ampmselect").val();"PM"===r&&o<12&&(o+=12),"AM"===r&&12===o&&(o=0)}if(n){var l=this.startDate.clone();l.hour(o),l.minute(a),l.second(s),this.setStartDate(l),this.singleDatePicker?this.endDate=this.startDate.clone():this.endDate&&this.endDate.format("YYYY-MM-DD")==l.format("YYYY-MM-DD")&&this.endDate.isBefore(l)&&this.setEndDate(l.clone())}else if(this.endDate){var c=this.endDate.clone();c.hour(o),c.minute(a),c.second(s),this.setEndDate(c)}this.updateCalendars(),this.updateFormInputs(),this.renderTimePicker("left"),this.renderTimePicker("right")},formInputsChanged:function(i){var n=e(i.target).closest(".calendar").hasClass("right"),o=t(this.container.find('input[name="daterangepicker_start"]').val(),this.locale.format),a=t(this.container.find('input[name="daterangepicker_end"]').val(),this.locale.format);o.isValid()&&a.isValid()&&(n&&a.isBefore(o)&&(o=a.clone()),this.setStartDate(o),this.setEndDate(a),n?this.container.find('input[name="daterangepicker_start"]').val(this.startDate.format(this.locale.format)):this.container.find('input[name="daterangepicker_end"]').val(this.endDate.format(this.locale.format))),this.updateView()},formInputsFocused:function(t){this.container.find('input[name="daterangepicker_start"], input[name="daterangepicker_end"]').removeClass("active"),e(t.target).addClass("active"),e(t.target).closest(".calendar").hasClass("right")&&(this.endDate=null,this.setStartDate(this.startDate.clone()),this.updateView())},formInputsBlurred:function(e){if(!this.endDate){var i=this.container.find('input[name="daterangepicker_end"]').val(),n=t(i,this.locale.format);n.isValid()&&(this.setEndDate(n),this.updateView())}},formInputsKeydown:function(t){13===t.keyCode&&(t.preventDefault(),this.formInputsChanged(t))},elementChanged:function(){if(this.element.is("input")&&this.element.val().length){var e=this.element.val().split(this.locale.separator),i=null,n=null;2===e.length&&(i=t(e[0],this.locale.format),n=t(e[1],this.locale.format)),(this.singleDatePicker||null===i||null===n)&&(i=t(this.element.val(),this.locale.format),n=i),i.isValid()&&n.isValid()&&(this.setStartDate(i),this.setEndDate(n),this.updateView())}},keydown:function(t){9!==t.keyCode&&13!==t.keyCode||this.hide(),27===t.keyCode&&(t.preventDefault(),t.stopPropagation(),this.hide())},updateElement:function(){this.element.is("input")&&!this.singleDatePicker&&this.autoUpdateInput?(this.element.val(this.startDate.format(this.locale.format)+this.locale.separator+this.endDate.format(this.locale.format)),this.element.trigger("change")):this.element.is("input")&&this.autoUpdateInput&&(this.element.val(this.startDate.format(this.locale.format)),this.element.trigger("change"))},remove:function(){this.container.remove(),this.element.off(".daterangepicker"),this.element.removeData()}},e.fn.daterangepicker=function(t,n){var o=e.extend(!0,{},e.fn.daterangepicker.defaultOptions,t);return this.each(function(){var t=e(this);t.data("daterangepicker")&&t.data("daterangepicker").remove(),t.data("daterangepicker",new i(t,o,n))}),this},i}); \ No newline at end of file diff --git a/public/assets/js/require-table.js b/public/assets/js/require-table.js index 5ba1f90..ff2cba8 100755 --- a/public/assets/js/require-table.js +++ b/public/assets/js/require-table.js @@ -87,21 +87,24 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table button: { edit: { name: 'edit', - icon: 'fa fa-pencil', + icon: '', + text: __('Edit'), title: __('Edit'), extend: 'data-toggle="tooltip" data-container="body"', classname: 'btn btn-xs btn-success btn-editone' }, del: { name: 'del', - icon: 'fa fa-trash', + icon: '', + text: __('Del'), title: __('Del'), extend: 'data-toggle="tooltip" data-container="body"', classname: 'btn btn-xs btn-danger btn-delone' }, dragsort: { name: 'dragsort', - icon: 'fa fa-arrows', + icon: '', + text: '排序', title: __('Drag to sort'), extend: 'data-toggle="tooltip"', classname: 'btn btn-xs btn-primary btn-dragsort' @@ -996,7 +999,7 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table if (disable) { classname = classname + ' disabled'; } - link = '' + (text ? ' ' + text : '') + ''; + link = '' + (icon ? '' : '') + (text ? (icon ? ' ' : '') + text : '') + ''; if (dropdown) { if (typeof dropdowns[dropdown] == 'undefined') { dropdowns[dropdown] = []; diff --git a/public/static/icons/bar-fav-on.png b/public/static/icons/bar-fav-on.png new file mode 100644 index 0000000..47da380 Binary files /dev/null and b/public/static/icons/bar-fav-on.png differ diff --git a/public/static/icons/bar-fav.png b/public/static/icons/bar-fav.png new file mode 100644 index 0000000..b8c6620 Binary files /dev/null and b/public/static/icons/bar-fav.png differ diff --git a/public/static/icons/bar-poster.png b/public/static/icons/bar-poster.png new file mode 100644 index 0000000..3144264 Binary files /dev/null and b/public/static/icons/bar-poster.png differ diff --git a/public/static/icons/bar-share.png b/public/static/icons/bar-share.png new file mode 100644 index 0000000..6243df0 Binary files /dev/null and b/public/static/icons/bar-share.png differ diff --git a/public/static/icons/cat-baby.png b/public/static/icons/cat-baby.png new file mode 100644 index 0000000..1935e09 Binary files /dev/null and b/public/static/icons/cat-baby.png differ diff --git a/public/static/icons/cat-business.png b/public/static/icons/cat-business.png new file mode 100644 index 0000000..a486bc5 Binary files /dev/null and b/public/static/icons/cat-business.png differ diff --git a/public/static/icons/cat-car.png b/public/static/icons/cat-car.png new file mode 100644 index 0000000..c707b43 Binary files /dev/null and b/public/static/icons/cat-car.png differ diff --git a/public/static/icons/cat-clean.png b/public/static/icons/cat-clean.png new file mode 100644 index 0000000..e301848 Binary files /dev/null and b/public/static/icons/cat-clean.png differ diff --git a/public/static/icons/cat-community.png b/public/static/icons/cat-community.png new file mode 100644 index 0000000..b3b5050 Binary files /dev/null and b/public/static/icons/cat-community.png differ diff --git a/public/static/icons/cat-consult.png b/public/static/icons/cat-consult.png new file mode 100644 index 0000000..8bc29c1 Binary files /dev/null and b/public/static/icons/cat-consult.png differ diff --git a/public/static/icons/cat-digital.png b/public/static/icons/cat-digital.png new file mode 100644 index 0000000..adba510 Binary files /dev/null and b/public/static/icons/cat-digital.png differ diff --git a/public/static/icons/cat-education.png b/public/static/icons/cat-education.png new file mode 100644 index 0000000..7b98137 Binary files /dev/null and b/public/static/icons/cat-education.png differ diff --git a/public/static/icons/cat-entertainment.png b/public/static/icons/cat-entertainment.png new file mode 100644 index 0000000..47da380 Binary files /dev/null and b/public/static/icons/cat-entertainment.png differ diff --git a/public/static/icons/cat-food.png b/public/static/icons/cat-food.png new file mode 100644 index 0000000..9c942d9 Binary files /dev/null and b/public/static/icons/cat-food.png differ diff --git a/public/static/icons/cat-friend.png b/public/static/icons/cat-friend.png new file mode 100644 index 0000000..674a8d4 Binary files /dev/null and b/public/static/icons/cat-friend.png differ diff --git a/public/static/icons/cat-furniture.png b/public/static/icons/cat-furniture.png new file mode 100644 index 0000000..df81ff4 Binary files /dev/null and b/public/static/icons/cat-furniture.png differ diff --git a/public/static/icons/cat-goods-v2.png b/public/static/icons/cat-goods-v2.png new file mode 100644 index 0000000..b5f1764 Binary files /dev/null and b/public/static/icons/cat-goods-v2.png differ diff --git a/public/static/icons/cat-goods.png b/public/static/icons/cat-goods.png new file mode 100644 index 0000000..b5f1764 Binary files /dev/null and b/public/static/icons/cat-goods.png differ diff --git a/public/static/icons/cat-health.png b/public/static/icons/cat-health.png new file mode 100644 index 0000000..9eba891 Binary files /dev/null and b/public/static/icons/cat-health.png differ diff --git a/public/static/icons/cat-house.png b/public/static/icons/cat-house.png new file mode 100644 index 0000000..f204ca7 Binary files /dev/null and b/public/static/icons/cat-house.png differ diff --git a/public/static/icons/cat-job.png b/public/static/icons/cat-job.png new file mode 100644 index 0000000..fde0f26 Binary files /dev/null and b/public/static/icons/cat-job.png differ diff --git a/public/static/icons/cat-law.png b/public/static/icons/cat-law.png new file mode 100644 index 0000000..a77a78e Binary files /dev/null and b/public/static/icons/cat-law.png differ diff --git a/public/static/icons/cat-move.png b/public/static/icons/cat-move.png new file mode 100644 index 0000000..d5d7e97 Binary files /dev/null and b/public/static/icons/cat-move.png differ diff --git a/public/static/icons/cat-pet.png b/public/static/icons/cat-pet.png new file mode 100644 index 0000000..9a4b99b Binary files /dev/null and b/public/static/icons/cat-pet.png differ diff --git a/public/static/icons/cat-photo.png b/public/static/icons/cat-photo.png new file mode 100644 index 0000000..539d8fb Binary files /dev/null and b/public/static/icons/cat-photo.png differ diff --git a/public/static/icons/cat-repair.png b/public/static/icons/cat-repair.png new file mode 100644 index 0000000..aa83c63 Binary files /dev/null and b/public/static/icons/cat-repair.png differ diff --git a/public/static/icons/cat-service.png b/public/static/icons/cat-service.png new file mode 100644 index 0000000..cfe0266 Binary files /dev/null and b/public/static/icons/cat-service.png differ diff --git a/public/static/icons/cat-sport.png b/public/static/icons/cat-sport.png new file mode 100644 index 0000000..88c92b5 Binary files /dev/null and b/public/static/icons/cat-sport.png differ diff --git a/public/static/icons/cat-vip.png b/public/static/icons/cat-vip.png new file mode 100644 index 0000000..003c7a3 Binary files /dev/null and b/public/static/icons/cat-vip.png differ diff --git a/public/static/icons/check.png b/public/static/icons/check.png new file mode 100644 index 0000000..c591541 Binary files /dev/null and b/public/static/icons/check.png differ diff --git a/public/static/icons/close.png b/public/static/icons/close.png new file mode 100644 index 0000000..3d4eb16 Binary files /dev/null and b/public/static/icons/close.png differ diff --git a/public/static/icons/comment-gray.png b/public/static/icons/comment-gray.png new file mode 100644 index 0000000..416383d Binary files /dev/null and b/public/static/icons/comment-gray.png differ diff --git a/public/static/icons/crown.png b/public/static/icons/crown.png new file mode 100644 index 0000000..003c7a3 Binary files /dev/null and b/public/static/icons/crown.png differ diff --git a/public/static/icons/edit.png b/public/static/icons/edit.png new file mode 100644 index 0000000..34920bf Binary files /dev/null and b/public/static/icons/edit.png differ diff --git a/public/static/icons/eye.png b/public/static/icons/eye.png new file mode 100644 index 0000000..6293c75 Binary files /dev/null and b/public/static/icons/eye.png differ diff --git a/public/static/icons/fire.png b/public/static/icons/fire.png new file mode 100644 index 0000000..9c942d9 Binary files /dev/null and b/public/static/icons/fire.png differ diff --git a/public/static/icons/folder.png b/public/static/icons/folder.png new file mode 100644 index 0000000..10780a5 Binary files /dev/null and b/public/static/icons/folder.png differ diff --git a/public/static/icons/home-bell.png b/public/static/icons/home-bell.png new file mode 100644 index 0000000..71c480a Binary files /dev/null and b/public/static/icons/home-bell.png differ diff --git a/public/static/icons/home-crown.png b/public/static/icons/home-crown.png new file mode 100644 index 0000000..21f9898 Binary files /dev/null and b/public/static/icons/home-crown.png differ diff --git a/public/static/icons/home-location.png b/public/static/icons/home-location.png new file mode 100644 index 0000000..7e6181b Binary files /dev/null and b/public/static/icons/home-location.png differ diff --git a/public/static/icons/home-search.png b/public/static/icons/home-search.png new file mode 100644 index 0000000..d563f74 Binary files /dev/null and b/public/static/icons/home-search.png differ diff --git a/public/static/icons/image-white.png b/public/static/icons/image-white.png new file mode 100644 index 0000000..50a3c01 Binary files /dev/null and b/public/static/icons/image-white.png differ diff --git a/public/static/icons/image.png b/public/static/icons/image.png new file mode 100644 index 0000000..539d8fb Binary files /dev/null and b/public/static/icons/image.png differ diff --git a/public/static/icons/inbox.png b/public/static/icons/inbox.png new file mode 100644 index 0000000..f69de6a Binary files /dev/null and b/public/static/icons/inbox.png differ diff --git a/public/static/icons/info.png b/public/static/icons/info.png new file mode 100644 index 0000000..f878a62 Binary files /dev/null and b/public/static/icons/info.png differ diff --git a/public/static/icons/link-dist.png b/public/static/icons/link-dist.png new file mode 100644 index 0000000..d5d7e97 Binary files /dev/null and b/public/static/icons/link-dist.png differ diff --git a/public/static/icons/link-order.png b/public/static/icons/link-order.png new file mode 100644 index 0000000..b5f1764 Binary files /dev/null and b/public/static/icons/link-order.png differ diff --git a/public/static/icons/link-recharge.png b/public/static/icons/link-recharge.png new file mode 100644 index 0000000..9ac7e3a Binary files /dev/null and b/public/static/icons/link-recharge.png differ diff --git a/public/static/icons/location.png b/public/static/icons/location.png new file mode 100644 index 0000000..30e2ab2 Binary files /dev/null and b/public/static/icons/location.png differ diff --git a/public/static/icons/lock.png b/public/static/icons/lock.png new file mode 100644 index 0000000..fba38fc Binary files /dev/null and b/public/static/icons/lock.png differ diff --git a/public/static/icons/login-person.png b/public/static/icons/login-person.png new file mode 100644 index 0000000..5f0ca84 Binary files /dev/null and b/public/static/icons/login-person.png differ diff --git a/public/static/icons/login-shop.png b/public/static/icons/login-shop.png new file mode 100644 index 0000000..03a1e2f Binary files /dev/null and b/public/static/icons/login-shop.png differ diff --git a/public/static/icons/mine-about.png b/public/static/icons/mine-about.png new file mode 100644 index 0000000..dfd8ab8 Binary files /dev/null and b/public/static/icons/mine-about.png differ diff --git a/public/static/icons/mine-dist.png b/public/static/icons/mine-dist.png new file mode 100644 index 0000000..d5d7e97 Binary files /dev/null and b/public/static/icons/mine-dist.png differ diff --git a/public/static/icons/mine-draft.png b/public/static/icons/mine-draft.png new file mode 100644 index 0000000..df81ff4 Binary files /dev/null and b/public/static/icons/mine-draft.png differ diff --git a/public/static/icons/mine-history.png b/public/static/icons/mine-history.png new file mode 100644 index 0000000..b56e7bc Binary files /dev/null and b/public/static/icons/mine-history.png differ diff --git a/public/static/icons/mine-order.png b/public/static/icons/mine-order.png new file mode 100644 index 0000000..b5f1764 Binary files /dev/null and b/public/static/icons/mine-order.png differ diff --git a/public/static/icons/mine-post.png b/public/static/icons/mine-post.png new file mode 100644 index 0000000..0c931a4 Binary files /dev/null and b/public/static/icons/mine-post.png differ diff --git a/public/static/icons/mine-service.png b/public/static/icons/mine-service.png new file mode 100644 index 0000000..560a056 Binary files /dev/null and b/public/static/icons/mine-service.png differ diff --git a/public/static/icons/mine-setting.png b/public/static/icons/mine-setting.png new file mode 100644 index 0000000..3f2be2c Binary files /dev/null and b/public/static/icons/mine-setting.png differ diff --git a/public/static/icons/mine-vip.png b/public/static/icons/mine-vip.png new file mode 100644 index 0000000..f2e2ca2 Binary files /dev/null and b/public/static/icons/mine-vip.png differ diff --git a/public/static/icons/msg-interact.png b/public/static/icons/msg-interact.png new file mode 100644 index 0000000..2ac7709 Binary files /dev/null and b/public/static/icons/msg-interact.png differ diff --git a/public/static/icons/msg-system.png b/public/static/icons/msg-system.png new file mode 100644 index 0000000..00fbf7e Binary files /dev/null and b/public/static/icons/msg-system.png differ diff --git a/public/static/icons/network.png b/public/static/icons/network.png new file mode 100644 index 0000000..adba510 Binary files /dev/null and b/public/static/icons/network.png differ diff --git a/public/static/icons/order-member.png b/public/static/icons/order-member.png new file mode 100644 index 0000000..be24a09 Binary files /dev/null and b/public/static/icons/order-member.png differ diff --git a/public/static/icons/order-other.png b/public/static/icons/order-other.png new file mode 100644 index 0000000..7c8b273 Binary files /dev/null and b/public/static/icons/order-other.png differ diff --git a/public/static/icons/order-post.png b/public/static/icons/order-post.png new file mode 100644 index 0000000..34920bf Binary files /dev/null and b/public/static/icons/order-post.png differ diff --git a/public/static/icons/order-recharge.png b/public/static/icons/order-recharge.png new file mode 100644 index 0000000..1b86b62 Binary files /dev/null and b/public/static/icons/order-recharge.png differ diff --git a/public/static/icons/paywechat.png b/public/static/icons/paywechat.png new file mode 100644 index 0000000..5d3f99a Binary files /dev/null and b/public/static/icons/paywechat.png differ diff --git a/public/static/icons/phone-orange.png b/public/static/icons/phone-orange.png new file mode 100644 index 0000000..560a056 Binary files /dev/null and b/public/static/icons/phone-orange.png differ diff --git a/public/static/icons/phone.png b/public/static/icons/phone.png new file mode 100644 index 0000000..8bc29c1 Binary files /dev/null and b/public/static/icons/phone.png differ diff --git a/public/static/icons/phonebind.png b/public/static/icons/phonebind.png new file mode 100644 index 0000000..d938aff Binary files /dev/null and b/public/static/icons/phonebind.png differ diff --git a/public/static/icons/plus-ink.png b/public/static/icons/plus-ink.png new file mode 100644 index 0000000..849f277 Binary files /dev/null and b/public/static/icons/plus-ink.png differ diff --git a/public/static/icons/plus-white.png b/public/static/icons/plus-white.png new file mode 100644 index 0000000..b6285d6 Binary files /dev/null and b/public/static/icons/plus-white.png differ diff --git a/public/static/icons/qrcode.png b/public/static/icons/qrcode.png new file mode 100644 index 0000000..e42fe07 Binary files /dev/null and b/public/static/icons/qrcode.png differ diff --git a/public/static/icons/receipt.png b/public/static/icons/receipt.png new file mode 100644 index 0000000..7c8b273 Binary files /dev/null and b/public/static/icons/receipt.png differ diff --git a/public/static/icons/search.png b/public/static/icons/search.png new file mode 100644 index 0000000..d563f74 Binary files /dev/null and b/public/static/icons/search.png differ diff --git a/public/static/icons/settings.png b/public/static/icons/settings.png new file mode 100644 index 0000000..aa83c63 Binary files /dev/null and b/public/static/icons/settings.png differ diff --git a/public/static/icons/share.png b/public/static/icons/share.png new file mode 100644 index 0000000..ca3ed4c Binary files /dev/null and b/public/static/icons/share.png differ diff --git a/public/static/icons/shield.png b/public/static/icons/shield.png new file mode 100644 index 0000000..a77a78e Binary files /dev/null and b/public/static/icons/shield.png differ diff --git a/public/static/icons/star-o.png b/public/static/icons/star-o.png new file mode 100644 index 0000000..d6db00c Binary files /dev/null and b/public/static/icons/star-o.png differ diff --git a/public/static/icons/star.png b/public/static/icons/star.png new file mode 100644 index 0000000..47da380 Binary files /dev/null and b/public/static/icons/star.png differ diff --git a/public/static/icons/tab-category-on.png b/public/static/icons/tab-category-on.png new file mode 100644 index 0000000..8badb4a Binary files /dev/null and b/public/static/icons/tab-category-on.png differ diff --git a/public/static/icons/tab-category.png b/public/static/icons/tab-category.png new file mode 100644 index 0000000..7d70ec7 Binary files /dev/null and b/public/static/icons/tab-category.png differ diff --git a/public/static/icons/tab-home-on.png b/public/static/icons/tab-home-on.png new file mode 100644 index 0000000..bdb37d0 Binary files /dev/null and b/public/static/icons/tab-home-on.png differ diff --git a/public/static/icons/tab-home.png b/public/static/icons/tab-home.png new file mode 100644 index 0000000..eeb12f7 Binary files /dev/null and b/public/static/icons/tab-home.png differ diff --git a/public/static/icons/tab-message-on.png b/public/static/icons/tab-message-on.png new file mode 100644 index 0000000..99e0a5f Binary files /dev/null and b/public/static/icons/tab-message-on.png differ diff --git a/public/static/icons/tab-message.png b/public/static/icons/tab-message.png new file mode 100644 index 0000000..c365240 Binary files /dev/null and b/public/static/icons/tab-message.png differ diff --git a/public/static/icons/tab-mine-on.png b/public/static/icons/tab-mine-on.png new file mode 100644 index 0000000..2fa95a7 Binary files /dev/null and b/public/static/icons/tab-mine-on.png differ diff --git a/public/static/icons/tab-mine.png b/public/static/icons/tab-mine.png new file mode 100644 index 0000000..a3cdfe6 Binary files /dev/null and b/public/static/icons/tab-mine.png differ diff --git a/public/static/icons/tab-post-on.png b/public/static/icons/tab-post-on.png new file mode 100644 index 0000000..92e7f92 Binary files /dev/null and b/public/static/icons/tab-post-on.png differ diff --git a/public/static/icons/tab-post.png b/public/static/icons/tab-post.png new file mode 100644 index 0000000..c55f34f Binary files /dev/null and b/public/static/icons/tab-post.png differ diff --git a/public/static/icons/users.png b/public/static/icons/users.png new file mode 100644 index 0000000..b3b5050 Binary files /dev/null and b/public/static/icons/users.png differ diff --git a/public/static/icons/wallet.png b/public/static/icons/wallet.png new file mode 100644 index 0000000..a486bc5 Binary files /dev/null and b/public/static/icons/wallet.png differ diff --git a/public/static/icons/wechat.svg b/public/static/icons/wechat.svg new file mode 100644 index 0000000..1c6ff91 --- /dev/null +++ b/public/static/icons/wechat.svg @@ -0,0 +1,4 @@ + + + + diff --git a/scratch_original_goods.png b/scratch_original_goods.png new file mode 100644 index 0000000..f11a2ca Binary files /dev/null and b/scratch_original_goods.png differ diff --git a/tests/order_cancel_and_detail_test.php b/tests/order_cancel_and_detail_test.php new file mode 100644 index 0000000..ae08227 --- /dev/null +++ b/tests/order_cancel_and_detail_test.php @@ -0,0 +1,199 @@ +find(); +if (!$user) { + echo "错误:数据库中没有用户数据!\n"; + exit(1); +} +$userId = (int)$user['id']; +echo "1. 选定测试用户 ID: {$userId} ({$user['username']})\n"; + +// 准备测试用的优惠券 +$now = time(); +$couponId = Db::name('fc_coupon')->insertGetId([ + 'name' => '测试优惠券', + 'type' => 'fixed', + 'amount' => 5.00, + 'min_amount' => 10.00, + 'days' => 7, + 'total' => 10, + 'received' => 1, + 'enabled' => 1, + 'createtime' => $now, + 'updatetime' => $now, +]); +$userCouponId = Db::name('fc_user_coupon')->insertGetId([ + 'user_id' => $userId, + 'coupon_id' => $couponId, + 'status' => 'unused', + 'expiretime' => $now + 86400 * 7, + 'createtime' => $now, +]); + +// 场景一:测试主动取消订单流程 +echo "\n--- 场景一:测试主动取消待支付订单 ---\n"; +$orderNo1 = 'TEST' . date('YmdHis') . rand(100, 999); +CouponService::lock($userId, $userCouponId, 20.00, $orderNo1); + +$orderId1 = Db::name('fc_order')->insertGetId([ + 'order_no' => $orderNo1, + 'user_id' => $userId, + 'type' => 'post', + 'title' => '测试二手闲置发布', + 'amount' => 15.00, + 'origin_amount' => 20.00, + 'coupon_amount' => 5.00, + 'coupon_id' => $userCouponId, + 'pay_type' => 'wxpay', + 'status' => 'pending', + 'related_id' => 99999, + 'createtime' => $now, + 'updatetime' => $now, +]); + +// 验证锁定状态 +$userCoupon = Db::name('fc_user_coupon')->where('id', $userCouponId)->find(); +assert($userCoupon['status'] === 'locked', "优惠券应为 locked 状态"); +echo "✓ 待支付订单创建成功,优惠券已正确锁定 (status=locked)\n"; + +// 执行主动取消 +$order1 = Db::name('fc_order')->where('id', $orderId1)->find(); +$closed = OrderClose::close($order1, 'user_cancel'); +assert($closed === true, "OrderClose::close 应该返回 true"); + +// 校验订单和优惠券状态 +$order1After = Db::name('fc_order')->where('id', $orderId1)->find(); +assert($order1After['status'] === 'closed', "订单状态应该已变为 closed"); +$userCouponAfter = Db::name('fc_user_coupon')->where('id', $userCouponId)->find(); +assert($userCouponAfter['status'] === 'unused', "优惠券应该已恢复为 unused"); +assert(empty($userCouponAfter['order_no']), "优惠券关联订单号应该已被清空"); +echo "✓ 主动取消成功:订单状态已变为 closed,锁定的优惠券已自动释放 (status=unused)\n"; + + +// 场景二:测试超时自动取消(惰性检查) +echo "\n--- 场景二:测试订单详情惰性超时自动取消 ---\n"; +$orderNo2 = 'TEST' . date('YmdHis') . rand(100, 999); +$timeout = OrderClose::getTimeoutSeconds(); +$pastTime = $now - ($timeout + 60); // 超过超时时间60秒 + +$orderId2 = Db::name('fc_order')->insertGetId([ + 'order_no' => $orderNo2, + 'user_id' => $userId, + 'type' => 'member', + 'title' => '测试开通月卡会员', + 'amount' => 39.00, + 'origin_amount' => 39.00, + 'coupon_amount' => 0.00, + 'coupon_id' => 0, + 'pay_type' => 'wxpay', + 'status' => 'pending', + 'related_id' => 1, + 'createtime' => $pastTime, + 'updatetime' => $pastTime, +]); + +// 模拟调用 checkAndCloseIfExpired +$order2 = Db::name('fc_order')->where('id', $orderId2)->find(); +$isExp = OrderClose::isExpired($order2); +assert($isExp === true, "超时的订单 isExpired 应该返回 true"); + +$order2Checked = OrderClose::checkAndCloseIfExpired($order2); +assert($order2Checked['status'] === 'closed', "超时检查后订单状态应自动变更为 closed"); + +$order2Db = Db::name('fc_order')->where('id', $orderId2)->find(); +assert($order2Db['status'] === 'closed', "数据库中订单状态应已是 closed"); +assert($order2Db['refund_reason'] === '超时未支付自动关闭', "关闭原因应记录为超时未支付自动关闭"); +echo "✓ 惰性超时取消成功:超过 {$timeout} 秒的订单自动更新为 closed\n"; + + +// 场景三:测试订单详情返回结构 +echo "\n--- 场景三:测试 Order 控制器 detail 接口 ---\n"; +$orderController = new \app\api\controller\Order(); +// 设置模拟请求与登录态(反射注入私有/受保护属性) +$userModel = \app\common\model\User::get($userId); +$refResolved = new ReflectionProperty($orderController, 'resolved'); +$refResolved->setAccessible(true); +$refResolved->setValue($orderController, true); + +$refUser = new ReflectionProperty($orderController, 'user'); +$refUser->setAccessible(true); +$refUser->setValue($orderController, $userModel); + +// 创建一个正常的待支付订单,检查倒计时和详情 +$orderNo3 = 'TEST' . date('YmdHis') . rand(100, 999); +$orderId3 = Db::name('fc_order')->insertGetId([ + 'order_no' => $orderNo3, + 'user_id' => $userId, + 'type' => 'recharge', + 'title' => '余额充值', + 'amount' => 50.00, + 'origin_amount' => 50.00, + 'coupon_amount' => 0.00, + 'coupon_id' => 0, + 'pay_type' => 'wxpay', + 'status' => 'pending', + 'related_id' => 0, + 'createtime' => $now - 300, // 5分钟前下单 + 'updatetime' => $now - 300, +]); + +$_POST['orderNo'] = $orderNo3; +$_GET['orderNo'] = $orderNo3; + +ob_start(); +try { + $orderController->detail(); +} catch (\think\exception\HttpResponseException $e) { + if (ob_get_level() > 0) ob_end_clean(); + $response = $e->getResponse(); + $data = $response->getData(); + echo "✓ detail 接口返回成功,code: " . $data['code'] . "\n"; + assert($data['code'] === 0, "接口状态码应为 0 (成功)"); + $detailData = $data['data']; + assert($detailData['orderNo'] === $orderNo3, "返回的订单号应一致"); + assert($detailData['status'] === 'pending', "状态应为 pending"); + assert($detailData['expireSeconds'] > 0, "expireSeconds 应大于 0"); + assert($detailData['amount'] == 50.00, "金额应为 50.00"); + echo "✓ 详情数据解析正确:剩余支付时间 " . $detailData['expireSeconds'] . " 秒,状态: " . $detailData['statusText'] . "\n"; +} + + +// 场景四:测试 cancel 接口 +echo "\n--- 场景四:测试 Order 控制器 cancel 接口 ---\n"; +$_POST['orderNo'] = $orderNo3; +ob_start(); +try { + $orderController->cancel(); +} catch (\think\exception\HttpResponseException $e) { + if (ob_get_level() > 0) ob_end_clean(); + $response = $e->getResponse(); + $data = $response->getData(); + echo "✓ cancel 接口调用成功,code: " . $data['code'] . ", message: " . $data['message'] . "\n"; + assert($data['code'] === 0, "接口状态码应为 0 (成功)"); + $order3Db = Db::name('fc_order')->where('id', $orderId3)->find(); + assert($order3Db['status'] === 'closed', "订单状态在取消后应变更为 closed"); + echo "✓ cancel 接口业务生效:订单 {$orderNo3} 已变为 closed\n"; +} + + +// 清理测试临时数据 +echo "\n--- 清理测试数据 ---\n"; +Db::name('fc_order')->where('id', 'in', [$orderId1, $orderId2, $orderId3])->delete(); +Db::name('fc_user_coupon')->where('id', $userCouponId)->delete(); +Db::name('fc_coupon')->where('id', $couponId)->delete(); +echo "✓ 测试数据清理完成\n"; + +echo "\n========================================\n"; +echo "🎉 全部测试用例通过!订单主动取消、自动取消与详情功能验证完毕!\n"; +echo "========================================\n"; diff --git a/uniapp/common/api/order.js b/uniapp/common/api/order.js index cc530c0..e572966 100644 --- a/uniapp/common/api/order.js +++ b/uniapp/common/api/order.js @@ -3,7 +3,7 @@ * 对应契约 §2.1:POST /order/recharge {amount,payType} → {orderNo,amount,status,payType} * 说明:与后端 application/api/controller/Order.php 不是同一文件,仅为前端封装。 */ -import { post } from '../utils/request.js' +import { get, post } from '../utils/request.js' export const orderApi = { /** @@ -12,6 +12,18 @@ export const orderApi = { * 服务端禁止 payType='balance'(用余额给余额加钱会凭空增发余额,属资损)。 */ recharge: (payload = {}) => post('/order/recharge', payload, { silent: true }), + + /** + * 订单详情 + * @param {Object} params {orderNo: string, id?: number} + */ + detail: (params = {}) => get('/order/detail', params, { silent: true }), + + /** + * 主动取消待支付订单 + * @param {Object} payload {orderNo: string, id?: number} + */ + cancel: (payload = {}) => post('/order/cancel', payload, { silent: true }), } export default orderApi diff --git a/uniapp/common/api/post.js b/uniapp/common/api/post.js index 3415618..50ddf96 100644 --- a/uniapp/common/api/post.js +++ b/uniapp/common/api/post.js @@ -65,6 +65,8 @@ export const postApi = { payView: (id, payload) => post(`/post/${id}/pay-view`, payload, { silent: true }), /** 发表评价(评分 + 图文) */ comment: (id, payload) => post(`/post/${id}/comment`, payload, { silent: true }), + /** 发布者回复评价 */ + replyComment: (commentId, payload) => post(`/post/comment/${commentId}/reply`, payload, { silent: true }), /** 评价列表(详情页「用户评价」,替代前端写死的假评价) */ comments: (id) => get(`/post/${id}/comments`, {}, { silent: true }), } diff --git a/uniapp/common/assets/icons.js b/uniapp/common/assets/icons.js index 3ee2de3..c235030 100644 --- a/uniapp/common/assets/icons.js +++ b/uniapp/common/assets/icons.js @@ -102,6 +102,7 @@ export const ICON_GROUPS = [ { key: 'mine-draft', name: '草稿箱', file: 'mine-draft.png' }, { key: 'mine-history', name: '搜索记录', file: 'mine-history.png' }, { key: 'mine-setting', name: '系统设置', file: 'mine-setting.png' }, + { key: 'mine-service', name: '联系客服', file: 'mine-service.png' }, { key: 'mine-about', name: '关于我们', file: 'mine-about.png' }, ], }, diff --git a/uniapp/common/config/index.js b/uniapp/common/config/index.js index adbf6c4..824815c 100644 --- a/uniapp/common/config/index.js +++ b/uniapp/common/config/index.js @@ -6,22 +6,56 @@ * - HBuilderX「发行/打包」→ NODE_ENV=production → prod:远程正式后端 */ -// 编译期常量;发行包会摇树消除 dev 分支,不会把本地地址打进正式包 -const ENV = - (typeof process !== 'undefined' && process.env && process.env.NODE_ENV) || - 'development' -const IS_DEV = ENV !== 'production' +/** + * 检测当前运行环境是否为生产环境(prod) + * + * 解决 HBuilderX 发行小程序时后台地址未生效的问题: + * 1. 编译期静态宏替换: + * 在 HBuilderX 发行/构建时,构建工具(Vite/Webpack)会直接将 `process.env.NODE_ENV` 宏替换为 `"production"`。 + * 千万不能在外部包裹 `typeof process !== 'undefined'`,否则编译后保留该判断, + * 而在微信小程序运行时环境中全局没有 process 对象,导致判断为 false 误回退为开发环境。 + * 2. 微信小程序运行态兜底: + * 通过 uni.getAccountInfoSync 读取小程序 envVersion,体验版(trial)和正式版(release)均自动切换为生产接口。 + * + * @returns {boolean} 是否为生产环境 + */ +function detectIsProduction() { + // 1. 编译期宏替换判断(发行模式下 process.env.NODE_ENV 在打包时会被替换为 'production') + if (process.env.NODE_ENV === 'production') { + return true + } + + // 2. 微信小程序运行期环境版本兜底判断 + // #ifdef MP-WEIXIN + try { + const accountInfo = typeof uni !== 'undefined' && uni.getAccountInfoSync && uni.getAccountInfoSync() + const envVersion = accountInfo && accountInfo.miniProgram && accountInfo.miniProgram.envVersion + if (envVersion === 'release' || envVersion === 'trial') { + return true + } + } catch (e) { + // 忽略异常,降级处理 + } + // #endif + + return false +} + +// 生产环境标识 +const IS_PROD = detectIsProduction() +const IS_DEV = !IS_PROD +const ENV = IS_PROD ? 'production' : 'development' // 各环境后端域名(dev=运行 / prod=发行) const HOSTS = { - dev: 'http://192.168.2.61:9980', // 本地后端(phpstudy 虚拟域名与端口 9980) + dev: 'https://308dfc36.r9.cpolar.cn', // 本地后端(phpstudy 虚拟域名与端口 9980) prod: 'https://fenleixinxi.gzyakj.com.cn', // 远程正式后端 } // 接口统一前缀 const API_PREFIX = '/api' // 网关 = 域名 + /api(版本号由下方 apiVersion 拼接) -const BASE_URL = HOSTS[IS_DEV ? 'dev' : 'prod'] + API_PREFIX +const BASE_URL = (IS_PROD ? HOSTS.prod : HOSTS.dev) + API_PREFIX export const config = { // 当前环境:'development'(HBuilderX 运行)| 'production'(发行) diff --git a/uniapp/common/constants/ui.js b/uniapp/common/constants/ui.js index d33ae62..7c13072 100644 --- a/uniapp/common/constants/ui.js +++ b/uniapp/common/constants/ui.js @@ -24,13 +24,14 @@ export const WITHDRAW_TEXT = { } /** 订单类型 */ -export const ORDER_TYPE_TEXT = { post: '发布订单', member: '会员订单', recharge: '充值订单' } +export const ORDER_TYPE_TEXT = { post: '发布订单', member: '会员订单', recharge: '充值订单', payview: '付费查看' } /** 订单类型 -> 图标 key */ export const ORDER_ICON_KEY = { post: 'order-post', member: 'order-member', recharge: 'order-recharge', + payview: 'order-other', } /** 资金流水类型 */ diff --git a/uniapp/common/mock/data.js b/uniapp/common/mock/data.js index 264bf74..8e7c385 100644 --- a/uniapp/common/mock/data.js +++ b/uniapp/common/mock/data.js @@ -188,7 +188,7 @@ export const datasets = { freeView: 20, // 每日免费查看联系方式条数 postDiscount: '8 折', distRate: '一级 20% / 二级 10%', - benefits: ['每日免费查看 20 条联系方式', '发布信息 8 折', '专属会员标识', '分销佣金加速结算'], + benefits: ['每日免费查看 20 条联系方式', '发布信息 8 折', '专属会员标识', '赠送大量发布额度'], }, /** 我的资产(coupons / couponCount 由 /member/assets 从 fc_user_coupon 实时聚合) */ diff --git a/uniapp/common/utils/qrcode-generator.js b/uniapp/common/utils/qrcode-generator.js new file mode 100644 index 0000000..a114a21 --- /dev/null +++ b/uniapp/common/utils/qrcode-generator.js @@ -0,0 +1,2087 @@ +var __getOwnPropNames = Object.getOwnPropertyNames; +var __commonJS = (cb, mod) => function __require() { + try { + return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; + } catch (e) { + throw mod = 0, e; + } +}; + +// node_modules/qrcode/lib/can-promise.js +var require_can_promise = __commonJS({ + "node_modules/qrcode/lib/can-promise.js"(exports, module) { + module.exports = function() { + return typeof Promise === "function" && Promise.prototype && Promise.prototype.then; + }; + } +}); + +// node_modules/qrcode/lib/core/utils.js +var require_utils = __commonJS({ + "node_modules/qrcode/lib/core/utils.js"(exports) { + var toSJISFunction; + var CODEWORDS_COUNT = [ + 0, + // Not used + 26, + 44, + 70, + 100, + 134, + 172, + 196, + 242, + 292, + 346, + 404, + 466, + 532, + 581, + 655, + 733, + 815, + 901, + 991, + 1085, + 1156, + 1258, + 1364, + 1474, + 1588, + 1706, + 1828, + 1921, + 2051, + 2185, + 2323, + 2465, + 2611, + 2761, + 2876, + 3034, + 3196, + 3362, + 3532, + 3706 + ]; + exports.getSymbolSize = function getSymbolSize(version) { + if (!version) throw new Error('"version" cannot be null or undefined'); + if (version < 1 || version > 40) throw new Error('"version" should be in range from 1 to 40'); + return version * 4 + 17; + }; + exports.getSymbolTotalCodewords = function getSymbolTotalCodewords(version) { + return CODEWORDS_COUNT[version]; + }; + exports.getBCHDigit = function(data) { + let digit = 0; + while (data !== 0) { + digit++; + data >>>= 1; + } + return digit; + }; + exports.setToSJISFunction = function setToSJISFunction(f) { + if (typeof f !== "function") { + throw new Error('"toSJISFunc" is not a valid function.'); + } + toSJISFunction = f; + }; + exports.isKanjiModeEnabled = function() { + return typeof toSJISFunction !== "undefined"; + }; + exports.toSJIS = function toSJIS(kanji) { + return toSJISFunction(kanji); + }; + } +}); + +// node_modules/qrcode/lib/core/error-correction-level.js +var require_error_correction_level = __commonJS({ + "node_modules/qrcode/lib/core/error-correction-level.js"(exports) { + exports.L = { bit: 1 }; + exports.M = { bit: 0 }; + exports.Q = { bit: 3 }; + exports.H = { bit: 2 }; + function fromString(string) { + if (typeof string !== "string") { + throw new Error("Param is not a string"); + } + const lcStr = string.toLowerCase(); + switch (lcStr) { + case "l": + case "low": + return exports.L; + case "m": + case "medium": + return exports.M; + case "q": + case "quartile": + return exports.Q; + case "h": + case "high": + return exports.H; + default: + throw new Error("Unknown EC Level: " + string); + } + } + exports.isValid = function isValid(level) { + return level && typeof level.bit !== "undefined" && level.bit >= 0 && level.bit < 4; + }; + exports.from = function from(value, defaultValue) { + if (exports.isValid(value)) { + return value; + } + try { + return fromString(value); + } catch (e) { + return defaultValue; + } + }; + } +}); + +// node_modules/qrcode/lib/core/bit-buffer.js +var require_bit_buffer = __commonJS({ + "node_modules/qrcode/lib/core/bit-buffer.js"(exports, module) { + function BitBuffer() { + this.buffer = []; + this.length = 0; + } + BitBuffer.prototype = { + get: function(index) { + const bufIndex = Math.floor(index / 8); + return (this.buffer[bufIndex] >>> 7 - index % 8 & 1) === 1; + }, + put: function(num, length) { + for (let i = 0; i < length; i++) { + this.putBit((num >>> length - i - 1 & 1) === 1); + } + }, + getLengthInBits: function() { + return this.length; + }, + putBit: function(bit) { + const bufIndex = Math.floor(this.length / 8); + if (this.buffer.length <= bufIndex) { + this.buffer.push(0); + } + if (bit) { + this.buffer[bufIndex] |= 128 >>> this.length % 8; + } + this.length++; + } + }; + module.exports = BitBuffer; + } +}); + +// node_modules/qrcode/lib/core/bit-matrix.js +var require_bit_matrix = __commonJS({ + "node_modules/qrcode/lib/core/bit-matrix.js"(exports, module) { + function BitMatrix(size) { + if (!size || size < 1) { + throw new Error("BitMatrix size must be defined and greater than 0"); + } + this.size = size; + this.data = new Uint8Array(size * size); + this.reservedBit = new Uint8Array(size * size); + } + BitMatrix.prototype.set = function(row, col, value, reserved) { + const index = row * this.size + col; + this.data[index] = value; + if (reserved) this.reservedBit[index] = true; + }; + BitMatrix.prototype.get = function(row, col) { + return this.data[row * this.size + col]; + }; + BitMatrix.prototype.xor = function(row, col, value) { + this.data[row * this.size + col] ^= value; + }; + BitMatrix.prototype.isReserved = function(row, col) { + return this.reservedBit[row * this.size + col]; + }; + module.exports = BitMatrix; + } +}); + +// node_modules/qrcode/lib/core/alignment-pattern.js +var require_alignment_pattern = __commonJS({ + "node_modules/qrcode/lib/core/alignment-pattern.js"(exports) { + var getSymbolSize = require_utils().getSymbolSize; + exports.getRowColCoords = function getRowColCoords(version) { + if (version === 1) return []; + const posCount = Math.floor(version / 7) + 2; + const size = getSymbolSize(version); + const intervals = size === 145 ? 26 : Math.ceil((size - 13) / (2 * posCount - 2)) * 2; + const positions = [size - 7]; + for (let i = 1; i < posCount - 1; i++) { + positions[i] = positions[i - 1] - intervals; + } + positions.push(6); + return positions.reverse(); + }; + exports.getPositions = function getPositions(version) { + const coords = []; + const pos = exports.getRowColCoords(version); + const posLength = pos.length; + for (let i = 0; i < posLength; i++) { + for (let j = 0; j < posLength; j++) { + if (i === 0 && j === 0 || // top-left + i === 0 && j === posLength - 1 || // bottom-left + i === posLength - 1 && j === 0) { + continue; + } + coords.push([pos[i], pos[j]]); + } + } + return coords; + }; + } +}); + +// node_modules/qrcode/lib/core/finder-pattern.js +var require_finder_pattern = __commonJS({ + "node_modules/qrcode/lib/core/finder-pattern.js"(exports) { + var getSymbolSize = require_utils().getSymbolSize; + var FINDER_PATTERN_SIZE = 7; + exports.getPositions = function getPositions(version) { + const size = getSymbolSize(version); + return [ + // top-left + [0, 0], + // top-right + [size - FINDER_PATTERN_SIZE, 0], + // bottom-left + [0, size - FINDER_PATTERN_SIZE] + ]; + }; + } +}); + +// node_modules/qrcode/lib/core/mask-pattern.js +var require_mask_pattern = __commonJS({ + "node_modules/qrcode/lib/core/mask-pattern.js"(exports) { + exports.Patterns = { + PATTERN000: 0, + PATTERN001: 1, + PATTERN010: 2, + PATTERN011: 3, + PATTERN100: 4, + PATTERN101: 5, + PATTERN110: 6, + PATTERN111: 7 + }; + var PenaltyScores = { + N1: 3, + N2: 3, + N3: 40, + N4: 10 + }; + exports.isValid = function isValid(mask) { + return mask != null && mask !== "" && !isNaN(mask) && mask >= 0 && mask <= 7; + }; + exports.from = function from(value) { + return exports.isValid(value) ? parseInt(value, 10) : void 0; + }; + exports.getPenaltyN1 = function getPenaltyN1(data) { + const size = data.size; + let points = 0; + let sameCountCol = 0; + let sameCountRow = 0; + let lastCol = null; + let lastRow = null; + for (let row = 0; row < size; row++) { + sameCountCol = sameCountRow = 0; + lastCol = lastRow = null; + for (let col = 0; col < size; col++) { + let module2 = data.get(row, col); + if (module2 === lastCol) { + sameCountCol++; + } else { + if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5); + lastCol = module2; + sameCountCol = 1; + } + module2 = data.get(col, row); + if (module2 === lastRow) { + sameCountRow++; + } else { + if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5); + lastRow = module2; + sameCountRow = 1; + } + } + if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5); + if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5); + } + return points; + }; + exports.getPenaltyN2 = function getPenaltyN2(data) { + const size = data.size; + let points = 0; + for (let row = 0; row < size - 1; row++) { + for (let col = 0; col < size - 1; col++) { + const last = data.get(row, col) + data.get(row, col + 1) + data.get(row + 1, col) + data.get(row + 1, col + 1); + if (last === 4 || last === 0) points++; + } + } + return points * PenaltyScores.N2; + }; + exports.getPenaltyN3 = function getPenaltyN3(data) { + const size = data.size; + let points = 0; + let bitsCol = 0; + let bitsRow = 0; + for (let row = 0; row < size; row++) { + bitsCol = bitsRow = 0; + for (let col = 0; col < size; col++) { + bitsCol = bitsCol << 1 & 2047 | data.get(row, col); + if (col >= 10 && (bitsCol === 1488 || bitsCol === 93)) points++; + bitsRow = bitsRow << 1 & 2047 | data.get(col, row); + if (col >= 10 && (bitsRow === 1488 || bitsRow === 93)) points++; + } + } + return points * PenaltyScores.N3; + }; + exports.getPenaltyN4 = function getPenaltyN4(data) { + let darkCount = 0; + const modulesCount = data.data.length; + for (let i = 0; i < modulesCount; i++) darkCount += data.data[i]; + const k = Math.abs(Math.ceil(darkCount * 100 / modulesCount / 5) - 10); + return k * PenaltyScores.N4; + }; + function getMaskAt(maskPattern, i, j) { + switch (maskPattern) { + case exports.Patterns.PATTERN000: + return (i + j) % 2 === 0; + case exports.Patterns.PATTERN001: + return i % 2 === 0; + case exports.Patterns.PATTERN010: + return j % 3 === 0; + case exports.Patterns.PATTERN011: + return (i + j) % 3 === 0; + case exports.Patterns.PATTERN100: + return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 === 0; + case exports.Patterns.PATTERN101: + return i * j % 2 + i * j % 3 === 0; + case exports.Patterns.PATTERN110: + return (i * j % 2 + i * j % 3) % 2 === 0; + case exports.Patterns.PATTERN111: + return (i * j % 3 + (i + j) % 2) % 2 === 0; + default: + throw new Error("bad maskPattern:" + maskPattern); + } + } + exports.applyMask = function applyMask(pattern, data) { + const size = data.size; + for (let col = 0; col < size; col++) { + for (let row = 0; row < size; row++) { + if (data.isReserved(row, col)) continue; + data.xor(row, col, getMaskAt(pattern, row, col)); + } + } + }; + exports.getBestMask = function getBestMask(data, setupFormatFunc) { + const numPatterns = Object.keys(exports.Patterns).length; + let bestPattern = 0; + let lowerPenalty = Infinity; + for (let p = 0; p < numPatterns; p++) { + setupFormatFunc(p); + exports.applyMask(p, data); + const penalty = exports.getPenaltyN1(data) + exports.getPenaltyN2(data) + exports.getPenaltyN3(data) + exports.getPenaltyN4(data); + exports.applyMask(p, data); + if (penalty < lowerPenalty) { + lowerPenalty = penalty; + bestPattern = p; + } + } + return bestPattern; + }; + } +}); + +// node_modules/qrcode/lib/core/error-correction-code.js +var require_error_correction_code = __commonJS({ + "node_modules/qrcode/lib/core/error-correction-code.js"(exports) { + var ECLevel = require_error_correction_level(); + var EC_BLOCKS_TABLE = [ + // L M Q H + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 2, + 2, + 1, + 2, + 2, + 4, + 1, + 2, + 4, + 4, + 2, + 4, + 4, + 4, + 2, + 4, + 6, + 5, + 2, + 4, + 6, + 6, + 2, + 5, + 8, + 8, + 4, + 5, + 8, + 8, + 4, + 5, + 8, + 11, + 4, + 8, + 10, + 11, + 4, + 9, + 12, + 16, + 4, + 9, + 16, + 16, + 6, + 10, + 12, + 18, + 6, + 10, + 17, + 16, + 6, + 11, + 16, + 19, + 6, + 13, + 18, + 21, + 7, + 14, + 21, + 25, + 8, + 16, + 20, + 25, + 8, + 17, + 23, + 25, + 9, + 17, + 23, + 34, + 9, + 18, + 25, + 30, + 10, + 20, + 27, + 32, + 12, + 21, + 29, + 35, + 12, + 23, + 34, + 37, + 12, + 25, + 34, + 40, + 13, + 26, + 35, + 42, + 14, + 28, + 38, + 45, + 15, + 29, + 40, + 48, + 16, + 31, + 43, + 51, + 17, + 33, + 45, + 54, + 18, + 35, + 48, + 57, + 19, + 37, + 51, + 60, + 19, + 38, + 53, + 63, + 20, + 40, + 56, + 66, + 21, + 43, + 59, + 70, + 22, + 45, + 62, + 74, + 24, + 47, + 65, + 77, + 25, + 49, + 68, + 81 + ]; + var EC_CODEWORDS_TABLE = [ + // L M Q H + 7, + 10, + 13, + 17, + 10, + 16, + 22, + 28, + 15, + 26, + 36, + 44, + 20, + 36, + 52, + 64, + 26, + 48, + 72, + 88, + 36, + 64, + 96, + 112, + 40, + 72, + 108, + 130, + 48, + 88, + 132, + 156, + 60, + 110, + 160, + 192, + 72, + 130, + 192, + 224, + 80, + 150, + 224, + 264, + 96, + 176, + 260, + 308, + 104, + 198, + 288, + 352, + 120, + 216, + 320, + 384, + 132, + 240, + 360, + 432, + 144, + 280, + 408, + 480, + 168, + 308, + 448, + 532, + 180, + 338, + 504, + 588, + 196, + 364, + 546, + 650, + 224, + 416, + 600, + 700, + 224, + 442, + 644, + 750, + 252, + 476, + 690, + 816, + 270, + 504, + 750, + 900, + 300, + 560, + 810, + 960, + 312, + 588, + 870, + 1050, + 336, + 644, + 952, + 1110, + 360, + 700, + 1020, + 1200, + 390, + 728, + 1050, + 1260, + 420, + 784, + 1140, + 1350, + 450, + 812, + 1200, + 1440, + 480, + 868, + 1290, + 1530, + 510, + 924, + 1350, + 1620, + 540, + 980, + 1440, + 1710, + 570, + 1036, + 1530, + 1800, + 570, + 1064, + 1590, + 1890, + 600, + 1120, + 1680, + 1980, + 630, + 1204, + 1770, + 2100, + 660, + 1260, + 1860, + 2220, + 720, + 1316, + 1950, + 2310, + 750, + 1372, + 2040, + 2430 + ]; + exports.getBlocksCount = function getBlocksCount(version, errorCorrectionLevel) { + switch (errorCorrectionLevel) { + case ECLevel.L: + return EC_BLOCKS_TABLE[(version - 1) * 4 + 0]; + case ECLevel.M: + return EC_BLOCKS_TABLE[(version - 1) * 4 + 1]; + case ECLevel.Q: + return EC_BLOCKS_TABLE[(version - 1) * 4 + 2]; + case ECLevel.H: + return EC_BLOCKS_TABLE[(version - 1) * 4 + 3]; + default: + return void 0; + } + }; + exports.getTotalCodewordsCount = function getTotalCodewordsCount(version, errorCorrectionLevel) { + switch (errorCorrectionLevel) { + case ECLevel.L: + return EC_CODEWORDS_TABLE[(version - 1) * 4 + 0]; + case ECLevel.M: + return EC_CODEWORDS_TABLE[(version - 1) * 4 + 1]; + case ECLevel.Q: + return EC_CODEWORDS_TABLE[(version - 1) * 4 + 2]; + case ECLevel.H: + return EC_CODEWORDS_TABLE[(version - 1) * 4 + 3]; + default: + return void 0; + } + }; + } +}); + +// node_modules/qrcode/lib/core/galois-field.js +var require_galois_field = __commonJS({ + "node_modules/qrcode/lib/core/galois-field.js"(exports) { + var EXP_TABLE = new Uint8Array(512); + var LOG_TABLE = new Uint8Array(256); + (function initTables() { + let x = 1; + for (let i = 0; i < 255; i++) { + EXP_TABLE[i] = x; + LOG_TABLE[x] = i; + x <<= 1; + if (x & 256) { + x ^= 285; + } + } + for (let i = 255; i < 512; i++) { + EXP_TABLE[i] = EXP_TABLE[i - 255]; + } + })(); + exports.log = function log(n) { + if (n < 1) throw new Error("log(" + n + ")"); + return LOG_TABLE[n]; + }; + exports.exp = function exp(n) { + return EXP_TABLE[n]; + }; + exports.mul = function mul(x, y) { + if (x === 0 || y === 0) return 0; + return EXP_TABLE[LOG_TABLE[x] + LOG_TABLE[y]]; + }; + } +}); + +// node_modules/qrcode/lib/core/polynomial.js +var require_polynomial = __commonJS({ + "node_modules/qrcode/lib/core/polynomial.js"(exports) { + var GF = require_galois_field(); + exports.mul = function mul(p1, p2) { + const coeff = new Uint8Array(p1.length + p2.length - 1); + for (let i = 0; i < p1.length; i++) { + for (let j = 0; j < p2.length; j++) { + coeff[i + j] ^= GF.mul(p1[i], p2[j]); + } + } + return coeff; + }; + exports.mod = function mod(divident, divisor) { + let result = new Uint8Array(divident); + while (result.length - divisor.length >= 0) { + const coeff = result[0]; + for (let i = 0; i < divisor.length; i++) { + result[i] ^= GF.mul(divisor[i], coeff); + } + let offset = 0; + while (offset < result.length && result[offset] === 0) offset++; + result = result.slice(offset); + } + return result; + }; + exports.generateECPolynomial = function generateECPolynomial(degree) { + let poly = new Uint8Array([1]); + for (let i = 0; i < degree; i++) { + poly = exports.mul(poly, new Uint8Array([1, GF.exp(i)])); + } + return poly; + }; + } +}); + +// node_modules/qrcode/lib/core/reed-solomon-encoder.js +var require_reed_solomon_encoder = __commonJS({ + "node_modules/qrcode/lib/core/reed-solomon-encoder.js"(exports, module) { + var Polynomial = require_polynomial(); + function ReedSolomonEncoder(degree) { + this.genPoly = void 0; + this.degree = degree; + if (this.degree) this.initialize(this.degree); + } + ReedSolomonEncoder.prototype.initialize = function initialize(degree) { + this.degree = degree; + this.genPoly = Polynomial.generateECPolynomial(this.degree); + }; + ReedSolomonEncoder.prototype.encode = function encode(data) { + if (!this.genPoly) { + throw new Error("Encoder not initialized"); + } + const paddedData = new Uint8Array(data.length + this.degree); + paddedData.set(data); + const remainder = Polynomial.mod(paddedData, this.genPoly); + const start = this.degree - remainder.length; + if (start > 0) { + const buff = new Uint8Array(this.degree); + buff.set(remainder, start); + return buff; + } + return remainder; + }; + module.exports = ReedSolomonEncoder; + } +}); + +// node_modules/qrcode/lib/core/version-check.js +var require_version_check = __commonJS({ + "node_modules/qrcode/lib/core/version-check.js"(exports) { + exports.isValid = function isValid(version) { + return !isNaN(version) && version >= 1 && version <= 40; + }; + } +}); + +// node_modules/qrcode/lib/core/regex.js +var require_regex = __commonJS({ + "node_modules/qrcode/lib/core/regex.js"(exports) { + var numeric = "[0-9]+"; + var alphanumeric = "[A-Z $%*+\\-./:]+"; + var kanji = "(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+"; + kanji = kanji.replace(/u/g, "\\u"); + var byte = "(?:(?![A-Z0-9 $%*+\\-./:]|" + kanji + ")(?:.|[\r\n]))+"; + exports.KANJI = new RegExp(kanji, "g"); + exports.BYTE_KANJI = new RegExp("[^A-Z0-9 $%*+\\-./:]+", "g"); + exports.BYTE = new RegExp(byte, "g"); + exports.NUMERIC = new RegExp(numeric, "g"); + exports.ALPHANUMERIC = new RegExp(alphanumeric, "g"); + var TEST_KANJI = new RegExp("^" + kanji + "$"); + var TEST_NUMERIC = new RegExp("^" + numeric + "$"); + var TEST_ALPHANUMERIC = new RegExp("^[A-Z0-9 $%*+\\-./:]+$"); + exports.testKanji = function testKanji(str) { + return TEST_KANJI.test(str); + }; + exports.testNumeric = function testNumeric(str) { + return TEST_NUMERIC.test(str); + }; + exports.testAlphanumeric = function testAlphanumeric(str) { + return TEST_ALPHANUMERIC.test(str); + }; + } +}); + +// node_modules/qrcode/lib/core/mode.js +var require_mode = __commonJS({ + "node_modules/qrcode/lib/core/mode.js"(exports) { + var VersionCheck = require_version_check(); + var Regex = require_regex(); + exports.NUMERIC = { + id: "Numeric", + bit: 1 << 0, + ccBits: [10, 12, 14] + }; + exports.ALPHANUMERIC = { + id: "Alphanumeric", + bit: 1 << 1, + ccBits: [9, 11, 13] + }; + exports.BYTE = { + id: "Byte", + bit: 1 << 2, + ccBits: [8, 16, 16] + }; + exports.KANJI = { + id: "Kanji", + bit: 1 << 3, + ccBits: [8, 10, 12] + }; + exports.MIXED = { + bit: -1 + }; + exports.getCharCountIndicator = function getCharCountIndicator(mode, version) { + if (!mode.ccBits) throw new Error("Invalid mode: " + mode); + if (!VersionCheck.isValid(version)) { + throw new Error("Invalid version: " + version); + } + if (version >= 1 && version < 10) return mode.ccBits[0]; + else if (version < 27) return mode.ccBits[1]; + return mode.ccBits[2]; + }; + exports.getBestModeForData = function getBestModeForData(dataStr) { + if (Regex.testNumeric(dataStr)) return exports.NUMERIC; + else if (Regex.testAlphanumeric(dataStr)) return exports.ALPHANUMERIC; + else if (Regex.testKanji(dataStr)) return exports.KANJI; + else return exports.BYTE; + }; + exports.toString = function toString(mode) { + if (mode && mode.id) return mode.id; + throw new Error("Invalid mode"); + }; + exports.isValid = function isValid(mode) { + return mode && mode.bit && mode.ccBits; + }; + function fromString(string) { + if (typeof string !== "string") { + throw new Error("Param is not a string"); + } + const lcStr = string.toLowerCase(); + switch (lcStr) { + case "numeric": + return exports.NUMERIC; + case "alphanumeric": + return exports.ALPHANUMERIC; + case "kanji": + return exports.KANJI; + case "byte": + return exports.BYTE; + default: + throw new Error("Unknown mode: " + string); + } + } + exports.from = function from(value, defaultValue) { + if (exports.isValid(value)) { + return value; + } + try { + return fromString(value); + } catch (e) { + return defaultValue; + } + }; + } +}); + +// node_modules/qrcode/lib/core/version.js +var require_version = __commonJS({ + "node_modules/qrcode/lib/core/version.js"(exports) { + var Utils = require_utils(); + var ECCode = require_error_correction_code(); + var ECLevel = require_error_correction_level(); + var Mode = require_mode(); + var VersionCheck = require_version_check(); + var G18 = 1 << 12 | 1 << 11 | 1 << 10 | 1 << 9 | 1 << 8 | 1 << 5 | 1 << 2 | 1 << 0; + var G18_BCH = Utils.getBCHDigit(G18); + function getBestVersionForDataLength(mode, length, errorCorrectionLevel) { + for (let currentVersion = 1; currentVersion <= 40; currentVersion++) { + if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, mode)) { + return currentVersion; + } + } + return void 0; + } + function getReservedBitsCount(mode, version) { + return Mode.getCharCountIndicator(mode, version) + 4; + } + function getTotalBitsFromDataArray(segments, version) { + let totalBits = 0; + segments.forEach(function(data) { + const reservedBits = getReservedBitsCount(data.mode, version); + totalBits += reservedBits + data.getBitsLength(); + }); + return totalBits; + } + function getBestVersionForMixedData(segments, errorCorrectionLevel) { + for (let currentVersion = 1; currentVersion <= 40; currentVersion++) { + const length = getTotalBitsFromDataArray(segments, currentVersion); + if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, Mode.MIXED)) { + return currentVersion; + } + } + return void 0; + } + exports.from = function from(value, defaultValue) { + if (VersionCheck.isValid(value)) { + return parseInt(value, 10); + } + return defaultValue; + }; + exports.getCapacity = function getCapacity(version, errorCorrectionLevel, mode) { + if (!VersionCheck.isValid(version)) { + throw new Error("Invalid QR Code version"); + } + if (typeof mode === "undefined") mode = Mode.BYTE; + const totalCodewords = Utils.getSymbolTotalCodewords(version); + const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel); + const dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8; + if (mode === Mode.MIXED) return dataTotalCodewordsBits; + const usableBits = dataTotalCodewordsBits - getReservedBitsCount(mode, version); + switch (mode) { + case Mode.NUMERIC: + return Math.floor(usableBits / 10 * 3); + case Mode.ALPHANUMERIC: + return Math.floor(usableBits / 11 * 2); + case Mode.KANJI: + return Math.floor(usableBits / 13); + case Mode.BYTE: + default: + return Math.floor(usableBits / 8); + } + }; + exports.getBestVersionForData = function getBestVersionForData(data, errorCorrectionLevel) { + let seg; + const ecl = ECLevel.from(errorCorrectionLevel, ECLevel.M); + if (Array.isArray(data)) { + if (data.length > 1) { + return getBestVersionForMixedData(data, ecl); + } + if (data.length === 0) { + return 1; + } + seg = data[0]; + } else { + seg = data; + } + return getBestVersionForDataLength(seg.mode, seg.getLength(), ecl); + }; + exports.getEncodedBits = function getEncodedBits(version) { + if (!VersionCheck.isValid(version) || version < 7) { + throw new Error("Invalid QR Code version"); + } + let d = version << 12; + while (Utils.getBCHDigit(d) - G18_BCH >= 0) { + d ^= G18 << Utils.getBCHDigit(d) - G18_BCH; + } + return version << 12 | d; + }; + } +}); + +// node_modules/qrcode/lib/core/format-info.js +var require_format_info = __commonJS({ + "node_modules/qrcode/lib/core/format-info.js"(exports) { + var Utils = require_utils(); + var G15 = 1 << 10 | 1 << 8 | 1 << 5 | 1 << 4 | 1 << 2 | 1 << 1 | 1 << 0; + var G15_MASK = 1 << 14 | 1 << 12 | 1 << 10 | 1 << 4 | 1 << 1; + var G15_BCH = Utils.getBCHDigit(G15); + exports.getEncodedBits = function getEncodedBits(errorCorrectionLevel, mask) { + const data = errorCorrectionLevel.bit << 3 | mask; + let d = data << 10; + while (Utils.getBCHDigit(d) - G15_BCH >= 0) { + d ^= G15 << Utils.getBCHDigit(d) - G15_BCH; + } + return (data << 10 | d) ^ G15_MASK; + }; + } +}); + +// node_modules/qrcode/lib/core/numeric-data.js +var require_numeric_data = __commonJS({ + "node_modules/qrcode/lib/core/numeric-data.js"(exports, module) { + var Mode = require_mode(); + function NumericData(data) { + this.mode = Mode.NUMERIC; + this.data = data.toString(); + } + NumericData.getBitsLength = function getBitsLength(length) { + return 10 * Math.floor(length / 3) + (length % 3 ? length % 3 * 3 + 1 : 0); + }; + NumericData.prototype.getLength = function getLength() { + return this.data.length; + }; + NumericData.prototype.getBitsLength = function getBitsLength() { + return NumericData.getBitsLength(this.data.length); + }; + NumericData.prototype.write = function write(bitBuffer) { + let i, group, value; + for (i = 0; i + 3 <= this.data.length; i += 3) { + group = this.data.substr(i, 3); + value = parseInt(group, 10); + bitBuffer.put(value, 10); + } + const remainingNum = this.data.length - i; + if (remainingNum > 0) { + group = this.data.substr(i); + value = parseInt(group, 10); + bitBuffer.put(value, remainingNum * 3 + 1); + } + }; + module.exports = NumericData; + } +}); + +// node_modules/qrcode/lib/core/alphanumeric-data.js +var require_alphanumeric_data = __commonJS({ + "node_modules/qrcode/lib/core/alphanumeric-data.js"(exports, module) { + var Mode = require_mode(); + var ALPHA_NUM_CHARS = [ + "0", + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "A", + "B", + "C", + "D", + "E", + "F", + "G", + "H", + "I", + "J", + "K", + "L", + "M", + "N", + "O", + "P", + "Q", + "R", + "S", + "T", + "U", + "V", + "W", + "X", + "Y", + "Z", + " ", + "$", + "%", + "*", + "+", + "-", + ".", + "/", + ":" + ]; + function AlphanumericData(data) { + this.mode = Mode.ALPHANUMERIC; + this.data = data; + } + AlphanumericData.getBitsLength = function getBitsLength(length) { + return 11 * Math.floor(length / 2) + 6 * (length % 2); + }; + AlphanumericData.prototype.getLength = function getLength() { + return this.data.length; + }; + AlphanumericData.prototype.getBitsLength = function getBitsLength() { + return AlphanumericData.getBitsLength(this.data.length); + }; + AlphanumericData.prototype.write = function write(bitBuffer) { + let i; + for (i = 0; i + 2 <= this.data.length; i += 2) { + let value = ALPHA_NUM_CHARS.indexOf(this.data[i]) * 45; + value += ALPHA_NUM_CHARS.indexOf(this.data[i + 1]); + bitBuffer.put(value, 11); + } + if (this.data.length % 2) { + bitBuffer.put(ALPHA_NUM_CHARS.indexOf(this.data[i]), 6); + } + }; + module.exports = AlphanumericData; + } +}); + +// node_modules/qrcode/lib/core/byte-data.js +var require_byte_data = __commonJS({ + "node_modules/qrcode/lib/core/byte-data.js"(exports, module) { + var Mode = require_mode(); + function ByteData(data) { + this.mode = Mode.BYTE; + if (typeof data === "string") { + this.data = new TextEncoder().encode(data); + } else { + this.data = new Uint8Array(data); + } + } + ByteData.getBitsLength = function getBitsLength(length) { + return length * 8; + }; + ByteData.prototype.getLength = function getLength() { + return this.data.length; + }; + ByteData.prototype.getBitsLength = function getBitsLength() { + return ByteData.getBitsLength(this.data.length); + }; + ByteData.prototype.write = function(bitBuffer) { + for (let i = 0, l = this.data.length; i < l; i++) { + bitBuffer.put(this.data[i], 8); + } + }; + module.exports = ByteData; + } +}); + +// node_modules/qrcode/lib/core/kanji-data.js +var require_kanji_data = __commonJS({ + "node_modules/qrcode/lib/core/kanji-data.js"(exports, module) { + var Mode = require_mode(); + var Utils = require_utils(); + function KanjiData(data) { + this.mode = Mode.KANJI; + this.data = data; + } + KanjiData.getBitsLength = function getBitsLength(length) { + return length * 13; + }; + KanjiData.prototype.getLength = function getLength() { + return this.data.length; + }; + KanjiData.prototype.getBitsLength = function getBitsLength() { + return KanjiData.getBitsLength(this.data.length); + }; + KanjiData.prototype.write = function(bitBuffer) { + let i; + for (i = 0; i < this.data.length; i++) { + let value = Utils.toSJIS(this.data[i]); + if (value >= 33088 && value <= 40956) { + value -= 33088; + } else if (value >= 57408 && value <= 60351) { + value -= 49472; + } else { + throw new Error( + "Invalid SJIS character: " + this.data[i] + "\nMake sure your charset is UTF-8" + ); + } + value = (value >>> 8 & 255) * 192 + (value & 255); + bitBuffer.put(value, 13); + } + }; + module.exports = KanjiData; + } +}); + +// node_modules/dijkstrajs/dijkstra.js +var require_dijkstra = __commonJS({ + "node_modules/dijkstrajs/dijkstra.js"(exports, module) { + "use strict"; + var dijkstra = { + single_source_shortest_paths: function(graph, s, d) { + var predecessors = {}; + var costs = {}; + costs[s] = 0; + var open = dijkstra.PriorityQueue.make(); + open.push(s, 0); + var closest, u, v, cost_of_s_to_u, adjacent_nodes, cost_of_e, cost_of_s_to_u_plus_cost_of_e, cost_of_s_to_v, first_visit; + while (!open.empty()) { + closest = open.pop(); + u = closest.value; + cost_of_s_to_u = closest.cost; + adjacent_nodes = graph[u] || {}; + for (v in adjacent_nodes) { + if (adjacent_nodes.hasOwnProperty(v)) { + cost_of_e = adjacent_nodes[v]; + cost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e; + cost_of_s_to_v = costs[v]; + first_visit = typeof costs[v] === "undefined"; + if (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) { + costs[v] = cost_of_s_to_u_plus_cost_of_e; + open.push(v, cost_of_s_to_u_plus_cost_of_e); + predecessors[v] = u; + } + } + } + } + if (typeof d !== "undefined" && typeof costs[d] === "undefined") { + var msg = ["Could not find a path from ", s, " to ", d, "."].join(""); + throw new Error(msg); + } + return predecessors; + }, + extract_shortest_path_from_predecessor_list: function(predecessors, d) { + var nodes = []; + var u = d; + var predecessor; + while (u) { + nodes.push(u); + predecessor = predecessors[u]; + u = predecessors[u]; + } + nodes.reverse(); + return nodes; + }, + find_path: function(graph, s, d) { + var predecessors = dijkstra.single_source_shortest_paths(graph, s, d); + return dijkstra.extract_shortest_path_from_predecessor_list( + predecessors, + d + ); + }, + /** + * A very naive priority queue implementation. + */ + PriorityQueue: { + make: function(opts) { + var T = dijkstra.PriorityQueue, t = {}, key; + opts = opts || {}; + for (key in T) { + if (T.hasOwnProperty(key)) { + t[key] = T[key]; + } + } + t.queue = []; + t.sorter = opts.sorter || T.default_sorter; + return t; + }, + default_sorter: function(a, b) { + return a.cost - b.cost; + }, + /** + * Add a new item to the queue and ensure the highest priority element + * is at the front of the queue. + */ + push: function(value, cost) { + var item = { value, cost }; + this.queue.push(item); + this.queue.sort(this.sorter); + }, + /** + * Return the highest priority element in the queue. + */ + pop: function() { + return this.queue.shift(); + }, + empty: function() { + return this.queue.length === 0; + } + } + }; + if (typeof module !== "undefined") { + module.exports = dijkstra; + } + } +}); + +// node_modules/qrcode/lib/core/segments.js +var require_segments = __commonJS({ + "node_modules/qrcode/lib/core/segments.js"(exports) { + var Mode = require_mode(); + var NumericData = require_numeric_data(); + var AlphanumericData = require_alphanumeric_data(); + var ByteData = require_byte_data(); + var KanjiData = require_kanji_data(); + var Regex = require_regex(); + var Utils = require_utils(); + var dijkstra = require_dijkstra(); + function getStringByteLength(str) { + return unescape(encodeURIComponent(str)).length; + } + function getSegments(regex, mode, str) { + const segments = []; + let result; + while ((result = regex.exec(str)) !== null) { + segments.push({ + data: result[0], + index: result.index, + mode, + length: result[0].length + }); + } + return segments; + } + function getSegmentsFromString(dataStr) { + const numSegs = getSegments(Regex.NUMERIC, Mode.NUMERIC, dataStr); + const alphaNumSegs = getSegments(Regex.ALPHANUMERIC, Mode.ALPHANUMERIC, dataStr); + let byteSegs; + let kanjiSegs; + if (Utils.isKanjiModeEnabled()) { + byteSegs = getSegments(Regex.BYTE, Mode.BYTE, dataStr); + kanjiSegs = getSegments(Regex.KANJI, Mode.KANJI, dataStr); + } else { + byteSegs = getSegments(Regex.BYTE_KANJI, Mode.BYTE, dataStr); + kanjiSegs = []; + } + const segs = numSegs.concat(alphaNumSegs, byteSegs, kanjiSegs); + return segs.sort(function(s1, s2) { + return s1.index - s2.index; + }).map(function(obj) { + return { + data: obj.data, + mode: obj.mode, + length: obj.length + }; + }); + } + function getSegmentBitsLength(length, mode) { + switch (mode) { + case Mode.NUMERIC: + return NumericData.getBitsLength(length); + case Mode.ALPHANUMERIC: + return AlphanumericData.getBitsLength(length); + case Mode.KANJI: + return KanjiData.getBitsLength(length); + case Mode.BYTE: + return ByteData.getBitsLength(length); + } + } + function mergeSegments(segs) { + return segs.reduce(function(acc, curr) { + const prevSeg = acc.length - 1 >= 0 ? acc[acc.length - 1] : null; + if (prevSeg && prevSeg.mode === curr.mode) { + acc[acc.length - 1].data += curr.data; + return acc; + } + acc.push(curr); + return acc; + }, []); + } + function buildNodes(segs) { + const nodes = []; + for (let i = 0; i < segs.length; i++) { + const seg = segs[i]; + switch (seg.mode) { + case Mode.NUMERIC: + nodes.push([ + seg, + { data: seg.data, mode: Mode.ALPHANUMERIC, length: seg.length }, + { data: seg.data, mode: Mode.BYTE, length: seg.length } + ]); + break; + case Mode.ALPHANUMERIC: + nodes.push([ + seg, + { data: seg.data, mode: Mode.BYTE, length: seg.length } + ]); + break; + case Mode.KANJI: + nodes.push([ + seg, + { data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) } + ]); + break; + case Mode.BYTE: + nodes.push([ + { data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) } + ]); + } + } + return nodes; + } + function buildGraph(nodes, version) { + const table = {}; + const graph = { start: {} }; + let prevNodeIds = ["start"]; + for (let i = 0; i < nodes.length; i++) { + const nodeGroup = nodes[i]; + const currentNodeIds = []; + for (let j = 0; j < nodeGroup.length; j++) { + const node = nodeGroup[j]; + const key = "" + i + j; + currentNodeIds.push(key); + table[key] = { node, lastCount: 0 }; + graph[key] = {}; + for (let n = 0; n < prevNodeIds.length; n++) { + const prevNodeId = prevNodeIds[n]; + if (table[prevNodeId] && table[prevNodeId].node.mode === node.mode) { + graph[prevNodeId][key] = getSegmentBitsLength(table[prevNodeId].lastCount + node.length, node.mode) - getSegmentBitsLength(table[prevNodeId].lastCount, node.mode); + table[prevNodeId].lastCount += node.length; + } else { + if (table[prevNodeId]) table[prevNodeId].lastCount = node.length; + graph[prevNodeId][key] = getSegmentBitsLength(node.length, node.mode) + 4 + Mode.getCharCountIndicator(node.mode, version); + } + } + } + prevNodeIds = currentNodeIds; + } + for (let n = 0; n < prevNodeIds.length; n++) { + graph[prevNodeIds[n]].end = 0; + } + return { map: graph, table }; + } + function buildSingleSegment(data, modesHint) { + let mode; + const bestMode = Mode.getBestModeForData(data); + mode = Mode.from(modesHint, bestMode); + if (mode !== Mode.BYTE && mode.bit < bestMode.bit) { + throw new Error('"' + data + '" cannot be encoded with mode ' + Mode.toString(mode) + ".\n Suggested mode is: " + Mode.toString(bestMode)); + } + if (mode === Mode.KANJI && !Utils.isKanjiModeEnabled()) { + mode = Mode.BYTE; + } + switch (mode) { + case Mode.NUMERIC: + return new NumericData(data); + case Mode.ALPHANUMERIC: + return new AlphanumericData(data); + case Mode.KANJI: + return new KanjiData(data); + case Mode.BYTE: + return new ByteData(data); + } + } + exports.fromArray = function fromArray(array) { + return array.reduce(function(acc, seg) { + if (typeof seg === "string") { + acc.push(buildSingleSegment(seg, null)); + } else if (seg.data) { + acc.push(buildSingleSegment(seg.data, seg.mode)); + } + return acc; + }, []); + }; + exports.fromString = function fromString(data, version) { + const segs = getSegmentsFromString(data, Utils.isKanjiModeEnabled()); + const nodes = buildNodes(segs); + const graph = buildGraph(nodes, version); + const path = dijkstra.find_path(graph.map, "start", "end"); + const optimizedSegs = []; + for (let i = 1; i < path.length - 1; i++) { + optimizedSegs.push(graph.table[path[i]].node); + } + return exports.fromArray(mergeSegments(optimizedSegs)); + }; + exports.rawSplit = function rawSplit(data) { + return exports.fromArray( + getSegmentsFromString(data, Utils.isKanjiModeEnabled()) + ); + }; + } +}); + +// node_modules/qrcode/lib/core/qrcode.js +var require_qrcode = __commonJS({ + "node_modules/qrcode/lib/core/qrcode.js"(exports) { + var Utils = require_utils(); + var ECLevel = require_error_correction_level(); + var BitBuffer = require_bit_buffer(); + var BitMatrix = require_bit_matrix(); + var AlignmentPattern = require_alignment_pattern(); + var FinderPattern = require_finder_pattern(); + var MaskPattern = require_mask_pattern(); + var ECCode = require_error_correction_code(); + var ReedSolomonEncoder = require_reed_solomon_encoder(); + var Version = require_version(); + var FormatInfo = require_format_info(); + var Mode = require_mode(); + var Segments = require_segments(); + function setupFinderPattern(matrix, version) { + const size = matrix.size; + const pos = FinderPattern.getPositions(version); + for (let i = 0; i < pos.length; i++) { + const row = pos[i][0]; + const col = pos[i][1]; + for (let r = -1; r <= 7; r++) { + if (row + r <= -1 || size <= row + r) continue; + for (let c = -1; c <= 7; c++) { + if (col + c <= -1 || size <= col + c) continue; + if (r >= 0 && r <= 6 && (c === 0 || c === 6) || c >= 0 && c <= 6 && (r === 0 || r === 6) || r >= 2 && r <= 4 && c >= 2 && c <= 4) { + matrix.set(row + r, col + c, true, true); + } else { + matrix.set(row + r, col + c, false, true); + } + } + } + } + } + function setupTimingPattern(matrix) { + const size = matrix.size; + for (let r = 8; r < size - 8; r++) { + const value = r % 2 === 0; + matrix.set(r, 6, value, true); + matrix.set(6, r, value, true); + } + } + function setupAlignmentPattern(matrix, version) { + const pos = AlignmentPattern.getPositions(version); + for (let i = 0; i < pos.length; i++) { + const row = pos[i][0]; + const col = pos[i][1]; + for (let r = -2; r <= 2; r++) { + for (let c = -2; c <= 2; c++) { + if (r === -2 || r === 2 || c === -2 || c === 2 || r === 0 && c === 0) { + matrix.set(row + r, col + c, true, true); + } else { + matrix.set(row + r, col + c, false, true); + } + } + } + } + } + function setupVersionInfo(matrix, version) { + const size = matrix.size; + const bits = Version.getEncodedBits(version); + let row, col, mod; + for (let i = 0; i < 18; i++) { + row = Math.floor(i / 3); + col = i % 3 + size - 8 - 3; + mod = (bits >> i & 1) === 1; + matrix.set(row, col, mod, true); + matrix.set(col, row, mod, true); + } + } + function setupFormatInfo(matrix, errorCorrectionLevel, maskPattern) { + const size = matrix.size; + const bits = FormatInfo.getEncodedBits(errorCorrectionLevel, maskPattern); + let i, mod; + for (i = 0; i < 15; i++) { + mod = (bits >> i & 1) === 1; + if (i < 6) { + matrix.set(i, 8, mod, true); + } else if (i < 8) { + matrix.set(i + 1, 8, mod, true); + } else { + matrix.set(size - 15 + i, 8, mod, true); + } + if (i < 8) { + matrix.set(8, size - i - 1, mod, true); + } else if (i < 9) { + matrix.set(8, 15 - i - 1 + 1, mod, true); + } else { + matrix.set(8, 15 - i - 1, mod, true); + } + } + matrix.set(size - 8, 8, 1, true); + } + function setupData(matrix, data) { + const size = matrix.size; + let inc = -1; + let row = size - 1; + let bitIndex = 7; + let byteIndex = 0; + for (let col = size - 1; col > 0; col -= 2) { + if (col === 6) col--; + while (true) { + for (let c = 0; c < 2; c++) { + if (!matrix.isReserved(row, col - c)) { + let dark = false; + if (byteIndex < data.length) { + dark = (data[byteIndex] >>> bitIndex & 1) === 1; + } + matrix.set(row, col - c, dark); + bitIndex--; + if (bitIndex === -1) { + byteIndex++; + bitIndex = 7; + } + } + } + row += inc; + if (row < 0 || size <= row) { + row -= inc; + inc = -inc; + break; + } + } + } + } + function createData(version, errorCorrectionLevel, segments) { + const buffer = new BitBuffer(); + segments.forEach(function(data) { + buffer.put(data.mode.bit, 4); + buffer.put(data.getLength(), Mode.getCharCountIndicator(data.mode, version)); + data.write(buffer); + }); + const totalCodewords = Utils.getSymbolTotalCodewords(version); + const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel); + const dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8; + if (buffer.getLengthInBits() + 4 <= dataTotalCodewordsBits) { + buffer.put(0, 4); + } + while (buffer.getLengthInBits() % 8 !== 0) { + buffer.putBit(0); + } + const remainingByte = (dataTotalCodewordsBits - buffer.getLengthInBits()) / 8; + for (let i = 0; i < remainingByte; i++) { + buffer.put(i % 2 ? 17 : 236, 8); + } + return createCodewords(buffer, version, errorCorrectionLevel); + } + function createCodewords(bitBuffer, version, errorCorrectionLevel) { + const totalCodewords = Utils.getSymbolTotalCodewords(version); + const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel); + const dataTotalCodewords = totalCodewords - ecTotalCodewords; + const ecTotalBlocks = ECCode.getBlocksCount(version, errorCorrectionLevel); + const blocksInGroup2 = totalCodewords % ecTotalBlocks; + const blocksInGroup1 = ecTotalBlocks - blocksInGroup2; + const totalCodewordsInGroup1 = Math.floor(totalCodewords / ecTotalBlocks); + const dataCodewordsInGroup1 = Math.floor(dataTotalCodewords / ecTotalBlocks); + const dataCodewordsInGroup2 = dataCodewordsInGroup1 + 1; + const ecCount = totalCodewordsInGroup1 - dataCodewordsInGroup1; + const rs = new ReedSolomonEncoder(ecCount); + let offset = 0; + const dcData = new Array(ecTotalBlocks); + const ecData = new Array(ecTotalBlocks); + let maxDataSize = 0; + const buffer = new Uint8Array(bitBuffer.buffer); + for (let b = 0; b < ecTotalBlocks; b++) { + const dataSize = b < blocksInGroup1 ? dataCodewordsInGroup1 : dataCodewordsInGroup2; + dcData[b] = buffer.slice(offset, offset + dataSize); + ecData[b] = rs.encode(dcData[b]); + offset += dataSize; + maxDataSize = Math.max(maxDataSize, dataSize); + } + const data = new Uint8Array(totalCodewords); + let index = 0; + let i, r; + for (i = 0; i < maxDataSize; i++) { + for (r = 0; r < ecTotalBlocks; r++) { + if (i < dcData[r].length) { + data[index++] = dcData[r][i]; + } + } + } + for (i = 0; i < ecCount; i++) { + for (r = 0; r < ecTotalBlocks; r++) { + data[index++] = ecData[r][i]; + } + } + return data; + } + function createSymbol(data, version, errorCorrectionLevel, maskPattern) { + let segments; + if (Array.isArray(data)) { + segments = Segments.fromArray(data); + } else if (typeof data === "string") { + let estimatedVersion = version; + if (!estimatedVersion) { + const rawSegments = Segments.rawSplit(data); + estimatedVersion = Version.getBestVersionForData(rawSegments, errorCorrectionLevel); + } + segments = Segments.fromString(data, estimatedVersion || 40); + } else { + throw new Error("Invalid data"); + } + const bestVersion = Version.getBestVersionForData(segments, errorCorrectionLevel); + if (!bestVersion) { + throw new Error("The amount of data is too big to be stored in a QR Code"); + } + if (!version) { + version = bestVersion; + } else if (version < bestVersion) { + throw new Error( + "\nThe chosen QR Code version cannot contain this amount of data.\nMinimum version required to store current data is: " + bestVersion + ".\n" + ); + } + const dataBits = createData(version, errorCorrectionLevel, segments); + const moduleCount = Utils.getSymbolSize(version); + const modules = new BitMatrix(moduleCount); + setupFinderPattern(modules, version); + setupTimingPattern(modules); + setupAlignmentPattern(modules, version); + setupFormatInfo(modules, errorCorrectionLevel, 0); + if (version >= 7) { + setupVersionInfo(modules, version); + } + setupData(modules, dataBits); + if (isNaN(maskPattern)) { + maskPattern = MaskPattern.getBestMask( + modules, + setupFormatInfo.bind(null, modules, errorCorrectionLevel) + ); + } + MaskPattern.applyMask(maskPattern, modules); + setupFormatInfo(modules, errorCorrectionLevel, maskPattern); + return { + modules, + version, + errorCorrectionLevel, + maskPattern, + segments + }; + } + exports.create = function create(data, options) { + if (typeof data === "undefined" || data === "") { + throw new Error("No input text"); + } + let errorCorrectionLevel = ECLevel.M; + let version; + let mask; + if (typeof options !== "undefined") { + errorCorrectionLevel = ECLevel.from(options.errorCorrectionLevel, ECLevel.M); + version = Version.from(options.version); + mask = MaskPattern.from(options.maskPattern); + if (options.toSJISFunc) { + Utils.setToSJISFunction(options.toSJISFunc); + } + } + return createSymbol(data, version, errorCorrectionLevel, mask); + }; + } +}); + +// node_modules/qrcode/lib/renderer/utils.js +var require_utils2 = __commonJS({ + "node_modules/qrcode/lib/renderer/utils.js"(exports) { + function hex2rgba(hex) { + if (typeof hex === "number") { + hex = hex.toString(); + } + if (typeof hex !== "string") { + throw new Error("Color should be defined as hex string"); + } + let hexCode = hex.slice().replace("#", "").split(""); + if (hexCode.length < 3 || hexCode.length === 5 || hexCode.length > 8) { + throw new Error("Invalid hex color: " + hex); + } + if (hexCode.length === 3 || hexCode.length === 4) { + hexCode = Array.prototype.concat.apply([], hexCode.map(function(c) { + return [c, c]; + })); + } + if (hexCode.length === 6) hexCode.push("F", "F"); + const hexValue = parseInt(hexCode.join(""), 16); + return { + r: hexValue >> 24 & 255, + g: hexValue >> 16 & 255, + b: hexValue >> 8 & 255, + a: hexValue & 255, + hex: "#" + hexCode.slice(0, 6).join("") + }; + } + exports.getOptions = function getOptions(options) { + if (!options) options = {}; + if (!options.color) options.color = {}; + const margin = typeof options.margin === "undefined" || options.margin === null || options.margin < 0 ? 4 : options.margin; + const width = options.width && options.width >= 21 ? options.width : void 0; + const scale = options.scale || 4; + return { + width, + scale: width ? 4 : scale, + margin, + color: { + dark: hex2rgba(options.color.dark || "#000000ff"), + light: hex2rgba(options.color.light || "#ffffffff") + }, + type: options.type, + rendererOpts: options.rendererOpts || {} + }; + }; + exports.getScale = function getScale(qrSize, opts) { + return opts.width && opts.width >= qrSize + opts.margin * 2 ? opts.width / (qrSize + opts.margin * 2) : opts.scale; + }; + exports.getImageWidth = function getImageWidth(qrSize, opts) { + const scale = exports.getScale(qrSize, opts); + return Math.floor((qrSize + opts.margin * 2) * scale); + }; + exports.qrToImageData = function qrToImageData(imgData, qr, opts) { + const size = qr.modules.size; + const data = qr.modules.data; + const scale = exports.getScale(size, opts); + const symbolSize = Math.floor((size + opts.margin * 2) * scale); + const scaledMargin = opts.margin * scale; + const palette = [opts.color.light, opts.color.dark]; + for (let i = 0; i < symbolSize; i++) { + for (let j = 0; j < symbolSize; j++) { + let posDst = (i * symbolSize + j) * 4; + let pxColor = opts.color.light; + if (i >= scaledMargin && j >= scaledMargin && i < symbolSize - scaledMargin && j < symbolSize - scaledMargin) { + const iSrc = Math.floor((i - scaledMargin) / scale); + const jSrc = Math.floor((j - scaledMargin) / scale); + pxColor = palette[data[iSrc * size + jSrc] ? 1 : 0]; + } + imgData[posDst++] = pxColor.r; + imgData[posDst++] = pxColor.g; + imgData[posDst++] = pxColor.b; + imgData[posDst] = pxColor.a; + } + } + }; + } +}); + +// node_modules/qrcode/lib/renderer/canvas.js +var require_canvas = __commonJS({ + "node_modules/qrcode/lib/renderer/canvas.js"(exports) { + var Utils = require_utils2(); + function clearCanvas(ctx, canvas, size) { + ctx.clearRect(0, 0, canvas.width, canvas.height); + if (!canvas.style) canvas.style = {}; + canvas.height = size; + canvas.width = size; + canvas.style.height = size + "px"; + canvas.style.width = size + "px"; + } + function getCanvasElement() { + try { + return document.createElement("canvas"); + } catch (e) { + throw new Error("You need to specify a canvas element"); + } + } + exports.render = function render(qrData, canvas, options) { + let opts = options; + let canvasEl = canvas; + if (typeof opts === "undefined" && (!canvas || !canvas.getContext)) { + opts = canvas; + canvas = void 0; + } + if (!canvas) { + canvasEl = getCanvasElement(); + } + opts = Utils.getOptions(opts); + const size = Utils.getImageWidth(qrData.modules.size, opts); + const ctx = canvasEl.getContext("2d"); + const image = ctx.createImageData(size, size); + Utils.qrToImageData(image.data, qrData, opts); + clearCanvas(ctx, canvasEl, size); + ctx.putImageData(image, 0, 0); + return canvasEl; + }; + exports.renderToDataURL = function renderToDataURL(qrData, canvas, options) { + let opts = options; + if (typeof opts === "undefined" && (!canvas || !canvas.getContext)) { + opts = canvas; + canvas = void 0; + } + if (!opts) opts = {}; + const canvasEl = exports.render(qrData, canvas, opts); + const type = opts.type || "image/png"; + const rendererOpts = opts.rendererOpts || {}; + return canvasEl.toDataURL(type, rendererOpts.quality); + }; + } +}); + +// node_modules/qrcode/lib/renderer/svg-tag.js +var require_svg_tag = __commonJS({ + "node_modules/qrcode/lib/renderer/svg-tag.js"(exports) { + var Utils = require_utils2(); + function getColorAttrib(color, attrib) { + const alpha = color.a / 255; + const str = attrib + '="' + color.hex + '"'; + return alpha < 1 ? str + " " + attrib + '-opacity="' + alpha.toFixed(2).slice(1) + '"' : str; + } + function svgCmd(cmd, x, y) { + let str = cmd + x; + if (typeof y !== "undefined") str += " " + y; + return str; + } + function qrToPath(data, size, margin) { + let path = ""; + let moveBy = 0; + let newRow = false; + let lineLength = 0; + for (let i = 0; i < data.length; i++) { + const col = Math.floor(i % size); + const row = Math.floor(i / size); + if (!col && !newRow) newRow = true; + if (data[i]) { + lineLength++; + if (!(i > 0 && col > 0 && data[i - 1])) { + path += newRow ? svgCmd("M", col + margin, 0.5 + row + margin) : svgCmd("m", moveBy, 0); + moveBy = 0; + newRow = false; + } + if (!(col + 1 < size && data[i + 1])) { + path += svgCmd("h", lineLength); + lineLength = 0; + } + } else { + moveBy++; + } + } + return path; + } + exports.render = function render(qrData, options, cb) { + const opts = Utils.getOptions(options); + const size = qrData.modules.size; + const data = qrData.modules.data; + const qrcodesize = size + opts.margin * 2; + const bg = !opts.color.light.a ? "" : "'; + const path = "'; + const viewBox = 'viewBox="0 0 ' + qrcodesize + " " + qrcodesize + '"'; + const width = !opts.width ? "" : 'width="' + opts.width + '" height="' + opts.width + '" '; + const svgTag = '' + bg + path + "\n"; + if (typeof cb === "function") { + cb(null, svgTag); + } + return svgTag; + }; + } +}); + +// node_modules/qrcode/lib/browser.js +var require_browser = __commonJS({ + "node_modules/qrcode/lib/browser.js"(exports) { + var canPromise = require_can_promise(); + var QRCode = require_qrcode(); + var CanvasRenderer = require_canvas(); + var SvgRenderer = require_svg_tag(); + function renderCanvas(renderFunc, canvas, text, opts, cb) { + const args = [].slice.call(arguments, 1); + const argsNum = args.length; + const isLastArgCb = typeof args[argsNum - 1] === "function"; + if (!isLastArgCb && !canPromise()) { + throw new Error("Callback required as last argument"); + } + if (isLastArgCb) { + if (argsNum < 2) { + throw new Error("Too few arguments provided"); + } + if (argsNum === 2) { + cb = text; + text = canvas; + canvas = opts = void 0; + } else if (argsNum === 3) { + if (canvas.getContext && typeof cb === "undefined") { + cb = opts; + opts = void 0; + } else { + cb = opts; + opts = text; + text = canvas; + canvas = void 0; + } + } + } else { + if (argsNum < 1) { + throw new Error("Too few arguments provided"); + } + if (argsNum === 1) { + text = canvas; + canvas = opts = void 0; + } else if (argsNum === 2 && !canvas.getContext) { + opts = text; + text = canvas; + canvas = void 0; + } + return new Promise(function(resolve, reject) { + try { + const data = QRCode.create(text, opts); + resolve(renderFunc(data, canvas, opts)); + } catch (e) { + reject(e); + } + }); + } + try { + const data = QRCode.create(text, opts); + cb(null, renderFunc(data, canvas, opts)); + } catch (e) { + cb(e); + } + } + exports.create = QRCode.create; + exports.toCanvas = renderCanvas.bind(null, CanvasRenderer.render); + exports.toDataURL = renderCanvas.bind(null, CanvasRenderer.renderToDataURL); + exports.toString = renderCanvas.bind(null, function(data, _, opts) { + return SvgRenderer.render(data, opts); + }); + } +}); +export default require_browser(); diff --git a/uniapp/common/utils/request.js b/uniapp/common/utils/request.js index 0867ba4..8969edd 100644 --- a/uniapp/common/utils/request.js +++ b/uniapp/common/utils/request.js @@ -12,7 +12,13 @@ import config from '../config/index.js' import storage from './storage.js' import { matchMock } from '../mock/index.js' -// 便于测试注入的运行时环境(默认使用全局 uni) +// 401 跳转节流标记(毫秒) +let lastLoginRedirectAt = 0 + +/** + * 便于测试注入的运行时环境(默认使用全局 uni) + * @returns {Object} 运行时环境对象 + */ export function getRuntime() { return { request: typeof uni !== 'undefined' && uni.request ? uni.request.bind(uni) : null, @@ -23,14 +29,23 @@ export function getRuntime() { } } -/** 拼接完整地址 */ +/** + * 拼接完整地址 + * @param {string} url 原始相对或绝对路径 + * @returns {string} 完整网络请求地址 + */ export function buildUrl(url) { if (/^https?:\/\//i.test(url)) return url const path = url.startsWith('/') ? url : `/${url}` return `${config.baseURL}/${config.apiVersion}${path}` } -/** 组装请求头 */ +/** + * 组装请求头 + * 同时注入 Authorization、token、X-Token,确保在任何 Nginx/Apache 代理环境下 token 都能安全穿透到后端 + * @param {Object} extra 额外的自定义请求头 + * @returns {Object} 组装后的完整 Headers + */ export function buildHeaders(extra = {}) { const token = storage.get(config.storageKeys.token, '') const headers = { @@ -38,14 +53,17 @@ export function buildHeaders(extra = {}) { 'X-Client': 'fenleixinxi', ...extra, } - if (token) headers.Authorization = `Bearer ${token}` + if (token) { + // 1. 标准 HTTP Bearer Token + headers.Authorization = `Bearer ${token}` + // 2. 兼容 FastAdmin 原生与 Nginx/Apache 反向代理(部分反向代理会丢弃 Authorization,但保留常规 Header) + headers.token = token + headers.Token = token + headers['X-Token'] = token + } return headers } -/** - * 底层请求(返回 Promise) - * @param {Object} options { url, method, data, header, silent, mock } - */ /** * 清理请求参数中 undefined / null / 空串 的无效字段 * 防止在微信小程序等环境下 GET 请求被底层错误序列化为 "key=undefined" @@ -64,6 +82,11 @@ export function cleanParams(data) { return cleaned } +/** + * 底层请求统一封装(返回 Promise) + * @param {Object} options 请求配置 { url, method, data, header, silent, mock } + * @returns {Promise} 请求结果 + */ export function request(options = {}) { const { url, @@ -95,7 +118,7 @@ export function request(options = {}) { header: headers, timeout: config.timeout, success(res) { - // HTTP 层 + // HTTP 层 401 判定 if (res.statusCode === 401) { onUnauthorized(runtime) return reject(toErr('登录已过期,请重新登录', 401)) @@ -107,6 +130,11 @@ export function request(options = {}) { ) } const body = res.data || {} + // 业务层 401 判定 + if (body.code === 401) { + onUnauthorized(runtime) + return reject(toErr(body.message || body.msg || '登录已过期,请重新登录', 401)) + } // 业务层:约定 code===0 或 code===200 为成功 if (body.code === 0 || body.code === 200) { resolve(body.data !== undefined ? body.data : body) @@ -127,6 +155,8 @@ export function request(options = {}) { * 失败处理: * 1) 若开启 mock 降级,则使用本地 mock 路由兜底(保证离线可演示) * 2) 否则抛出异常 + * @param {Object} err 错误对象 + * @param {Object} ctx 请求上下文 */ function handleFail(err, ctx) { const { url, method, data, silent, runtime, resolve, reject } = ctx @@ -146,14 +176,42 @@ function handleFail(err, ctx) { reject(e) } -/** 401 处理 */ +/** + * 401 未登录/登录失效统一处理 + * 1. 清除本地缓存的 token 与用户信息 + * 2. 3秒内节流防抖,避免并发请求时多次重复弹窗与重复跳转 + * 3. 避免当前已经在登录页时重复跳转 + * 4. 记录来源页面便于登录后无感跳回 + * @param {Object} runtime 运行时对象 + */ function onUnauthorized(runtime) { storage.remove(config.storageKeys.token) storage.remove(config.storageKeys.userInfo) - runtime.showToast({ title: '登录已过期', icon: 'none' }) - runtime.navigateTo({ url: '/pages/auth/login' }) + + const now = Date.now() + if (now - lastLoginRedirectAt < 3000) { + return + } + lastLoginRedirectAt = now + + const pages = (typeof getCurrentPages === 'function' && getCurrentPages()) || [] + const current = pages[pages.length - 1] + const rawRoute = current && (current.route || (current.$page && current.$page.route)) + const route = typeof rawRoute === 'string' ? rawRoute : '' + + if (!route || !route.includes('pages/auth/login')) { + runtime.showToast({ title: '登录已过期', icon: 'none' }) + const redirectParam = route ? `?redirect=${encodeURIComponent('/' + route)}` : '' + runtime.navigateTo({ url: `/pages/auth/login${redirectParam}` }) + } } +/** + * 创建标准化 Error 对象 + * @param {string} message 错误消息 + * @param {number} code 业务或状态码 + * @returns {Error} + */ function toErr(message, code = -1) { const e = new Error(message) e.code = code diff --git a/uniapp/components/fc-navbar/fc-navbar.vue b/uniapp/components/fc-navbar/fc-navbar.vue index eff2bdf..53f8452 100644 --- a/uniapp/components/fc-navbar/fc-navbar.vue +++ b/uniapp/components/fc-navbar/fc-navbar.vue @@ -10,8 +10,8 @@ paddingRight: capsulePadding ? (capsulePadding + 'px') : '24rpx', }" > - - + + ‹ @@ -84,26 +84,48 @@ export default { } catch (e) {} }, /** - * 点击返回上一页,若无历史页面则返回首页 + * 点击返回上一页,若无历史页面或返回失败则执行降级跳转 */ onBack() { + this.$emit('back') const pages = (typeof getCurrentPages === 'function') ? getCurrentPages() : [] if (pages && pages.length > 1) { - uni.navigateBack() - } else { - // #ifdef H5 - uni.redirectTo({ - url: '/pages/index/index', + uni.navigateBack({ + delta: 1, fail: () => { - uni.reLaunch({ url: '/pages/index/index' }) + this.fallbackNavigation() }, }) - // #endif - // #ifndef H5 - uni.reLaunch({ url: '/pages/index/index' }) - // #endif + } else { + this.fallbackNavigation() } }, + /** + * 导航失败时的降级逻辑(优先返回上一级业务列表,最后兜底首页) + */ + fallbackNavigation() { + // #ifdef H5 + uni.redirectTo({ + url: '/pages/index/index', + fail: () => { + uni.reLaunch({ url: '/pages/index/index' }) + }, + }) + // #endif + // #ifndef H5 + uni.navigateBack({ + delta: 1, + fail: () => { + uni.redirectTo({ + url: '/pages/member/orders', + fail: () => { + uni.reLaunch({ url: '/pages/index/index' }) + }, + }) + }, + }) + // #endif + }, }, } @@ -152,30 +174,31 @@ export default { width: 100%; } .fc-navbar__back { - width: 68rpx; - height: 68rpx; + width: 80rpx; + height: 100%; + min-height: 76rpx; display: flex; align-items: center; justify-content: center; flex-shrink: 0; cursor: pointer; - border-radius: 50%; position: relative; - z-index: 3; - transition: background-color 0.2s ease, transform 0.15s ease; + z-index: 10; + transition: opacity 0.15s ease, transform 0.15s ease; &:active { - transform: scale(0.9); - background-color: rgba(255, 255, 255, 0.2); + transform: scale(0.92); + opacity: 0.75; } } .fc-navbar--white .fc-navbar__back:active { - background-color: rgba(0, 0, 0, 0.06); + opacity: 0.7; } .fc-navbar__back-icon { - font-size: 52rpx; + font-size: 54rpx; line-height: 1; - font-weight: 300; + font-weight: 400; margin-top: -6rpx; + pointer-events: none; } .fc-navbar__title { flex: 1; @@ -190,8 +213,8 @@ export default { &--center { position: absolute; - left: 0; - right: 0; + left: 80rpx; + right: 80rpx; top: 0; bottom: 0; display: flex; @@ -199,7 +222,7 @@ export default { justify-content: center; text-align: center; pointer-events: none; - padding: 0 160rpx; + padding: 0 80rpx; box-sizing: border-box; z-index: 1; } diff --git a/uniapp/manifest.json b/uniapp/manifest.json index 21262e8..69b91da 100644 --- a/uniapp/manifest.json +++ b/uniapp/manifest.json @@ -1,6 +1,6 @@ { "name" : "fenleixinxi", - "appid" : "__UNI__4F5F344", + "appid" : "__UNI__CFFF983", "description" : "", "versionName" : "1.1.0", "versionCode" : "110", diff --git a/uniapp/pages.json b/uniapp/pages.json index ae7d49c..3aaa264 100644 --- a/uniapp/pages.json +++ b/uniapp/pages.json @@ -25,7 +25,7 @@ "backgroundColor": "#f2fef7" } }, - { + { "path": "pages/post/drafts", "style": { "navigationBarTitleText": "草稿箱", @@ -33,7 +33,7 @@ "backgroundColor": "#f2fef7" } }, -{ + { "path": "pages/post/mine", "style": { "navigationBarTitleText": "我的发布", @@ -170,6 +170,14 @@ "navigationStyle": "custom", "backgroundColor": "#f2fef7" } + }, + { + "path": "pages/order/detail", + "style": { + "navigationBarTitleText": "订单详情", + "navigationStyle": "custom", + "backgroundColor": "#f2fef7" + } } ], "globalStyle": { diff --git a/uniapp/pages/auth/login.vue b/uniapp/pages/auth/login.vue index ed5d824..747758a 100644 --- a/uniapp/pages/auth/login.vue +++ b/uniapp/pages/auth/login.vue @@ -105,6 +105,7 @@ export default { return { loading: false, agreed: false, // 协议勾选状态 + redirectUrl: '', // 登录成功后回跳地址 h5Form: { phone: '', password: '', @@ -122,8 +123,16 @@ export default { }, /** * 页面加载 + * @param {Object} query 路由参数(支持携带 redirect 回跳地址) */ - onLoad() { + onLoad(query) { + if (query && query.redirect) { + try { + this.redirectUrl = decodeURIComponent(query.redirect) + } catch (e) { + this.redirectUrl = query.redirect + } + } loadUiConfig() }, methods: { @@ -224,7 +233,10 @@ export default { code: wxCode, phoneCode, }) - await store.fetchProfile() + // 静默容错:login 返回时已持久化保存 token 与 userInfo,避免二次刷新因网络偶发抖动阻塞跳转 + try { + await store.fetchProfile() + } catch (e) {} uni.showToast({ title: '登录成功', icon: 'success' }) setTimeout(() => { @@ -286,14 +298,36 @@ export default { }, /** * 登录成功后智能跳转 + * 1. 优先回跳至 redirect 指定的目标页面 + * 2. 检查页面历史栈,杜绝退回上一页依然是登录页(pages/auth/login)的死循环 + * 3. 兜底重定向至个人中心 */ redirectAfterLogin() { - const pages = (typeof getCurrentPages === 'function') ? getCurrentPages() : [] - if (pages && pages.length > 1) { - uni.navigateBack() - } else { - uni.reLaunch({ url: '/pages/mine/index' }) + // 1. 若携带了合法的来源页面,重定向回目标页 + if (this.redirectUrl && !this.redirectUrl.includes('pages/auth/login')) { + uni.redirectTo({ + url: this.redirectUrl, + fail: () => { + uni.reLaunch({ url: this.redirectUrl }) + }, + }) + return } + + // 2. 检查页面栈 + const pages = typeof getCurrentPages === 'function' ? getCurrentPages() : [] + if (pages && pages.length > 1) { + const prevPage = pages[pages.length - 2] + const prevRoute = prevPage && (prevPage.route || (prevPage.$page && prevPage.$page.route) || '') + // 上一页必须不是登录页才执行 navigateBack + if (prevRoute && !prevRoute.includes('pages/auth/login')) { + uni.navigateBack() + return + } + } + + // 3. 兜底安全重启至个人中心 + uni.reLaunch({ url: '/pages/mine/index' }) }, }, } diff --git a/uniapp/pages/category/channel.vue b/uniapp/pages/category/channel.vue index d326679..ce594fe 100644 --- a/uniapp/pages/category/channel.vue +++ b/uniapp/pages/category/channel.vue @@ -103,11 +103,15 @@ export default { return !!this.fixedCategoryId }, }, + /** + * 页面加载:读取分类入参并彻底防止 URL 编码乱码 + * @param {Object} query 路由参数 + */ onLoad(query) { this.categoryId = Number(query.categoryId || 0) this.fixedCategoryId = Number(query.categoryId || 0) if (query.name) { - const decoded = decodeURIComponent(query.name) + const decoded = this.safeDecode(query.name) this.pageTitle = decoded uni.setNavigationBarTitle({ title: decoded }) } @@ -121,6 +125,22 @@ export default { iconUrl, categoryIconUrl, catIcon, + /** + * 彻底安全解码 URL 参数(防一层、二层及多层 URL 编码导致的 %E6%95%... 乱码) + * @param {string} str 待解码的字符串 + * @returns {string} 解码后的文本 + */ + safeDecode(str) { + let res = String(str || '').trim() + try { + while (/%[0-9a-fA-F]{2}/.test(res)) { + const next = decodeURIComponent(res) + if (next === res) break + res = next + } + } catch (e) {} + return res + }, /** * 页面初始化:拉取分类与区域筛选项,并执行首次信息流拉取 */ @@ -130,12 +150,12 @@ export default { try { this.categories = await homeApi.categories() } catch (e) {} - } else if (!this.pageTitle) { - // 若未传分类名,则通过接口查到名称补齐导航栏标题 + } else { + // 若未传分类名或标题仍残留编码字符,通过接口查到名称补齐/修正导航栏标题 try { const cats = await homeApi.categories() const current = (cats || []).find((c) => Number(c.id) === Number(this.categoryId)) - if (current) { + if (current && (!this.pageTitle || /%[0-9a-fA-F]{2}/.test(this.pageTitle))) { this.pageTitle = current.name uni.setNavigationBarTitle({ title: current.name }) } diff --git a/uniapp/pages/detail/detail.vue b/uniapp/pages/detail/detail.vue index 4688ac1..442d6d0 100644 --- a/uniapp/pages/detail/detail.vue +++ b/uniapp/pages/detail/detail.vue @@ -1,213 +1,433 @@