1.对接银联支付接口

master
杨杰 3 years ago
parent ed6ee63274
commit 105b307fa4
  1. 16
      high-unionPay/App.vue
  2. 5
      high-unionPay/Utils/Api.js
  3. 1
      high-unionPay/index.html
  4. 2
      high-unionPay/pages.json
  5. 4
      high-unionPay/pages/goods/goods.vue
  6. 2
      high-unionPay/pages/goods/refuel/refuel.vue
  7. 274
      high-unionPay/pages/order/confirmation.vue
  8. 7
      high-unionPay/pages/pay/success/success.vue
  9. 6
      high-unionPay/pages/tabBar/user/user.vue
  10. 2
      high-unionPay/pages/unionPay/unionPay-entrance/unionPay-entrance.vue

@ -5,15 +5,15 @@
// brestUrl: 'http://192.168.3.4:9302/brest', // brestUrl: 'http://192.168.3.4:9302/brest',
// imgUrl: 'https://192.168.3.4:9301/filesystem/', // imgUrl: 'https://192.168.3.4:9301/filesystem/',
// //
url: 'https://hsg.dctpay.com/crest', // url: 'https://hsg.dctpay.com/crest',
imgUrl: 'https://hsg.dctpay.com/filesystem/', // imgUrl: 'https://hsg.dctpay.com/filesystem/',
brestUrl : 'https://hsg.dctpay.com/brest', // brestUrl : 'https://hsg.dctpay.com/brest',
imageWxImg:'https://hsg.dctpay.com/filesystem/wxApplets/', // imageWxImg:'https://hsg.dctpay.com/filesystem/wxApplets/',
// //
// url: 'https://hsgcs.dctpay.com/crest', url: 'https://hsgcs.dctpay.com/crest',
// brestUrl : 'https://hsgcs.dctpay.com/brest', brestUrl : 'https://hsgcs.dctpay.com/brest',
// imgUrl: 'https://hsgcs.dctpay.com/filesystem/', imgUrl: 'https://hsgcs.dctpay.com/filesystem/',
// imageWxImg:'https://hsgcs.dctpay.com/filesystem/wxApplets/', imageWxImg:'https://hsgcs.dctpay.com/filesystem/wxApplets/',
userInfo: "", userInfo: "",
brestUserInfo : '', brestUserInfo : '',
openId: '', openId: '',

@ -170,6 +170,11 @@ export const orderToUNionPay = params => {
return POST('POST', `${base}/outRechargeOrder/orderToPay`, params).then(res => res.data); return POST('POST', `${base}/outRechargeOrder/orderToPay`, params).then(res => res.data);
} }
//银联提交订单
export const unionPay = params => {
return POST('POST', `${base}/order/unionPay`, params).then(res => res.data);
}
/** /**

@ -8,7 +8,6 @@
<%= htmlWebpackPlugin.options.title %> <%= htmlWebpackPlugin.options.title %>
</title> </title>
<script> <script>
console.log('=========')
document.addEventListener('DOMContentLoaded', function() { document.addEventListener('DOMContentLoaded', function() {
document.documentElement.style.fontSize = document.documentElement.clientWidth / 20 + 'px' document.documentElement.style.fontSize = document.documentElement.clientWidth / 20 + 'px'
}) })

@ -490,7 +490,7 @@
"path" : "pages/unionPay/unionPay-entrance/unionPay-entrance", "path" : "pages/unionPay/unionPay-entrance/unionPay-entrance",
"style" : "style" :
{ {
"navigationBarTitleText": "银联入口", "navigationBarTitleText": "嗨加油",
"navigationBarTextStyle": "white", "navigationBarTextStyle": "white",
"navigationBarBackgroundColor": "#0083f5", "navigationBarBackgroundColor": "#0083f5",
"backgroundColorTop": "#0083f5", "backgroundColorTop": "#0083f5",

@ -81,7 +81,7 @@
</image> </image>
</view> </view>
</view> </view>
<wybPopup ref="popup" type="bottom" width="500" scrollY="true" radius="6" :showCloseIcon="true"> <wybPopup ref="popup" type="bottom" width="500" radius="6" :showCloseIcon="true">
<view class="fotct font18 fontwig6 fcor333 mart10 height30">赠送卡券</view> <view class="fotct font18 fontwig6 fcor333 mart10 height30">赠送卡券</view>
<view class="width92 height110 tccs mart10" v-for="product in goodsData[0].handselCouponList" <view class="width92 height110 tccs mart10" v-for="product in goodsData[0].handselCouponList"
:key="product.id"> :key="product.id">
@ -89,7 +89,7 @@
<image mode="widthFix" class="flleft" src="../../static/img/logo.png"></image> <image mode="widthFix" class="flleft" src="../../static/img/logo.png"></image>
<view class="tcrig"> <view class="tcrig">
<view class="font16 fontwig6 fcor333 text1">{{ product.highCouponModel.couponName }}</view> <view class="font16 fontwig6 fcor333 text1">{{ product.highCouponModel.couponName }}</view>
<view class="font13 fcor999 mart5">有效期至201-05-15 225959(待改)</view> <view class="font13 fcor999 mart5">有效期至:{{product.highCouponModel.salesEndTime | formatDate('-')}}</view>
<view class="info mart5" v-if="product.highCouponModel.payType == 1"> <view class="info mart5" v-if="product.highCouponModel.payType == 1">
<view class="price">{{ product.highCouponModel.discountPrice}}</view> <view class="price">{{ product.highCouponModel.discountPrice}}</view>
<view class="slogan" <view class="slogan"

@ -459,7 +459,7 @@
} }
.stuMenu { .stuMenu {
width: 33.3%; width: 33%;
height: 30px; height: 30px;
line-height: 30px; line-height: 30px;
font-size: 14px; font-size: 14px;

@ -73,8 +73,7 @@
</view> </view>
</view> </view>
<view class="width94 line1 mart5 marb5"></view> <view class="width94 line1 mart5 marb5"></view>
<view class="height50 width100 backcorfff" v-if="couponList.payType == 2 || couponList.payType==3 " <view class="height50 width100 backcorfff" @tap="paytype='jinbi'">
@tap="paytype='jinbi'">
<view class="width70 flleft fcor333 fontwig6 font16 text1" style="padding-left: 4%;"> <view class="width70 flleft fcor333 fontwig6 font16 text1" style="padding-left: 4%;">
积分支付<text class="font14 fcor666 margle">可用积分: {{user.gold}}</text> 积分支付<text class="font14 fcor666 margle">可用积分: {{user.gold}}</text>
</view> </view>
@ -83,25 +82,14 @@
<radio :checked="paytype=='jinbi'" color="#0083f5" /> <radio :checked="paytype=='jinbi'" color="#0083f5" />
</view> </view>
</view> </view>
<view class="width94 line1 mart5 marb5" v-if="couponList.payType == 2 || couponList.payType==3 "></view> <view class="width94 line1 mart5 marb5"></view>
<view class="height50 width100 backcorfff" @tap="paytype='weixin'" <view class="height50 width100 backcorfff" @tap="paytype='unionPay'">
v-if="couponList.payType == 1 || couponList.payType==3 ">
<view class="width50 flleft fcor333 fontwig6 font16" style="padding-left: 4%;"> <view class="width50 flleft fcor333 fontwig6 font16" style="padding-left: 4%;">
微信支付 银联支付
</view> </view>
<view class="width40 flright fotrt paddtright10 font15 fontwig6 fcor666 alijun" <view class="width40 flright fotrt paddtright10 font15 fontwig6 fcor666 alijun"
style="align-items: center;"> style="align-items: center;">
<radio :checked="paytype=='weixin'" color="#0083f5" /> <radio :checked="paytype=='unionPay'" color="#0083f5" />
</view>
</view>
<view class="width94 line1 mart5 marb5" v-if="couponList.payType == 1 || couponList.payType==3 "></view>
<view class="height50 width100 backcorfff" @tap="paytype='gonghuika'">
<view class="width70 flleft fcor333 fontwig6 font16 text1" style="padding-left: 4%;">
汇联通工会卡<text class="font14 fcor666 margle">可用余额: {{tongCardPrice}}</text>
</view>
<view class="width20 flright fotrt paddtright10 font15 fontwig6 fcor666 alijun"
style="align-items: center;">
<radio :checked="paytype=='gonghuika'" @click="changeRiado()" color="#0083f5" />
</view> </view>
</view> </view>
</view> </view>
@ -139,7 +127,7 @@
</view> </view>
</view> </view>
<wybPopup ref="popup" type="bottom" width="500" scrollY="true" radius="6" :showCloseIcon="true"> <wybPopup ref="popup" type="bottom" width="500" radius="6" :showCloseIcon="true">
<view class="fotct font18 fontwig6 fcor333 mart10 height30">优惠券选择</view> <view class="fotct font18 fontwig6 fcor333 mart10 height30">优惠券选择</view>
<view class="width92 height110 tccs mart10" v-for="(items, index) in UserNormalDiscountList" :key="items" <view class="width92 height110 tccs mart10" v-for="(items, index) in UserNormalDiscountList" :key="items"
@click="radioChanges(items)"> @click="radioChanges(items)">
@ -154,7 +142,7 @@
</view> </view>
</view> </view>
</wybPopup> </wybPopup>
<ssPaymentPassword ref="paymentPassword" :mode="1" @submit="submitHandle"/> <ssPaymentPassword ref="paymentPassword" :mode="1" @submit="submitHandle" />
</view> </view>
</template> </template>
@ -168,15 +156,13 @@
orderToPay, orderToPay,
orderToGoldPay, orderToGoldPay,
findUser, findUser,
unionPay,
hltUnionCardPay, hltUnionCardPay,
getHuiLianTongCardBalance
} from '../../Utils/Api.js'; } from '../../Utils/Api.js';
import wybPopup from '../../components/wyb-popup/wyb-popup.vue'; import wybPopup from '../../components/wyb-popup/wyb-popup.vue';
import ssPaymentPassword from '../../components/sanshui-payment-password' import ssPaymentPassword from '../../components/sanshui-payment-password'
let app = getApp(); let app = getApp();
// #ifdef H5
var jweixin = require('jweixin-module');
// #endif
export default { export default {
components: { components: {
wybPopup, wybPopup,
@ -214,7 +200,7 @@
this.getCouponById(); this.getCouponById();
}, },
onShow() { onShow() {
let that =this; let that = this;
that.paytype = ''; that.paytype = '';
that.user = app.globalData.userInfo; that.user = app.globalData.userInfo;
that.getUserNormalDiscountList(); that.getUserNormalDiscountList();
@ -255,7 +241,6 @@
if (res.return_code == '000000') { if (res.return_code == '000000') {
app.globalData.userInfo = res.return_data; app.globalData.userInfo = res.return_data;
this.user = res.return_data; this.user = res.return_data;
this.getHuiLianTongCardBalance();
uni.setStorage({ uni.setStorage({
key: "user", key: "user",
data: res.return_data data: res.return_data
@ -331,19 +316,6 @@
} }
}) })
}, },
//
//
getHuiLianTongCardBalance() {
let params = {
cardNo: this.user.hltCardNo.cardNo
}
getHuiLianTongCardBalance(params).then(res => {
if (res.return_code == '000000') {
this.tongCardPrice = res.return_data.balance;
}
});
},
// H5 // H5
jumpH5Bding() { jumpH5Bding() {
uni.navigateTo({ uni.navigateTo({
@ -362,7 +334,7 @@
app.globalData.userInfo = res.return_data app.globalData.userInfo = res.return_data
.object .object
.highUser; .highUser;
this.user = res.return_data this.user = res.return_data
.object .object
.highUser; .highUser;
uni.setStorage({ uni.setStorage({
@ -390,7 +362,7 @@
}) })
let goods = { let goods = {
"memDiscountId": this.memDiscountId, "memDiscountId": this.memDiscountId,
"identificationCode":app.globalData.identificationCode, "identificationCode": app.globalData.identificationCode,
"highChildOrderList": [{ "highChildOrderList": [{
"goodsType": 1, "goodsType": 1,
"goodsId": this.couponId, "goodsId": this.couponId,
@ -400,12 +372,6 @@
addOrder(goods).then(res => { addOrder(goods).then(res => {
if (res.return_code == '000000') { if (res.return_code == '000000') {
uni.hideLoading(); uni.hideLoading();
// uni.redirectTo({
// url: '../pay/payment/payment?amount=' + res.return_data.payPrice +
// '&paytype=' + this.couponList.payType + '&orderId=' + res.return_data.id +
// '&couponId=' + this.couponId + '&typeaout=' + res.return_data
// .highChildOrderList[0].ext1
// })
this.jumpType = res.return_data.highChildOrderList[0].ext1; this.jumpType = res.return_data.highChildOrderList[0].ext1;
this.orderId = res.return_data.id; this.orderId = res.return_data.id;
this.orderToPay(res.return_data); this.orderToPay(res.return_data);
@ -440,55 +406,7 @@
// //
orderToPay(item) { orderToPay(item) {
let that = this; let that = this;
if (that.paytype == 'weixin') { if (that.paytype == 'jinbi') {
let params = {
"orderId": item.id,
"openId": app.globalData.openId,
"orderScene": "GOODS_ORDER"
}
orderToPay(params).then(res => {
if (res.return_code == '000000') {
// #ifdef MP
uni.showLoading({
title: '支付中...'
})
uni.requestPayment({
"appId": res.return_data.appId,
"nonceStr": res.return_data.nonceStr,
"package": res.return_data.package,
"paySign": res.return_data.sign,
"signType": "MD5",
"timeStamp": res.return_data.timeStamp,
success: function(res) {
uni.hideLoading();
uni.showToast({
title: '支付成功'
})
uni.reLaunch({
url: '../pay/success/success?id=' + that.couponId
});
},
fail: function(err) {
uni.hideLoading();
uni.navigateBack({})
},
});
// #endif
//
// #ifdef H5
//
that.payRequest(res);
// #endif
} else {
uni.showToast({
title: res.return_msg,
icon: 'none'
})
}
})
} else if (that.paytype == 'jinbi') {
if (!that.user.isSetPayPwd) { if (!that.user.isSetPayPwd) {
uni.navigateTo({ uni.navigateTo({
url: '../login/updatePas/updatePas' url: '../login/updatePas/updatePas'
@ -496,29 +414,8 @@
return; return;
} }
that.$refs.paymentPassword.modalFun('show'); that.$refs.paymentPassword.modalFun('show');
} else if (that.paytype == 'gonghuika') { } else if (that.paytype == 'unionPay') {
if (!that.user.isSetPayPwd) { this.unionPay();
uni.navigateTo({
url: '../login/updatePas/updatePas'
})
return;
}
if (!that.user.isSetHltCard) {
uni.showToast({
icon: 'none',
title: '当前账号还未绑定,前往绑定',
duration: 2000,
success() {
setTimeout(() => {
uni.navigateTo({
url: '../user/bindingCard/bindingCard'
})
}, 1000)
}
});
return;
}
that.$refs.paymentPassword.modalFun('show');
} else { } else {
uni.showToast({ uni.showToast({
title: '请选择支付方式', title: '请选择支付方式',
@ -527,55 +424,67 @@
}) })
} }
}, },
submitHandle(e) { //
this.PaymentPassword = e.value; unionPay() {
if(this.PaymentPassword == ''){ let goods = {
uni.showToast({ "orderId": this.orderId
title: '请勿手动关闭弹窗',
icon: 'none',
duration: 2000
})
return;
} }
uni.showLoading({ unionPay(goods).then(res => {
title: '支付中...' if (res.return_code == '000000') {
}) this.uniontopay(res.return_data.prepayid);
if (this.paytype == 'jinbi') { } else {
let params = { uni.showToast({
"orderId": this.orderId, title: res.return_msg,
"password": this.PaymentPassword icon: 'none',
duration: 2000
});
} }
orderToGoldPay(params).then(res => { })
uni.hideLoading(); },
if (res.return_code == '000000') { //
uniontopay(item) {
let that = this;
upsdk.pluginReady(function() {
upsdk.pay({
tn: item,
success: function(res) {
uni.showToast({ uni.showToast({
title: '支付成功' title: '支付成功'
}) })
uni.reLaunch({ uni.reLaunch({
url: '../pay/success/success?id=' + this.couponId url: '../pay/success/success?id=' + that.couponId
}); });
return; },
} fail: function(err) {
if (res.return_code == '102130') { uni.showToast({
uni.navigateTo({ title: err.msg,
url: '../../login/updatePas/updatePas' icon: 'none',
duration: 2000
}) })
return; // , err.msg , TN,
} }
uni.showToast({ });
title: res.return_msg, });
icon: 'none' },
}) //
submitHandle(e) {
this.PaymentPassword = e.value;
if (this.PaymentPassword == '') {
uni.showToast({
title: '请勿手动关闭弹窗',
icon: 'none',
duration: 2000
}) })
return; return;
} }
uni.showLoading({
title: '支付中...'
})
let params = { let params = {
"orderId": this.orderId, "orderId": this.orderId,
"cardNo": this.user.hltCardNo.cardNo,
"password": this.PaymentPassword "password": this.PaymentPassword
} }
hltUnionCardPay(params).then(res => { orderToGoldPay(params).then(res => {
uni.hideLoading(); uni.hideLoading();
if (res.return_code == '000000') { if (res.return_code == '000000') {
uni.showToast({ uni.showToast({
@ -584,79 +493,18 @@
uni.reLaunch({ uni.reLaunch({
url: '../pay/success/success?id=' + this.couponId url: '../pay/success/success?id=' + this.couponId
}); });
return;
} }
if (res.return_code == '102130') { if (res.return_code == '102130') {
uni.navigateTo({ uni.navigateTo({
url: '../../login/updatePas/updatePas' url: '../../login/updatePas/updatePas'
}) })
return;
} }
uni.showToast({ uni.showToast({
title: res.return_msg, title: res.return_msg,
icon: 'none' icon: 'none'
}) })
}) })
}
},
payRequest: function(self) {
uni.showLoading({
title: '支付中...'
})
jweixin.config({
// debug: false, // ,apialertpclogpc
appId: self.return_data.appId, //
timestamp: self.return_data.timeStamp, //
nonceStr: self.return_data.nonceStr, //
signature: self.return_data.sign, // 1
jsApiList: ['chooseWXPay'] // 使JSJS2
});
uni.hideLoading();
jweixin.ready(function() {
jweixin.checkJsApi({
jsApiList: ['chooseWXPay'], // JSJS2,
success: function(res) {},
fail: function(res) {}
});
jweixin.chooseWXPay({
appId: self.return_data.appId,
timestamp: self.return_data
.timeStamp, // jssdk使timestamp使timeStampS
nonceStr: self.return_data.nonceStr, // 32
package: self.return_data
.package, // prepay_idprepay_id=***
signType: 'MD5', // 'SHA1'使'MD5'
paySign: self.return_data.sign, //
success: function(res) {
//
uni.showToast({
title: '支付成功'
})
if (that.jumpType == 4) {
uni.reLaunch({
url: '/pages/tabBar/user/user'
});
return;
}
uni.reLaunch({
url: '../success/success?id=' + that.couponId
});
},
cancel: function(r) {},
fail: function(res) {}
});
});
jweixin.error(function(res) {
uni.showToast({
icon: 'none',
title: '支付失败了',
duration: 4000
});
});
},
} }
} }
</script> </script>

@ -228,9 +228,12 @@
}) })
}, },
toUser() { toUser() {
uni.switchTab({ // uni.switchTab({
// url: '/pages/tabBar/user/user'
// });
uni.reLaunch({
url: '/pages/tabBar/user/user' url: '/pages/tabBar/user/user'
}); })
}, },
scan() { scan() {
uni.scanCode({ uni.scanCode({

@ -243,9 +243,9 @@
}); });
}, },
onShow() { onShow() {
// if (app.globalData.userInfo) { if (app.globalData.userInfo) {
// this.findUser(); this.findUser();
// } }
if (!app.globalData.userInfo.isSetPayPwd) { if (!app.globalData.userInfo.isSetPayPwd) {
this.czList = [ this.czList = [

@ -23,7 +23,7 @@
jumprecharge(item) { jumprecharge(item) {
if (item == 1) { if (item == 1) {
uni.navigateTo({ uni.navigateTo({
url: '../../goods/goods-list/goods-list?id=1' url: '../../goods/goods-list/goods-list?id=2'
}) })
return; return;
} }

Loading…
Cancel
Save