933 lines
41 KiB
Plaintext
933 lines
41 KiB
Plaintext
@using Hncore.Pass.Vpn.Response.Product
|
||
@using Hncore.Infrastructure.Extension
|
||
@using Hncore.Pass.BaseInfo.Response
|
||
@using Hncore.Infrastructure.Serializer;
|
||
@using Hncore.Pass.BaseInfo.Service
|
||
@using Hncore.Infrastructure.Common
|
||
@model PackageInfoResponse
|
||
@inject UserService m_UserService
|
||
@inject Hncore.Pass.Vpn.Service.ProductAccountService m_AccountService
|
||
@{
|
||
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);
|
||
}
|
||
var randomPwd = ValidateCodeHelper.MakeNumCode(3).ToLower();
|
||
var randomAccount1 = ValidateCodeHelper.MakeCharCode(3).ToLower() + ValidateCodeHelper.MakeNumCode(4).ToLower();
|
||
@* while (m_AccountService.Exist(m => m.Account == randomAccount1))
|
||
{
|
||
randomAccount1 = ValidateCodeHelper.MakeCharCode(2).ToLower() + ValidateCodeHelper.MakeNumCode(4).ToLower();
|
||
} *@
|
||
|
||
var randomAccountMutil = ValidateCodeHelper.MakeCharCode(3).ToLower();
|
||
|
||
var product_id = Model.Product.Id;
|
||
if (product_id == 20 ||product_id == 21||product_id == 26||product_id == 27) {
|
||
randomAccount1 = ValidateCodeHelper.MakeCharCode(2).ToLower() + ValidateCodeHelper.MakeNumCode(5).ToLower();
|
||
randomAccountMutil = ValidateCodeHelper.MakeCharCode(6).ToLower();
|
||
randomPwd = ValidateCodeHelper.MakeNumCode(6).ToLower();
|
||
}
|
||
}
|
||
<script src="~/js/vue.js"></script>
|
||
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
|
||
<script type="text/javascript">
|
||
$(function () {
|
||
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/IndexInfo";
|
||
}
|
||
}
|
||
});
|
||
$(".btnNav").click(function () {
|
||
$(".mask").fadeIn();
|
||
});
|
||
$(".btnClose").click(function () {
|
||
$(".mask").fadeOut();
|
||
});
|
||
|
||
$(".dan").click(function () {
|
||
$(this).addClass("zActive");
|
||
$(".pi").removeClass("zActive");
|
||
$(".conDan").show();
|
||
$(".conPi").hide();
|
||
});
|
||
$(".pi").click(function () {
|
||
$(this).addClass("zActive");
|
||
$(".dan").removeClass("zActive");
|
||
$(".conDan").hide();
|
||
$(".conPi").show();
|
||
})
|
||
})
|
||
</script>
|
||
|
||
<vc:redirecct-login></vc:redirecct-login>
|
||
<vc:pay-wait></vc:pay-wait>
|
||
<div id="app">
|
||
<div class="cpTop">
|
||
<p class="choose">当前已选产品:</p>
|
||
<div class="kArea">
|
||
<div>
|
||
<div class="col-sm-4 text-right">
|
||
<p style="font-weight:bold;font-size:2em;">@Model.Product.Name</p>
|
||
</div>
|
||
<div class="col-sm-4">
|
||
<p class="kaci" style="font-size:1.3em;">@Model.Package.Name</p>
|
||
</div>
|
||
<div class="col-sm-4 text-left">
|
||
@if(Model.Package.Price < 60 && (Model.Package.Id == 64||Model.Package.Id == 1004)){
|
||
<span class="price">¥60.00</span>
|
||
} else {
|
||
@if (Model.Package.IsTest == 0) {
|
||
<span class="price">¥@Model.Package.Price</span>
|
||
} else {
|
||
<span class="price">¥1.0</span>
|
||
}
|
||
}
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="chongxin">
|
||
<div class="item redText">
|
||
|
||
@if (Model.Package.ProductId == 20 || Model.Package.ProductId == 21)
|
||
{
|
||
<p>*无极不支持退款,请先开天卡测试</p>
|
||
} else {
|
||
<p>*请确认好产品套餐,换货将产生费用</p>
|
||
}
|
||
</div>
|
||
|
||
<div class="item">
|
||
<button type="button" class="btnBlue" onclick="history.go(-1)">返回重新选择</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
@if (Model.Package.IsTest == 0) {
|
||
<div class="row mytab">
|
||
<div class="col-sm-6 col-xs-6 text-right">
|
||
<span class="dan zActive">单个注册</span>
|
||
</div>
|
||
<div v-if="@Model.Package.Price != 0.1" class="col-sm-6 col-xs-6 text-left">
|
||
<span class="pi">批量注册</span>
|
||
</div>
|
||
</div>
|
||
}
|
||
<div class="conDan">
|
||
<div class="row">
|
||
<div class="col-sm-4 col-xs-4;" style="text-align:right;">
|
||
IP账号:
|
||
</div>
|
||
<div class="col-sm-8 col-xs-8 shuru">
|
||
<input type="text" v-model="OneBuyModel.Account" />
|
||
</div>
|
||
</div>
|
||
<div class="row">
|
||
<div class="col-sm-4 col-xs-4" style="text-align:right;">
|
||
IP账号密码:
|
||
</div>
|
||
<div class="col-sm-8 col-xs-8 shuru">
|
||
<input type="text" v-model="OneBuyModel.Pwd" v-on:blur="checkOnePwd" />
|
||
</div>
|
||
</div>
|
||
@if (Model.Package.IsTest == 0) {
|
||
<div class="row">
|
||
<div class="col-sm-4 col-xs-4" style="text-align:right;">
|
||
连接数:
|
||
</div>
|
||
<div v-if="@Model.Package.Price != 0.1" class="col-sm-8 col-xs-8">
|
||
<div class="jiajian">
|
||
<div class="item" v-on:click="OneBuyModel.ConnectCount>1&&OneBuyModel.ConnectCount--">
|
||
-
|
||
</div>
|
||
<div class="item">
|
||
<input type="text" style="width:100%;height:60px;border:0;padding-left:20px" v-model="OneBuyModel.ConnectCount" />
|
||
@*<span>{{OneBuyModel.ConnectCount}}</span>*@
|
||
</div>
|
||
<div class="item" v-on:click="OneBuyModel.ConnectCount++">
|
||
+
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div v-if="@Model.Package.Price == 0.1" class="col-sm-8 col-xs-8">
|
||
1
|
||
</div>
|
||
</div>
|
||
<div class="row">
|
||
<div class="col-sm-4 col-xs-4" style="text-align:right;">
|
||
选择优惠券:
|
||
</div>
|
||
<div class="col-sm-8 col-xs-8 select">
|
||
<select class="chooseYhq" v-model="OneBuyModel.CouponId">
|
||
<option value="volvo">选择优惠券</option>
|
||
<option v-for="item in Coupons" :value="item.Id">{{item.Name}}</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
|
||
}
|
||
<div class="row" v-if="@userEntity.is_agent == 1" style="text-align:right;">
|
||
<div class="col-sm-4 col-xs-4" style="text-align:right;">
|
||
代理下会员号:
|
||
</div>
|
||
<div class="col-sm-8 col-xs-8 shuru">
|
||
<input type="text" v-model="OneBuyModel.phone"/>
|
||
</div>
|
||
</div>
|
||
<div class="row">
|
||
<div class="col-sm-4 col-xs-4" style="text-align:right;">
|
||
余额:
|
||
</div>
|
||
<div class="col-sm-8 col-xs-8">
|
||
<div class="">
|
||
当前账户余额<span class="blueText">@(userEntity.RestAmount)</span>元
|
||
<a href="/User/Index">前往充值</a>
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="row" v-if="showPayType">
|
||
<div class="col-sm-4 col-xs-4" style="text-align:right;">
|
||
支付方式:
|
||
</div>
|
||
<div class="col-sm-8 col-xs-8 pay">
|
||
<div class="radio" v-on:click="OneBuyModel.OPayType=100">
|
||
<input id="zhifubaopay_s1" name="OPayType" type="radio" v-model="OneBuyModel.OPayType" checked value="100">
|
||
<label for="zhifubaopay_s1" class="radio-label"><img src="~/m/img/zfb.png"> 支付宝支付</label>
|
||
</div>
|
||
<div class="radio" v-on:click="OneBuyModel.OPayType=70">
|
||
<input id="weixinpay_s1" name="OPayType" type="radio" v-model="OneBuyModel.OPayType" value="70">
|
||
<label for="weixinpay_s1" class="radio-label"><img src="~/m/img/wx.png"> 微信支付</label>
|
||
</div>
|
||
<div class="radio" >
|
||
<input id="UseAccountAmount" name="OPayType" type="radio" v-model="OneBuyModel.UseAccountAmount" value="1">
|
||
<label for="UseAccountAmount" class="radio-label" style="line-height:150%"> 余额支付</label>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
<div class="row">
|
||
<div class="col-sm-4 col-xs-4" style="text-align:right;">
|
||
总金额:
|
||
</div>
|
||
<div class="col-sm-8 col-xs-8">
|
||
<span>{{OneTotalAmount}}</span>元
|
||
</div>
|
||
</div>
|
||
<div class="row">
|
||
<div class="col-sm-4 col-xs-4" style="text-align:right;">
|
||
应付款:
|
||
</div>
|
||
<div class="col-sm-8 col-xs-8">
|
||
<span class="yingfu" style="font-size: 35px;font-weight: bold;">{{OnePayAmount}}</span>元
|
||
|
||
</div>
|
||
</div>
|
||
<div class="row">
|
||
<div class="col-sm-4 col-xs-4" style="text-align:right;">
|
||
</div>
|
||
<div class="col-sm-8 col-xs-8">
|
||
<p>{{auto_discount_text}}</p>
|
||
</div>
|
||
</div>
|
||
<p class="redText songquan">{{Tip}}</p>
|
||
<div class="ok">
|
||
<button type="button" class="btnPay pay-botton" v-on:click="onePay">确认支付</button>
|
||
</div>
|
||
</div>
|
||
<div class="conPi">
|
||
<p class="shuoming">批量注册的账号会使用【账号前缀】+【开始数】+【个数】顺序进行注册,</p>
|
||
<p class="shuoming">如:注册账号前缀为【user】开始数为【2】个数为【10】,则注册的账号为:user2,user3,user4,....user11</p>
|
||
<div class="row">
|
||
<div class="col-sm-4 col-xs-4" style="text-align:right;">
|
||
IP账号前缀:
|
||
</div>
|
||
<div class="col-sm-8 col-xs-8 shuru">
|
||
<input type="text" v-on:input="changeAccountCount()" v-model="MoreBuyModel.Account" />
|
||
</div>
|
||
</div>
|
||
<div class="row">
|
||
<div class="col-sm-4 col-xs-4" style="text-align:right;">
|
||
IP开始号:
|
||
</div>
|
||
<div class="col-sm-8 col-xs-8 shuru">
|
||
<input type="number" v-on:input="changeAccountCount()" v-model="MoreBuyModel.MinPostfix" />
|
||
</div>
|
||
</div>
|
||
<div class="row">
|
||
<div class="col-sm-4 col-xs-4" style="text-align:right;">
|
||
IP注册个数:
|
||
</div>
|
||
<div class="col-sm-8 col-xs-8 shuru">
|
||
<input type="number" v-on:input="changeAccountCount()" v-model="MoreBuyModel.MaxPostfix" />
|
||
</div>
|
||
</div>
|
||
<div class="row">
|
||
<div class="col-sm-4 col-xs-4" style="text-align:right;">
|
||
即将生成的账号:
|
||
</div>
|
||
<div class="col-sm-8 col-xs-8 shuru">
|
||
<p class="jinggao">{{acount_list}}</p>
|
||
</div>
|
||
</div>
|
||
<div class="row">
|
||
<div class="col-sm-4 col-xs-4" style="text-align:right;">
|
||
IP账号密码:
|
||
</div>
|
||
<div class="col-sm-8 col-xs-8 shuru">
|
||
<input type="text" v-model="MoreBuyModel.Pwd" />
|
||
</div>
|
||
</div>
|
||
<div class="row">
|
||
<div class="col-sm-4 col-xs-4" style="text-align:right;">
|
||
连接数:
|
||
</div>
|
||
<div class="col-sm-4 col-xs-4" style="text-align:right;">
|
||
<div class="jiajian">
|
||
<div class="item" @@click="MoreBuyModel.ConnectCount>1&&MoreBuyModel.ConnectCount--">
|
||
-
|
||
</div>
|
||
<div class="item">
|
||
<input type="text" style="width:100%;height:60px;border:0;padding-left:20px" v-model="MoreBuyModel.ConnectCount" />
|
||
</div>
|
||
<div class="item" @@click="MoreBuyModel.ConnectCount++">
|
||
+
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="col-sm-8 col-xs-8">
|
||
@*<span class="quanxian">超过10个请联系客服开通</span>*@
|
||
</div>
|
||
</div>
|
||
<div class="row">
|
||
<div class="col-sm-4 col-xs-4" style="text-align:right;">
|
||
选择优惠券:
|
||
</div>
|
||
<div class="col-sm-8 col-xs-8 select">
|
||
<select class="chooseYhq" v-model="MoreBuyModel.CouponId">
|
||
<option value="volvo">选择优惠券</option>
|
||
<option v-for="item in Coupons" :value="item.Id">{{item.Name}}</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
<div class="row" v-if="@userEntity.is_agent == 1">
|
||
<div class="col-sm-4 col-xs-4" style="text-align:right;">
|
||
代理下会员号:
|
||
</div>
|
||
<div class="col-sm-8 col-xs-8 shuru">
|
||
<input type="text" v-model="MoreBuyModel.phone"/>
|
||
</div>
|
||
</div>
|
||
<div class="row">
|
||
|
||
<div class="col-sm-4 col-xs-4" style="text-align:right;">
|
||
余额:
|
||
</div>
|
||
<div class="col-sm-8 col-xs-8">
|
||
<div class="">
|
||
当前账户余额<span class="blueText">@(userEntity.RestAmount)</span>元
|
||
<a href="/User/Index">前往充值</a>
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="row" v-if="showPayType">
|
||
<div class="col-sm-4 col-xs-4" style="text-align:right;">
|
||
支付方式:
|
||
</div>
|
||
<div class="col-sm-8 col-xs-8 pay">
|
||
<div class="radio" v-on:click="MoreBuyModel.OPayType=100">
|
||
<input id="zhifubaopay_s" name="radio" type="radio" value="100" checked v-model="MoreBuyModel.OPayType">
|
||
<label for="zhifubaopay_s" class="radio-label"><img src="~/m/img/zfb.png"> 支付宝支付</label>
|
||
</div>
|
||
<div class="radio" v-on:click="MoreBuyModel.OPayType=70">
|
||
<input id="weixinpay_s" name="radio" type="radio" value="70" v-model="MoreBuyModel.OPayType">
|
||
<label for="weixinpay_s" class="radio-label"><img src="~/m/img/wx.png"> 微信支付</label>
|
||
</div>
|
||
<div class="radio" >
|
||
<input id="UseAccountAmount_s" name="radio" type="radio" v-model="MoreBuyModel.UseAccountAmount" value="1">
|
||
<label for="UseAccountAmount_s" class="radio-label" style="line-height:150%"> 余额支付</label>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
<div class="row">
|
||
<div class="col-sm-4 col-xs-4" style="text-align:right;">
|
||
总金额:
|
||
</div>
|
||
<div class="col-sm-8 col-xs-8">
|
||
<span>{{MoreTotalAmount}}</span>元
|
||
</div>
|
||
</div>
|
||
<div class="row">
|
||
<div class="col-sm-4 col-xs-4" style="text-align:right;">
|
||
应付款:
|
||
</div>
|
||
<div class="col-sm-8 col-xs-8">
|
||
<span class="yingfu">{{MorePayAmount}}</span>元
|
||
</div>
|
||
</div>
|
||
<div class="row">
|
||
<div class="col-sm-4 col-xs-4" style="text-align:right;">
|
||
</div>
|
||
<div class="col-sm-8 col-xs-8">
|
||
<p>{{auto_discount_text}}</p>
|
||
</div>
|
||
</div>
|
||
<p class="redText songquan">{{Tip}}</p>
|
||
<div class="ok">
|
||
<button type="button" class="btnPay pay-botton" @@click="morePay">确认支付</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<!-- 支付弹窗结束 -->
|
||
|
||
<div id="aliPayBox" style="display:none"></div>
|
||
|
||
|
||
@section Scripts{
|
||
<script>
|
||
var productId =@(Model.Product.Id);
|
||
/** 表单序列化成json字符串的方法 */
|
||
function form2JsonString(formId) {
|
||
var paramArray = $('#' + formId).serializeArray();
|
||
var jsonObj = {};
|
||
$(paramArray).each(function () {
|
||
jsonObj[this.name] = this.value;
|
||
});
|
||
console.log(jsonObj);
|
||
return JSON.stringify(jsonObj);
|
||
}
|
||
|
||
var app = new Vue({
|
||
el: '#app',
|
||
data: {
|
||
auto_discount_text:'',
|
||
acount_list:'',
|
||
showPayType:true,
|
||
payHandler:null,
|
||
Tip:'',
|
||
RestAmount: @(userEntity.RestAmount),
|
||
Coupons: [],
|
||
SelectCoupon: {},
|
||
OrderInfo: {},
|
||
OneChecker: {
|
||
AccountOk: true,
|
||
PwdOk:true
|
||
},
|
||
MoreChecker: {
|
||
AccountOk: true,
|
||
PwdOk: true,
|
||
Max:10,
|
||
},
|
||
OneBuyModel: {
|
||
Price:@(Model.Package.Price),
|
||
PackageId:@(Model.Package.Id),
|
||
CouponAmount: 0,
|
||
OrderType: 1,
|
||
Account: '@(randomAccount1)',
|
||
Pwd: '@(randomPwd)',
|
||
ConnectCount: 1,
|
||
CouponId: 0,
|
||
UseAccountAmount: 0,
|
||
OPayType: 100,
|
||
PayChannel:40,
|
||
phone:''
|
||
},
|
||
MoreBuyModel: {
|
||
Price:@(Model.Package.Price),
|
||
PackageId:@(Model.Package.Id),
|
||
CouponAmount: 0,
|
||
OrderType: 2,
|
||
Account: '@(randomAccountMutil)',
|
||
Pwd: '@(randomPwd)',
|
||
ConnectCount: 1,
|
||
CouponId: 0,
|
||
UseAccountAmount: 0,
|
||
OPayType: 100,
|
||
MinPostfix: 1,
|
||
MaxPostfix: 1,
|
||
PayChannel:40,
|
||
phone:''
|
||
}
|
||
},
|
||
computed: {
|
||
OneTotalAmount: function () {
|
||
var total= this.OneBuyModel.Price * this.OneBuyModel.ConnectCount
|
||
//西瓜极客优惠券
|
||
if((@(Model.Package.Id) == 64||@(Model.Package.Id) == 1004) && @(Model.Package.Price)<60){
|
||
total = this.OneBuyModel.ConnectCount * 60.00
|
||
}
|
||
if (@(Model.Package.IsTest) == 1) {
|
||
total = 1.00;
|
||
}
|
||
return total.toFixed(2);
|
||
},
|
||
OnePayAmount: function () {
|
||
var restAmout = this.OneBuyModel.UseAccountAmount == 1 ?this.RestAmount:0;
|
||
var total = this.OneBuyModel.Price * this.OneBuyModel.ConnectCount - this.OneBuyModel.CouponAmount ;
|
||
total= total < 0 ? 0 : total;
|
||
total = parseFloat(total.toFixed(2));
|
||
|
||
|
||
if(total != 0.1){
|
||
//最低价
|
||
var min_cost = @(Model.Package.MinPrice) * this.OneBuyModel.ConnectCount - this.OneBuyModel.CouponAmount;
|
||
if(total<min_cost){
|
||
total = min_cost;
|
||
}
|
||
}
|
||
|
||
if (@(Model.Package.IsTest) == 1) {
|
||
total = 1.00;
|
||
}
|
||
return total.toFixed(2);
|
||
},
|
||
MoreTotalAmount: function () {
|
||
var total= this.MoreBuyModel.Price * this.MoreBuyModel.ConnectCount * this.MoreBuyModel.MaxPostfix;
|
||
//西瓜极客优惠券
|
||
if((@(Model.Package.Id) == 64||@(Model.Package.Id) == 1004) && @(Model.Package.Price)<60){
|
||
total = this.MoreBuyModel.ConnectCount * 60.00 * this.MoreBuyModel.MaxPostfix
|
||
}
|
||
return total.toFixed(2);
|
||
},
|
||
MorePayAmount: function () {
|
||
var restAmout = this.MoreBuyModel.UseAccountAmount == 1 ? this.RestAmount : 0;
|
||
var total = this.MoreBuyModel.Price * this.MoreBuyModel.ConnectCount * this.MoreBuyModel.MaxPostfix - this.MoreBuyModel.CouponAmount ;
|
||
total= total < 0 ? 0 : total;
|
||
total = parseFloat(total.toFixed(2));
|
||
|
||
|
||
|
||
//最低价
|
||
var min_cost = @(Model.Package.MinPrice) * this.MoreBuyModel.ConnectCount * this.MoreBuyModel.MaxPostfix - 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($(".kaci").text() == '天卡'){
|
||
this.OneBuyModel.CouponAmount = totalAmount * item.CouponValue * 0.1;
|
||
} else {
|
||
alert('非天卡无效');
|
||
this.OneBuyModel.CouponId = '0';
|
||
}
|
||
}
|
||
return;
|
||
} else {
|
||
this.OneBuyModel.CouponAmount = 0;
|
||
}
|
||
}
|
||
},
|
||
immediate: true
|
||
},
|
||
'MoreBuyModel.CouponId': { //加引号监听对象里的属性
|
||
handler: function (newValue, oldValue) {
|
||
|
||
if( this.MoreBuyModel.CouponId == 10000000){
|
||
return;
|
||
}
|
||
var totalAmount = this.MoreBuyModel.Price * this.MoreBuyModel.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.MoreBuyModel.CouponAmount = item.CouponValue;
|
||
} else {
|
||
//亲 请勿非法操作呦^.^ 请按照正常的流程操作 我们后台是有记录滴
|
||
if($(".kaci").text() == '天卡'){
|
||
this.MoreBuyModel.CouponAmount = totalAmount * item.CouponValue * 0.1;
|
||
} else {
|
||
alert('非天卡无效');
|
||
this.MoreBuyModel.CouponId = '0';
|
||
}
|
||
}
|
||
return;
|
||
} else {
|
||
this.MoreBuyModel.CouponAmount = 0;
|
||
}
|
||
}
|
||
},
|
||
immediate: true
|
||
},
|
||
'OneBuyModel.OPayType': { //加引号监听对象里的属性
|
||
handler: function (newValue, oldValue) {
|
||
var wx = 10;
|
||
this.OneBuyModel.UseAccountAmount = false;
|
||
if (isWeiXin()) wx = 20;
|
||
this.OneBuyModel.PayChannel = newValue == 70 ? wx : 40;
|
||
},
|
||
immediate: true
|
||
},
|
||
'MoreBuyModel.OPayType': { //加引号监听对象里的属性
|
||
handler: function (newValue, oldValue) {
|
||
var wx = 10;
|
||
this.MoreBuyModel.UseAccountAmount = false;
|
||
if (isWeiXin()) wx = 20;
|
||
this.MoreBuyModel.PayChannel = newValue == 70 ? wx : 40;
|
||
},
|
||
immediate: true
|
||
}
|
||
},
|
||
created () {
|
||
this.OneBuyModel.CouponId = 10000000
|
||
this.MoreBuyModel.CouponId = 10000000
|
||
},
|
||
mounted: function () {
|
||
if (isWeiXin()) {
|
||
this.OneBuyModel.PayChannel = 20;
|
||
this.OneBuyModel.OPayType = 70;
|
||
this.MoreBuyModel.PayChannel = 20;
|
||
this.MoreBuyModel.OPayType = 70;
|
||
this.showPayType = false;
|
||
}
|
||
@if(user != null) {
|
||
<text>this.getCoupons()</text>
|
||
}
|
||
},
|
||
methods: {
|
||
isNum(value) {
|
||
return typeof value === 'number' && !isNaN(value);
|
||
},
|
||
selectFn: function (e) {
|
||
console.log(e.target.value) // 选择项的value
|
||
},
|
||
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);
|
||
}
|
||
}
|
||
})
|
||
},
|
||
hasNumAndChar(str) {
|
||
var zg = /^[0-9a-zA-Z]*$/;
|
||
if (!zg.test(str)) {
|
||
return false;
|
||
} else {
|
||
return true;
|
||
}
|
||
},
|
||
checkOneAccount() {
|
||
|
||
if (productId == 20||productId == 21||productId == 27) {
|
||
if (this.OneBuyModel.Account.length > 10 || this.OneBuyModel.Account.length < 7 || !this.hasNumAndChar(this.OneBuyModel.Account)) {
|
||
alert("此产品账号必须在7-10位");
|
||
this.OneChecker.AccountOk = false;
|
||
return false;
|
||
}
|
||
|
||
this.OneChecker.AccountOk = true;
|
||
return true;
|
||
}
|
||
if (this.OneBuyModel.Account.length > 10 || this.OneBuyModel.Account.length < 4|| !this.hasNumAndChar(this.OneBuyModel.Account)) {
|
||
this.OneChecker.AccountOk = false;
|
||
alert('账号长度必须在4-10位,且不能包含特殊字符');
|
||
return false;
|
||
}
|
||
this.OneChecker.AccountOk = true;
|
||
return true;
|
||
},
|
||
checkOnePwd() {
|
||
if (productId == 27 || productId == 6) {
|
||
if (this.OneBuyModel.Pwd.length < 7 || this.OneBuyModel.Pwd.length > 10 || !this.hasNumAndChar(this.OneBuyModel.Pwd)) {
|
||
alert("此产品密码必须大于6位");
|
||
this.OneChecker.PwdOk = false;
|
||
return false;
|
||
}
|
||
this.OneChecker.PwdOk = true;
|
||
return true;
|
||
}
|
||
if (this.OneBuyModel.Pwd.length > 6 || this.OneBuyModel.Pwd.length <1 || !this.hasNumAndChar(this.OneBuyModel.Pwd)) {
|
||
this.OneChecker.PwdOk = false;
|
||
alert('密码长度必须在1-6位,且不能包含特殊字符');
|
||
return false;
|
||
}
|
||
this.OneChecker.PwdOk = true;
|
||
return true;
|
||
},
|
||
checkMoreAccount() {
|
||
|
||
if (productId == 20||productId == 21||productId == 27) {
|
||
if (this.MoreBuyModel.Account.length < 6 || this.MoreBuyModel.Account.length > 8 || !this.hasNumAndChar(this.MoreBuyModel.Account)) {
|
||
alert("此产品账号必须在7-10位");
|
||
this.MoreChecker.AccountOk = false;
|
||
return false;
|
||
}
|
||
|
||
this.MoreChecker.AccountOk = true;
|
||
return true;
|
||
}
|
||
if (this.MoreBuyModel.Account.length > 10 || this.MoreBuyModel.Account.length < 3|| !this.hasNumAndChar(this.MoreBuyModel.Account)) {
|
||
this.MoreChecker.AccountOk = false;
|
||
alert('账号长度必须在4-10位,且不能包含特殊字符');
|
||
return false;
|
||
}
|
||
this.MoreChecker.AccountOk = true;
|
||
return true;
|
||
},
|
||
checkMorePwd() {
|
||
if (productId == 27 || productId == 6) {
|
||
if (this.MoreBuyModel.Pwd.length < 7 || this.MoreBuyModel.Pwd.length > 10 || !this.hasNumAndChar(this.MoreBuyModel.Pwd)) {
|
||
alert("此产品密码必须大于6位");
|
||
this.MoreChecker.PwdOk = false;
|
||
return false;
|
||
}
|
||
this.MoreChecker.PwdOk = true;
|
||
return true;
|
||
}
|
||
if (this.MoreBuyModel.Pwd.length > 6 || this.MoreBuyModel.Pwd.length < 1 || !this.hasNumAndChar(this.MoreBuyModel.Pwd)) {
|
||
this.MoreChecker.PwdOk = false;
|
||
alert('密码长度必须在1-6位,且不能包含特殊字符');
|
||
return false;
|
||
}
|
||
this.MoreChecker.PwdOk = true;
|
||
return true;
|
||
},
|
||
onePay: function () {
|
||
this.OneBuyModel.ConnectCount = parseInt(this.OneBuyModel.ConnectCount)
|
||
if (!this.isNum(this.OneBuyModel.ConnectCount)) return;
|
||
if (!this.checkOneAccount() || !this.checkOnePwd()) return;
|
||
|
||
if (this.OneBuyModel.UseAccountAmount) {
|
||
if (this.RestAmount < this.OnePayAmount){
|
||
alert('余额不足,请充值。您也可以使用微信、支付宝支付。');return;
|
||
} else {
|
||
this.RestAmount = this.RestAmount - this.OnePayAmount;
|
||
}
|
||
}
|
||
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('购买成功');
|
||
window.location.href = "/user/myaccounts";
|
||
showPayOk();
|
||
} else {
|
||
that.payCallback(res.Data)
|
||
that.isPay(res.Data.OrderInfo.OrderNo);
|
||
}
|
||
} else {
|
||
//that.Tip = res.Message;
|
||
tipPayWait(res.Message);
|
||
}
|
||
}
|
||
});
|
||
},
|
||
morePay: function () {
|
||
this.MoreBuyModel.ConnectCount = parseInt(this.MoreBuyModel.ConnectCount)
|
||
if (!this.isNum(this.MoreBuyModel.ConnectCount)) return;
|
||
if (!this.checkMoreAccount() || !this.checkMorePwd() || this.MoreBuyModel.MaxPostfix>500) return;
|
||
var that = this;
|
||
if (this.MoreBuyModel.UseAccountAmount) {
|
||
if (this.RestAmount < this.MorePayAmount){
|
||
alert('余额不足,请充值。您也可以使用微信、支付宝支付。');return;
|
||
} else {
|
||
this.RestAmount = this.RestAmount - this.MorePayAmount;
|
||
}
|
||
}
|
||
if (this.MoreBuyModel.UseAccountAmount === true) this.MoreBuyModel.UseAccountAmount = 1;
|
||
if (this.MoreBuyModel.UseAccountAmount === false) this.MoreBuyModel.UseAccountAmount = 0;
|
||
showPayWait();
|
||
$.ajax({
|
||
type: 'POST',
|
||
url: '/product/CreateOrder',
|
||
dataType: "json",
|
||
contentType: "application/json",
|
||
data: JSON.stringify(this.MoreBuyModel),
|
||
success: function (res) {
|
||
if (res.Code == 10000) {
|
||
hidePayWait();
|
||
if (res.Data == "00") {
|
||
alert('购买成功');
|
||
window.location.href = "/user/myaccounts";
|
||
showPayOk();
|
||
} 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;
|
||
if (!data.PayData) { alert("下单失败");return; }
|
||
var payChannel = this.OrderInfo.PayChannel;
|
||
if (payChannel == 10) {
|
||
this.h5WxPay(data.PayData)
|
||
} else if (payChannel == 20) {
|
||
this.jsWxPay(data.PayData);
|
||
} else if (payChannel == 40) {
|
||
this.aliPay(data.PayData);
|
||
}
|
||
},
|
||
h5WxPay(payData) {
|
||
window.location.href = payData;
|
||
},
|
||
jsWxPay(payData) {
|
||
WeixinJSBridge.invoke(
|
||
'getBrandWCPayRequest',
|
||
JSON.parse(payData),
|
||
function (res) {
|
||
if (res.err_msg == "get_brand_wcpay_request:ok") {
|
||
window.location.href = "/User/MyAccounts";
|
||
} else if (res.err_msg == "get_brand_wcpay_request:cancel") {
|
||
|
||
} else {
|
||
alert("支付失败" + res.err_msg);
|
||
}
|
||
});
|
||
},
|
||
aliPay(payData) {
|
||
$("#aliPayBox").html(payData);
|
||
//window.location.href = payData;
|
||
},
|
||
checkAccount: function () {
|
||
var account = $("#sAccount").val()
|
||
var url = '/api/course/v1/productaccount/ExistAccount?productId=' + productId + '&accounts=' + account;
|
||
$.ajax({
|
||
type: 'GET',
|
||
url: url,
|
||
success: function (res) {
|
||
console.log(res);
|
||
if (res.Code != 10000) {
|
||
$("#sAccountTip").text(res.Message)
|
||
}
|
||
}
|
||
})
|
||
},
|
||
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();
|
||
alert('购买成功');
|
||
window.location.href = "/user/myaccounts";
|
||
}
|
||
}
|
||
})
|
||
}, 3000)
|
||
},
|
||
close() {
|
||
clearInterval(this.payHandler);
|
||
$('.payMask').hide();
|
||
$('#qrcode').empty();
|
||
},
|
||
changeAccountCount() {
|
||
this.acount_list = '';
|
||
let start_account = this.MoreBuyModel.MinPostfix;
|
||
let end_account = this.MoreBuyModel.MaxPostfix;
|
||
if(end_account>3){
|
||
for(let i = start_account;i<parseInt(start_account)+3;i++){
|
||
this.acount_list += this.MoreBuyModel.Account+i+',';
|
||
}
|
||
this.acount_list = this.acount_list.substr(0,this.acount_list.length - 1);
|
||
this.acount_list += '...'+this.MoreBuyModel.Account+(parseInt(start_account)+parseInt(end_account)-1)
|
||
} else {
|
||
for(let i = start_account;i<parseInt(start_account)+parseInt(end_account);i++){
|
||
this.acount_list += this.MoreBuyModel.Account+i+',';
|
||
}
|
||
|
||
this.acount_list = this.acount_list.substr(0,this.acount_list.length - 1);
|
||
}
|
||
}
|
||
}
|
||
})
|
||
|
||
function checkAccount() {
|
||
var account = $("#sAccount").val()
|
||
var url = '/api/course/v1/productaccount/ExistAccount?productId=' + productId+ '&accounts=' + account;
|
||
$.ajax({
|
||
type: 'GET',
|
||
url: url,
|
||
success: function (res) {
|
||
console.log(res);
|
||
if (res.Code != 10000) {
|
||
$("#sAccountTip").text(res.Message)
|
||
}
|
||
}
|
||
})
|
||
}
|
||
</script>
|
||
} |