2 Star 0 Fork 0

DarkSunny/huifu_pay

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
util.js 3.36 KB
Copy Edit Raw Blame History
dongtingliang authored 2024-11-20 18:40 . 初始化代码
/*eslint-disable*/
// 获取URL中参数值
function GetQueryString(name) {
var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
var r = window.location.search.substr(1).match(reg);
if (r != null) return decodeURI(r[2]);
return null;
}
function deepClone(source) {
if (!source && typeof source !== 'object') {
throw new Error('error arguments', 'deepClone');
}
const targetObj = source.constructor === Array ? [] : {};
Object.keys(source).forEach((keys) => {
if (source[keys] && typeof source[keys] === 'object') {
targetObj[keys] = deepClone(source[keys]);
} else {
targetObj[keys] = source[keys];
}
});
return targetObj;
}
// 微信授权
function weixinAuth() {
let urlNow = encodeURIComponent(window.location.href);
let scope = 'snsapi_base'; //snsapi_userinfo //静默授权 用户无感知
let appid = configObj.mobile.wxConfig.appid;
let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${urlNow}&response_type=code&scope=${scope}&state=STATE&connect_redirect=1#wechat_redirect`;
window.location.replace(url);
}
// 银联授权
function unionAuth() {
let urlNow = encodeURIComponent(window.location.href);
let url = 'https://qr.95516.com/qrcGtwWeb-web/api/userAuth?version=1.0.0&redirectUrl=' + urlNow;
window.location.replace(url);
}
var isInWeiXinApp = window.navigator.userAgent.toLowerCase().search(/MicroMessenger/i) > -1;
var isInAliPayApp = window.navigator.userAgent.toLowerCase().search(/AlipayClient/i) > -1;
var isInUnionApp = window.navigator.userAgent.toLowerCase().search(/CloudPay/i) > -1;
//生成自定义位数随机数
function randomNum(minNum, maxNum) {
switch (arguments.length) {
case 1:
return parseInt(Math.random() * minNum + 1);
case 2:
return parseInt(Math.random() * (maxNum - minNum + 1) + minNum);
default:
return 0;
}
}
// 支付状态
var mods = {};
// 支付渠道
// alipay_wap: 支付宝H5支付
// wx_pub: 微信H5支付
mods.channelConfig = {
alipay_qr: 'alipay_qr',
alipay_wap: 'alipay_wap',
wx_pub: 'wx_pub',
};
// payment参数校验结果
mods.chackMsg = {
orderError: '发起支付失败',
channelError: '支付渠道参数错误',
amountError: '支付金额参数错误',
queryUrlError: '支付结果url参数未知',
};
// 支付状态值
mods.payStatus = {
succeeded: 'succeeded',
failed: 'failed',
pending: 'pending',
timeout: 'timeout',
cancel: 'unknown',
unknown: 'unknown',
paramError: 'paramError',
};
// 支付结果对象
mods.payResult = {
succeeded: {
result_status: mods.payStatus.succeeded,
result_message: '订单支付成功',
result_info: {},
},
failed: {
result_status: mods.payStatus.failed,
result_message: '订单支付失败',
result_info: {},
},
pending: {
result_status: mods.payStatus.pending,
result_message: '订单支付中',
result_info: {},
},
timeout: {
result_status: mods.payStatus.timeout,
result_message: '订单支付超时',
result_info: {},
},
cancel: {
result_status: mods.payStatus.cancel,
result_message: '支付取消',
result_info: {},
},
unknown: {
result_status: mods.payStatus.unknown,
result_message: '订单结果未知',
result_info: {},
},
paramError: {
result_status: mods.payStatus.paramError,
result_message: '参数错误',
result_info: {},
},
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/darksunny_admin/huifu_pay.git
git@gitee.com:darksunny_admin/huifu_pay.git
darksunny_admin
huifu_pay
huifu_pay
master

Search

0d507c66 1850385 C8b1a773 1850385