源文件
This commit is contained in:
92
jeepay-ui-uapp-cashier/http/apiManager.js
Normal file
92
jeepay-ui-uapp-cashier/http/apiManager.js
Normal file
@@ -0,0 +1,92 @@
|
||||
/**
|
||||
* api接口管理, 全部以$开头
|
||||
* @author terrfly
|
||||
* @site https://www.jeequan.com
|
||||
* @date 2021/12/17 09:57
|
||||
*/
|
||||
|
||||
|
||||
import http from '@/http/http.js'
|
||||
import appConfig from '@/config/appConfig.js'
|
||||
|
||||
/** 获取获取用户ID的跳转URL */
|
||||
export function $getRedirectUrl (data) {
|
||||
return http.req('/api/cashier/redirectUrl', data, 'POST')
|
||||
}
|
||||
|
||||
/** 获取url **/
|
||||
export function $getChannelUserId (data) {
|
||||
return http.req('/api/cashier/channelUserId', data, 'POST')
|
||||
}
|
||||
|
||||
/** 调起支付接口, 获取支付数据包 **/
|
||||
export function $getPayPackage (amount, buyerRemark, mbrId, mbrTel,calcDiscount='') {
|
||||
|
||||
let data = { amount: amount, buyerRemark: buyerRemark, channelUserId: appConfig.channelUserId, mbrId, mbrTel,discount:calcDiscount }
|
||||
|
||||
// 是否 子商户小程序 调起
|
||||
data.isUseSubmchAccount = appConfig.isUseSubmchAccount
|
||||
return http.req('/api/cashier/pay', data, 'POST')
|
||||
}
|
||||
|
||||
/** 调起支付接口, 获取订单信息 **/
|
||||
export function $getPayOrderInfo () {
|
||||
return http.req('/api/cashier/payOrderInfo', null, 'POST')
|
||||
}
|
||||
|
||||
/** 取消支付时 语音播报提示 **/
|
||||
export function $payCancelBoardCast (payOrderId) {
|
||||
let data = { payOrderId: payOrderId }
|
||||
return http.req('/api/cashier/payCancelBoardCast', data, 'POST')
|
||||
}
|
||||
|
||||
/** 调起支付后,返回内容上报服务器 **/
|
||||
export function $payEventBoardCast (payOrderId, resData) {
|
||||
let data = { payOrderId: payOrderId, resData: resData }
|
||||
return http.req('/api/cashier/payEventBoardCast', data, 'POST')
|
||||
}
|
||||
|
||||
/** 支付成功后,获取广告 **/
|
||||
export function $getAdvert (data=null) {
|
||||
return http.req('/api/advert', data, 'GET')
|
||||
}
|
||||
// 查询是否开启会员模块 此接口 会返回 会员接口的baseURL
|
||||
export function $getIsMemberPower () {
|
||||
let data = { channelUserId: appConfig.channelUserId }
|
||||
return http.req('/api/cashier/memberConfig', data, 'GET')
|
||||
}
|
||||
|
||||
// 查询平台营销功能
|
||||
export function $getMarketingConfig (configKey,storeId='') {
|
||||
let data = { channelUserId: appConfig.channelUserId,configKey:configKey,storeId:storeId }
|
||||
return http.req('/api/cashier/config', data, 'GET')
|
||||
}
|
||||
|
||||
|
||||
// 计算营销红包实付金额
|
||||
export function $getCalcDiscount (amount,storeId = '') {
|
||||
let data = { channelUserId: appConfig.channelUserId,amount:amount,storeId:storeId }
|
||||
return http.req('/api/cashier/calcDiscount', data, 'GET')
|
||||
}
|
||||
|
||||
|
||||
// 支付成功后获取优惠详情
|
||||
export function $getDiscountDetail (payOrderId) {
|
||||
return http.req('/api/cashier/getDiscountDetail/'+payOrderId, 'GET')
|
||||
}
|
||||
|
||||
/** Api调起支付接口, 获取支付数据包 **/
|
||||
export function $getApiPay (amount, code,buyerRemark='') {
|
||||
|
||||
let data = { amount: amount,code:code,channelUserId:appConfig.channelUserId,auth_code:code, buyerRemark: buyerRemark }
|
||||
|
||||
// 是否 子商户小程序 调起
|
||||
data.isUseSubmchAccount = appConfig.isUseSubmchAccount
|
||||
return http.req('/api/cashier/pay', data, 'POST')
|
||||
}
|
||||
|
||||
|
||||
/** 交易轮训支付请求门店 **/
|
||||
export function $payApiDoRoute (amount, remark) {
|
||||
return http.req('/api/cashier/doRoute', { amount: amount, remark: remark }, 'POST')
|
||||
}
|
||||
30
jeepay-ui-uapp-cashier/http/apiMember.js
Normal file
30
jeepay-ui-uapp-cashier/http/apiMember.js
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
import http from '@/http/http.js'
|
||||
import appConfig from '@/config/appConfig.js'
|
||||
|
||||
|
||||
// 获取充值规则
|
||||
export function $apiMembers (data = { method: 'mch.mbr.recharge.rule' }) {
|
||||
return http.req(undefined, data, "POST", { url: appConfig.memberBaseUrl + '/api/anon/member' })
|
||||
}
|
||||
// 获取会员信息
|
||||
export function $getMemberInfo () {
|
||||
return http.req(undefined, {}, 'GET', { url: appConfig.memberBaseUrl + '/api/member' })
|
||||
}
|
||||
// 会员充值接口
|
||||
export function $recharge (data) {
|
||||
return http.req(undefined, data, 'POST', { url: appConfig.memberBaseUrl + '/api/member/recharge' })
|
||||
}
|
||||
// 会员卡支付
|
||||
export function $payRemberCard (amount, remark) {
|
||||
return http.req(undefined, { amount, remark }, "POST", { url: appConfig.memberBaseUrl + '/api/member/pay' })
|
||||
}
|
||||
// 查询会员充值记录
|
||||
export function $getMemberRechargeRecord (params) {
|
||||
return http.req(undefined, params, 'GET', { url: appConfig.memberBaseUrl + '/api/member/rechargeRecord' })
|
||||
}
|
||||
|
||||
// 查询会员消费记录
|
||||
export function $getConsumeRecod (params) {
|
||||
return http.req(undefined, params, 'GET', { url: appConfig.memberBaseUrl + '/api/member/accountHistory' })
|
||||
}
|
||||
102
jeepay-ui-uapp-cashier/http/http.js
Normal file
102
jeepay-ui-uapp-cashier/http/http.js
Normal file
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
* HTTP的封装, 基于uni.request
|
||||
* 包括: 通用响应结果的处理 和 业务的增删改查函数
|
||||
*
|
||||
* @author terrfly
|
||||
* @site https://www.jeequan.com
|
||||
* @date 2021/12/16 18:35
|
||||
*/
|
||||
|
||||
// 导入全局属性
|
||||
import appConfig from '@/config/appConfig.js'
|
||||
import {toErrPageFunc} from '@/util/toErrorPageUtil.js'
|
||||
import storageManage from '@/util/storageManage.js'
|
||||
|
||||
|
||||
function req(uri, data, method = "GET", extParams = {}){
|
||||
|
||||
// 放置token
|
||||
let headerObject = {}
|
||||
headerObject[appConfig.tokenKey] = appConfig.tokenValue
|
||||
headerObject.pageType = appConfig.currentPageType
|
||||
headerObject.iToken = storageManage.iToken()
|
||||
|
||||
// 麒麟
|
||||
// let iToken = 'Q8240202142732831';
|
||||
|
||||
//收银呗
|
||||
// let iToken = 'Q8240510155041616';
|
||||
|
||||
// headerObject[appConfig.tokenKey] = iToken
|
||||
// headerObject.pageType = appConfig.currentPageType
|
||||
// headerObject.iToken = iToken
|
||||
|
||||
return uni.request(
|
||||
Object.assign({
|
||||
url: appConfig.env.JEEPAY_PAY_BASE_URL + uri,
|
||||
data: data,
|
||||
method: method,
|
||||
header: headerObject
|
||||
}, extParams)).then((httpData) => {
|
||||
|
||||
// 从http响应数据中解构响应数据 [ 响应码、 bodyData ]
|
||||
let { statusCode, data } = httpData
|
||||
|
||||
// 避免混淆重新命名
|
||||
let bodyData = data
|
||||
|
||||
// http响应码不正确
|
||||
if(statusCode != 200){
|
||||
return Promise.reject(bodyData) // 跳转到catch函数
|
||||
}
|
||||
|
||||
// 业务响应异常
|
||||
if(bodyData.code != 0){
|
||||
|
||||
toErrPageFunc(bodyData.msg)
|
||||
return Promise.reject(bodyData.msg)
|
||||
}
|
||||
|
||||
// 构造请求成功的响应数据
|
||||
return Promise.resolve({ bizData: bodyData.data, data: data })
|
||||
|
||||
}).catch( res => {
|
||||
return Promise.reject(res)
|
||||
});
|
||||
}
|
||||
|
||||
// 通用list
|
||||
function list(uri, params){
|
||||
return req(uri, params, 'GET')
|
||||
}
|
||||
|
||||
// 通用add
|
||||
function add(uri, data){
|
||||
return req(uri, data, 'POST')
|
||||
}
|
||||
|
||||
// 通用 根据ID获取
|
||||
function getById(uri, bizId){
|
||||
return req(`${uri}/${bizId}`, {}, 'GET')
|
||||
}
|
||||
|
||||
// 通用 更新
|
||||
function updateById(uri, bizId, data){
|
||||
return req(`${uri}/${bizId}`, data, 'PUT')
|
||||
}
|
||||
|
||||
// 通用 删除
|
||||
function delById(uri, bizId){
|
||||
return req(`${uri}/${bizId}`, {}, 'DELETE')
|
||||
}
|
||||
|
||||
|
||||
|
||||
export default {
|
||||
req : req,
|
||||
list: list,
|
||||
add: add,
|
||||
getById: getById,
|
||||
updateById: updateById,
|
||||
delById: delById
|
||||
}
|
||||
Reference in New Issue
Block a user