userList.blade.php 14 KB

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