Нет описания

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. </div>
  264. </div>
  265. </c:if>
  266. <c:if test="${pkgInfo.paytype == 2}">
  267. <div class="form-item">
  268. <div class="form-text">
  269. <img src="/static/img/icon-pay-alipay.png" class="icon">
  270. <span>支付宝支付</span>
  271. </div>
  272. <div class="select">
  273. <input type="radio" name="pay" value="alipay" class="redcheck" id="pay">
  274. </div>
  275. </div>
  276. <div class="form-item">
  277. <div class="form-text">
  278. <img src="/static/img/icon-pay-weixin.png" class="icon">
  279. <span>微信支付,请联系在线客服充值</span>
  280. </div>
  281. <div class="select">
  282. </div>
  283. </div>
  284. </c:if>
  285. <c:if test="${pkgInfo.paytype == 3}">
  286. <div class="form-item">
  287. <div class="form-text">
  288. <img src="/static/img/icon-wallet.png" class="icon">
  289. <span>钱包特惠支付(余额:¥${balance})</span>
  290. </div>
  291. <div class="select">
  292. <input type="radio" name="pay" value="balance" class="redcheck" id="pay">
  293. </div>
  294. </div>
  295. <div class="wallet-money show">
  296. <div class="swiper-container wallet-container">
  297. <div class="swiper-wrapper">
  298. <c:forEach var="item" items="${cons}">
  299. <div class="swiper-slide" data-id="${item.id}" data-jine="${item.jine}">
  300. <div class="sum">
  301. <i class="bar">赠送${item.zsong}元</i>
  302. <span>${item.jine}</span>
  303. </div>
  304. </div>
  305. </c:forEach>
  306. </div>
  307. </div>
  308. <div class="swiper-button-next"></div>
  309. <div class="swiper-button-prev"></div>
  310. </div>
  311. </c:if>
  312. </div>
  313. <input type="hidden" id="usertotalbalance" value="${balance}"/>
  314. <form class="form_wrap" method="post" accept-charset="utf-8">
  315. <div class="bottom-paybox">
  316. <div class="price">¥<strong id="total-price">${pkgInfo.price}</strong></div>
  317. <input type="hidden" name="pkgid" id="pkgid" value="${pkgInfo.pkgid}"/>
  318. <input type="hidden" name="amount" id="trxamt" value="${pkgInfo.price}"/>
  319. <input type="hidden" name="devid" id="devid" value="${devid}"/>
  320. <input type="hidden" name="type" id="type" value="1"/>
  321. <input type="hidden" name="paytype" id="paytype" value="0" />
  322. <input type="hidden" name="speedpackid" id="speedpackid" value="${!empty spkgs?spkgs[0].id:''}"/>
  323. <input type="hidden" id="pkgprice" name="pkgprice" value=""/>
  324. <input type="hidden" id="memberid" name="memberid" value=""/>
  325. <input type="hidden" id="opt" name="opt" value="${opt }"/>
  326. <div class="pay-btn">
  327. <input type="button" class="btn" value="支付" />
  328. </div>
  329. </div>
  330. </form>
  331. <!--弹层-优惠券-->
  332. <div class='menu-mask' id="PopCoupons">
  333. <div class="popbox animated fadeInUp">
  334. <h2 class="tcenter">选择优惠券</h2>
  335. <div class="popbox-con">
  336. <div class="lite-card-select btn-coupons">
  337. <div class="list">
  338. <c:forEach var="item" items="${cons}">
  339. <div class="item">
  340. <div class="name" data="满${item.coupon}减${item.discount}" data-getprice="${item.coupon}" data-price="${item.discount}">满${item.coupon}减${item.discount}</div>
  341. <div class="allow"></div>
  342. </div>
  343. </c:forEach>
  344. </div>
  345. </div>
  346. </div>
  347. <div class="icon-close" onclick="CloseBox('PopCoupons')"></div>
  348. </div>
  349. </div>
  350. <div class="mask"></div>
  351. <script>
  352. var mprice=888;
  353. var pkgprice=888;
  354. var ubalance;
  355. var thumbSwiper = new Swiper(".benefit-list", {
  356. spaceBetween: 10,
  357. slidesPerView: "auto",
  358. freeMode: true,
  359. watchSlidesProgress: true,
  360. });
  361. //钱包滑动
  362. var swiper = new Swiper(".wallet-container", {
  363. slidesPerGroup: 1,
  364. slidesPerView: 3,
  365. spaceBetween: 12,
  366. navigation: {
  367. nextEl: ".swiper-button-next",
  368. prevEl: ".swiper-button-prev",
  369. },
  370. });
  371. //选中
  372. $(".wallet-container .swiper-slide").click(function() {
  373. var obj = $(this);
  374. var isClicked = obj.hasClass("cur") ? true : false;
  375. $('.wallet-container .swiper-slide').removeClass('cur');
  376. isClicked ? null : obj.addClass("cur");
  377. if(obj.hasClass("cur")) {
  378. var mid = $(this).data("id");
  379. var mjine = $(this).data("jine");
  380. $("#memberid").val(mid);
  381. mprice=parseFloat(mjine).toFixed(2)||0;
  382. $("#total-price").html(mprice);
  383. } else {
  384. $("#memberid").val('');
  385. mprice=0;
  386. $("#total-price").html(pkgprice);
  387. }
  388. });
  389. $(".benefit-list .item").click(function() {
  390. var obj = $(this);
  391. var isClicked = obj.hasClass("cur") ? true : false;
  392. $(".benefit-list .item").removeClass("cur");
  393. isClicked ? null : obj.addClass("cur");
  394. calculateTotal(); // 统一调用计算总价函数
  395. $("#speedpackid").val(obj.hasClass("cur")?obj.data("speedpackid"):'');
  396. });
  397. $(".btn-coupons .item").click(function() {
  398. var obj = $(this);
  399. var isClicked = obj.hasClass("active") ? true : false;
  400. $(".btn-coupons .item").removeClass("active");
  401. isClicked ? null : obj.addClass("active");
  402. if (isClicked) {
  403. $("#coupons").text('选择优惠券');
  404. } else {
  405. $("#coupons").text($(this).find(".name").attr("data"));
  406. }
  407. var popCouponsElement = document.getElementById('PopCoupons');
  408. setTimeout(function() {
  409. if (popCouponsElement) {
  410. popCouponsElement.style.display = "none";
  411. }
  412. }, 500);
  413. calculateTotal(); // 统一调用计算总价函数
  414. });
  415. $(".redcheck").click(function() {
  416. var ptype = $(this).val();
  417. if(ptype == 'wx'){
  418. $("#total-price").html(pkgprice);
  419. $(".wallet-money").hide();
  420. } else if(ptype == 'balance') {
  421. $("#total-price").html(mprice);
  422. $(".wallet-money").show();
  423. }
  424. });
  425. // 统一的总价计算函数
  426. function calculateTotal() {
  427. var productPrice = parseFloat($("#price").text()); // 商品价格
  428. var speedPackagePrice = 0; // 加速套餐价格
  429. var couponPrice = 0; // 优惠券金额
  430. var getPrice = 0; // 优惠券使用门槛
  431. // 获取选中的加速套餐价格
  432. if ($(".benefit-list .item.cur").length > 0) {
  433. speedPackagePrice = parseFloat($(".benefit-list .item.cur").attr("data-price"))||0;
  434. }
  435. // 获取选中的优惠券金额
  436. if ($("#PopCoupons .item.active").length > 0) {
  437. getPrice = parseFloat($("#PopCoupons .item.active .name").attr("data-getprice"))||0;
  438. couponPrice = parseFloat($("#PopCoupons .item.active .name").attr("data-price"))||0;
  439. // 检查是否满足优惠券使用条件
  440. var totalPriceBeforeCoupon = productPrice + speedPackagePrice;
  441. if (getPrice > totalPriceBeforeCoupon) {
  442. couponPrice = 0;
  443. }
  444. }
  445. // 计算总价:商品价格 + 加速套餐价格 - 优惠券金额
  446. var totalPrice = productPrice + speedPackagePrice - couponPrice;
  447. pkgprice=totalPrice;
  448. mprice=totalPrice;
  449. $("#total-price").html(totalPrice.toFixed(2));
  450. $("#trxamt").val(totalPrice.toFixed(2));
  451. if($(".redcheck:checked").val() == 'balance') {
  452. var usertotalbalance = parseFloat($("#usertotalbalance").val());
  453. ubalance=usertotalbalance;
  454. if(usertotalbalance >= pkgprice) {
  455. $(".wallet-money").hide();
  456. } else {
  457. $(".wallet-money").show();
  458. $(".wallet-container .swiper-slide").each(function(i) {
  459. var mjine = $(this).data("jine");
  460. var fmjine = parseFloat(mjine);
  461. if(fmjine>=pkgprice) {
  462. $(this).trigger("click");
  463. swiper.slideTo(i);
  464. }
  465. });
  466. }
  467. }
  468. }
  469. // 页面加载完成后初始化计算一次总价
  470. $(document).ready(function() {
  471. calculateTotal();
  472. var isRequesting = false;
  473. $(".pay-btn").click(function(e){
  474. if (isRequesting) return;
  475. isRequesting = true;
  476. $(".mask").show();
  477. var input = $('.form_wrap').find('input,select'), param = {};
  478. input.each(function(i,item){
  479. item = $(item);
  480. var vType = item.attr('vtype'), ind = 0;
  481. param[item.attr('name')] = item.val();
  482. //alert(item);
  483. });
  484. var paytype = $(".redcheck:checked").val();
  485. if(paytype == "alipay") {
  486. if (!navigator.userAgent.match(/MicroMessenger/i)) {
  487. alert("请使用微信访问!");
  488. $('.mask').hide();
  489. isRequesting = false;
  490. return;
  491. }
  492. param['amount']=pkgprice;
  493. $.post('/mifi/toalipay.do',param,function(res){
  494. $('.mask').hide();
  495. if(typeof(res) === 'string'){
  496. res = JSON.parse(res);
  497. }
  498. if(res.status !== "200"){
  499. alert(res.msg);
  500. }else{
  501. location.href = res.pay_info;
  502. }
  503. isRequesting = false;
  504. });
  505. } else if(paytype == "balance") {
  506. if(ubalance>=pkgprice) {
  507. param['amount']=pkgprice;
  508. $.post('/mifi/buyBalance.do',param,function(res){
  509. $('.mask').hide();
  510. if(res == 'OK'){
  511. alert("支付成功");
  512. location.href = "/device/getDevInfo.do?sn="+$("#devid").val();
  513. } else {
  514. alert(res);
  515. if(res == '用户余额不足!'){
  516. location.href = "/mifi/getMember.do";
  517. }
  518. }
  519. isRequesting = false;
  520. },'json');
  521. } else {
  522. if (!navigator.userAgent.match(/MicroMessenger/i)) {
  523. alert("请使用微信访问!");
  524. $('.mask').hide();
  525. isRequesting = false;
  526. return;
  527. }
  528. param['amount']=mprice;
  529. param['pkgprice']=pkgprice;
  530. if(isNaN(pkgprice)){
  531. location.reload();
  532. }
  533. param['type']=2;
  534. var memberid = $("#memberid").val();
  535. if(memberid==''||mprice==0){
  536. alert("请选择金额!");
  537. $('.mask').hide();
  538. isRequesting = false;
  539. return;
  540. } else if(mprice<pkgprice){
  541. alert("金额不足,请重新选择金额!");
  542. $('.mask').hide();
  543. isRequesting = false;
  544. return;
  545. } else {
  546. $.post('/mifi/toalipay.do',param,function(res){
  547. $('.mask').hide();
  548. if(typeof(res) === 'string'){
  549. res = JSON.parse(res);
  550. }
  551. if(res.status !== "200"){
  552. alert(res.msg);
  553. }else{
  554. location.href = res.pay_info;
  555. }
  556. isRequesting = false;
  557. });
  558. }
  559. }
  560. } else if(paytype == "wx"){
  561. alert("请联系在线客服充值!");
  562. $('.mask').hide();
  563. isRequesting = false;
  564. return;
  565. } else {
  566. alert("请选择支付方式!");
  567. $('.mask').hide();
  568. isRequesting = false;
  569. return;
  570. }
  571. });
  572. });
  573. </script>
  574. </body>
  575. </html>