123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566 |
- /**
- *Created by ZHJY on 2020/7/14.
- */
- var payContainer = new Vue({
- el:"#payContainer",
- mixins: [cardsMixns,hlbPayMixin,cmSysVitaMixins],
- data: {
- loginLoading:true,
- isSubMitStatus:false,
- payInfo:{
- payBankNum: '', //支付类型
- shopOrderId: '', //订单ID
- obligation: '', //待支付金额
- payAmount: 0,//本次支付金额
- payMobileUrl: '',//二维码生成链接
- payData:{}, //支付数据
- payUserType:'B2B',
- payType:'1',
- },
- iframe:'',
- orderFlag:1,// 是否是订单 0非订单 1订单
- couponInfo:{},
- bankListB2BData:[],// 企业网银银行列表
- bankListB2CData:[],// 个人网银银行列表
- methodTab:['线上支付','转账支付'],
- mobileData:[
- {imgUrl:'/img/pay/iconbank-ali@2x.png',bankName:'支付宝支付',bankNum:'ALIPAY'},
- {imgUrl:'/img/pay/iconbank-wx@2x.png',bankName:'微信支付',bankNum:'WEIXIN'},
- {imgUrl:'/img/pay/iconbank-B2Bbank@2x.png',bankName:'网银支付',bankNum:'ICBC_B2B'},
- {imgUrl:'/img/pay/iconbank-B2Cbank@2x.png',bankName:'个人网银',bankNum:'ICBC_B2C'}
- ],
- pageType:'',//页面跳转类型 1 二手支付
- obligation:'',//订单待付金额
- payableAmount:'',//应付金额
- receiptAmount:'',//已支付金额
- balanceAmount:'',//应付剩余金额
- payAmount:'',//本次支付金额
- paymentIimit:50000,
- paymentIimitText:'',
- discernReceiptList:[],//支付记录列表
- mbOrderId:'',//支付订单ID
- bigPayInfo:{},// 银联转账信息
- BankUserType:1,
- mobileTabIndex:null,
- bankTabIndex:0,
- isRequest:false,
- isPayAlert:false,
- isPaySwitch:false,
- paySuccessCounter:'',
- bankPayLink_url:'',
- invoiceStatus:false,
- isReceiptStatus:false,
- onlinePay:'',
- QuickPayFlag: false,//快捷支付开关
- B2BpayFlag: false,//企业网银支付开关
- is_Wechat_bowcr:false, // 是否是微信浏览器
- weChatFlag: false, // 微信支付开关
- aliPayFlag: false, // 支付宝支付开关
- svipPayFlag: false, // 是否支付开通超级会员
- couponPayFlag: false, // 是否支付优惠券
- payStatusText:'支付全部金额后,供应商会在24小时后发货,周末、节假日顺延。',
- productID:'',//发布商品的ID
- comboInfo: null, //选中的svip套餐信息
- vipRecordId: undefined,
- couponRecordId:undefined,
- couponId:undefined,
- userId:0,
- orderId:0,
- orderNo:0,
- list: [],// 快捷支付我的银行
- },
- filters: {
- NumFormat:function(value) {
- if(!value) return '0.00';
- var intPart = Number(value) - Number(value)%1; //获取整数部分(这里是windy93的方法)
- var intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,'); //将整数部分逢三一断
- var floatPart = ".00"; //预定义小数部分
- var value2Array = value.toString().split(".");
- if(value2Array.length == 2) { //=2表示数据有小数位
- floatPart = value2Array[1].toString(); //拿到小数部分
- if(floatPart.length == 1) { //补0,实际上用不着
- return intPartFormat + "." + floatPart + '0';
- } else {
- return intPartFormat + "." + floatPart;
- }
- } else {
- return intPartFormat + floatPart;
- }
- }
- },
- computed: {
- showAliPayMode(){
- return !this.is_Wechat_bowcr && (this.aliPayFlag || this.svipPayFlag || this.couponPayFlag)
- },
- showWeChatPayMode(){
- return this.weChatFlag || this.svipPayFlag || this.couponPayFlag
- },
- showB2BpayMode(){
- return this.B2BpayFlag || this.svipPayFlag || this.couponPayFlag
- },
- showQuickpayMode() {
- return this.QuickPayFlag
- }
- },
- methods: {
- initCouponDetail:function (couponId) {//初始化优惠券数据
- const _self = this;
- ProductApi.QueryCouponDetail({ couponId: couponId },function (response) {
- if(response.code === 0){
- _self.couponInfo = response.data
- if(globalUserData){
- _self.userId = globalUserData.userId;
- }
- }else{
- CAIMEI.Alert(response.msg, '确定', false);
- }
- })
- },
- infoPayOrderCheckoutCounter:function(){//初始化子订单数据
- const _self = this;
- PayApi.PayOrderCheckoutShoporders({shopOrderId:_self.payInfo.shopOrderId},function(response){
- if(response.code === 0){
- console.log(response);
- var data = response.data; //金额初始化
- _self.payInfo.payAmount = (data.shopOrder.realPay - data.shopOrder.receiptAmount).toFixed(2);
- _self.discernReceiptList = data.discernReceipt;// 支付记录
- _self.payInfo.obligation = data.shopOrder.obligation;
- _self.orderId = data.shopOrder.orderId;// 主订单Id
- _self.orderNo = data.shopOrder.orderNo;// 主订单编号
- _self.obligation = data.shopOrder.obligation;// 待付金额
- _self.payableAmount = data.shopOrder.realPay;
- _self.receiptAmount = data.shopOrder.receiptAmount;
- _self.balanceAmount = (_self.obligation*100 - _self.payInfo.payAmount*100)/100;
- _self.payAmount = (_self.payableAmount - _self.receiptAmount).toFixed(2);
- _self.paySuccessCounter = data.shopOrder.paySuccessCounter;
- _self.onlinePay = data.onlinePay;
- _self.isRequest = true;
- // 支付方式配置
- _self.checkPayMode(data.onlinePayWays,data.weChatFlag,data.aliPayFlag)
- _self.PayOrderOnLineSwitch();
- }else{
- CAIMEI.Alert(response.msg,'确定',false);
- }
- })
- },
- // 校验支付模式
- checkPayMode(range,weChatFlag,aliPayFlag){
- // test range = '4'
- // 1微信 2支付宝 3个人网银 4企业网银
- if(weChatFlag === '2'){
- this.weChatFlag = false
- }else{
- this.weChatFlag = range.indexOf('1') > -1
- }
- if(aliPayFlag === '2'){
- this.aliPayFlag = false
- }else{
- this.aliPayFlag = range.indexOf('1') > -1
- }
- this.B2BpayFlag = range.indexOf('4') > -1
- this.QuickPayFlag = range.indexOf('5') > -1
- // 设置默认支付方式
- if(this.QuickPayFlag){
- this.mobileTabIndex = 4
- }else{
- this.mobileTabIndex = this.aliPayFlag ? 0 : this.weChatFlag ? 1 : this.B2BpayFlag ? 2 : 3
- }
- },
- getBankList () {// 获取网银支付银行列表
- const _self = this;
- PayApi.PayGetBankCode({},function(response){
- if(response.code === 0){
- _self.bankListB2BData = response.data.B2B;
- _self.bankListB2CData = response.data.B2C;
- }else{
- console.log('获取网银支付银行列表异常')
- }
- })
- },
- PayOrderOnLineSwitch(){//获取是否可以先上支付
- const _self = this;
- PayApi.PayOrderOnLineSwitch({},function(response){
- if(response.code === 0){
- if(response.data === 0){
- _self.isPaySwitch = true;
- if (_self.pageType === '2') {
- CAIMEI.dialog('支付系统遇到点小问题,请稍后重试', false);
- return;
- }
- CAIMEI.Alert('线上支付功能正在维护中,请前往查看线下转账方式进行付款','确定',true,function(){
- window.location.href= '/pay/caimei-payunder.html?orderId='+_self.orderId;
- });
- }
- }else{
- CAIMEI.Alert(response.msg,'确定',false);
- }
- })
- },
- PayMobileSubmitFn:function(){//点击移动支付方式
- const _self = this;
- if(_self.isPaySwitch && _self.pageType === '2'){
- CAIMEI.dialog('支付系统遇到点小问题,请稍后重试', false);
- return;
- }
- if(_self.pageType === '3'){// 移动支付优惠券
- _self.PayCouponMiniPayFn();
- }else{
- if(_self.payInfo.payBankNum === ''){
- CAIMEI.dialog('请选择支付方式');
- return;
- }
- if(_self.payAmount === ''){
- CAIMEI.dialog('请输入本次支付金额');
- return;
- }
- if(_self.payAmount === 0){
- CAIMEI.dialog('本次支付金额不能为0');
- return;
- }
- if(_self.payAmount*100 < 2){
- CAIMEI.dialog('本次支付金额必须大于¥0.02');
- return;
- }
- // if(_self.payAmount > _self.paymentIimit){
- // switch (_self.payInfo.payBankNum) {
- // case 'WEIXIN':
- // _self.paymentIimitText = '本次支付金额已超出微信支付限额,请输入小于5万的金额进行支付。';
- // break;
- // case 'ALIPAY':
- // _self.paymentIimitText = '本次支付金额已超出支付宝限额,请输入小于5万的金额进行支付。';
- // break;
- // }
- // CAIMEI.Alert(_self.paymentIimitText,'知道了');
- // return;
- // }
- if(_self.payInfo.payBankNum === "WEIXIN"){// 微信
- if(_self.pageType === '1'){ // 二手
- _self.hlb_PaySecondMiniWxPay();
- }else if(_self.pageType === '2'){ // 会员
- _self.hlb_PayVipMiniWxPay();
- }else{ // 正常订单
- _self.hlb_PayOrderMiniWxPay();
- }
- }else if(_self.payInfo.payBankNum === "ALIPAY"){// 支付宝
- if(_self.pageType === '1'){// 二手
- _self.hlb_PayOrdersecondScanAliPay();
- }else if(_self.pageType === '2'){ // 会员
- _self.hlb_PayVipScanAliPay();
- }else{// 正常订单
- _self.hlb_PayOrderPcScanAliPay();
- }
- }
- }
- },
- PaySubmitFn(){//点击网银支付方式
- if(this.isPaySwitch && this.pageType === '2'){
- CAIMEI.dialog('支付系统遇到点小问题,请稍后重试', false);
- return;
- }
- if(this.pageType === '3'){// 网银支付优惠券
- if(this.payInfo.payBankNum === ''){
- CAIMEI.dialog('请选择银行!');
- return;
- }
- this.hlb_PayCouponUnionPayFn();
- }else{
- if(this.payInfo.payBankNum === ''){
- CAIMEI.dialog('请选择银行!');
- return;
- }
- if(this.payAmount <= 10){
- CAIMEI.dialog('网银支付的金额必须大于¥10.00');
- return;
- }
- if( this.orderFlag === 1 && this.mobileTabIndex === 2){
- if(this.payAmount*1 !== this.obligation){
- CAIMEI.Alert('企业网银支付每次收取的手续费较高,建议一次性全额付款。','确定',false);
- return;
- }
- }
- if(this.pageType === '1'){// 二手
- this.hlb_PayOrdersecondUnion();
- } else if (this.pageType === '2') { // 会员
- this.hlb_PayVipPcMallPay();
- } else {// 正常订单
- this.hlb_PayOrderPcMallPay();
- }
- }
- },
- handleQuickPay(){
- //快捷支付
- if(this.pageType === '1'){// 二手
- this.orderPayQuickPay();
- } else if (this.pageType === '2') { // 会员
- this.orderPayQuickPay();
- } else if (this.pageType === '3') { // 优惠券
- this.orderPayQuickPay();
- } else {// 正常订单
- this.orderPayQuickPay();
- }
- },
- PayCouponMiniPayFn () { // 移动支付购买优惠券
- const _self = this;
- if(this.payInfo.payBankNum === "WEIXIN"){
- this.hlb_PayCouponMiniWxPay();
- }else if(this.payInfo.payBankNum === "ALIPAY"){//支付宝支付
- this.hlb_PayCouponAliPay();
- }
- },
- changePayAmount(event){//输入支付金额控制
- const _self = this;
- const value = event.target.value;
- if(value === "" || value <0 ){//判断是否等于0 或者为空
- this.payAmount = '';
- this.payInfo.payAmount = this.payInfo.obligation;
- this.balanceAmount = this.toFixedFn(this.payInfo.obligation);
- }else if(Number(value) > this.payInfo.obligation){//判断大于应付金额
- this.payAmount = this.payInfo.obligation;
- this.payInfo.payAmount = this.payAmount;
- this.balanceAmount = this.toFixedFn(this.payInfo.obligation-this.payInfo.payAmount);
- }else{
- this.payAmount = value;
- this.payInfo.payAmount = this.payAmount;
- this.balanceAmount = this.toFixedFn(this.payInfo.obligation-this.payInfo.payAmount);
- }
- },
- changePayAmountBlur(event){//失去焦点设置金额
- const _self = this;
- this.payAmount = this.toFixedFn(event.target.value);
- this.payInfo.payAmount = this.payAmount;
- },
- changeTab(index,item){//选择支付方式切换
- this.tabIndex = index;
- switch (this.tabIndex) {
- case 0:
- this.payInfo.payBankNum = 'ALIPAY';
- break;
- case 1:
- this.payInfo.payBankNum = '';
- break;
- }
- },
- checkMobilePay(index,bankNum){//选择移动支付方式
- this.current = '';
- this.mobileTabIndex = index;
- this.payInfo.payBankNum = bankNum;
- switch (index) {
- case 2:// 企业网银
- this.bankTabIndex = 0
- this.payInfo.payType = '1';
- this.payInfo.payUserType = 'B2B';
- this.payInfo.payBankNum = this.bankListB2BData[0].b2B;
- break;
- case 3:// 个人网银
- this.bankTabIndex = 0
- this.payInfo.payType = '2';
- this.payInfo.payUserType = 'B2C';
- this.payInfo.payBankNum = this.bankListB2CData[0].b2C;
- break;
- }
- },
- checkBankPay(index,item){//选择网银支付方式-选择银行
- var _self = this;
- _self.bankTabIndex = index;
- switch (_self.mobileTabIndex) {
- case 2:// 企业网银
- _self.payInfo.payBankNum = item.b2B;
- break;
- case 3:// 个人网银
- _self.payInfo.payBankNum = item.b2C;
- break;
- }
- },
- copyLinkPaySubmitFn(){//复制网银支付链接
- var _self = this;
- if(_self.isPaySwitch && _self.pageType === '2'){
- CAIMEI.dialog('支付系统遇到点小问题,请稍后重试', false);
- return;
- }
- if(_self.payAmount === ''){
- CAIMEI.dialog('请输入本次支付金额');
- return;
- }
- if(_self.payAmount === 0){
- CAIMEI.dialog('本次支付金额不能为0');
- return;
- }
- if(_self.payAmount <= 10){
- CAIMEI.dialog('网银支付的金额必须大于¥12.00');
- return;
- }
- if( _self.orderFlag === 1 && _self.mobileTabIndex === 2){
- if(_self.payAmount*1 !== _self.obligation){
- CAIMEI.Alert('企业网银支付每次收取的手续费较高,建议一次性全额付款。','确定',false);
- return;
- }
- }
- let params = {};
- if(_self.pageType === 2){
- params = {
- unpaidAmount:_self.payAmount,
- vipRecordId: _self.vipRecordId,
- payType:_self.payInfo.payType,
- }
- }else{
- params = {
- unpaidAmount:_self.payAmount,
- shopOrderId:_self.payInfo.shopOrderId,
- payType:_self.payInfo.payType
- }
- }
- _self.hlb_CopyLinkPaySubmitFn(params)
- },
- hidePayAlert(){//隐藏已支付弹窗
- var _self = this;
- _self.isPayAlert = false;
- },
- RefreshBody(){//刷新页面
- var _self = this;
- if(_self.payInfo.payBankNum == 'WEIXIN'){
- if( _self.pageType == '2' ){ // 验证支付(支付会员)
- PayApi.PayOrderPayVipCheck({recordId : _self.vipRecordId},function(response){
- // console.log(response);
- if(response.code === 0){
- _self.windowLocationHref('success');
- }else{
- _self.windowLocationHref('error');
- }
- });
- }else if(_self.pageType == '3'){ // 验证支付(优惠券)
- PayApi.PayOrderPayCouponCheck({ couponRecordId: _self.couponRecordId },function(response){
- // console.log(response);
- if(response.code === 0){
- _self.windowLocationHref('success');
- }else{
- _self.windowLocationHref('error');
- }
- });
- }else{
- PayApi.PayOrderPayWhetherSuccess({shopOrderId: _self.payInfo.shopOrderId, paySuccessCounter:_self.paySuccessCounter,shopOrderId:_self.payInfo.shopOrderId},function(response){
- _self.isPayAlert = false;
- if(response.code === 0){
- _self.windowLocationHref('success');
- }else{
- _self.windowLocationHref('error');
- }
- });
- }
- }else if(_self.payInfo.payBankNum == 'ALIPAY'){// 校验支付宝支付成功
- PayApi.PayOrderFindOrderStatus({mbOrderId:_self.mbOrderId,orderFlag:_self.orderFlag,shopOrderId:_self.payInfo.shopOrderId},function(response){
- if(response.code === 0){
- _self.isPayAlert = false;
- var data = response.data;
- if(data.rt7_orderStatus === 'SUCCESS'){
- _self.windowLocationHref('success');
- }else{
- _self.windowLocationHref('error');
- }
- }else{
- CAIMEI.Alert(response.msg,'确定',false);
- }
- });
- }else{// 校验网银支付成功
- PayApi.PayOrderUnionStatus({mbOrderId:_self.mbOrderId,orderFlag:_self.orderFlag,shopOrderId:_self.payInfo.shopOrderId},function(response){
- if(response.code === 0){
- _self.isPayAlert = false;
- var data = response.data;
- if(data.rt10_orderStatus === 'SUCCESS'){
- _self.windowLocationHref('success');
- }else{
- _self.windowLocationHref('error');
- }
- }else{
- CAIMEI.Alert(response.msg,'确定',false);
- }
- });
- }
- },
- windowLocationHref(state){
- const _self = this;
- if( _self.pageType === '1'){
- window.location.href = '/pay/success.html?pageType=second&type='+state+'&payAmount='+_self.payAmount;
- }else if(_self.pageType === '2'){
- window.location.href = '/pay/success.html?pageType=vip&type='+state+'&payAmount='+_self.payAmount;
- }else if(_self.pageType === '3') {
- window.location.href = '/pay/success.html?pageType=coupon&type=' + state + '&payAmount=' + _self.couponInfo.moneyCouponPrice;
- }else{
- window.location.href = '/pay/success.html?pageType=www&type='+state+'&payAmount='+_self.payAmount;
- }
- },
- payTypeText(record) {
- //处理支付记录文字
- const map = {
- 12: '企业网银',
- 13: '微信支付',
- 14: '支付宝',
- 15: '微信支付',
- 16: '余额抵扣',
- }
- if(record.payType === 28 || record.payType === 29 ){
- return record.quickPayStr
- }else{
- return map[record.payType]
- }
- },
- toFixedFn(text){//处理小数点后两位数
- return Number(text).toFixed(2);
- },
- },
- mounted () {
- const _self = this;
- // 判断当前支付是订单支付
- this.pageType = CAIMEI.getUrlParam('pageType');
- if (this.pageType === '1') {//二手
- this.productID = CAIMEI.getUrlParam('productID');
- this.payAmount = _self.toFixedFn(100);
- this.isRequest = true;
- this.payStatusText = '';
- this.orderFlag = 0;
- } else if (this.pageType === '2') { // 支付会员
- this.svipPayFlag = true;
- this.orderFlag = 0;
- this.vipRecordId = this.params.vipRecordId = parseInt(CAIMEI.getUrlParam('vipRecordId'));
- this.params.quickPayFlag = 2;
- this.PayOrderOnLineSwitch();
- // 从本地获取选中的svip套餐信息后删除本地信息
- this.comboInfo = JSON.parse(CAIMEI.Storage.getItem('comboInfo'));
- // CAIMEI.Storage.removeItem('comboInfo');
- // 设置支付金额
- this.payAmount = this.toFixedFn(this.comboInfo.price);
- // 获取银行列表
- this.getBankList();
- this.userClubBanks()
- } else if(this.pageType === '3') {// 支付优惠券
- this.couponPayFlag = true
- this.orderFlag = 0;
- this.couponId = this.params.couponId = parseInt(CAIMEI.getUrlParam('couponId'));
- this.couponRecordId = this.params.couponRecordId = parseInt(CAIMEI.getUrlParam('couponRecordId'));
- this.params.quickPayFlag = 4;
- this.initCouponDetail(this.couponId);
- this.PayOrderOnLineSwitch();
- this.getBankList();
- this.userClubBanks()
- }else{
- this.orderFlag = 1;
- this.payInfo.shopOrderId = this.params.shopOrderId = CAIMEI.getUrlParam('shopOrderId');
- this.params.quickPayFlag = 1;
- // 获取银行列表
- this.getBankList();
- this.userClubBanks()
- //正常订单初始化
- this.infoPayOrderCheckoutCounter();
- }
- const viewer = window.navigator.userAgent.toLowerCase();
- if(viewer.match(/MicroMessenger/i) == 'micromessenger'){
- this.is_Wechat_bowcr = true;
- this.payInfo.payBankNum = 'WEIXIN';
- this.mobileTabIndex = 1;
- }else{
- this.is_Wechat_bowcr = false;
- this.payInfo.payBankNum = 'ALIPAY';
- this.mobileTabIndex = 0;
- }
- this.loginLoading = false
- }
- });
|