services.blade.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. @extends('user.layouts')
  2. @section('css')
  3. <link rel="stylesheet" href="assets/global/vendor/ionrangeslider/ionrangeslider.min.css">
  4. @endsection
  5. @section('content')
  6. <div class="page-content">
  7. <div class="row">
  8. <div class="col-xxl-2 col-lg-3">
  9. <div class="card card-shadow">
  10. <div class="card-block p-20">
  11. <button type="button" class="btn btn-floating btn-sm btn-pure">
  12. <i class="icon wb-payment green-500"></i>
  13. </button>
  14. <span class="font-weight-400">{{trans('home.account_credit')}}</span>
  15. <div class="content-text text-center mb-0">
  16. <span class="font-size-40 font-weight-100">{{Auth::getUser()->credit}}</span>
  17. <br/>
  18. <button class="btn btn-danger float-right mr-15" data-toggle="modal" data-target="#charge_modal">{{trans('home.recharge')}}</button>
  19. </div>
  20. </div>
  21. </div>
  22. @if($renewTraffic)
  23. <div class="card card-shadow">
  24. <div class="card-block p-20">
  25. <button type="button" class="btn btn-floating btn-sm btn-pure">
  26. <i class="icon wb-payment green-500"></i>
  27. </button>
  28. <span class="font-weight-400">流量重置</span>
  29. <div class="content-text text-center mb-0">
  30. <span class="font-size-20 font-weight-100">需要 <code>{{$renewTraffic}}</code> 元</span>
  31. <br/>
  32. <button class="btn btn-danger mt-10" onclick="resetTraffic()">重置</button>
  33. </div>
  34. </div>
  35. </div>
  36. @endif
  37. </div>
  38. <div class="col-xxl-10 col-lg-9">
  39. <div class="panel">
  40. <div class="panel-heading p-20">
  41. <h1 class="panel-title cyan-700">
  42. <i class="icon wb-shopping-cart"></i>{{trans('home.services')}}
  43. </h1>
  44. </div>
  45. <div class="panel-body">
  46. <div class="row">
  47. @foreach($goodsList as $goods)
  48. <div class="col-md-6 col-xl-4 col-xxl-3 pb-30">
  49. <div class="pricing-list text-left">
  50. <div class="pricing-header text-white" style="background-color: {{$goods->color}}">
  51. <div class="pricing-title font-size-20">{{$goods->name}}</div>
  52. @if($goods->limit_num)
  53. <div class="ribbon ribbon-vertical ribbon-bookmark ribbon-reverse ribbon-primary mr-10">
  54. <span class="ribbon-inner h-auto">限<br>购</span>
  55. </div>
  56. @elseif($goods->is_hot)
  57. <div class="ribbon ribbon-vertical ribbon-bookmark ribbon-reverse ribbon-danger mr-10">
  58. <span class="ribbon-inner h-auto">热<br>销</span>
  59. </div>
  60. @endif
  61. <div class="pricing-price text-white @if($goods->type === 1) text-center @endif">
  62. <span class="pricing-currency">¥</span>
  63. <span class="pricing-amount">{{$goods->price}}</span>
  64. @if($goods->type === 2)
  65. <span class="pricing-period">/ {{$goods->days}}{{trans('home.day')}}</span>
  66. @endif
  67. </div>
  68. @if($goods->info)
  69. <p class="px-30 pb-25 text-center">{{$goods->description}}</p>
  70. @endif
  71. </div>
  72. <ul class="pricing-features">
  73. <li>
  74. <strong>{{$goods->traffic_label}}</strong>{{trans('home.bandwidth')}}
  75. {!!$goods->type === 1? ' <code>'.$dataPlusDays.'</code> '.trans('home.day'):'/'.trans('home.month')!!}
  76. </li>
  77. <li>
  78. <strong>{{trans('home.service_unlimited')}}</strong> {{trans('home.service_device')}}
  79. </li>
  80. {!!$goods->info!!}
  81. </ul>
  82. <div class="pricing-footer text-center bg-blue-grey-100">
  83. <a href="{{route('buy', $goods->id)}}" class="btn btn-lg btn-primary"> {{trans('home.service_buy_button')}}</a>
  84. </div>
  85. </div>
  86. </div>
  87. @endforeach
  88. </div>
  89. </div>
  90. </div>
  91. </div>
  92. </div>
  93. </div>
  94. <div id="charge_modal" class="modal fade" aria-labelledby="charge_modal" role="dialog" tabindex="-1"
  95. aria-hidden="true">
  96. <div class="modal-dialog modal-simple modal-center">
  97. <div class="modal-content">
  98. <div class="modal-header">
  99. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  100. <span aria-hidden="true">×</span></button>
  101. <h4 class="modal-title">{{trans('home.recharge_credit')}}</h4>
  102. </div>
  103. <div class="modal-body">
  104. <div class="alert alert-danger" id="charge_msg" style="display: none;"></div>
  105. <form action="#" method="post">
  106. @if(sysConfig('is_onlinePay') || sysConfig('alipay_qrcode') || sysConfig('wechat_qrcode'))
  107. <div class="mb-15 w-p50">
  108. <select class="form-control" name="charge_type" id="charge_type">
  109. @if(sysConfig('is_onlinePay'))
  110. <option value="1">{{trans('home.online_pay')}}</option>
  111. @endif
  112. @if(sysConfig('alipay_qrcode') || sysConfig('wechat_qrcode'))
  113. <option value="2">二维码</option>
  114. @endif
  115. <option value="3">{{trans('home.coupon_code')}}</option>
  116. </select>
  117. </div>
  118. @endif
  119. @if(sysConfig('is_onlinePay'))
  120. <div class="form-group row charge_credit">
  121. <label for="amount" class="offset-md-1 col-md-2 col-form-label">充值金额</label>
  122. <div class="col-md-8">
  123. <input type="text" name="amount" id="amount" data-plugin="ionRangeSlider" data-min=1 data-max=300 data-from=40 data-prefix="¥"/>
  124. </div>
  125. </div>
  126. @endif
  127. @if(sysConfig('alipay_qrcode') || sysConfig('wechat_qrcode'))
  128. <div class="text-center" id="charge_qrcode">
  129. <div class="row">
  130. <p class="col-md-12 mb-10">付款时,请
  131. <mark>备注邮箱账号</mark>
  132. ,充值会在<code>24</code>小时内受理!
  133. </p>
  134. @if(sysConfig('wechat_qrcode'))
  135. <div class="col-md-6">
  136. <img class="w-p75 mb-10" src="{{sysConfig('wechat_qrcode')}}" alt=""/>
  137. <p>微 信 | WeChat</p>
  138. </div>
  139. @endif
  140. @if(sysConfig('alipay_qrcode'))
  141. <div class="col-md-6">
  142. <img class="w-p75 mb-10" src="{{sysConfig('alipay_qrcode')}}" alt=""/>
  143. <p>支 付 宝 | AliPay</p>
  144. </div>
  145. @endif
  146. </div>
  147. </div>
  148. @endif
  149. <div class="form-group row" id="charge_coupon_code">
  150. <label for="charge_coupon"
  151. class="offset-md-2 col-md-2 col-form-label"> {{trans('home.coupon_code')}} </label>
  152. <div class="col-md-6">
  153. <input type="text" class="form-control round" name="charge_coupon" id="charge_coupon" placeholder="{{trans('home.please_input_coupon')}}">
  154. </div>
  155. </div>
  156. </form>
  157. </div>
  158. <div class="modal-footer">
  159. <div class="btn btn-group-lg charge_credit">
  160. @include('user.components.purchase')
  161. </div>
  162. <button type="button" class="btn btn-primary" id="change_btn" onclick="pay()">{{trans('home.recharge')}}</button>
  163. </div>
  164. </div>
  165. </div>
  166. </div>
  167. @endsection
  168. @section('script')
  169. <script src="assets/global/vendor/ionrangeslider/ion.rangeSlider.min.js"></script>
  170. <script src="assets/global/js/Plugin/ionrangeslider.js"></script>
  171. <script type="text/javascript">
  172. function itemControl(value) {
  173. if (value === 1) {
  174. $('.charge_credit').show();
  175. $('#change_btn').hide();
  176. $('#charge_qrcode').hide();
  177. $('#charge_coupon_code').hide();
  178. }
  179. else if (value === 2) {
  180. $('.charge_credit').hide();
  181. $('#change_btn').hide();
  182. $('#charge_qrcode').show();
  183. $('#charge_coupon_code').hide();
  184. }
  185. else {
  186. $('.charge_credit').hide();
  187. $('#charge_qrcode').hide();
  188. $('#charge_coupon_code').show();
  189. $('#change_btn').show();
  190. }
  191. }
  192. $(document).ready(function() {
  193. let which_selected = 3;
  194. @if(sysConfig('is_onlinePay'))
  195. which_selected = 1;
  196. @elseif(sysConfig('alipay_qrcode') || sysConfig('wechat_qrcode'))
  197. which_selected = 2;
  198. @endif
  199. itemControl(which_selected);
  200. $('charge_type').val(which_selected);
  201. });
  202. // 切换充值方式
  203. $('#charge_type').change(function() {
  204. itemControl(parseInt($(this).val()));
  205. });
  206. // 重置流量
  207. function resetTraffic() {
  208. swal.fire({
  209. title: '重置流量',
  210. text: '本次重置流量将扣除余额 {{$renewTraffic}} 元?',
  211. icon: 'question',
  212. showCancelButton: true,
  213. cancelButtonText: '{{trans('home.ticket_close')}}',
  214. confirmButtonText: '{{trans('home.ticket_confirm')}}',
  215. }).then((result) => {
  216. if (result.value) {
  217. $.post('{{route('resetTraffic')}}', {_token: '{{csrf_token()}}'}, function(ret) {
  218. if (ret.status === 'success') {
  219. swal.fire({title: ret.message, icon: 'success', timer: 1000, showConfirmButton: false}).
  220. then(() => window.location.reload());
  221. }
  222. else {
  223. swal.fire({
  224. title: ret.message,
  225. text: ret.data,
  226. icon: 'error',
  227. }).then(() => window.location.reload());
  228. }
  229. });
  230. }
  231. });
  232. }
  233. // 充值
  234. function pay(method, pay_type) {
  235. const paymentType = parseInt($('#charge_type').val() ?? 3);
  236. const charge_coupon = $('#charge_coupon').val().trim();
  237. const amount = parseInt($('#amount').val());
  238. if (paymentType === 1) {
  239. if (amount <= 0) {
  240. swal.fire({title: '错误', text: '充值余额不合规', icon: 'warning', timer: 1000, showConfirmButton: false});
  241. return false;
  242. }
  243. $.ajax({
  244. method: 'POST',
  245. url: '{{route('purchase')}}',
  246. data: {_token: '{{csrf_token()}}', amount: amount, method: method, pay_type: pay_type},
  247. dataType: 'json',
  248. beforeSend: function() {
  249. $('#charge_msg').show().html('创建支付单中...');
  250. },
  251. success: function(ret) {
  252. if (ret.status === 'fail') {
  253. return false;
  254. }
  255. else {
  256. $('#charge_msg').show().html(ret.message);
  257. if (ret.data) {
  258. window.location.href = '{{route('orderDetail' , '')}}/' + ret.data;
  259. }
  260. else if (ret.url) {
  261. window.location.href = ret.url;
  262. }
  263. }
  264. },
  265. error: function() {
  266. $('#charge_msg').show().html("{{trans('home.error_response')}}");
  267. },
  268. });
  269. }
  270. else if (paymentType === 3) {
  271. if (charge_coupon === '') {
  272. $('#charge_msg').show().html("{{trans('home.coupon_not_empty')}}");
  273. $('#charge_coupon').focus();
  274. return false;
  275. }
  276. $.ajax({
  277. method: 'POST',
  278. url: '{{route('recharge')}}',
  279. data: {_token: '{{csrf_token()}}', coupon_sn: charge_coupon},
  280. beforeSend: function() {
  281. $('#charge_msg').show().html("{{trans('home.recharging')}}");
  282. },
  283. success: function(ret) {
  284. if (ret.status === 'fail') {
  285. $('#charge_msg').show().html(ret.message);
  286. return false;
  287. }
  288. $('#charge_modal').modal('hide');
  289. window.location.reload();
  290. },
  291. error: function() {
  292. $('#charge_msg').show().html("{{trans('home.error_response')}}");
  293. },
  294. });
  295. }
  296. }
  297. </script>
  298. @endsection