Nessuna descrizione

pkgorderali.jsp 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  1. <%@ page language="java" pageEncoding="UTF-8"%>
  2. <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
  3. <!DOCTYPE html>
  4. <html>
  5. <head>
  6. <meta charset="UTF-8" />
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  8. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=yes" />
  9. <meta name="renderer" content="webkit">
  10. <meta http-equiv="Cache-Control" content="no-siteapp" />
  11. <meta name="applicable-device" content="mobile">
  12. <meta name="format-detection" content="telephone=no" />
  13. <meta http-equiv="title" content="" />
  14. <title>购买套餐</title>
  15. <meta name="description" content="" />
  16. <meta name="keywords" content="" />
  17. <link rel="stylesheet" href="/static/css/animate.min.css" type="text/css" media="all" />
  18. <link rel="stylesheet" href="/static/css/style.css" type="text/css" media="all" />
  19. <link rel="stylesheet" href="/static/css/swiper-bundle.min.css" type="text/css" media="all" />
  20. <script language="javascript" type="text/javascript" src="/static/js/jquery-3.6.0.min.js"></script>
  21. <script language="javascript" type="text/javascript" src="/static/js/animate.min.js"></script>
  22. <script language="javascript" type="text/javascript" src="/static/js/main.js"></script>
  23. <script language="javascript" type="text/javascript" src="/static/js/swiper-bundle.min.js"></script>
  24. <style>
  25. .form-wallet{
  26. border-bottom: 1px solid #f0f0f0;
  27. }
  28. .form-wallet .form-item{
  29. border-bottom: none;
  30. }
  31. .wallet-money{
  32. display: none;
  33. width: 100%;
  34. padding: 2px 25px;
  35. height:65px;
  36. position: relative;
  37. }
  38. .wallet-money.show{
  39. display: block;
  40. }
  41. .wallet-container{
  42. display: block;
  43. width: 100%;
  44. min-height:45px;
  45. position: relative;
  46. list-style: none;
  47. overflow: hidden;
  48. z-index: 1;
  49. }
  50. .wallet-container .swiper-slide{
  51. display: block;
  52. width: 33.33%;
  53. height: 45px;
  54. position: relative;
  55. border-radius: 8px;
  56. overflow: hidden;
  57. background-color: #FFFFFF;
  58. border: 1px solid #e8e8e8;
  59. }
  60. .wallet-container .swiper-slide.cur{
  61. border: 1px solid #cb5f1f;
  62. }
  63. .wallet-container .swiper-slide img{
  64. display: block;
  65. width: 100%;
  66. max-height: auto;
  67. }
  68. .wallet-container .swiper-slide .sum{
  69. position: relative;
  70. display: block;
  71. justify-content: center;
  72. align-items: center;
  73. width: 100%;
  74. height: 100%;
  75. font-size: 14px;
  76. line-height: 2;
  77. font-family: Arial;
  78. font-weight: bold;
  79. text-align: center;
  80. padding-top: 0;
  81. }
  82. .wallet-container .swiper-slide .sum i{
  83. display: block;
  84. width: 100%;
  85. font-size: 9px;
  86. height: 15px;
  87. line-height: 16px;
  88. color: #FFF;
  89. background-color: #dd170e;
  90. }
  91. .wallet-container .swiper-slide .sum::after{
  92. content: '';
  93. position: absolute;
  94. top: 0;
  95. left: 0;
  96. display: none;
  97. width: 100%;
  98. height: 10px;
  99. background-color: #dd170e;
  100. }
  101. .swiper-button-prev{
  102. left: 0;
  103. }
  104. .swiper-button-next{
  105. right: 0;
  106. }
  107. .swiper-button-prev,.swiper-button-next{
  108. top: 17px;
  109. margin-top: 0;
  110. width: 15px;
  111. height: 15px;
  112. opacity: 0.6;
  113. }
  114. .swiper-button-disabled{
  115. opacity: 0.2;
  116. }
  117. .swiper-button-next:after,.swiper-button-prev:after{
  118. color: #929292;
  119. font-size: 18px;
  120. }
  121. .swiper-button-next:hover:after,.swiper-button-prev:hover:after{
  122. color: #FF6600;
  123. }
  124. </style>
  125. </head>
  126. <body>
  127. <div class="box">
  128. <div class="recharge-top">
  129. <div class="pic">
  130. <img src="/static/img/img-recharge.png" alt="">
  131. </div>
  132. <div class="text">
  133. <div class="title">${pkgInfo.pkgName}</div>
  134. <div class="desc"></div>
  135. <div class="price">¥<strong id="price">${pkgInfo.price}</strong></div>
  136. </div>
  137. </div>
  138. </div>
  139. <div class="box benefit-box">
  140. <div class="benefit-list swiper">
  141. <div class="swiper-wrapper">
  142. <c:forEach var="item" items="${spkgs}" varStatus="loop">
  143. <div class="item swiper-slide ${loop.index==0?' cur':''}" data-price="${item.price}" data-speedpackid="${item.id}">
  144. <div class="wrap">
  145. <i class="icon"><img src="/static/img/icon-diamond${item.id%2+1}.png"></i>
  146. <div class="title">${item.name}</div>
  147. <div class="desc">${item.desc}</div>
  148. <div class="price">¥<strong>${item.price}</strong></div>
  149. <div class="valid">有效期:
  150. <c:choose>
  151. <c:when test="${item.expiryDay == 0 }">1天</c:when>
  152. <c:when test="${item.expiryDay == 1 }">30天</c:when>
  153. <c:when test="${item.expiryDay == 2 }">90天</c:when>
  154. <c:when test="${item.expiryDay == 3 }">半年</c:when>
  155. <c:when test="${item.expiryDay == 4 }">1年</c:when>
  156. <c:when test="${item.expiryDay == 5 }">两年</c:when>
  157. <c:when test="${item.expiryDay == 6 }">7天</c:when>
  158. <c:when test="${item.expiryDay == 7 }">3年</c:when>
  159. <c:when test="${item.expiryDay == 8 }">3天</c:when>
  160. <c:when test="${item.expiryDay == 9 }">两天</c:when>
  161. <c:when test="${item.expiryDay == 11 }">7个月</c:when>
  162. <c:when test="${item.expiryDay == 12 }">14个月</c:when>
  163. <c:when test="${item.expiryDay == 18 }">15个月</c:when>
  164. <c:when test="${item.expiryDay == 13 }">两年半</c:when>
  165. <c:when test="${item.expiryDay == 14 }">3年8个月</c:when>
  166. <c:when test="${item.expiryDay == 15 }">4年 </c:when>
  167. <c:when test="${item.expiryDay == 16 }">5年</c:when>
  168. <c:when test="${item.expiryDay == 17 }">6年</c:when>
  169. </c:choose>
  170. </div>
  171. <div class="select"><i></i></div>
  172. </div>
  173. </div>
  174. </c:forEach>
  175. </div>
  176. </div>
  177. </div>
  178. <div class="box">
  179. <div class="form-item">
  180. <label>充值设备号</label>
  181. <div class="form-text">${devid}</div>
  182. </div>
  183. <div class="form-item">
  184. <label>套餐有效期</label>
  185. <div class="form-text">
  186. <c:choose>
  187. <c:when test="${pkgInfo.expiryDay == 0 }">1天</c:when>
  188. <c:when test="${pkgInfo.expiryDay == 1 }">30天</c:when>
  189. <c:when test="${pkgInfo.expiryDay == 2 }">90天</c:when>
  190. <c:when test="${pkgInfo.expiryDay == 3 }">半年</c:when>
  191. <c:when test="${pkgInfo.expiryDay == 4 }">1年</c:when>
  192. <c:when test="${pkgInfo.expiryDay == 5 }">两年</c:when>
  193. <c:when test="${pkgInfo.expiryDay == 6 }">7天</c:when>
  194. <c:when test="${pkgInfo.expiryDay == 7 }">3年</c:when>
  195. <c:when test="${pkgInfo.expiryDay == 8 }">3天</c:when>
  196. <c:when test="${pkgInfo.expiryDay == 9 }">两天</c:when>
  197. <c:when test="${pkgInfo.expiryDay == 11 }">7个月</c:when>
  198. <c:when test="${pkgInfo.expiryDay == 12 }">14个月</c:when>
  199. <c:when test="${pkgInfo.expiryDay == 18 }">15个月</c:when>
  200. <c:when test="${pkgInfo.expiryDay == 13 }">两年半</c:when>
  201. <c:when test="${pkgInfo.expiryDay == 14 }">3年8个月</c:when>
  202. <c:when test="${pkgInfo.expiryDay == 15 }">4年 </c:when>
  203. <c:when test="${pkgInfo.expiryDay == 16 }">5年</c:when>
  204. <c:when test="${pkgInfo.expiryDay == 17 }">6年</c:when>
  205. </c:choose>
  206. </div>
  207. </div>
  208. <div class="form-item">
  209. <label>全国通用</label>
  210. <div class="form-text">移动、联通、电信三网合一自由切换</div>
  211. </div>
  212. <div class="form-item">
  213. <label>套餐价格</label>
  214. <div class="form-text">¥${pkgInfo.price}</div>
  215. </div>
  216. <div class="form-item" onclick="ShowBox('PopCoupons')">
  217. <label>优惠券</label>
  218. <div class="form-text" id="coupons">选择优惠券</div>
  219. </div>
  220. </div>
  221. <div class="box mb70">
  222. <c:if test="${pkgInfo.paytype == 1}">
  223. <div class="form-item">
  224. <div class="form-text">
  225. <img src="/static/img/icon-wallet.png" class="icon">
  226. <span>钱包特惠支付(余额:¥${balance})</span>
  227. </div>
  228. <div class="select">
  229. <input type="radio" name="pay" value="balance" class="redcheck" id="pay">
  230. </div>
  231. </div>
  232. <div class="wallet-money show">
  233. <div class="swiper-container wallet-container">
  234. <div class="swiper-wrapper">
  235. <c:forEach var="item" items="${cons}">
  236. <div class="swiper-slide" data-id="${item.id}" data-jine="${item.jine}">
  237. <div class="sum">
  238. <i class="bar">赠送${item.zsong}元</i>
  239. <span>${item.jine}</span>
  240. </div>
  241. </div>
  242. </c:forEach>
  243. </div>
  244. </div>
  245. <div class="swiper-button-next"></div>
  246. <div class="swiper-button-prev"></div>
  247. </div>
  248. <div class="form-item">
  249. <div class="form-text">
  250. <img src="/static/img/icon-pay-alipay.png" class="icon">
  251. <span>支付宝支付</span>
  252. </div>
  253. <div class="select">
  254. <input type="radio" name="pay" value="alipay" class="redcheck" id="pay">
  255. </div>
  256. </div>
  257. <div class="form-item">
  258. <div class="form-text">
  259. <img src="/static/img/icon-pay-weixin.png" class="icon">
  260. <span>微信支付,请联系客服充值</span>
  261. </div>
  262. <div class="select">
  263. <input type="radio" name="pay" value="wx" class="redcheck" id="pay">
  264. </div>
  265. </div>
  266. </c:if>
  267. <c:if test="${pkgInfo.paytype == 2}">
  268. <div class="form-item">
  269. <div class="form-text">
  270. <img src="/static/img/icon-pay-alipay.png" class="icon">
  271. <span>支付宝支付</span>
  272. </div>
  273. <div class="select">
  274. <input type="radio" name="pay" value="alipay" class="redcheck" id="pay">
  275. </div>
  276. </div>
  277. <div class="form-item">
  278. <div class="form-text">
  279. <img src="/static/img/icon-pay-weixin.png" class="icon">
  280. <span>微信支付,请联系客服充值</span>
  281. </div>
  282. <div class="select">
  283. <input type="radio" name="pay" value="wx" class="redcheck" id="pay">
  284. </div>
  285. </div>
  286. </c:if>
  287. <c:if test="${pkgInfo.paytype == 3}">
  288. <div class="form-item">
  289. <div class="form-text">
  290. <img src="/static/img/icon-wallet.png" class="icon">
  291. <span>钱包特惠支付(余额:¥${balance})</span>
  292. </div>
  293. <div class="select">
  294. <input type="radio" name="pay" value="balance" class="redcheck" id="pay">
  295. </div>
  296. </div>
  297. <div class="wallet-money show">
  298. <div class="swiper-container wallet-container">
  299. <div class="swiper-wrapper">
  300. <c:forEach var="item" items="${cons}">
  301. <div class="swiper-slide" data-id="${item.id}" data-jine="${item.jine}">
  302. <div class="sum">
  303. <i class="bar">赠送${item.zsong}元</i>
  304. <span>${item.jine}</span>
  305. </div>
  306. </div>
  307. </c:forEach>
  308. </div>
  309. </div>
  310. <div class="swiper-button-next"></div>
  311. <div class="swiper-button-prev"></div>
  312. </div>
  313. </c:if>
  314. </div>
  315. <input type="hidden" id="usertotalbalance" value="${balance}"/>
  316. <form class="form_wrap" method="post" accept-charset="utf-8">
  317. <div class="bottom-paybox">
  318. <div class="price">¥<strong id="total-price">${pkgInfo.price}</strong></div>
  319. <input type="hidden" name="pkgid" id="pkgid" value="${pkgInfo.pkgid}"/>
  320. <input type="hidden" name="amount" id="trxamt" value="${pkgInfo.price}"/>
  321. <input type="hidden" name="devid" id="devid" value="${devid}"/>
  322. <input type="hidden" name="type" id="type" value="1"/>
  323. <input type="hidden" name="paytype" id="paytype" value="0" />
  324. <input type="hidden" name="speedpackid" id="speedpackid" value="${!empty spkgs?spkgs[0].id:''}"/>
  325. <input type="hidden" id="pkgprice" name="pkgprice" value=""/>
  326. <input type="hidden" id="memberid" name="memberid" value=""/>
  327. <input type="hidden" id="opt" name="opt" value="${opt }"/>
  328. <div class="pay-btn">
  329. <input type="button" class="btn" value="支付" />
  330. </div>
  331. </div>
  332. </form>
  333. <!--弹层-优惠券-->
  334. <div class='menu-mask' id="PopCoupons">
  335. <div class="popbox animated fadeInUp">
  336. <h2 class="tcenter">选择优惠券</h2>
  337. <div class="popbox-con">
  338. <div class="lite-card-select btn-coupons">
  339. <div class="list">
  340. <c:forEach var="item" items="${cons}">
  341. <div class="item">
  342. <div class="name" data="满${item.coupon}减${item.discount}" data-getprice="${item.coupon}" data-price="${item.discount}">满${item.coupon}减${item.discount}</div>
  343. <div class="allow"></div>
  344. </div>
  345. </c:forEach>
  346. </div>
  347. </div>
  348. </div>
  349. <div class="icon-close" onclick="CloseBox('PopCoupons')"></div>
  350. </div>
  351. </div>
  352. <div class="mask"></div>
  353. <script>
  354. var mprice=888;
  355. var pkgprice=888;
  356. var ubalance;
  357. var thumbSwiper = new Swiper(".benefit-list", {
  358. spaceBetween: 10,
  359. slidesPerView: "auto",
  360. freeMode: true,
  361. watchSlidesProgress: true,
  362. });
  363. //钱包滑动
  364. var swiper = new Swiper(".wallet-container", {
  365. slidesPerGroup: 1,
  366. slidesPerView: 3,
  367. spaceBetween: 12,
  368. navigation: {
  369. nextEl: ".swiper-button-next",
  370. prevEl: ".swiper-button-prev",
  371. },
  372. });
  373. //选中
  374. $(".wallet-container .swiper-slide").click(function() {
  375. var obj = $(this);
  376. var isClicked = obj.hasClass("cur") ? true : false;
  377. $('.wallet-container .swiper-slide').removeClass('cur');
  378. isClicked ? null : obj.addClass("cur");
  379. if(obj.hasClass("cur")) {
  380. var mid = $(this).data("id");
  381. var mjine = $(this).data("jine");
  382. $("#memberid").val(mid);
  383. mprice=parseFloat(mjine).toFixed(2)||0;
  384. $("#total-price").html(mprice);
  385. } else {
  386. $("#memberid").val('');
  387. mprice=0;
  388. $("#total-price").html(pkgprice);
  389. }
  390. });
  391. $(".benefit-list .item").click(function() {
  392. var obj = $(this);
  393. var isClicked = obj.hasClass("cur") ? true : false;
  394. $(".benefit-list .item").removeClass("cur");
  395. isClicked ? null : obj.addClass("cur");
  396. calculateTotal(); // 统一调用计算总价函数
  397. $("#speedpackid").val(obj.hasClass("cur")?obj.data("speedpackid"):'');
  398. });
  399. $(".btn-coupons .item").click(function() {
  400. var obj = $(this);
  401. var isClicked = obj.hasClass("active") ? true : false;
  402. $(".btn-coupons .item").removeClass("active");
  403. isClicked ? null : obj.addClass("active");
  404. if (isClicked) {
  405. $("#coupons").text('选择优惠券');
  406. } else {
  407. $("#coupons").text($(this).find(".name").attr("data"));
  408. }
  409. var popCouponsElement = document.getElementById('PopCoupons');
  410. setTimeout(function() {
  411. if (popCouponsElement) {
  412. popCouponsElement.style.display = "none";
  413. }
  414. }, 500);
  415. calculateTotal(); // 统一调用计算总价函数
  416. });
  417. $(".redcheck").click(function() {
  418. var ptype = $(this).val();
  419. if(ptype == 'wx'){
  420. $("#total-price").html(pkgprice);
  421. $(".wallet-money").hide();
  422. } else if(ptype == 'balance') {
  423. $("#total-price").html(mprice);
  424. $(".wallet-money").show();
  425. }
  426. });
  427. // 统一的总价计算函数
  428. function calculateTotal() {
  429. var productPrice = parseFloat($("#price").text()); // 商品价格
  430. var speedPackagePrice = 0; // 加速套餐价格
  431. var couponPrice = 0; // 优惠券金额
  432. var getPrice = 0; // 优惠券使用门槛
  433. // 获取选中的加速套餐价格
  434. if ($(".benefit-list .item.cur").length > 0) {
  435. speedPackagePrice = parseFloat($(".benefit-list .item.cur").attr("data-price"))||0;
  436. }
  437. // 获取选中的优惠券金额
  438. if ($("#PopCoupons .item.active").length > 0) {
  439. getPrice = parseFloat($("#PopCoupons .item.active .name").attr("data-getprice"))||0;
  440. couponPrice = parseFloat($("#PopCoupons .item.active .name").attr("data-price"))||0;
  441. // 检查是否满足优惠券使用条件
  442. var totalPriceBeforeCoupon = productPrice + speedPackagePrice;
  443. if (getPrice > totalPriceBeforeCoupon) {
  444. couponPrice = 0;
  445. }
  446. }
  447. // 计算总价:商品价格 + 加速套餐价格 - 优惠券金额
  448. var totalPrice = productPrice + speedPackagePrice - couponPrice;
  449. pkgprice=totalPrice;
  450. mprice=totalPrice;
  451. $("#total-price").html(totalPrice.toFixed(2));
  452. $("#trxamt").val(totalPrice.toFixed(2));
  453. if($(".redcheck:checked").val() == 'balance') {
  454. var usertotalbalance = parseFloat($("#usertotalbalance").val());
  455. ubalance=usertotalbalance;
  456. if(usertotalbalance >= pkgprice) {
  457. $(".wallet-money").hide();
  458. } else {
  459. $(".wallet-money").show();
  460. $(".wallet-container .swiper-slide").each(function(i) {
  461. var mjine = $(this).data("jine");
  462. var fmjine = parseFloat(mjine);
  463. if(fmjine>=pkgprice) {
  464. $(this).trigger("click");
  465. swiper.slideTo(i);
  466. }
  467. });
  468. }
  469. }
  470. }
  471. // 页面加载完成后初始化计算一次总价
  472. $(document).ready(function() {
  473. calculateTotal();
  474. var isRequesting = false;
  475. $(".pay-btn").click(function(e){
  476. if (isRequesting) return;
  477. isRequesting = true;
  478. $(".mask").show();
  479. var input = $('.form_wrap').find('input,select'), param = {};
  480. input.each(function(i,item){
  481. item = $(item);
  482. var vType = item.attr('vtype'), ind = 0;
  483. param[item.attr('name')] = item.val();
  484. //alert(item);
  485. });
  486. var paytype = $(".redcheck:checked").val();
  487. if(paytype == "alipay") {
  488. if (!navigator.userAgent.match(/MicroMessenger/i)) {
  489. alert("请使用微信访问!");
  490. $('.mask').hide();
  491. isRequesting = false;
  492. return;
  493. }
  494. param['amount']=pkgprice;
  495. $.post('/mifi/toalipay.do',param,function(res){
  496. $('.mask').hide();
  497. if(typeof(res) === 'string'){
  498. res = JSON.parse(res);
  499. }
  500. if(res.status !== "200"){
  501. alert(res.msg);
  502. }else{
  503. location.href = res.pay_info;
  504. }
  505. isRequesting = false;
  506. });
  507. } else if(paytype == "balance") {
  508. if(ubalance>=pkgprice) {
  509. param['amount']=pkgprice;
  510. $.post('/mifi/buyBalance.do',param,function(res){
  511. $('.mask').hide();
  512. if(res == 'OK'){
  513. alert("支付成功");
  514. location.href = "/device/getDevInfo.do?sn="+$("#devid").val();
  515. } else {
  516. alert(res);
  517. if(res == '用户余额不足!'){
  518. location.href = "/mifi/getMember.do";
  519. }
  520. }
  521. isRequesting = false;
  522. },'json');
  523. } else {
  524. if (!navigator.userAgent.match(/MicroMessenger/i)) {
  525. alert("请使用微信访问!");
  526. $('.mask').hide();
  527. isRequesting = false;
  528. return;
  529. }
  530. param['amount']=mprice;
  531. param['pkgprice']=pkgprice;
  532. if(isNaN(pkgprice)){
  533. location.reload();
  534. }
  535. param['type']=2;
  536. var memberid = $("#memberid").val();
  537. if(memberid==''||mprice==0){
  538. alert("请选择金额!");
  539. $('.mask').hide();
  540. isRequesting = false;
  541. return;
  542. } else if(mprice<pkgprice){
  543. alert("金额不足,请重新选择金额!");
  544. $('.mask').hide();
  545. isRequesting = false;
  546. return;
  547. } else {
  548. $.post('/mifi/toalipay.do',param,function(res){
  549. $('.mask').hide();
  550. if(typeof(res) === 'string'){
  551. res = JSON.parse(res);
  552. }
  553. if(res.status !== "200"){
  554. alert(res.msg);
  555. }else{
  556. location.href = res.pay_info;
  557. }
  558. isRequesting = false;
  559. });
  560. }
  561. }
  562. } else if(paytype == "wx"){
  563. alert("请联系客服充值!");
  564. $('.mask').hide();
  565. isRequesting = false;
  566. return;
  567. } else {
  568. alert("请选择支付方式!");
  569. $('.mask').hide();
  570. isRequesting = false;
  571. return;
  572. }
  573. });
  574. });
  575. </script>
  576. </body>
  577. </html>