parent
54e211723d
commit
acc680a9cd
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* @Author: ch
|
||||
* @Date: 2022-07-09 16:28:10
|
||||
* @LastEditors: ch
|
||||
* @LastEditTime: 2022-07-09 17:25:13
|
||||
* @Description: file content
|
||||
*/
|
||||
|
||||
import {ToAsyncAwait, MsbRequest} from '@/common/utils';
|
||||
|
||||
// 第三方鉴权服务
|
||||
const AUTH_URL = '/third';
|
||||
const APPID = 'wxd2015f0c56defa02';
|
||||
|
||||
|
||||
/**
|
||||
* 获取授权页面地址
|
||||
* @param {*} data
|
||||
*/
|
||||
export const ApiGetAuthUrl = (params) =>
|
||||
ToAsyncAwait(MsbRequest.get(`${AUTH_URL}/wx/mp/getAuthorizationUrl/${params.appid}`, params));
|
||||
/**
|
||||
* 获取openId
|
||||
* @param {*} data
|
||||
*/
|
||||
export const ApiGetOpenId = ({code, appid}) =>
|
||||
ToAsyncAwait(MsbRequest.get(`${AUTH_URL}/wx/mp/getOpenId/${appid}`, { code }));
|
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* @Author: ch
|
||||
* @Date: 2022-07-09 16:27:57
|
||||
* @LastEditors: ch
|
||||
* @LastEditTime: 2022-07-09 18:29:05
|
||||
* @Description: file content
|
||||
*/
|
||||
|
||||
import {ToAsyncAwait, MsbRequest} from '@/common/utils';
|
||||
|
||||
// 第三方鉴权服务
|
||||
const AUTH_URL = '/third';
|
||||
|
||||
|
||||
/**
|
||||
* 获取订单信息
|
||||
* @param {*} data
|
||||
*/
|
||||
export const ApiGetOrderInfo = ({payOrderNo}) =>
|
||||
ToAsyncAwait(MsbRequest.get(`/payCenter/payCenter/prepayOrder/${payOrderNo}`));
|
||||
/**
|
||||
* 获取openId
|
||||
* @param {*} data
|
||||
*/
|
||||
export const ApiPostH5Pay = (data) =>
|
||||
ToAsyncAwait(MsbRequest.put(`payCenter/payCenter/cashierPay`, data));
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* @Author: ch
|
||||
* @Date: 2022-04-29 14:26:10
|
||||
* @LastEditors: ch
|
||||
* @LastEditTime: 2022-06-30 16:03:35
|
||||
* @Description: file content
|
||||
*/
|
||||
|
||||
import { ApiPostAliH5Pay, ApiPostAliAppPay } from '@/common/api/pay';
|
||||
import ENV from '@/common/config/env';
|
||||
export const Alipay = async ({orderId})=>{
|
||||
|
||||
// #ifdef APP-PLUS
|
||||
const {error, result} = await ApiPostAliAppPay({orderId});
|
||||
if(error){
|
||||
uni.$u.toast(error.message);
|
||||
return false;
|
||||
}
|
||||
const par = result.payDataInfo;
|
||||
uni.requestPayment({
|
||||
provider: 'alipay',
|
||||
orderInfo :par.payData,
|
||||
success(res) {
|
||||
uni.navigateTo({
|
||||
url : `/payResult?orderId=${orderId}&payType=appWx`
|
||||
});
|
||||
},
|
||||
fail(e) {
|
||||
uni.navigateTo({
|
||||
url : `/payResult?orderId=${orderId}&payType=appWx`
|
||||
});
|
||||
}
|
||||
}).then(res => {
|
||||
console.log('res',res);
|
||||
})
|
||||
// #endif
|
||||
|
||||
// #ifdef H5
|
||||
const { error, result } = await ApiPostAliH5Pay({
|
||||
orderId,
|
||||
returnUrl : decodeURIComponent(`${ENV.staticUrl}/payResult?orderId=${orderId}&payType=alih5`)
|
||||
});
|
||||
if(error){
|
||||
uni.$u.toast(error.message);
|
||||
return false;
|
||||
}
|
||||
window.location.href = result.payDataInfo.payUrl;
|
||||
// #endif
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
/*
|
||||
* @Author: ch
|
||||
* @Date: 2022-03-22 16:52:28
|
||||
* @LastEditors: ch
|
||||
* @LastEditTime: 2022-07-09 16:46:43
|
||||
* @LastEditTime: 2022-06-29 17:22:32
|
||||
* @Description: 所有工具类统一在这输出
|
||||
*/
|
||||
import * as util from './utils';
|
||||
import * as requset from './requset';
|
||||
export * from './utils';
|
||||
export * from './requset';
|
||||
|
||||
export default { ...util, ...requset}
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* @Author: ch
|
||||
* @Date: 2022-07-09 18:02:07
|
||||
* @LastEditors: ch
|
||||
* @LastEditTime: 2022-07-09 18:35:59
|
||||
* @Description: 这个文件里面的方法都是直接挂载在uni对象和this上的
|
||||
*/
|
||||
import Vue from 'vue';
|
||||
const _$toast = (msg, duration = 3000) => {
|
||||
return new Promise((reverse, reject) => {
|
||||
uni.showToast({
|
||||
title: msg,
|
||||
icon: 'none',
|
||||
duration,
|
||||
success() {
|
||||
setTimeout(() => {
|
||||
reverse(true)
|
||||
}, duration)
|
||||
},
|
||||
fail() {
|
||||
reject(false)
|
||||
}
|
||||
});
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
const utils = {
|
||||
_$toast
|
||||
}
|
||||
for (let key in utils) {
|
||||
uni[key] = utils[key];
|
||||
Vue.prototype[key] = utils[key];
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* @Author: ch
|
||||
* @Date: 2022-03-17 19:15:10
|
||||
* @LastEditors: ch
|
||||
* @LastEditTime: 2022-07-09 16:55:11
|
||||
* @Description: 一些无法归类的公共方法容器
|
||||
*/
|
||||
|
||||
import {
|
||||
toAsyncAwait as ToAsyncAwait,
|
||||
isPhone as IsPhone,
|
||||
formatDate as FormatDate,
|
||||
creatUuid as CreateUUID,
|
||||
formatSearchJson as FormatSearchJson,
|
||||
formatJsonSearch as FormatJsonSearch
|
||||
|
||||
} from "js-util-all";
|
||||
|
||||
// 工具类的文件需要把文件提供的工具类统一放最下方做一个统一输出
|
||||
export {
|
||||
// async await 标识结果处理
|
||||
ToAsyncAwait,
|
||||
// 判断是否为手机号
|
||||
IsPhone,
|
||||
FormatSearchJson,
|
||||
FormatJsonSearch,
|
||||
}
|
@ -1,78 +0,0 @@
|
||||
/*
|
||||
* @Author: ch
|
||||
* @Date: 2022-04-29 14:26:10
|
||||
* @LastEditors: ch
|
||||
* @LastEditTime: 2022-07-08 17:38:48
|
||||
* @Description: file content
|
||||
*/
|
||||
|
||||
import { ApiPostWxH5Pay, ApiPostWxJsApiPay, ApiPostWxAppPay } from '@/common/api/pay';
|
||||
import ENV from '@/common/config/env';
|
||||
export const Wxpay = async ({orderId,openId})=>{
|
||||
|
||||
// #ifdef APP-PLUS
|
||||
const {error, result} = await ApiPostWxAppPay({orderId});
|
||||
const par = result.payDataInfo;
|
||||
uni.requestPayment({
|
||||
provider: 'wxpay',
|
||||
orderInfo :{
|
||||
"appid": par.appId, // 微信开放平台 - 应用 - AppId
|
||||
"noncestr": par.nonceStr, // 随机字符串
|
||||
"package": par.packageValue, // 固定值
|
||||
"partnerid": par.partnerId, // 微信支付商户号
|
||||
"prepayid": par.prepayId, // 统一下单订单号
|
||||
"timestamp": par.timeStamp ,// 时间戳(单位:秒)
|
||||
"sign": par.sign // 签名,这里用的 MD5 签名
|
||||
},
|
||||
success(res) {
|
||||
uni.navigateTo({
|
||||
url : `/payResult?orderId=${orderId}&payType=appWx`
|
||||
});
|
||||
},
|
||||
fail(e) {
|
||||
uni.navigateTo({
|
||||
url : `/payResult?orderId=${orderId}&payType=appWx`
|
||||
});
|
||||
}
|
||||
}).then(res => {
|
||||
console.log('res',res);
|
||||
})
|
||||
// #endif
|
||||
|
||||
// #ifdef H5
|
||||
// 有openId则判断在微信浏览器内
|
||||
if(openId) {
|
||||
// 微信JSAPI
|
||||
const {error, result} = await ApiPostWxJsApiPay({orderId,openId});
|
||||
if(error){
|
||||
uni.$u.toast(error.message);
|
||||
return false;
|
||||
}
|
||||
const par = result.payDataInfo;
|
||||
WeixinJSBridge.invoke('getBrandWCPayRequest', {
|
||||
appId : par.appId,
|
||||
timeStamp : par.timeStamp,
|
||||
nonceStr : par.nonceStr,
|
||||
package: par.packageValue,
|
||||
signType : par.signType,
|
||||
paySign : par.paySign
|
||||
}, res => {
|
||||
if(res.err_msg !== 'get_brand_wcpay_request:cancel'){
|
||||
uni.navigateTo({
|
||||
url : `/payResult?orderId=${orderId}&payType=wxjsapi`
|
||||
});
|
||||
}
|
||||
})
|
||||
}else{
|
||||
// h5支付
|
||||
const {error, result} = await ApiPostWxH5Pay({orderId});
|
||||
if(error){
|
||||
uni.$u.toast(error.message);
|
||||
return false;
|
||||
}
|
||||
const redirect_url = decodeURIComponent(`${ENV.staticUrl}/payResult?orderId=${orderId}&payType=wxh5`);
|
||||
window.location.href = `${result.payDataInfo.h5Url}&redirect_url=${redirect_url}`;
|
||||
}
|
||||
// #endif
|
||||
|
||||
}
|
Loading…
Reference in new issue