userList.blade.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. @extends('admin.layouts')
  2. @section('css')
  3. <link href="/assets/global/vendor/bootstrap-table/bootstrap-table.min.css" type="text/css" rel="stylesheet">
  4. <link href="/assets/custom/range.min.css" type="text/css" rel="stylesheet">
  5. @endsection
  6. @section('content')
  7. <div class="page-content container-fluid">
  8. <div class="panel">
  9. <div class="panel-heading">
  10. <h2 class="panel-title">用户列表</h2>
  11. <div class="panel-actions">
  12. <button class="btn btn-outline-default" onclick="exportSSJson()">
  13. <i class="icon wb-download" aria-hidden="true"></i>导出JSON
  14. </button>
  15. <button class="btn btn-outline-default" onclick="batchAddUsers()">
  16. <i class="icon wb-plus" aria-hidden="true"></i>批量生成
  17. </button>
  18. <a href="/admin/addUser" class="btn btn-outline-default">
  19. <i class="icon wb-user-add" aria-hidden="true"></i>添加用户
  20. </a>
  21. </div>
  22. </div>
  23. <div class="panel-body">
  24. <div class="form-row">
  25. <div class="form-group col-xxl-1 col-lg-1 col-md-1 col-sm-4">
  26. <input type="number" class="form-control" id="id" name="id" value="{{Request::get('id')}}" placeholder="ID"/>
  27. </div>
  28. <div class="form-group col-xxl-2 col-lg-3 col-md-3 col-sm-4">
  29. <input type="text" class="form-control" id="email" name="email" value="{{Request::get('email')}}" placeholder="用户名"/>
  30. </div>
  31. <div class="form-group col-xxl-2 col-lg-3 col-md-3 col-sm-4">
  32. <input type="text" class="form-control" id="wechat" name="wechat" value="{{Request::get('wechat')}}" placeholder="微信"/>
  33. </div>
  34. <div class="form-group col-xxl-2 col-lg-3 col-md-3 col-sm-4">
  35. <input type="number" class="form-control" id="qq" name="qq" value="{{Request::get('qq')}}" placeholder="QQ"/>
  36. </div>
  37. <div class="form-group col-xxl-1 col-lg-2 col-md-2 col-sm-4">
  38. <input type="number" class="form-control" id="port" name="port" value="{{Request::get('port')}}" placeholder="端口"/>
  39. </div>
  40. <div class="form-group col-xxl-1 col-lg-3 col-md-3 col-sm-4">
  41. <select class="form-control" id="pay_way" name="pay_way" onChange="Search()">
  42. <option value="" @if(Request::get('pay_way') == '') selected hidden @endif>付费方式</option>
  43. <option value="0" @if(Request::get('pay_way') == '0') selected hidden @endif>免费</option>
  44. <option value="1" @if(Request::get('pay_way') == '1') selected hidden @endif>月付</option>
  45. <option value="2" @if(Request::get('pay_way') == '2') selected hidden @endif>季付</option>
  46. <option value="3" @if(Request::get('pay_way') == '3') selected hidden @endif>半年付</option>
  47. <option value="4" @if(Request::get('pay_way') == '4') selected hidden @endif>年付</option>
  48. </select>
  49. </div>
  50. <div class="form-group col-xxl-1 col-lg-3 col-md-3 col-4">
  51. <select class="form-control" id="status" name="status" onChange="Search()">
  52. <option value="" @if(Request::get('status') == '') selected hidden @endif>账号状态</option>
  53. <option value="-1" @if(Request::get('status') == '-1') selected hidden @endif>禁用</option>
  54. <option value="0" @if(Request::get('status') == '0') selected hidden @endif>未激活</option>
  55. <option value="1" @if(Request::get('status') == '1') selected hidden @endif>正常</option>
  56. </select>
  57. </div>
  58. <div class="form-group col-xxl-1 col-lg-3 col-md-3 col-4">
  59. <select class="form-control" id="enable" name="enable" onChange="Search()">
  60. <option value="" @if(Request::get('enable') == '') selected hidden @endif>代理状态</option>
  61. <option value="1" @if(Request::get('enable') == '1') selected hidden @endif>启用</option>
  62. <option value="0" @if(Request::get('enable') == '0') selected hidden @endif>禁用</option>
  63. </select>
  64. </div>
  65. <div class="form-group col-xxl-1 col-lg-3 col-md-3 col-4 btn-group">
  66. <button class="btn btn-primary" onclick="Search()">搜 索</button>
  67. <a href="/admin/userList" class="btn btn-danger">重 置</a>
  68. </div>
  69. </div>
  70. <table class="text-md-center" data-toggle="table" data-mobile-responsive="true">
  71. <thead class="thead-default">
  72. <tr>
  73. <th> #</th>
  74. <th> 用户名</th>
  75. <th> 余额</th>
  76. <th> 端口</th>
  77. <th> 订阅码</th>
  78. <th> 流量使用</th>
  79. <th> 最后使用</th>
  80. <th> 有效期</th>
  81. <th> 状态</th>
  82. <th> 代理</th>
  83. <th> 操作</th>
  84. </tr>
  85. </thead>
  86. <tbody>
  87. @if ($userList->isEmpty())
  88. <tr>
  89. <td colspan="11">暂无数据</td>
  90. </tr>
  91. @else
  92. @foreach ($userList as $user)
  93. <tr class="{{$user->trafficWarning ? ' table-danger' : ''}}">
  94. <td> {{$user->id}} </td>
  95. <td> {{$user->email}} </td>
  96. <td> {{$user->balance}} </td>
  97. <td>
  98. {!!$user->port? : '<span class="badge badge-lg badge-danger"> 未分配 </span>'!!}
  99. </td>
  100. <td>
  101. <a href="javascript:" class="copySubscribeLink" data-clipboard-action="copy" data-clipboard-text="{{$user->link}}">{{$user->subscribe->code}}</a>
  102. </td>
  103. <td> {{$user->used_flow}} / {{$user->transfer_enable}} </td>
  104. <td> {{$user->t? date('Y-m-d H:i', $user->t): '未使用'}} </td>
  105. <td>
  106. @if ($user->expireWarning == '-1')
  107. <span class="badge badge-lg badge-danger"> {{$user->expire_time}} </span>
  108. @elseif ($user->expireWarning == '0')
  109. <span class="badge badge-lg badge-warning"> {{$user->expire_time}} </span>
  110. @elseif ($user->expireWarning == '1')
  111. <span class="badge badge-lg badge-default"> {{$user->expire_time}} </span>
  112. @else
  113. {{$user->expire_time}}
  114. @endif
  115. </td>
  116. <td>
  117. @if ($user->status > 0)
  118. <span class="badge badge-lg badge-primary"><i class="wb-check" aria-hidden="true"></i></span>
  119. @elseif ($user->status < 0)
  120. <span class="badge badge-lg badge-danger"><i class="wb-close" aria-hidden="true"></i></span>
  121. @else
  122. <span class="badge badge-lg badge-default"><i class="wb-minus" aria-hidden="true"></i></span>
  123. @endif
  124. </td>
  125. <td>
  126. <span class="badge badge-lg badge-{{$user->enable?'info':'danger'}}"><i class="wb-{{$user->enable?'check':'close'}}" aria-hidden="true"></i></span>
  127. </td>
  128. <td>
  129. <div class="btn-group">
  130. <a href="/admin/editUser/{{$user->id}}{{Request::getQueryString()? '?'.Request::getQueryString() : ''}}" class="btn btn-primary"><i class="icon wb-edit" aria-hidden="true"></i></a>
  131. <a href="javascript:delUser('{{$user->id}}','{{$user->email}}');" class="btn btn-danger"><i class="icon wb-trash" aria-hidden="true"></i></a>
  132. <a href="/admin/export/{{$user->id}}" class="btn btn-primary"><i class="icon wb-code" aria-hidden="true"></i></a>
  133. <a href="/admin/userMonitor/{{$user->id}}" class="btn btn-primary"><i class="icon wb-stats-bars" aria-hidden="true"></i></a>
  134. <a href="/admin/onlineIPMonitor?id={{$user->id}}" class="btn btn-primary"><i class="icon wb-cloud" aria-hidden="true"></i></a>
  135. <a href="javascript:resetTraffic('{{$user->id}}','{{$user->email}}');" class="btn btn-primary"><i class="icon wb-reload" aria-hidden="true"></i></a>
  136. <a href="javascript:switchToUser('{{$user->id}}');" class="btn btn-primary"><i class="icon wb-user" aria-hidden="true"></i></a>
  137. </div>
  138. </td>
  139. </tr>
  140. @endforeach
  141. @endif
  142. </tbody>
  143. </table>
  144. </div>
  145. <div class="panel-footer">
  146. <div class="row">
  147. <div class="col-sm-4">
  148. 共 <code>{{$userList->total()}}</code> 个账号
  149. </div>
  150. <div class="col-sm-8">
  151. <nav class="Page navigation float-right">
  152. {{$userList->links()}}
  153. </nav>
  154. </div>
  155. </div>
  156. </div>
  157. </div>
  158. </div>
  159. @endsection
  160. @section('script')
  161. <script src="/assets/global/vendor/bootstrap-table/bootstrap-table.min.js" type="text/javascript"></script>
  162. <script src="/assets/global/vendor/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js" type="text/javascript"></script>
  163. <script src="/assets/custom/Plugin/clipboardjs/clipboard.min.js" type="text/javascript"></script>
  164. <script type="text/javascript">
  165. // 导出原版json配置
  166. function exportSSJson() {
  167. swal.fire({
  168. title: '导出成功',
  169. text: '成功导出原版SS的用户配置信息,加密方式为系统默认的加密方式',
  170. type: 'success',
  171. timer: 1300,
  172. showConfirmButton: false,
  173. }).then(() => window.location.href = '/admin/exportSSJson')
  174. }
  175. // 批量生成账号
  176. function batchAddUsers() {
  177. swal.fire({
  178. title: '用户生成数量',
  179. input: 'range',
  180. inputAttributes: {
  181. min: 1,
  182. max: 10,
  183. },
  184. inputValue: 1,
  185. type: 'question',
  186. showCancelButton: true,
  187. cancelButtonText: '{{trans('home.ticket_close')}}',
  188. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  189. }).then((result) => {
  190. if (result.value) {
  191. $.post("/admin/batchAddUsers", {_token: '{{csrf_token()}}', amount: result.value}, function (ret) {
  192. if (ret.status === 'success') {
  193. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false})
  194. .then(() => window.location.reload())
  195. } else {
  196. swal.fire({title: ret.message, type: "error"}).then(() => window.location.reload())
  197. }
  198. });
  199. }
  200. });
  201. }
  202. //回车检测
  203. $(document).on("keypress", "input", function (e) {
  204. if (e.which === 13) {
  205. Search();
  206. return false;
  207. }
  208. });
  209. // 搜索
  210. function Search() {
  211. window.location.href = '/admin/userList' + '?id=' + $("#id").val() + '&email=' + $("#email").val() + '&wechat=' + $("#wechat").val() + '&qq=' + $("#qq").val() + '&port=' + $("#port").val() + '&pay_way=' + $("#pay_way option:selected").val() + '&status=' + $("#status option:selected").val() + '&enable=' + $("#enable option:selected").val();
  212. }
  213. // 删除账号
  214. function delUser(id, email) {
  215. swal.fire({
  216. title: '警告',
  217. text: '确定删除用户 【' + email + '】 ?',
  218. type: 'warning',
  219. showCancelButton: true,
  220. cancelButtonText: '{{trans('home.ticket_close')}}',
  221. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  222. }).then((result) => {
  223. if (result.value) {
  224. $.post("/admin/delUser", {id: id, _token: '{{csrf_token()}}'}, function (ret) {
  225. if (ret.status === 'success') {
  226. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false})
  227. .then(() => window.location.reload())
  228. } else {
  229. swal.fire({title: ret.message, type: "error"}).then(() => window.location.reload())
  230. }
  231. });
  232. }
  233. });
  234. }
  235. // 重置流量
  236. function resetTraffic(id, email) {
  237. swal.fire({
  238. title: '警告',
  239. text: '确定重置 【' + email + '】 流量吗?',
  240. type: 'warning',
  241. showCancelButton: true,
  242. cancelButtonText: '{{trans('home.ticket_close')}}',
  243. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  244. }).then((result) => {
  245. if (result.value) {
  246. $.post("/admin/resetUserTraffic", {_token: '{{csrf_token()}}', id: id}, function (ret) {
  247. if (ret.status === 'success') {
  248. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false})
  249. .then(() => window.location.reload())
  250. } else {
  251. swal.fire({title: ret.message, type: "error"}).then(() => window.location.reload())
  252. }
  253. });
  254. }
  255. });
  256. }
  257. // 切换用户身份
  258. function switchToUser(id) {
  259. $.ajax({
  260. 'url': "/admin/switchToUser",
  261. 'data': {
  262. 'user_id': id,
  263. '_token': '{{csrf_token()}}'
  264. },
  265. 'dataType': "json",
  266. 'type': "POST",
  267. success: function (ret) {
  268. if (ret.status === 'success') {
  269. swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false})
  270. .then(() => window.location.href = "/")
  271. } else {
  272. swal.fire({title: ret.message, type: "error"}).then(() => window.location.reload())
  273. }
  274. }
  275. });
  276. }
  277. const clipboard = new ClipboardJS('.copySubscribeLink');
  278. clipboard.on('success', function () {
  279. swal.fire({
  280. title: '复制成功',
  281. type: 'success',
  282. timer: 1000,
  283. showConfirmButton: false
  284. });
  285. });
  286. clipboard.on('error', function () {
  287. swal.fire({
  288. title: '复制失败,请手动复制',
  289. type: 'error',
  290. timer: 1500,
  291. showConfirmButton: false
  292. });
  293. });
  294. </script>
  295. @endsection