| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603 |
- <%@ page language="java" pageEncoding="UTF-8"%>
- <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8" />
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=yes" />
- <meta name="renderer" content="webkit">
- <meta http-equiv="Cache-Control" content="no-siteapp" />
- <meta name="applicable-device" content="mobile">
- <meta name="format-detection" content="telephone=no" />
- <meta http-equiv="title" content="" />
- <title>购买套餐</title>
- <meta name="description" content="" />
- <meta name="keywords" content="" />
- <link rel="stylesheet" href="/static/css/animate.min.css" type="text/css" media="all" />
- <link rel="stylesheet" href="/static/css/style.css" type="text/css" media="all" />
- <link rel="stylesheet" href="/static/css/swiper-bundle.min.css" type="text/css" media="all" />
- <script language="javascript" type="text/javascript" src="/static/js/jquery-3.6.0.min.js"></script>
- <script language="javascript" type="text/javascript" src="/static/js/animate.min.js"></script>
- <script language="javascript" type="text/javascript" src="/static/js/main.js"></script>
- <script language="javascript" type="text/javascript" src="/static/js/swiper-bundle.min.js"></script>
- <style>
- .form-wallet{
- border-bottom: 1px solid #f0f0f0;
- }
- .form-wallet .form-item{
- border-bottom: none;
- }
- .wallet-money{
- display: none;
- width: 100%;
- padding: 2px 25px;
- height:65px;
- position: relative;
- }
- .wallet-money.show{
- display: block;
- }
- .wallet-container{
- display: block;
- width: 100%;
- min-height:45px;
- position: relative;
- list-style: none;
- overflow: hidden;
- z-index: 1;
- }
- .wallet-container .swiper-slide{
- display: block;
- width: 33.33%;
- height: 45px;
- position: relative;
- border-radius: 8px;
- overflow: hidden;
- background-color: #FFFFFF;
- border: 1px solid #e8e8e8;
- }
- .wallet-container .swiper-slide.cur{
- border: 1px solid #cb5f1f;
- }
- .wallet-container .swiper-slide img{
- display: block;
- width: 100%;
- max-height: auto;
- }
- .wallet-container .swiper-slide .sum{
- position: relative;
- display: block;
- justify-content: center;
- align-items: center;
- width: 100%;
- height: 100%;
- font-size: 14px;
- line-height: 2;
- font-family: Arial;
- font-weight: bold;
- text-align: center;
- padding-top: 0;
- }
- .wallet-container .swiper-slide .sum i{
- display: block;
- width: 100%;
- font-size: 9px;
- height: 15px;
- line-height: 16px;
- color: #FFF;
- background-color: #dd170e;
- }
- .wallet-container .swiper-slide .sum::after{
- content: '';
- position: absolute;
- top: 0;
- left: 0;
- display: none;
- width: 100%;
- height: 10px;
- background-color: #dd170e;
- }
- .swiper-button-prev{
- left: 0;
- }
- .swiper-button-next{
- right: 0;
- }
- .swiper-button-prev,.swiper-button-next{
- top: 17px;
- margin-top: 0;
- width: 15px;
- height: 15px;
- opacity: 0.6;
- }
- .swiper-button-disabled{
- opacity: 0.2;
- }
- .swiper-button-next:after,.swiper-button-prev:after{
- color: #929292;
- font-size: 18px;
- }
- .swiper-button-next:hover:after,.swiper-button-prev:hover:after{
- color: #FF6600;
- }
- </style>
- </head>
- <body>
- <div class="box">
- <div class="recharge-top">
- <div class="pic">
- <img src="/static/img/img-recharge.png" alt="">
- </div>
- <div class="text">
- <div class="title">${pkgInfo.pkgName}</div>
- <div class="desc"></div>
- <div class="price">¥<strong id="price">${pkgInfo.price}</strong></div>
- </div>
- </div>
- </div>
- <div class="box benefit-box">
- <div class="benefit-list swiper">
- <div class="swiper-wrapper">
- <c:forEach var="item" items="${spkgs}" varStatus="loop">
- <div class="item swiper-slide ${loop.index==0?' cur':''}" data-price="${item.price}" data-speedpackid="${item.id}">
- <div class="wrap">
- <i class="icon"><img src="/static/img/icon-diamond${item.id%2+1}.png"></i>
- <div class="title">${item.name}</div>
- <div class="desc">${item.desc}</div>
- <div class="price">¥<strong>${item.price}</strong></div>
- <div class="valid">有效期:
- <c:choose>
- <c:when test="${item.expiryDay == 0 }">1天</c:when>
- <c:when test="${item.expiryDay == 1 }">30天</c:when>
- <c:when test="${item.expiryDay == 2 }">90天</c:when>
- <c:when test="${item.expiryDay == 3 }">半年</c:when>
- <c:when test="${item.expiryDay == 4 }">1年</c:when>
- <c:when test="${item.expiryDay == 5 }">两年</c:when>
- <c:when test="${item.expiryDay == 6 }">7天</c:when>
- <c:when test="${item.expiryDay == 7 }">3年</c:when>
- <c:when test="${item.expiryDay == 8 }">3天</c:when>
- <c:when test="${item.expiryDay == 9 }">两天</c:when>
- <c:when test="${item.expiryDay == 11 }">7个月</c:when>
- <c:when test="${item.expiryDay == 12 }">14个月</c:when>
- <c:when test="${item.expiryDay == 18 }">15个月</c:when>
- <c:when test="${item.expiryDay == 13 }">两年半</c:when>
- <c:when test="${item.expiryDay == 14 }">3年8个月</c:when>
- <c:when test="${item.expiryDay == 15 }">4年 </c:when>
- <c:when test="${item.expiryDay == 16 }">5年</c:when>
- <c:when test="${item.expiryDay == 17 }">6年</c:when>
- </c:choose>
- </div>
- <div class="select"><i></i></div>
- </div>
- </div>
- </c:forEach>
- </div>
- </div>
- </div>
- <div class="box">
- <div class="form-item">
- <label>充值设备号</label>
- <div class="form-text">${devid}</div>
- </div>
- <div class="form-item">
- <label>套餐有效期</label>
- <div class="form-text">
- <c:choose>
- <c:when test="${pkgInfo.expiryDay == 0 }">1天</c:when>
- <c:when test="${pkgInfo.expiryDay == 1 }">30天</c:when>
- <c:when test="${pkgInfo.expiryDay == 2 }">90天</c:when>
- <c:when test="${pkgInfo.expiryDay == 3 }">半年</c:when>
- <c:when test="${pkgInfo.expiryDay == 4 }">1年</c:when>
- <c:when test="${pkgInfo.expiryDay == 5 }">两年</c:when>
- <c:when test="${pkgInfo.expiryDay == 6 }">7天</c:when>
- <c:when test="${pkgInfo.expiryDay == 7 }">3年</c:when>
- <c:when test="${pkgInfo.expiryDay == 8 }">3天</c:when>
- <c:when test="${pkgInfo.expiryDay == 9 }">两天</c:when>
- <c:when test="${pkgInfo.expiryDay == 11 }">7个月</c:when>
- <c:when test="${pkgInfo.expiryDay == 12 }">14个月</c:when>
- <c:when test="${pkgInfo.expiryDay == 18 }">15个月</c:when>
- <c:when test="${pkgInfo.expiryDay == 13 }">两年半</c:when>
- <c:when test="${pkgInfo.expiryDay == 14 }">3年8个月</c:when>
- <c:when test="${pkgInfo.expiryDay == 15 }">4年 </c:when>
- <c:when test="${pkgInfo.expiryDay == 16 }">5年</c:when>
- <c:when test="${pkgInfo.expiryDay == 17 }">6年</c:when>
- </c:choose>
- </div>
- </div>
- <div class="form-item">
- <label>全国通用</label>
- <div class="form-text">移动、联通、电信三网合一自由切换</div>
- </div>
- <div class="form-item">
- <label>套餐价格</label>
- <div class="form-text">¥${pkgInfo.price}</div>
- </div>
- <div class="form-item" onclick="ShowBox('PopCoupons')">
- <label>优惠券</label>
- <div class="form-text" id="coupons">选择优惠券</div>
- </div>
- </div>
- <div class="box mb70">
- <c:if test="${pkgInfo.paytype == 1}">
- <div class="form-item">
- <div class="form-text">
- <img src="/static/img/icon-wallet.png" class="icon">
- <span>钱包特惠支付(余额:¥${balance})</span>
- </div>
- <div class="select">
- <input type="radio" name="pay" value="balance" class="redcheck" id="pay">
- </div>
- </div>
- <div class="wallet-money show">
- <div class="swiper-container wallet-container">
- <div class="swiper-wrapper">
- <c:forEach var="item" items="${cons}">
- <div class="swiper-slide" data-id="${item.id}" data-jine="${item.jine}">
- <div class="sum">
- <i class="bar">赠送${item.zsong}元</i>
- <span>${item.jine}</span>
- </div>
- </div>
- </c:forEach>
- </div>
- </div>
- <div class="swiper-button-next"></div>
- <div class="swiper-button-prev"></div>
- </div>
- <div class="form-item">
- <div class="form-text">
- <img src="/static/img/icon-pay-alipay.png" class="icon">
- <span>支付宝支付</span>
- </div>
- <div class="select">
- <input type="radio" name="pay" value="alipay" class="redcheck" id="pay">
- </div>
- </div>
- <div class="form-item">
- <div class="form-text">
- <img src="/static/img/icon-pay-weixin.png" class="icon">
- <span>微信支付,请联系客服充值</span>
- </div>
- <div class="select">
- <input type="radio" name="pay" value="wx" class="redcheck" id="pay">
- </div>
- </div>
- </c:if>
- <c:if test="${pkgInfo.paytype == 2}">
- <div class="form-item">
- <div class="form-text">
- <img src="/static/img/icon-pay-alipay.png" class="icon">
- <span>支付宝支付</span>
- </div>
- <div class="select">
- <input type="radio" name="pay" value="alipay" class="redcheck" id="pay">
- </div>
- </div>
- <div class="form-item">
- <div class="form-text">
- <img src="/static/img/icon-pay-weixin.png" class="icon">
- <span>微信支付,请联系客服充值</span>
- </div>
- <div class="select">
- <input type="radio" name="pay" value="wx" class="redcheck" id="pay">
- </div>
- </div>
- </c:if>
- <c:if test="${pkgInfo.paytype == 3}">
- <div class="form-item">
- <div class="form-text">
- <img src="/static/img/icon-wallet.png" class="icon">
- <span>钱包特惠支付(余额:¥${balance})</span>
- </div>
- <div class="select">
- <input type="radio" name="pay" value="balance" class="redcheck" id="pay">
- </div>
- </div>
- <div class="wallet-money show">
- <div class="swiper-container wallet-container">
- <div class="swiper-wrapper">
- <c:forEach var="item" items="${cons}">
- <div class="swiper-slide" data-id="${item.id}" data-jine="${item.jine}">
- <div class="sum">
- <i class="bar">赠送${item.zsong}元</i>
- <span>${item.jine}</span>
- </div>
- </div>
- </c:forEach>
- </div>
- </div>
- <div class="swiper-button-next"></div>
- <div class="swiper-button-prev"></div>
- </div>
- </c:if>
- </div>
- <input type="hidden" id="usertotalbalance" value="${balance}"/>
- <form class="form_wrap" method="post" accept-charset="utf-8">
- <div class="bottom-paybox">
- <div class="price">¥<strong id="total-price">${pkgInfo.price}</strong></div>
- <input type="hidden" name="pkgid" id="pkgid" value="${pkgInfo.pkgid}"/>
- <input type="hidden" name="amount" id="trxamt" value="${pkgInfo.price}"/>
- <input type="hidden" name="devid" id="devid" value="${devid}"/>
- <input type="hidden" name="type" id="type" value="1"/>
- <input type="hidden" name="paytype" id="paytype" value="0" />
- <input type="hidden" name="speedpackid" id="speedpackid" value="${!empty spkgs?spkgs[0].id:''}"/>
-
- <input type="hidden" id="pkgprice" name="pkgprice" value=""/>
- <input type="hidden" id="memberid" name="memberid" value=""/>
- <input type="hidden" id="opt" name="opt" value="${opt }"/>
- <div class="pay-btn">
- <input type="button" class="btn" value="支付" />
- </div>
- </div>
- </form>
- <!--弹层-优惠券-->
- <div class='menu-mask' id="PopCoupons">
- <div class="popbox animated fadeInUp">
- <h2 class="tcenter">选择优惠券</h2>
- <div class="popbox-con">
- <div class="lite-card-select btn-coupons">
- <div class="list">
- <c:forEach var="item" items="${cons}">
- <div class="item">
- <div class="name" data="满${item.coupon}减${item.discount}" data-getprice="${item.coupon}" data-price="${item.discount}">满${item.coupon}减${item.discount}</div>
- <div class="allow"></div>
- </div>
- </c:forEach>
- </div>
- </div>
- </div>
- <div class="icon-close" onclick="CloseBox('PopCoupons')"></div>
- </div>
- </div>
- <div class="mask"></div>
- <script>
- var mprice=888;
- var pkgprice=888;
- var ubalance;
-
- var thumbSwiper = new Swiper(".benefit-list", {
- spaceBetween: 10,
- slidesPerView: "auto",
- freeMode: true,
- watchSlidesProgress: true,
- });
- //钱包滑动
- var swiper = new Swiper(".wallet-container", {
- slidesPerGroup: 1,
- slidesPerView: 3,
- spaceBetween: 12,
- navigation: {
- nextEl: ".swiper-button-next",
- prevEl: ".swiper-button-prev",
- },
- });
- //选中
- $(".wallet-container .swiper-slide").click(function() {
- var obj = $(this);
- var isClicked = obj.hasClass("cur") ? true : false;
- $('.wallet-container .swiper-slide').removeClass('cur');
- isClicked ? null : obj.addClass("cur");
- if(obj.hasClass("cur")) {
- var mid = $(this).data("id");
- var mjine = $(this).data("jine");
- $("#memberid").val(mid);
- mprice=parseFloat(mjine).toFixed(2)||0;
- $("#total-price").html(mprice);
- } else {
- $("#memberid").val('');
- mprice=0;
- $("#total-price").html(pkgprice);
- }
-
- });
- $(".benefit-list .item").click(function() {
- var obj = $(this);
- var isClicked = obj.hasClass("cur") ? true : false;
- $(".benefit-list .item").removeClass("cur");
- isClicked ? null : obj.addClass("cur");
- calculateTotal(); // 统一调用计算总价函数
- $("#speedpackid").val(obj.hasClass("cur")?obj.data("speedpackid"):'');
- });
-
- $(".btn-coupons .item").click(function() {
- var obj = $(this);
- var isClicked = obj.hasClass("active") ? true : false;
- $(".btn-coupons .item").removeClass("active");
- isClicked ? null : obj.addClass("active");
- if (isClicked) {
- $("#coupons").text('选择优惠券');
- } else {
- $("#coupons").text($(this).find(".name").attr("data"));
- }
- var popCouponsElement = document.getElementById('PopCoupons');
- setTimeout(function() {
- if (popCouponsElement) {
- popCouponsElement.style.display = "none";
- }
- }, 500);
- calculateTotal(); // 统一调用计算总价函数
- });
-
- $(".redcheck").click(function() {
- var ptype = $(this).val();
- if(ptype == 'wx'){
- $("#total-price").html(pkgprice);
- $(".wallet-money").hide();
- } else if(ptype == 'balance') {
- $("#total-price").html(mprice);
- $(".wallet-money").show();
- }
- });
-
-
- // 统一的总价计算函数
- function calculateTotal() {
- var productPrice = parseFloat($("#price").text()); // 商品价格
- var speedPackagePrice = 0; // 加速套餐价格
- var couponPrice = 0; // 优惠券金额
- var getPrice = 0; // 优惠券使用门槛
-
- // 获取选中的加速套餐价格
- if ($(".benefit-list .item.cur").length > 0) {
- speedPackagePrice = parseFloat($(".benefit-list .item.cur").attr("data-price"))||0;
- }
-
- // 获取选中的优惠券金额
- if ($("#PopCoupons .item.active").length > 0) {
- getPrice = parseFloat($("#PopCoupons .item.active .name").attr("data-getprice"))||0;
- couponPrice = parseFloat($("#PopCoupons .item.active .name").attr("data-price"))||0;
-
- // 检查是否满足优惠券使用条件
- var totalPriceBeforeCoupon = productPrice + speedPackagePrice;
- if (getPrice > totalPriceBeforeCoupon) {
- couponPrice = 0;
- }
- }
-
- // 计算总价:商品价格 + 加速套餐价格 - 优惠券金额
- var totalPrice = productPrice + speedPackagePrice - couponPrice;
- pkgprice=totalPrice;
- mprice=totalPrice;
- $("#total-price").html(totalPrice.toFixed(2));
- $("#trxamt").val(totalPrice.toFixed(2));
-
- if($(".redcheck:checked").val() == 'balance') {
- var usertotalbalance = parseFloat($("#usertotalbalance").val());
- ubalance=usertotalbalance;
- if(usertotalbalance >= pkgprice) {
- $(".wallet-money").hide();
- } else {
- $(".wallet-money").show();
- $(".wallet-container .swiper-slide").each(function(i) {
- var mjine = $(this).data("jine");
- var fmjine = parseFloat(mjine);
- if(fmjine>=pkgprice) {
- $(this).trigger("click");
- swiper.slideTo(i);
- }
- });
- }
- }
- }
-
- // 页面加载完成后初始化计算一次总价
- $(document).ready(function() {
- calculateTotal();
-
- var isRequesting = false;
- $(".pay-btn").click(function(e){
- if (isRequesting) return;
- isRequesting = true;
- $(".mask").show();
-
- var input = $('.form_wrap').find('input,select'), param = {};
- input.each(function(i,item){
- item = $(item);
- var vType = item.attr('vtype'), ind = 0;
- param[item.attr('name')] = item.val();
- //alert(item);
- });
- var paytype = $(".redcheck:checked").val();
- if(paytype == "alipay") {
- if (!navigator.userAgent.match(/MicroMessenger/i)) {
- alert("请使用微信访问!");
- $('.mask').hide();
- isRequesting = false;
- return;
- }
- param['amount']=pkgprice;
- $.post('/mifi/toalipay.do',param,function(res){
- $('.mask').hide();
- if(typeof(res) === 'string'){
- res = JSON.parse(res);
- }
-
- if(res.status !== "200"){
- alert(res.msg);
- }else{
- location.href = res.pay_info;
- }
- isRequesting = false;
- });
- } else if(paytype == "balance") {
- if(ubalance>=pkgprice) {
- param['amount']=pkgprice;
- $.post('/mifi/buyBalance.do',param,function(res){
- $('.mask').hide();
- if(res == 'OK'){
- alert("支付成功");
- location.href = "/device/getDevInfo.do?sn="+$("#devid").val();
- } else {
- alert(res);
- if(res == '用户余额不足!'){
- location.href = "/mifi/getMember.do";
- }
- }
- isRequesting = false;
- },'json');
- } else {
- if (!navigator.userAgent.match(/MicroMessenger/i)) {
- alert("请使用微信访问!");
- $('.mask').hide();
- isRequesting = false;
- return;
- }
- param['amount']=mprice;
- param['pkgprice']=pkgprice;
- if(isNaN(pkgprice)){
- location.reload();
- }
- param['type']=2;
- var memberid = $("#memberid").val();
- if(memberid==''||mprice==0){
- alert("请选择金额!");
- $('.mask').hide();
- isRequesting = false;
- return;
- } else if(mprice<pkgprice){
- alert("金额不足,请重新选择金额!");
- $('.mask').hide();
- isRequesting = false;
- return;
- } else {
- $.post('/mifi/toalipay.do',param,function(res){
- $('.mask').hide();
- if(typeof(res) === 'string'){
- res = JSON.parse(res);
- }
-
- if(res.status !== "200"){
- alert(res.msg);
- }else{
- location.href = res.pay_info;
- }
- isRequesting = false;
- });
- }
- }
- } else if(paytype == "wx"){
- alert("请联系客服充值!");
- $('.mask').hide();
- isRequesting = false;
- return;
- } else {
- alert("请选择支付方式!");
- $('.mask').hide();
- isRequesting = false;
- return;
- }
-
- });
- });
- </script>
- </body>
- </html>
|