Files
juipnet/Host/Views/Product/rebuy.cshtml
“wanyongkang” 100b484a3d http->https
2024-03-19 15:49:56 +08:00

445 lines
19 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
@using Hncore.Pass.Vpn.Response.Product
@using Hncore.Infrastructure.Extension
@using Hncore.Pass.BaseInfo.Response
@using Hncore.Infrastructure.Serializer;
@using Hncore.Pass.BaseInfo.Service
@model PackageInfoResponse
@inject UserService m_UserService
@{
ViewData["Title"] = "购买产品";
UserLoginModel user = null;
Hncore.Pass.BaseInfo.Models.User userEntity = new Hncore.Pass.BaseInfo.Models.User();
if (this.Context.Request.Cookies.TryGetValue("userInfo", out string userCookie))
{
user = userCookie.FromJsonTo<UserLoginModel>();
userEntity = await m_UserService.GetById(user.Id);
}
}
<script src="~/js/vue.js"></script>
<script type="text/javascript">
let realverify = {
cookie:document.cookie,
}
$.ajax({
type: 'POST',
async:false,
url: 'https://php-api.juip.com/api/Realname/index',
dataType: "json",
contentType: "application/json",
data: JSON.stringify(realverify),
beforeSend: function(xhr) {
xhr.withCredentials = true;
},
crossDomain: true,
success: function (res) {
if (res.Code == -10000) {
alert('接主管部门要求,会员需要实名认证方可使用该产品,点击确定进入实名认证。');
window.location.href="/User/Index";
}
}
});
$(function () {
$('.spinner .btn:first-of-type').on('click', function () {
$('.spinner input').val(parseInt($('.spinner input').val(), 10) + 1);
});
$('.spinner .btn:last-of-type').on('click', function () {
$('.spinner input').val(parseInt($('.spinner input').val(), 10) - 1);
});
$(".dan").addClass("cu");
$(".dan").click(function () {
$(this).addClass("cu");
$(".pi").removeClass("cu");
$(".t1").show();
$(".t2").hide();
});
$(".pi").click(function () {
$(this).addClass("cu");
$(".dan").removeClass("cu");
$(".t1").hide();
$(".t2").show();
})
})
</script>
<vc:pay-wait></vc:pay-wait>
<vc:pay-ok></vc:pay-ok>
<div class="container-fluid top">
<div class="container">
<div class="row">
<div class="col-lg-3 text-right" style="padding-top:20px;">
当前已选产品:
</div>
<div class="col-lg-6" style="padding-top:20px;">
<div>
<div style="float:left; font-size: 25px; font-weight: bold; color: #ee7a69;"><span style="color:black;">
@Model.Product.Name - @Model.Package.Name </span> &nbsp;
@if(Model.Package.Price < 60 && (Model.Package.Id == 64||Model.Package.Id == 1004)){
<div style="float:right;">¥60.00</div>
} else {
@if (Model.Package.IsTest == 0) {
<div style="float:right;">¥@Model.Package.Price 元</div>
} else {
<div style="float:right;">¥1.0元</div>
}
}
</div>
</div>
<br><br>
<p class="tishi tishika" style="text-align:left;padding:0;">*请务必选好所需商品,换货会产生费用</p>
@if (Model.Package.Name == "天卡")
{
<p class="tishi " style="text-align:left">*天卡不支持退款,请谨慎购买</p>
}
</div>
<div class="col-lg-3">
<a href="javascript:history.go(-1)">返回重新选择》</a>
</div>
</div>
</div>
</div>
<div id="app">
<!-- con -->
<div class="container zhuce">
<div class="reg_tab">
<div class="item dan active_dan">
续费
</div>
</div>
</div>
<div class="container t1">
<form action="~/product/CreateOrder" method="post" id="accountForm">
<input type="hidden" name="PackageId" value="@Model.Package.Id" />
<input type="hidden" name="OrderType" value="1" />
<div class="row">
<div class="col-lg-4 text-right">
IP产品账号
</div>
<div class="col-lg-4 regDan">
<input type="text" name="Account" value="" v-model="OneBuyModel.Account" disabled />
<p class="jinggao" id="sAccountTip"></p>
</div>
<div class="col-lg-4 text-left warnText">
<sapn class="grayText">支持10位以内字母数字</sapn>
</div>
</div>
@*<div class="row">
<div class="col-lg-4 text-right">
IP产品密码
</div>
<div class="col-lg-4 regDan">
<input type="text" name="Pwd" v-model="OneBuyModel.Pwd" />
</div>
<div class="col-lg-4 text-left">
<span class="grayText">支持6位以内字母数字</span>
</div>
</div>*@
<div class="row">
<div class="col-lg-4 text-right">
连接数:
</div>
<div class="col-lg-4">
<div class="buchang">
<div class="item">
{{OneBuyModel.ConnectCount}}
</div>
</div>
</div>
<div class="col-lg-4 text-left">
<span></span>
</div>
</div>
<div class="row">
<div class="col-lg-4 text-right">
选择优惠券:
</div>
<div class="col-lg-4 regDan">
<div class="dropdown">
<select name="" class="btn btn-default dropdown-toggle" v-model="OneBuyModel.CouponId">
<option value="0">请选择优惠券</option>
<option v-for="item in Coupons" :value="item.Id">{{item.Name}}</option>
</select>
</div>
</div>
<div class="col-lg-4 text-left">
<span class="grayText">淘宝每次下单获得优惠券</span>
</div>
</div>
<div class="row">
<div class="col-lg-4 text-right">
余额:
</div>
<div class="col-lg-4">
当前账户余额<span class="blueText">@(userEntity.RestAmount)</span>元
<a href="/User/Index">前往充值</a>
</div>
<div class="col-lg-4">
</div>
</div>
<div class="row">
<div class="col-lg-4 text-right">
支付方式:
</div>
<div class="col-lg-4 zhifufangshi">
<input id="zhifubaopay_s1" type="radio" name="OPayType" value="100" checked v-model="OneBuyModel.OPayType"> <img src="~/img/zfb.png"><label for="zhifubaopay_s1">支付宝支付</label>
<input id="weixinpay_s1" type="radio" name="OPayType" value="70" v-model="OneBuyModel.OPayType"> <img src="~/img/wx.png"><label for="weixinpay_s1">微信支付</label>
<input id="UseAccountAmount_s1" type="radio" name="OPayType" value="1" v-model="OneBuyModel.UseAccountAmount"> <label for="UseAccountAmount_s1">余额支付</label>
</div>
<div class="col-lg-4 text-left">
<span></span>
</div>
</div>
<div class="row">
<div class="col-lg-4 text-right">
总金额:
</div>
<div class="col-lg-4">
<span class="blueText">{{TotalAmount}}</span>元
</div>
<div class="col-lg-4 text-left">
<span></span>
</div>
</div>
<div class="row">
<div class="col-lg-4 text-right">
应付款:
</div>
<div class="col-lg-4">
<span style="font-size: 30px;font-weight: bold;">{{PayAmount}}</span>元
<span>{{auto_discount_text}}</span>
</div>
<div class="col-lg-4 text-left">
<span></span>
</div>
</div>
<p class="ijiao-tip" style="color:red">{{Tip}}</p>
<p class="tijiao"><button class="btn btn-primary pay-botton" type="button" v-on:click="onePay">确认支付</button></p>
</form>
</div>
<!-- 支付弹窗开始 -->
<div class="payMask">
<div class="payCon">
<img src="~/img/close.png" class="payClose" v-on:click="close">
<p class="payTit"><img src="~/img/wx.png">微信支付 收银台</p>
<div class="row">
<div class="col-lg-6 text-center">
@*<p>订单将在25分钟后关闭请及时付款</p>*@
<p>
@*<img id="wxPayQr" src="img/ewm.png">*@
<div id="qrcode" style="width:200px;height:200px"></div>
</p>
@*<p>二维码已经失效,请刷新后重新扫码支付</p>*@
</div>
<div class="col-lg-6 text-left leftBorder">
<p>新开订单</p>
<p class="payPrice">¥<span>{{OrderInfo.OtherPayAmount}}</span></p>
<p>收款方聚IP</p>
<p>下单时间:<span>{{OrderInfo.CreateTime}}</span></p>
<p>订单号:<span>{{OrderInfo.OrderNo}}</span></p>
</div>
</div>
</div>
</div>
<!-- 支付弹窗结束 -->
<div id="aliPayBox" style="display:none"></div>
</div>
@section Scripts{
<script>
var productId =@(Model.Product.Id);
var app = new Vue({
el: '#app',
data: {
auto_discount_text:'',
payHandler: null,
Tip:'',
RestAmount: @(userEntity.RestAmount),
Coupons: [],
SelectCoupon: {},
OrderInfo: {},
OneBuyModel: {
Price:@(Model.Package.Price),
PackageId:@(Model.Package.Id),
OrderType: @ViewBag.orderType,
Account: '@ViewBag.accounts',
CouponAmount: 0,
Pwd: '',
ConnectCount: @(ViewBag.ConnectCount),
CouponId: 0,
UseAccountAmount: 0,
OPayType: 100,
PayChannel:50,
}
},
computed: {
TotalAmount: function () {
var count = this.OneBuyModel.Account.split(',').length;
var total = this.OneBuyModel.Price * this.OneBuyModel.ConnectCount * count;
//西瓜极客优惠券
if((@(Model.Package.Id) == 64||@(Model.Package.Id) == 1004) && @(Model.Package.Price)<60){
total = this.OneBuyModel.ConnectCount * 60.00 * count
}
return total.toFixed(2);
},
PayAmount: function () {
var count = this.OneBuyModel.Account.split(',').length;
var restAmout = this.OneBuyModel.UseAccountAmount == 1 ? this.RestAmount : 0;
var total = this.OneBuyModel.Price * this.OneBuyModel.ConnectCount * count - this.OneBuyModel.CouponAmount ;
total= total < 0 ? 0 : total;
total = parseFloat(total.toFixed(2));
//最低价
var min_cost = @(Model.Package.MinPrice) * this.OneBuyModel.ConnectCount * count - this.OneBuyModel.CouponAmount;
if(total<min_cost){
total = min_cost;
}
return total.toFixed(2);
}
},
watch: {
'OneBuyModel.CouponId': { //加引号监听对象里的属性
handler: function (newValue, oldValue) {
if( this.OneBuyModel.CouponId == 10000000){
return;
}
var totalAmount = this.OneBuyModel.Price * this.OneBuyModel.ConnectCount;
for (var i = 0; i < this.Coupons.length; i++) {
var item = this.Coupons[i];
if (totalAmount < item.AllowMinAmount) {
continue;
}
if (item.Id == newValue) {
if (item.CouponType == 1) {//满减
this.OneBuyModel.CouponAmount = item.CouponValue;
} else {
//亲 请勿非法操作呦^.^ 请按照正常的流程操作 我们后台是有记录滴
if($(".sname").text() == '天卡'){
this.OneBuyModel.CouponAmount = totalAmount * item.CouponValue * 0.1;
} else {
alert('非天卡无效');
this.OneBuyModel.CouponId = '0';
}
}
return;
}
}
},
immediate: true
},
'OneBuyModel.OPayType': { //加引号监听对象里的属性
handler: function (newValue, oldValue) {
this.OneBuyModel.UseAccountAmount = false;
this.OneBuyModel.PayChannel = newValue == 70 ? 30 : 50;
},
immediate: true
}
},
mounted: function () {
this.getCoupons();
},
created () {
this.OneBuyModel.CouponId = 10000000
},
methods: {
getCoupons: function () {
var that = this;
var url = '/api/sells/v1/coupon/GetAvailableCoupon';
$.ajax({
type: 'GET',
url: url,
success: function (res) {
console.log(res);
if (res.Code == 10000) {
if(@(Model.Package.Id) == 64||@(Model.Package.Id) == 1004){
var coupon_json = {
"Coupon":{
"Id":10000000,
"Name":"极客-西瓜-满减劵",
}
}
res.Data.push(coupon_json);
}
that.Coupons = res.Data.map(m => m.Coupon);
}
}
})
},
onePay: function () {
if (this.OneBuyModel.UseAccountAmount) {
if (this.RestAmount < this.PayAmount){
alert('余额不足,请充值。您也可以使用微信、支付宝支付。');return;
} else {
this.RestAmount = this.RestAmount - this.PayAmount;
}
}
var that = this;
if (this.OneBuyModel.UseAccountAmount === true) this.OneBuyModel.UseAccountAmount = 1;
if (this.OneBuyModel.UseAccountAmount === false) this.OneBuyModel.UseAccountAmount = 0;
showPayWait();
$.ajax({
type: 'POST',
url: '/product/CreateOrder',
dataType: "json",
contentType: "application/json",
data: JSON.stringify(this.OneBuyModel),
success: function (res) {
console.log(res);
if (res.Code == 10000) {
hidePayWait();
if (res.Data == "00") {
alert("续费成功");
} else {
that.payCallback(res.Data)
that.isPay(res.Data.OrderInfo.OrderNo);
}
} else {
//that.Tip = res.Message;
tipPayWait(res.Message);
}
}
});
},
payCallback: function (data) {
this.OrderInfo = data.OrderInfo;
var payType = this.OrderInfo.PayType;
if (payType == 70) {
$(".payMask").show();
$('#qrcode').qrcode(data.PayData);
} else if (payType == 100) {
$("#aliPayBox").html(data.PayData);
}
},
isPay: function (orderNo) {
var that = this;
this.payHandler = setInterval(function () {
var url = '/product/IsPay?orderNo=' + orderNo;
$.ajax({
type: 'GET',
url: url,
success: function (res) {
if (res.Code == 10000 && res.Data == 1) {
clearInterval(that.payHandler);
$(".payMask").hide();
showPayOk();
//window.location.href = "/user/myaccounts";
}
}
})
}, 3000)
},
close() {
clearInterval(this.payHandler);
$('.payMask').hide();
$('#qrcode').empty();
}
}
})
</script>
}