Compare commits

...

3 Commits

Author SHA1 Message Date
杨杰 4924fe1086 1.修改支付重复点击 1 year ago
杨杰 7669d96f0e 1.打包扫码支付 1 year ago
杨杰 2481e22a17 1.对接惠支付 云闪付支付 1 year ago
  1. 1
      App.vue
  2. 5
      Utils/Api.js
  3. 3
      Utils/Request.js
  4. 41
      pages/index/index.vue
  5. 63
      pages/welcome/welcome.vue

@ -24,6 +24,7 @@
// graurl:'https://gratia-pay.dctpay.com/crest', // graurl:'https://gratia-pay.dctpay.com/crest',
// 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/',
isClick: true, //
}, },
onLaunch: function() { onLaunch: function() {

@ -63,3 +63,8 @@ export const getUserDetail = params => {
export const queryUserDiscountList = params => { export const queryUserDiscountList = params => {
return POST('GET', `${base}/discount/queryUserDiscountList`, params).then(res => res.data); return POST('GET', `${base}/discount/queryUserDiscountList`, params).then(res => res.data);
} }
// 获取拉卡拉银联用户id
export const getUnionUserId = params => {
return POST('POST', `${grabase}/tradeOrder/getUnionUserId`, params).then(res => res.data);
}

@ -40,8 +40,9 @@ function request(method, url, data) {
} }
}, },
fail(err) { fail(err) {
app.globalData.isClick = true;
uni.showToast({ uni.showToast({
title: '请求失败', title: '请求失败,查看网络是否正常',
icon: 'none', icon: 'none',
duration: 1500, duration: 1500,
}) })

@ -672,13 +672,16 @@
// if (userAgent.match(/Alipay/i) == "alipay") { // if (userAgent.match(/Alipay/i) == "alipay") {
// this.createJSAPIOrder('ALIPAY'); // this.createJSAPIOrder('ALIPAY');
// } else if (userAgent.match(/MicroMessenger/i) == "micromessenger") { // } else if (userAgent.match(/MicroMessenger/i) == "micromessenger") {
if (app.globalData.isClick) {
this.createJSAPIOrder(); this.createJSAPIOrder();
app.globalData.isClick = false;
}
// } // }
}, },
// //
createJSAPIOrder(item) { createJSAPIOrder(item) {
uni.showLoading({ uni.showLoading({
title:'请求中' title: '请求中'
}) })
// "WECHAT ALIPAY UQRCODEPAY", // "WECHAT ALIPAY UQRCODEPAY",
let phone = ''; let phone = '';
@ -699,6 +702,7 @@
if (res.return_code == '000000') { if (res.return_code == '000000') {
this.jsapiPay(res.return_data.outTradeNo); this.jsapiPay(res.return_data.outTradeNo);
} else { } else {
app.globalData.isClick = true;
uni.showToast({ uni.showToast({
title: res.return_msg, title: res.return_msg,
duration: 2000, duration: 2000,
@ -709,10 +713,14 @@
}, },
// //
jsapiPay(item) { jsapiPay(item) {
uni.showLoading({
title: '请求中'
})
let datas = { let datas = {
outTradeNo: item outTradeNo: item
} }
jsapiPay(datas).then(res => { jsapiPay(datas).then(res => {
uni.hideLoading();
if (res.return_code == '000000') { if (res.return_code == '000000') {
if (res.return_data.payParam && app.globalData.platformType == 'WECHAT') { if (res.return_data.payParam && app.globalData.platformType == 'WECHAT') {
this.wechatpayRequest(res.return_data); this.wechatpayRequest(res.return_data);
@ -733,6 +741,7 @@
duration: 2000 duration: 2000
}) })
} else { } else {
app.globalData.isClick = true;
uni.showToast({ uni.showToast({
title: res.return_msg, title: res.return_msg,
duration: 2000, duration: 2000,
@ -848,10 +857,11 @@
}, },
// //
wechatpayRequest: function(self) { wechatpayRequest: function(self) {
let that = this;
uni.showLoading({ uni.showLoading({
title: '支付中...' title: '支付中...'
}) })
if (self.platformType == 1) { if (self.platformType == 1 || self.platformType == 5) {
jweixin.config({ jweixin.config({
debug: false, // ,apialertpclogpc debug: false, // ,apialertpclogpc
appId: self.payParam.acc_resp_fields.app_id, // appId: self.payParam.acc_resp_fields.app_id, //
@ -864,8 +874,12 @@
jweixin.ready(function() { jweixin.ready(function() {
jweixin.checkJsApi({ jweixin.checkJsApi({
jsApiList: ['chooseWXPay'], // JSJS2, jsApiList: ['chooseWXPay'], // JSJS2,
success: function(res) {}, success: function(res) {
fail: function(res) {} app.globalData.isClick = true;
},
fail: function(res) {
app.globalData.isClick = true;
}
}); });
jweixin.chooseWXPay({ jweixin.chooseWXPay({
appId: self.payParam.acc_resp_fields.app_id, appId: self.payParam.acc_resp_fields.app_id,
@ -883,11 +897,16 @@
title: '支付成功' title: '支付成功'
}) })
}, },
cancel: function(r) {}, cancel: function(r) {
fail: function(res) {} app.globalData.isClick = true;
},
fail: function(res) {
app.globalData.isClick = true;
}
}); });
}); });
jweixin.error(function(res) { jweixin.error(function(res) {
app.globalData.isClick = true;
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '支付失败了', title: '支付失败了',
@ -924,11 +943,16 @@
title: '支付成功' title: '支付成功'
}) })
}, },
cancel: function(r) {}, cancel: function(r) {
fail: function(res) {} app.globalData.isClick = true;
},
fail: function(res) {
app.globalData.isClick = true;
}
}); });
}); });
jweixin.error(function(res) { jweixin.error(function(res) {
app.globalData.isClick = true;
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: '支付失败了', title: '支付失败了',
@ -942,6 +966,7 @@
alipayApi.tradePay({ alipayApi.tradePay({
tradeNO: item tradeNO: item
}, function(res) { }, function(res) {
app.globalData.isClick = true;
// alert(JSON.stringify(res)); // alert(JSON.stringify(res));
// //
}); });

@ -1,25 +1,35 @@
<template> <template>
<view> <view>
</view> </view>
</template> </template>
<script> <script>
import { import {
getH5AccessToken, getH5AccessToken,
getAlipayUserId getAlipayUserId,
getUnionUserId
} from '../../Utils/Api.js'; } from '../../Utils/Api.js';
let app = getApp(); let app = getApp();
export default { export default {
data() { data() {
return { return {
appUpIdentifier: ''
} }
}, },
onLoad(options) { onLoad(options) {
//
if (app.globalData.platformType == 'UQRCODEPAY') {
var useragent = navigator.userAgent;
var agentname = useragent.split('UnionPay/');
var agentno = agentname[1];
var agentnoname = agentno.split(')');
var lastangetname = agentnoname[0];
this.appUpIdentifier = 'UnionPay/' + lastangetname;
}
var arr1 = window.location.href; var arr1 = window.location.href;
var arr2 = arr1.split('='); var arr2 = arr1.split('=');
if (app.globalData.platformType == 'WECHAT' || app.globalData.platformType == 'ALIPAY') { if (app.globalData.platformType == 'WECHAT' || app.globalData.platformType == 'ALIPAY' || app.globalData
.platformType == 'UQRCODEPAY') {
if (arr2[1].length == 12) { if (arr2[1].length == 12) {
var arr3 = arr2[1].split('#/'); var arr3 = arr2[1].split('#/');
app.globalData.snNo = arr3[0]; app.globalData.snNo = arr3[0];
@ -31,6 +41,16 @@
} else { } else {
let that = this; let that = this;
var arr4; var arr4;
if (app.globalData.platformType == 'UQRCODEPAY') {
arr4 = arr2[1].split('&');
app.globalData.code = arr4[0];
uni.getStorage({
key: 'snNumber',
success(e) {
app.globalData.snNo = e.data;
}
})
} else {
arr4 = arr2[2].split('&'); arr4 = arr2[2].split('&');
app.globalData.code = arr4[0]; app.globalData.code = arr4[0];
uni.getStorage({ uni.getStorage({
@ -40,6 +60,7 @@
} }
}) })
} }
}
if (app.globalData.code && app.globalData.platformType == 'WECHAT') { if (app.globalData.code && app.globalData.platformType == 'WECHAT') {
this.getH5AccessToken(); this.getH5AccessToken();
@ -47,6 +68,9 @@
if (app.globalData.code && app.globalData.platformType == 'ALIPAY') { if (app.globalData.code && app.globalData.platformType == 'ALIPAY') {
this.getAlipayUserId(); this.getAlipayUserId();
} }
if (app.globalData.code && app.globalData.platformType == 'UQRCODEPAY') {
this.getUnionUserId();
}
} else { } else {
var arr1 = window.location.href; var arr1 = window.location.href;
var arr2 = arr1.split('='); var arr2 = arr1.split('=');
@ -60,9 +84,10 @@
url: '../index/index' url: '../index/index'
}) })
} }
}, },
methods: { methods: {
//H5 openId //H5 openId
getH5AccessToken() { getH5AccessToken() {
let params = { let params = {
@ -103,6 +128,28 @@
} }
}); });
}, },
//openid
getUnionUserId() {
let params = {
"serialNumber": app.globalData.snNo,
"userAuthCode": app.globalData.code,
"appUpIdentifier": this.appUpIdentifier
}
getUnionUserId(params).then(res => {
if (res.return_code == '000000' && res.return_data.respData.userId) {
app.globalData.openId = res.return_data.respData.userId;
uni.setStorage({
key: "openId",
data: res.return_data.respData.userId
})
uni.reLaunch({
url: '../index/index'
})
} else {
this.jumpWeb();
}
});
},
// //
jumpWeb() { jumpWeb() {
if (app.globalData.platformType == 'WECHAT') { if (app.globalData.platformType == 'WECHAT') {
@ -113,6 +160,10 @@
location.href = location.href =
'https://openauth.alipay.com/oauth2/publicAppAuthorize.htm?app_id=2021003176605875&scope=auth_base&redirect_uri=https://pay.dctpay.com/redirect?redirect_uri=https%3A%2F%2Fpay.dctpay.com%2FscanPay%3Fsn%3D1000017476'; 'https://openauth.alipay.com/oauth2/publicAppAuthorize.htm?app_id=2021003176605875&scope=auth_base&redirect_uri=https://pay.dctpay.com/redirect?redirect_uri=https%3A%2F%2Fpay.dctpay.com%2FscanPay%3Fsn%3D1000017476';
} }
if (app.globalData.platformType == 'UQRCODEPAY') {
location.href =
'https://qr.95516.com/qrcGtwWeb-web/api/userAuth?version=1.0.0&redirectUrl=https://pay.dctpay.com/scanPay';
}
}, },
} }
} }

Loading…
Cancel
Save