first
This commit is contained in:
624
http/apiManager.js
Normal file
624
http/apiManager.js
Normal file
@@ -0,0 +1,624 @@
|
||||
/**
|
||||
* api接口管理, 全部以$开头
|
||||
* @author terrfly
|
||||
* @site https://www.jeequan.com
|
||||
* @date 2021/12/17 09:57
|
||||
*/
|
||||
|
||||
import http from './http.js'
|
||||
import appConfig from '@/config/appConfig.js'
|
||||
import {
|
||||
Base64
|
||||
} from 'js-base64'
|
||||
import infoBox from '@/commons/utils/infoBox.js'
|
||||
|
||||
export const req = {
|
||||
list: (uri, params) => {
|
||||
return http.req(uri, params, 'GET', false)
|
||||
},
|
||||
|
||||
add: (uri, data) => {
|
||||
return http.req(uri, data, 'POST', false)
|
||||
},
|
||||
|
||||
getById: (uri, bizId) => {
|
||||
return http.req(`${uri}/${bizId}`, {}, 'GET', false)
|
||||
},
|
||||
|
||||
updateById: (uri, bizId, data) => {
|
||||
return http.req(`${uri}/${bizId}`, data, 'PUT', false)
|
||||
},
|
||||
|
||||
delById: (uri, bizId) => {
|
||||
return http.req(`${uri}/${bizId}`, {}, 'DELETE', false)
|
||||
},
|
||||
}
|
||||
|
||||
export const reqLoad = {
|
||||
list: (uri, params) => {
|
||||
return http.req(uri, params, 'GET')
|
||||
},
|
||||
|
||||
add: (uri, data) => {
|
||||
return http.req(uri, data, 'POST')
|
||||
},
|
||||
|
||||
getById: (uri, bizId) => {
|
||||
return http.req(`${uri}/${bizId}`, {}, 'GET')
|
||||
},
|
||||
|
||||
updateById: (uri, bizId, data) => {
|
||||
return http.req(`${uri}/${bizId}`, data, 'PUT')
|
||||
},
|
||||
|
||||
delById: (uri, bizId) => {
|
||||
return http.req(`${uri}/${bizId}`, {}, 'DELETE')
|
||||
},
|
||||
|
||||
// 通用 新增 or 更新
|
||||
addOrUpdate: (bizId, url, data, showMessage = true) => {
|
||||
//包含bizId 请求的是修改接口
|
||||
if (bizId) {
|
||||
return reqLoad.updateById(url, bizId, data).then((res) => {
|
||||
if (showMessage) {
|
||||
return infoBox.showSuccessToast('更新成功').then(() => res)
|
||||
}
|
||||
return Promise.resolve(res)
|
||||
})
|
||||
} else {
|
||||
return reqLoad.add(url, data).then((res) => {
|
||||
if (showMessage) {
|
||||
return infoBox.showSuccessToast('新增成功').then(() => res)
|
||||
}
|
||||
return Promise.resolve(res)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 上传文件 url **/
|
||||
export const API_URL_SINGLE_FILE_UPLOAD = '/api/ossFiles/singleFile'
|
||||
|
||||
/** 公告 **/
|
||||
export const API_URL_SYS_ARTICLES = '/api/sysArticles'
|
||||
|
||||
/** 支付订单列表 */
|
||||
export const API_URL_PAY_ORDER_LIST = '/api/payOrder'
|
||||
|
||||
/** 退款订单列表 */
|
||||
export const API_URL_REFUND_LIST = '/api/refundOrder'
|
||||
|
||||
/** 商户应用 */
|
||||
export const API_URL_MCH_APP_LIST = '/api/mchApps'
|
||||
|
||||
/** 门店列表 */
|
||||
export const API_URL_MCH_STORE_LIST = '/api/mchStore'
|
||||
|
||||
/** 通知接收人列表 */
|
||||
export const API_URL_WXMP_USER_LIST = '/api/wxmp'
|
||||
|
||||
/** 进件管理 */
|
||||
export const API_URL_MCH_APPLYMENT_LIST = '/api/mchApplyments'
|
||||
|
||||
/** 员工管理 */
|
||||
export const API_URL_SYS_USER_LIST = '/api/sysUsers'
|
||||
|
||||
/** 码牌管理 */
|
||||
export const API_URL_SYS_CODE_LIST = '/api/mchQrCodes'
|
||||
|
||||
/** 通用设备管理 deviceType 1-喇叭 2-打印机 3-扫码POS 4-智能POS 6-刷脸设备*/
|
||||
export const API_URL_SYS_DEVICE_LIST = '/api/store/device'
|
||||
|
||||
/** 辅助终端管理*/
|
||||
export const API_URL_SYS_TERMINALS = '/api/mchTerminals'
|
||||
|
||||
/** 用户绑定门店列表 */
|
||||
export const API_URL_USER_BIND_STORE_LIST = '/api/mchStore/userStoreRelas'
|
||||
|
||||
/** 商户支付通道列表 */
|
||||
export const API_URL_PAY_PASSAGE_LIST = '/api/mch/payPassages'
|
||||
/** 广告列表 */
|
||||
export const API_URI_PAY_AD_LIST = '/api/advert'
|
||||
/** 如意门店操作 */
|
||||
export const API_URI_DEV_RUYI = '/api/alipayShop'
|
||||
|
||||
/** 会员管理 */
|
||||
export const API_URL_MEMBERS = '/api/member'
|
||||
|
||||
/** 会员充值记录 */
|
||||
export const API_URL_MEMBER_RECHARGE_RECORDS = '/api/member/rechargeRecord'
|
||||
|
||||
/** 会员充值规则管理 */
|
||||
export const API_URL_MEMBER_RECHARGE_RULES = '/api/member/rechargeRule'
|
||||
|
||||
/** 会员账户流水 */
|
||||
export const API_URL_MEMBER_ACCOUNT_HISTORY = '/api/member/accountHistory'
|
||||
|
||||
//营销红包开始
|
||||
|
||||
//红包规则
|
||||
export const API_URL_MCH_REF_PACKET_RULE_LIST = '/api/redPacketRule'
|
||||
//新增红包规则
|
||||
export const API_URL_MCH_REF_PACKET_RULE_ADD = '/api/redPacketRule'
|
||||
|
||||
//顾客统计
|
||||
export const API_URL_MCH_REF_PACKET_RULE_COUNT = '/api/redPacketUser/count'
|
||||
//顾客列表
|
||||
export const API_URL_MCH_REF_PACKET_USER_LIST = '/api/redPacketUser'
|
||||
//顾客红包
|
||||
export const API_URL_MCH_REF_PACKET_INFO_LIST = '/api/redPacketInfo'
|
||||
//红包查询规则详情
|
||||
export const API_URL_MCH_REF_PACKET_RULE_QUERY = '/api/redPacketRule'
|
||||
//红包修改规则
|
||||
export const API_URL_MCH_REF_PACKET_RULE_EDIT = '/api/redPacketRule/edit'
|
||||
//红包余额变动明细列表
|
||||
export const API_URL_MCH_REF_PACKET_CHANGE = '/api/redPacketChange'
|
||||
//渠道列表
|
||||
export const API_URL_MCH_ISV_LIST = '/api/isvInfo/isvInfoList'
|
||||
|
||||
|
||||
|
||||
/* 密码登录 */
|
||||
export function $loginByPwd(username, pwd, safetyCode) {
|
||||
// 登录类型
|
||||
let lt = ''
|
||||
// #ifdef APP-PLUS
|
||||
lt = Base64.encode('APP')
|
||||
// #endif
|
||||
// #ifdef H5 || MP-WEIXIN
|
||||
lt = Base64.encode('LITE')
|
||||
// #endif
|
||||
|
||||
let data = {
|
||||
ia: Base64.encode(username),
|
||||
ip: Base64.encode(pwd),
|
||||
mc: safetyCode ? Base64.encode(safetyCode) : null,
|
||||
lt: lt,
|
||||
}
|
||||
return http.req('/api/anon/auth/validate', data, 'POST')
|
||||
}
|
||||
|
||||
/* 验证码登录 */
|
||||
export function $phoneCodeLogin(phone, code) {
|
||||
// 登录类型
|
||||
let lt = ''
|
||||
// #ifdef APP-PLUS
|
||||
lt = Base64.encode('APP')
|
||||
// #endif
|
||||
// #ifdef H5 || MP-WEIXIN
|
||||
lt = Base64.encode('LITE')
|
||||
// #endif
|
||||
|
||||
let data = {
|
||||
phone: Base64.encode(phone),
|
||||
code: Base64.encode(code),
|
||||
lt: lt,
|
||||
}
|
||||
|
||||
return http.req('/api/anon/auth/phoneCode', data, 'POST')
|
||||
}
|
||||
|
||||
// 找回密码
|
||||
export function $retrieve({
|
||||
phone,
|
||||
code,
|
||||
newPwd
|
||||
}) {
|
||||
let data = {
|
||||
phone: Base64.encode(phone),
|
||||
code: Base64.encode(code),
|
||||
newPwd: newPwd ? Base64.encode(newPwd) : ''
|
||||
}
|
||||
return http.req('/api/anon/cipher/retrieve', data, 'POST')
|
||||
}
|
||||
|
||||
/* 修改密码 */
|
||||
export function $modifyPwd({
|
||||
originalPwd,
|
||||
confirmPwd
|
||||
}) {
|
||||
let data = {
|
||||
originalPwd: Base64.encode(originalPwd),
|
||||
confirmPwd: Base64.encode(confirmPwd)
|
||||
}
|
||||
return http.req("/api/current/modifyPwd", data, "PUT")
|
||||
}
|
||||
|
||||
/* 注册新商户 */
|
||||
export function $mchRegister({
|
||||
mchName,
|
||||
confirmPwd,
|
||||
inviteCode,
|
||||
phone,
|
||||
code
|
||||
}) {
|
||||
let data = {
|
||||
mchName: mchName, // 用户名称
|
||||
confirmPwd: Base64.encode(confirmPwd), // 确认密码
|
||||
inviteCode, // 邀请码
|
||||
phone: Base64.encode(phone), // 手机号
|
||||
code: Base64.encode(code), // 短信验证码
|
||||
}
|
||||
return http.req('/api/anon/register/mchRegister', data, 'POST')
|
||||
}
|
||||
|
||||
/* 发送短信验证码 */
|
||||
export function $sendSms(data, smsType) {
|
||||
return http.req('/api/anon/sms/code', {
|
||||
phone: data.phone,
|
||||
vercode: data.vercode,
|
||||
vercodeToken: data.vercodeToken,
|
||||
smsType: smsType
|
||||
}, 'POST')
|
||||
}
|
||||
|
||||
/* 获取个人信息 */
|
||||
export function $userInfo(cid1, cid2) {
|
||||
return http.req('/api/current/user', {
|
||||
cid1,
|
||||
cid2
|
||||
}, 'GET')
|
||||
}
|
||||
|
||||
/* 获取公司信息 */
|
||||
export function $getSiteInfos() {
|
||||
return http.req('/api/anon/siteInfos', {}, 'GET')
|
||||
}
|
||||
|
||||
// 隐私政策与服务协议
|
||||
export function $getTreaty() {
|
||||
return http.req('/api/anon/treaty', {}, 'GET')
|
||||
}
|
||||
|
||||
/* 快捷收银 */
|
||||
export function $appPay(storeId, amount, sellerRemark, wayCode, authCode) {
|
||||
let data = {
|
||||
storeId,
|
||||
amount,
|
||||
sellerRemark,
|
||||
wayCode,
|
||||
authCode
|
||||
}
|
||||
|
||||
// 二维码, 返回结果为 图片地址
|
||||
if (wayCode == 'QR_CASHIER') {
|
||||
data.payDataType = 'codeImgUrl'
|
||||
}
|
||||
|
||||
return http.req('/api/pay/app', data, 'POST')
|
||||
}
|
||||
|
||||
/* 当前商户信息 */
|
||||
export function $getMchInfo() {
|
||||
return http.req('/api/mainChart', {}, 'GET')
|
||||
}
|
||||
|
||||
/* 订单打印 */
|
||||
export function $payOrderPrint(orderId) {
|
||||
return http.req('/api/payOrder/print/' + orderId, {}, 'GET')
|
||||
}
|
||||
|
||||
/* 订单退款 */
|
||||
export function $payOrderRefund(orderId, refundAmount, refundReason, refundPassword) {
|
||||
return http.req(
|
||||
'/api/payOrder/refunds/' + orderId, {
|
||||
refundAmount: refundAmount,
|
||||
refundReason: refundReason,
|
||||
refundPassword: Base64.encode(refundPassword),
|
||||
refundModel: 1
|
||||
},
|
||||
'POST'
|
||||
)
|
||||
}
|
||||
// // 首页统计信息
|
||||
// export function $indexStatistics (queryDateRange) {
|
||||
// return http.req('/api/mainChart/payDayCount', { queryDateRange }, 'GET')
|
||||
// }
|
||||
|
||||
// 首页统计信息
|
||||
export function $indexStatistics(queryDateRange) {
|
||||
return http.req('/api/payOrder/count?queryDateRange', {
|
||||
queryDateRange
|
||||
}, 'GET')
|
||||
}
|
||||
|
||||
// 统计报表
|
||||
export function $getStatInfo(data) {
|
||||
return http.req('/api/statistic/total', data, 'GET', false)
|
||||
}
|
||||
// 统计报表设备 门店 支付方式统计
|
||||
export function $getStatistic(data) {
|
||||
return http.req('/api/statistic', data, 'GET')
|
||||
}
|
||||
|
||||
/* 经纬度转换为areacode */
|
||||
export function $location2areacode(location) {
|
||||
return http.req('/api/mchStore/location2areacode/', {
|
||||
location: location
|
||||
}, 'GET')
|
||||
}
|
||||
|
||||
|
||||
/* 获取上传form信息 */
|
||||
export function $ossFilesForm(bizType, file) {
|
||||
let postData = {
|
||||
bizType: bizType,
|
||||
sourceFileName: file.name || file.path, // 如果没有name 则使用pach替换
|
||||
sourceFileSize: file.size,
|
||||
}
|
||||
|
||||
return http.req('/api/ossFiles/form', postData, 'POST')
|
||||
}
|
||||
|
||||
/* 系统设置 */
|
||||
// 获取语音播报开关信息
|
||||
export function $mchConfig(groupKey) {
|
||||
return http.req('/api/mchConfig', {
|
||||
groupKey: groupKey
|
||||
}, 'GET')
|
||||
}
|
||||
// 修改语音播报开关信息
|
||||
export function $orderConfig(configData, mchNo) {
|
||||
console.log('mchNo', mchNo);
|
||||
return http.req('/api/mchConfig/orderConfig', {
|
||||
configData: configData,
|
||||
mchNo: mchNo
|
||||
}, 'PUT')
|
||||
}
|
||||
|
||||
/* 修改个人信息 */
|
||||
export function $modifyUser({
|
||||
realname,
|
||||
avatarUrl
|
||||
}) {
|
||||
return http.req("/api/current/user", {
|
||||
realname,
|
||||
avatarUrl
|
||||
}, "PUT")
|
||||
}
|
||||
|
||||
/* 获取密码规则 */
|
||||
export function $getPasswordRules() {
|
||||
return http.req("/api/anon/cipher/pwdRulesRegexp", "GET")
|
||||
}
|
||||
|
||||
// 验证是否有密码
|
||||
export function $isSipw() {
|
||||
return http.req("/api/mchConfig/hasSipwValidate", "GET")
|
||||
}
|
||||
|
||||
// 验证原支付密码是否正确
|
||||
export function $isMchSipw(originalPwd) {
|
||||
return http.req("/api/mchConfig/mchSipwValidate", {
|
||||
originalPwd: Base64.encode(originalPwd)
|
||||
}, "POST")
|
||||
}
|
||||
|
||||
/* 更新支付密码 */
|
||||
export function $updateMchSipw({
|
||||
originalPwd,
|
||||
confirmPwd
|
||||
}) {
|
||||
let data = {
|
||||
originalPwd: Base64.encode(originalPwd),
|
||||
confirmPwd: Base64.encode(confirmPwd)
|
||||
}
|
||||
return http.req("/api/mchConfig/mchSipw", data, "PUT")
|
||||
}
|
||||
|
||||
/* 版本检测 */
|
||||
export function $versionDetection({
|
||||
versionNumber
|
||||
}) {
|
||||
return http.req("/api/anon/clientVersion/versionInfo", {
|
||||
versionNumber: versionNumber
|
||||
}, "GET")
|
||||
}
|
||||
|
||||
/* 查询用户权限 */
|
||||
export function $getUserEntRoles(sysUserId) {
|
||||
return http.req("/api/sysUsers/userEntRoles/" + sysUserId, {}, "GET")
|
||||
}
|
||||
|
||||
/* 更新用户权限 */
|
||||
export function $updateUserEntRoles(sysUserId, ruleName, state) {
|
||||
return http.req("/api/sysUsers/userEntRoles/" + sysUserId, {
|
||||
ruleName,
|
||||
state
|
||||
}, "PUT")
|
||||
}
|
||||
|
||||
|
||||
/* 根据支付方式查询可配置的支付接口 */
|
||||
export function $getAvailablePayInterface(appId, wayCode) {
|
||||
return http.req(`/api/mch/payPassages/availablePayInterface/${appId}/${wayCode}`, "GET")
|
||||
}
|
||||
|
||||
/* 支付方式配置支付接口 */
|
||||
export function $wayCodeConfigIfCode(appId, wayCode, ifCode) {
|
||||
|
||||
let reqData = {
|
||||
appId: appId,
|
||||
wayCode: wayCode,
|
||||
ifCode: ifCode,
|
||||
state: 1
|
||||
}
|
||||
return http.req(`/api/mch/payPassages/mchPassage`, reqData, "POST")
|
||||
}
|
||||
/*码牌扫码 二维码解析*/
|
||||
export function $parseQrCodeUrl(qrUrl) {
|
||||
return http.req('/api/mchQrCodes/parseQrCodeUrl', {
|
||||
qrUrl
|
||||
}, 'GET')
|
||||
}
|
||||
/*码牌绑定*/
|
||||
export function $bindEmptyQR(qrcInfo) {
|
||||
return http.req('/api/mchQrCodes/bindEmptyQR', qrcInfo, 'POST')
|
||||
}
|
||||
/*解绑码牌*/
|
||||
export function $unBindQrc(qrcId) {
|
||||
return http.req('/api/mchQrCodes/unbind/' + qrcId, {}, 'POST')
|
||||
}
|
||||
/*码牌查询受支持的云喇叭设备*/
|
||||
export function $getHornList(qrcId) {
|
||||
return http.req('/api/mchQrCodes/bindDevice/' + qrcId, 'GET')
|
||||
}
|
||||
/* 更新默认 */
|
||||
export function $updateTrmDefault(trmId, defaultFlag) {
|
||||
return http.req('/api/mchTerminals/trmDefaults', {
|
||||
trmId,
|
||||
defaultFlag
|
||||
}, 'PUT')
|
||||
}
|
||||
|
||||
/* 设备解绑 */
|
||||
export function $deviceUnbind(deviceId) {
|
||||
return http.req('/api/store/device/unbind/' + deviceId, {}, 'POST')
|
||||
}
|
||||
|
||||
|
||||
/* 渠道报备列表 */
|
||||
export function $terminalChannelBindList(trmId) {
|
||||
return http.req('/api/mchTerminals/channelBindInfos/' + trmId, {}, 'GET')
|
||||
}
|
||||
|
||||
/* 渠道报备 */
|
||||
export function $terminalChannelBindSend(trmId, ifCode) {
|
||||
return http.req('/api/mchTerminals/channelSendup/' + trmId, {
|
||||
ifCode: ifCode,
|
||||
state: 1
|
||||
}, 'POST')
|
||||
}
|
||||
|
||||
|
||||
// 扫码登录
|
||||
export function $scanCodeLogin(qrcodeNo, qrcodeStatus) {
|
||||
return http.req("/api/current/qrcode/login", {
|
||||
qrcodeNo,
|
||||
qrcodeStatus
|
||||
}, "POST")
|
||||
}
|
||||
|
||||
// 云喇叭 播报测试
|
||||
export function $speakTest(devId, amount) {
|
||||
return http.req("/api/store/device/speak/" + devId, amount, "POST")
|
||||
}
|
||||
|
||||
// 云打印 打印测试
|
||||
export function $printTest(devId, amount) {
|
||||
return http.req(`/api/store/device/print/${devId}`, {
|
||||
amount
|
||||
}, "POST")
|
||||
}
|
||||
|
||||
/* 获取百度语音播报token */
|
||||
export function $getBaiduToken() {
|
||||
return http.req("/api/pushinfo/getBaiduToken", {}, "GET")
|
||||
}
|
||||
// 获取通知接收人二维码图片
|
||||
export function $getWxMpInfo() {
|
||||
return http.req("/api/wxmp/getWxmpInfo", {}, "GET")
|
||||
}
|
||||
|
||||
/* 获取进件通道列表 */
|
||||
export function $getAllAllowApplymentIfCodeList() {
|
||||
return http.req("/api/payConfig/ifCodes", {
|
||||
infoId: 'CURRENT',
|
||||
configMode: 'mchApplyment'
|
||||
}, "GET")
|
||||
}
|
||||
/* 查询店长可以绑定的门店 */
|
||||
export function $getBindStoreList(params) {
|
||||
return http.req('/api/mchStore/bindStoreList', params, "GET")
|
||||
}
|
||||
|
||||
/* 提交unipush cid */
|
||||
export function $pushInfoRegister(data) {
|
||||
console.log('push cid', data);
|
||||
return http.req("/api/pushinfo/register", data, "POST")
|
||||
}
|
||||
/* 获取广告接口*/
|
||||
export function $adList(params) {
|
||||
return http.req('/api/advert/appAdvert', params, 'GET')
|
||||
}
|
||||
/** 如意Lite 绑定解绑接口 */
|
||||
export function $BindLite(data) {
|
||||
return http.req('/api/alipayIot/bind/' + data.deviceId, data, "POST")
|
||||
}
|
||||
|
||||
// 获取支付宝扫码授权
|
||||
export function $aliPayQrCodeOrApply(account = '', type = 'queryResult') {
|
||||
return http.req(`/api/alipaySpOperation/${type}`, {
|
||||
alipayAccount: account
|
||||
}, type == 'apply' ? 'POST' : 'GET')
|
||||
}
|
||||
// 获取支付宝授权信息
|
||||
export function $aliAccountInfo() {
|
||||
return http.req('/api/alipaySpOperation/authInfo', {}, 'GET')
|
||||
}
|
||||
|
||||
// 查询蚂蚁店铺状态
|
||||
export function $queryAliStore(storeId) {
|
||||
return req.getById('/api/alipayShop/createResult', storeId)
|
||||
}
|
||||
|
||||
|
||||
// 获取上传图片 大小
|
||||
export function $getUploadImgSize() {
|
||||
return http.req('/api/defaultConfig', {}, "GET")
|
||||
}
|
||||
|
||||
// 会员调账
|
||||
export function $memberManual(params) {
|
||||
return http.req('/api/member/manual/' + params.memberId, params, "POST")
|
||||
}
|
||||
|
||||
//查询或修改会员配置信息
|
||||
export function $findOrEditMemberConfig(data, mode = 'GET', uri = '') {
|
||||
return http.req('/api/mchConfig' + uri, data, mode)
|
||||
}
|
||||
/* 会员数据统计 */
|
||||
export function $memberInfoCount(params) {
|
||||
return http.req('/api/member/count', params, 'GET')
|
||||
}
|
||||
|
||||
/* 查询商户支付应用 费率参数是否配置 */
|
||||
export function $getMchPayPassage(appId, ifCode) {
|
||||
return http.req(`/api/payConfig/existPayParams/${appId}/${ifCode}`, {}, 'GET')
|
||||
}
|
||||
|
||||
/* 获取进件渠道列表 */
|
||||
export function $getAllIsvInfoList(ifCode, range = 0) {
|
||||
return http.req("/api/isvInfo/isvInfoList", {
|
||||
pageNumber: "-1",
|
||||
range: range,
|
||||
ifCode: ifCode
|
||||
}, "GET")
|
||||
}
|
||||
|
||||
|
||||
// 请求验证码
|
||||
export function $isCode() {
|
||||
return http.req("/api/anon/auth/vercode", "GET")
|
||||
}
|
||||
|
||||
export function $pmdfb(data) {
|
||||
return http.req("/api/store/device/setMarqueeInfo", data, "POST")
|
||||
}
|
||||
|
||||
export function $getImgWH(params) {
|
||||
return http.req(`/api/store/device/getMarketPoint/${params}`, "GET")
|
||||
}
|
||||
|
||||
export function $initializeImg(params) {
|
||||
return http.req(`/api/store/device/getMarketPic/${params}`, "GET")
|
||||
}
|
||||
|
||||
export function $uploadImg(data) {
|
||||
return http.req(`/api/store/device/setMarketPic`, data, "POST")
|
||||
}
|
||||
|
||||
/* 获取上传form信息 */
|
||||
export function $NewOssFilesForm(data) {
|
||||
return http.req("/api/ossFiles/form", data, "POST")
|
||||
}
|
||||
47
http/businessApiManger.js
Normal file
47
http/businessApiManger.js
Normal file
@@ -0,0 +1,47 @@
|
||||
import request from './businessHttp.js'
|
||||
import useStorage from '@/commons/utils/useStroage.js'
|
||||
|
||||
/**
|
||||
* 登录
|
||||
* @param {Object} data
|
||||
*/
|
||||
export function login(data) {
|
||||
return request('/login/wx/merchant/login', data, 'post')
|
||||
}
|
||||
|
||||
/**
|
||||
* 桌台列表
|
||||
* @param {Object} areaId
|
||||
*/
|
||||
export function tableList(areaId) {
|
||||
return request('/table/list', {
|
||||
shopId: useStorage.get('userInfo').shopId,
|
||||
areaId: areaId
|
||||
}, 'post')
|
||||
}
|
||||
|
||||
/**
|
||||
* 区域列表
|
||||
* @param {Object} data
|
||||
*/
|
||||
export function areaList(data) {
|
||||
return request('/table/area', {
|
||||
shopId: useStorage.get('userInfo').shopId
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定桌码
|
||||
* @param {Object} data
|
||||
*/
|
||||
export function tableBinding(data) {
|
||||
return request('/table/binding', data, 'post')
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录获取openid
|
||||
* @param {Object} data
|
||||
*/
|
||||
export function wxlogin(data) {
|
||||
return request('/login/wx/business/login', data)
|
||||
}
|
||||
46
http/businessHttp.js
Normal file
46
http/businessHttp.js
Normal file
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* 因为两个小程序接口不一致,餐饮商超商家端的接口使用该http
|
||||
*/
|
||||
import useStorage from '@/commons/utils/useStroage.js'
|
||||
|
||||
// const baseURL = 'http://192.168.2.128:9000/cashierService'
|
||||
// const baseURL = 'http://192.168.2.41:9888/cashierService'
|
||||
let baseURL = 'https://wxcashiertest.sxczgkj.cn/cashierService'
|
||||
// #ifdef H5
|
||||
baseURL = '/shopApi'
|
||||
// #endif
|
||||
// const baseURL = 'https://cashier.sxczgkj.cn/cashierService'
|
||||
export default function(api = '', data = {}, method = 'GET') {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.request({
|
||||
url: `${baseURL}${api}`,
|
||||
method: method,
|
||||
data: data,
|
||||
header: {
|
||||
'environment': 'wx',
|
||||
'type': 'ios',
|
||||
'version': '1.0.0',
|
||||
'token': useStorage.get('token'),
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
success: res => {
|
||||
if (res.data.code == 0) {
|
||||
resolve(res.data)
|
||||
} else {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
"title": res.data.msg
|
||||
})
|
||||
reject(res.data.msg)
|
||||
}
|
||||
},
|
||||
fail: err => {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
"title": err.errMsg
|
||||
})
|
||||
reject(err)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
22
http/classApi.js
Normal file
22
http/classApi.js
Normal file
@@ -0,0 +1,22 @@
|
||||
class API {
|
||||
constructor(url,req) {
|
||||
const map={
|
||||
add:'POST',
|
||||
del:'DELETE',
|
||||
update:'PUT',
|
||||
get:'GET'
|
||||
}
|
||||
this.url=url
|
||||
for(let key in map){
|
||||
this[key]=function(data){
|
||||
data=Array.isArray(data)?data:{...data,shopId:uni.getStorageSync('shopId')}
|
||||
if(key==='del'){
|
||||
delete data.shopId
|
||||
}
|
||||
return req(url, data,map[key])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default API
|
||||
164
http/http.js
Normal file
164
http/http.js
Normal file
@@ -0,0 +1,164 @@
|
||||
/**
|
||||
* HTTP的封装, 基于uni.request
|
||||
* 包括: 通用响应结果的处理 和 业务的增删改查函数
|
||||
*
|
||||
* @author terrfly
|
||||
* @site https://www.jeequan.com
|
||||
* @date 2021/12/16 18:35
|
||||
*/
|
||||
|
||||
// 导入全局属性
|
||||
import appConfig from '@/config/appConfig.js'
|
||||
import storageManage from '@/commons/utils/storageManage.js'
|
||||
import { sm4DecryptByResData } from '@/commons/utils/encryptUtil.js'
|
||||
import infoBox from "@/commons/utils/infoBox.js"
|
||||
import go from '@/commons/utils/go.js';
|
||||
let baseUrl = 'http://101.37.12.135:8080'
|
||||
// #ifdef H5
|
||||
baseUrl = '/server3/mch'
|
||||
// #endif
|
||||
// #ifndef H5
|
||||
baseUrl = 'http://101.37.12.135:8080/mch'
|
||||
// #endif
|
||||
|
||||
// 多少 ms 以内, 不提示loading
|
||||
const loadingShowTime = 200
|
||||
|
||||
// 通用处理逻辑
|
||||
function commonsProcess(showLoading, httpReqCallback){
|
||||
|
||||
// 判断是否请求完成(用作 是否loading )
|
||||
// 包括: 'ing', 'ingLoading', 'finish'
|
||||
let reqState = 'ing'
|
||||
|
||||
// 是否已经提示的错误信息
|
||||
let isShowErrorToast = false
|
||||
|
||||
|
||||
// 请求完成, 需要处理的动作
|
||||
let reqFinishFunc = () => {
|
||||
|
||||
if(reqState == 'ingLoading'){ // 关闭loading弹层
|
||||
infoBox.hideLoading()
|
||||
}
|
||||
reqState = 'finish' // 请求完毕
|
||||
}
|
||||
|
||||
// 明确显示loading
|
||||
if(showLoading){
|
||||
// xx ms内响应完成,不提示loading
|
||||
setTimeout(() => {
|
||||
if(reqState == 'ing'){
|
||||
reqState = 'ingLoading'
|
||||
infoBox.showLoading()
|
||||
}
|
||||
}, loadingShowTime)
|
||||
}
|
||||
|
||||
return httpReqCallback().then((httpData) => {
|
||||
|
||||
reqFinishFunc(); // 请求完毕的动作
|
||||
|
||||
// 从http响应数据中解构响应数据 [ 响应码、 bodyData ]
|
||||
let { statusCode, data } = httpData
|
||||
// 避免混淆重新命名
|
||||
let bodyData = data
|
||||
if(statusCode == 401){
|
||||
|
||||
// 清楚 token
|
||||
storageManage.token(null, true)
|
||||
|
||||
// 提示信息
|
||||
isShowErrorToast = true
|
||||
infoBox.showErrorToast('请登录').then(() => {
|
||||
go.to("PAGES_LOGIN", {}, go.GO_TYPE_RELAUNCH)
|
||||
})
|
||||
return Promise.reject(bodyData) // 跳转到catch函数
|
||||
}
|
||||
// http响应码不正确
|
||||
if(statusCode != 200){
|
||||
isShowErrorToast = true
|
||||
infoBox.showErrorToast('服务器异常')
|
||||
return Promise.reject(bodyData) // 跳转到catch函数
|
||||
}
|
||||
|
||||
// 业务响应异常
|
||||
if(bodyData.code != 0){
|
||||
isShowErrorToast = true
|
||||
infoBox.showToast(bodyData.msg)
|
||||
if(bodyData.code == 5005){ // 密码已过期, 直接跳转到更改密码页面
|
||||
uni.reLaunch({url: '/pageUser/setting/updatePwd'})
|
||||
}
|
||||
if(bodyData.code == 500){ // 密码已过期, 直接跳转到更改密码页面
|
||||
uni.redirectTo({url: '/pages/login/index'})
|
||||
}
|
||||
return Promise.reject(bodyData)
|
||||
}
|
||||
|
||||
// 加密数据
|
||||
if(!bodyData.data && bodyData.encryptData){
|
||||
|
||||
return Promise.resolve({ bizData: sm4DecryptByResData(bodyData.encryptData), code: bodyData.code })
|
||||
}
|
||||
|
||||
// 构造请求成功的响应数据
|
||||
return Promise.resolve({ bizData: bodyData.data, code: bodyData.code })
|
||||
|
||||
}).catch( res => {
|
||||
|
||||
reqFinishFunc(); // 请求完毕的动作
|
||||
|
||||
// 如果没有提示错误, 那么此处提示 异常。
|
||||
if(!isShowErrorToast){
|
||||
infoBox.showErrorToast(`请求网络异常`)
|
||||
}
|
||||
|
||||
return Promise.reject(res)
|
||||
|
||||
}).finally(() => { // finally 是 then结束后再执行, 此处不适用。 需要在请求完成后立马调用: reqFinishFunc()
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 默认 显示loading(控制 xxs 内 不提示loading )
|
||||
function req(uri, data, method = "GET", showLoading = true, extParams = {}){
|
||||
|
||||
// 放置token
|
||||
let headerObject = {}
|
||||
headerObject[appConfig.tokenKey] = storageManage.token()
|
||||
headerObject["satoken"] = storageManage.token()
|
||||
|
||||
return commonsProcess(showLoading, () => {
|
||||
return uni.request(
|
||||
Object.assign({url: baseUrl + uri, data: data, method: method, header: headerObject}, extParams )
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
// 上传
|
||||
function upload(uri, data, file, showLoading = true, extParams = {}){
|
||||
|
||||
// 放置token
|
||||
let headerObject = {}
|
||||
headerObject[appConfig.tokenKey] = storageManage.token()
|
||||
|
||||
return commonsProcess(showLoading, () => {
|
||||
return uni.uploadFile(
|
||||
Object.assign({url: baseUrl + uri, formData: data, name: "file", filePath: file.path, header: headerObject}, extParams )
|
||||
).then((httpData) => {
|
||||
// uni.upload 返回bodyData 的是 string类型。 需要解析。
|
||||
httpData.data = JSON.parse(httpData.data)
|
||||
return Promise.resolve(httpData)
|
||||
})
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export default {
|
||||
req : req,
|
||||
upload : upload
|
||||
}
|
||||
182
http/newApi/http.js
Normal file
182
http/newApi/http.js
Normal file
@@ -0,0 +1,182 @@
|
||||
/**
|
||||
* HTTP的封装, 基于uni.request
|
||||
* 包括: 通用响应结果的处理 和 业务的增删改查函数
|
||||
*
|
||||
* @author terrfly
|
||||
* @site https://www.jeequan.com
|
||||
* @date 2021/12/16 18:35
|
||||
*/
|
||||
|
||||
// 导入全局属性
|
||||
import appConfig from '@/config/appConfig.js'
|
||||
import storageManage from '@/commons/utils/storageManage.js'
|
||||
import {
|
||||
sm4DecryptByResData
|
||||
} from '@/commons/utils/encryptUtil.js'
|
||||
import infoBox from "@/commons/utils/infoBox.js"
|
||||
import go from '@/commons/utils/go.js';
|
||||
let baseUrl = 'http://101.37.12.135:8080'
|
||||
// #ifdef H5
|
||||
baseUrl = '/server3'
|
||||
// #endif
|
||||
// 多少 ms 以内, 不提示loading
|
||||
const loadingShowTime = 200
|
||||
|
||||
// 通用处理逻辑
|
||||
function commonsProcess(showLoading, httpReqCallback) {
|
||||
|
||||
// 判断是否请求完成(用作 是否loading )
|
||||
// 包括: 'ing', 'ingLoading', 'finish'
|
||||
let reqState = 'ing'
|
||||
|
||||
// 是否已经提示的错误信息
|
||||
let isShowErrorToast = false
|
||||
|
||||
|
||||
// 请求完成, 需要处理的动作
|
||||
let reqFinishFunc = () => {
|
||||
|
||||
if (reqState == 'ingLoading') { // 关闭loading弹层
|
||||
infoBox.hideLoading()
|
||||
}
|
||||
reqState = 'finish' // 请求完毕
|
||||
}
|
||||
|
||||
// 明确显示loading
|
||||
if (showLoading) {
|
||||
// xx ms内响应完成,不提示loading
|
||||
setTimeout(() => {
|
||||
if (reqState == 'ing') {
|
||||
reqState = 'ingLoading'
|
||||
infoBox.showLoading()
|
||||
}
|
||||
}, loadingShowTime)
|
||||
}
|
||||
|
||||
return httpReqCallback().then((httpData) => {
|
||||
console.log(httpData);
|
||||
reqFinishFunc(); // 请求完毕的动作
|
||||
|
||||
// 从http响应数据中解构响应数据 [ 响应码、 bodyData ]
|
||||
let {
|
||||
statusCode,
|
||||
data
|
||||
} = httpData
|
||||
|
||||
// 避免混淆重新命名
|
||||
let bodyData = data
|
||||
if (statusCode == 401) {
|
||||
|
||||
// 清楚 token
|
||||
storageManage.token(null, true)
|
||||
|
||||
// 提示信息
|
||||
isShowErrorToast = true
|
||||
infoBox.showErrorToast('请登录').then(() => {
|
||||
go.to("PAGES_LOGIN", {}, go.GO_TYPE_RELAUNCH)
|
||||
})
|
||||
return Promise.reject(bodyData) // 跳转到catch函数
|
||||
}
|
||||
// http响应码不正确
|
||||
if (statusCode != 200) {
|
||||
isShowErrorToast = true
|
||||
infoBox.showErrorToast('服务器异常')
|
||||
return Promise.reject(bodyData) // 跳转到catch函数
|
||||
}
|
||||
|
||||
// 业务响应异常
|
||||
if (bodyData.code != 200) {
|
||||
isShowErrorToast = true
|
||||
infoBox.showToast(bodyData.msg)
|
||||
if (bodyData.code == 5005) { // 密码已过期, 直接跳转到更改密码页面
|
||||
uni.reLaunch({
|
||||
url: '/pageUser/setting/updatePwd'
|
||||
})
|
||||
}
|
||||
if(bodyData.code == 500){ // 密码已过期, 直接跳转到更改密码页面
|
||||
uni.redirectTo({url: '/pages/login/index'})
|
||||
}
|
||||
return Promise.reject(bodyData)
|
||||
}
|
||||
|
||||
// 加密数据
|
||||
if (!bodyData.data && bodyData.encryptData) {
|
||||
|
||||
return Promise.resolve({
|
||||
bizData: sm4DecryptByResData(bodyData.encryptData),
|
||||
code: bodyData.code
|
||||
})
|
||||
}
|
||||
|
||||
// 构造请求成功的响应数据
|
||||
return Promise.resolve({
|
||||
bizData: bodyData.data,
|
||||
code: bodyData.code
|
||||
})
|
||||
|
||||
}).catch(res => {
|
||||
reqFinishFunc(); // 请求完毕的动作
|
||||
|
||||
// 如果没有提示错误, 那么此处提示 异常。
|
||||
if (!isShowErrorToast) {
|
||||
infoBox.showErrorToast(`请求网络异常`)
|
||||
}
|
||||
|
||||
return Promise.reject(res)
|
||||
|
||||
}).finally(() => { // finally 是 then结束后再执行, 此处不适用。 需要在请求完成后立马调用: reqFinishFunc()
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 默认 显示loading(控制 xxs 内 不提示loading )
|
||||
function req(uri, data, method = "GET", showLoading = true, extParams = {}) {
|
||||
let headerObject = {}
|
||||
// headerObject[appConfig.tokenKey] = storageManage.token()
|
||||
headerObject["satoken"] = storageManage.token()
|
||||
headerObject["content-type"] = 'application/json'
|
||||
|
||||
return commonsProcess(showLoading, () => {
|
||||
return uni.request(
|
||||
Object.assign({
|
||||
url: baseUrl + uri,
|
||||
data: data,
|
||||
method: method,
|
||||
header: headerObject
|
||||
}, extParams)
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 上传
|
||||
function upload(uri, data, file, showLoading = true, extParams = {}) {
|
||||
|
||||
// 放置token
|
||||
let headerObject = {}
|
||||
// headerObject[appConfig.tokenKey] = storageManage.token()
|
||||
headerObject["satoken"] = storageManage.token()
|
||||
|
||||
return commonsProcess(showLoading, () => {
|
||||
return uni.uploadFile(
|
||||
Object.assign({
|
||||
url: appConfig.env.JEEPAY_BASE_URL + uri,
|
||||
formData: data,
|
||||
name: "file",
|
||||
filePath: file.path,
|
||||
header: headerObject
|
||||
}, extParams)
|
||||
).then((httpData) => {
|
||||
// uni.upload 返回bodyData 的是 string类型。 需要解析。
|
||||
httpData.data = JSON.parse(httpData.data)
|
||||
return Promise.resolve(httpData)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
req: req,
|
||||
upload: upload
|
||||
}
|
||||
11
http/newApi/login.js
Normal file
11
http/newApi/login.js
Normal file
@@ -0,0 +1,11 @@
|
||||
import http from './http.js'
|
||||
import appConfig from '@/config/appConfig.js'
|
||||
import {
|
||||
Base64
|
||||
} from 'js-base64'
|
||||
import infoBox from '@/commons/utils/infoBox.js'
|
||||
/* 登录 */
|
||||
export function $login(postData) {
|
||||
// return http.req('/login', params, 'GET')
|
||||
return http.req('/login', postData, 'POST')
|
||||
}
|
||||
219
http/yskApi/Instead.js
Normal file
219
http/yskApi/Instead.js
Normal file
@@ -0,0 +1,219 @@
|
||||
// 代课下单
|
||||
import http from './http.js'
|
||||
import $API from '@/http/classApi.js'
|
||||
import appConfig from '@/config/appConfig.js'
|
||||
import {
|
||||
Base64
|
||||
} from 'js-base64'
|
||||
import infoBox from '@/commons/utils/infoBox.js'
|
||||
|
||||
const request=http.request
|
||||
/**
|
||||
* 获取当前台桌订单信息
|
||||
* @returns
|
||||
*/
|
||||
export function getCart(params) {
|
||||
return request({
|
||||
url: `/api/place/cart`,
|
||||
method: "get",
|
||||
params:{
|
||||
shopId: uni.getStorageSync('shopId'),
|
||||
...params
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 已上架商品列表
|
||||
* @returns
|
||||
*/
|
||||
export function getGoodsLists(params) {
|
||||
return request({
|
||||
url: `/api/place/activate`,
|
||||
method: "get",
|
||||
params:{
|
||||
shopId: uni.getStorageSync('shopId'),
|
||||
...params
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 点单
|
||||
* @returns
|
||||
*/
|
||||
export function addCart(data) {
|
||||
return request({
|
||||
url: `/api/place/addCart`,
|
||||
method: "post",
|
||||
data:{
|
||||
shopId: uni.getStorageSync('shopId'),
|
||||
...data
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空购物车/支付订单
|
||||
* @returns
|
||||
*/
|
||||
export function $clearCart(data) {
|
||||
return request({
|
||||
url: `/api/place/clearCart`,
|
||||
method: "delete",
|
||||
data:{
|
||||
shopId: uni.getStorageSync('shopId'),
|
||||
...data
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除购物车某个商品
|
||||
* @returns
|
||||
*/
|
||||
export function $removeCart(data) {
|
||||
return request({
|
||||
url: `/api/place/removeCart`,
|
||||
method: "delete",
|
||||
data:{
|
||||
shopId: uni.getStorageSync('shopId'),
|
||||
...data
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 更新规格
|
||||
* @returns
|
||||
*/
|
||||
export function $updateCart(data) {
|
||||
return request({
|
||||
url: `/api/place/updateCart`,
|
||||
method: "put",
|
||||
data:{
|
||||
shopId: uni.getStorageSync('shopId'),
|
||||
...data
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 批量打包
|
||||
* @returns
|
||||
*/
|
||||
export function $allPack(data) {
|
||||
return request({
|
||||
url: `/api/place/pack`,
|
||||
method: "put",
|
||||
data:{
|
||||
shopId: uni.getStorageSync('shopId'),
|
||||
...data
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 获取取餐号
|
||||
* @returns
|
||||
*/
|
||||
export function $getMasterId(data) {
|
||||
return request({
|
||||
url: `/api/place/masterId`,
|
||||
method: "get",
|
||||
params:{
|
||||
shopId: uni.getStorageSync('shopId'),
|
||||
...data
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 支付方式获取
|
||||
* @returns
|
||||
*/
|
||||
export function $getPayType(data) {
|
||||
return request({
|
||||
url: `/api/place/payType`,
|
||||
method: "get",
|
||||
params:{
|
||||
shopId: uni.getStorageSync('shopId'),
|
||||
...data
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 创建订单
|
||||
* @returns
|
||||
*/
|
||||
export function $createOrder(data) {
|
||||
return request({
|
||||
url: `/api/place/order`,
|
||||
method: "post",
|
||||
data:{
|
||||
shopId: uni.getStorageSync('shopId'),
|
||||
...data
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 挂起订单
|
||||
* @returns
|
||||
*/
|
||||
export function $cacheOrder(data) {
|
||||
return request({
|
||||
url: `/api/place/pending`,
|
||||
method: "post",
|
||||
data:{
|
||||
shopId: uni.getStorageSync('shopId'),
|
||||
...data
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取已挂起订单
|
||||
* @returns
|
||||
*/
|
||||
export function $getCacheOrder(data) {
|
||||
return request({
|
||||
url: `/api/place/pending/cart`,
|
||||
method: "get",
|
||||
params:{
|
||||
shopId: uni.getStorageSync('shopId'),
|
||||
...data
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 会员点单/取消会员点单
|
||||
export function $setUser(data) {
|
||||
return request({
|
||||
url: `/api/place/updateVip`,
|
||||
method: "put",
|
||||
data:{
|
||||
shopId: uni.getStorageSync('shopId'),
|
||||
...data
|
||||
}
|
||||
});
|
||||
}
|
||||
// 删除订单
|
||||
export function $delOrder(data) {
|
||||
return request({
|
||||
url: `/api/place/order`,
|
||||
method: "delete",
|
||||
data:{
|
||||
shopId: uni.getStorageSync('shopId'),
|
||||
...data
|
||||
}
|
||||
});
|
||||
}
|
||||
// 支付订单
|
||||
export function $payOrder(data) {
|
||||
return request({
|
||||
url: '/api/place/pay',
|
||||
method: "put",
|
||||
data:{
|
||||
shopId: uni.getStorageSync('shopId'),
|
||||
...data
|
||||
}
|
||||
});
|
||||
}
|
||||
30
http/yskApi/couponCategory.js
Normal file
30
http/yskApi/couponCategory.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import http from './http.js'
|
||||
import appConfig from '@/config/appConfig.js'
|
||||
import {
|
||||
Base64
|
||||
} from 'js-base64'
|
||||
import infoBox from '@/commons/utils/infoBox.js'
|
||||
|
||||
/* 查询团购卷分类 */
|
||||
export function $tbCouponCategory(data, mehtod = 'GET') {
|
||||
return http.req('/api/tbCouponCategory', {
|
||||
...data,
|
||||
shopId: uni.getStorageSync('shopId')
|
||||
}, 'GET')
|
||||
}
|
||||
|
||||
|
||||
export default {
|
||||
add: function(data) {
|
||||
return $tbCouponCategory(data, 'POST')
|
||||
},
|
||||
del: function(data) {
|
||||
return $tbCouponCategory(data, 'DELETE')
|
||||
},
|
||||
update: function(data) {
|
||||
return $tbCouponCategory(data, 'PUT')
|
||||
},
|
||||
get: function(data) {
|
||||
return $tbCouponCategory(data)
|
||||
}
|
||||
}
|
||||
33
http/yskApi/devices.js
Normal file
33
http/yskApi/devices.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import http from './http.js'
|
||||
const request=http.request
|
||||
|
||||
/**
|
||||
* 增加打印机
|
||||
* @returns
|
||||
*/
|
||||
export function tbPrintMachine(data, method = 'post') {
|
||||
return request({
|
||||
url: '/api/tbPrintMachine',
|
||||
method: method,
|
||||
data: {
|
||||
shopId: uni.getStorageSync('shopId'),
|
||||
...data
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印机列表
|
||||
* @returns
|
||||
*/
|
||||
export function tbPrintMachineGet(params) {
|
||||
return request({
|
||||
url: '/api/tbPrintMachine',
|
||||
method: 'get',
|
||||
params: {
|
||||
shopId: uni.getStorageSync('shopId'),
|
||||
sort: '',
|
||||
...params
|
||||
}
|
||||
})
|
||||
}
|
||||
11
http/yskApi/file.js
Normal file
11
http/yskApi/file.js
Normal file
@@ -0,0 +1,11 @@
|
||||
import http from './http.js'
|
||||
import appConfig from '@/config/appConfig.js'
|
||||
import {
|
||||
Base64
|
||||
} from 'js-base64'
|
||||
import infoBox from '@/commons/utils/infoBox.js'
|
||||
|
||||
/* 上传图片 */
|
||||
export function $uploadFile(file,data) {
|
||||
return http.upload('/api/qiNiuContent', data,file)
|
||||
}
|
||||
109
http/yskApi/goods.js
Normal file
109
http/yskApi/goods.js
Normal file
@@ -0,0 +1,109 @@
|
||||
import http from './http.js'
|
||||
import $API from '@/http/classApi.js'
|
||||
import appConfig from '@/config/appConfig.js'
|
||||
import {
|
||||
Base64
|
||||
} from 'js-base64'
|
||||
import infoBox from '@/commons/utils/infoBox.js'
|
||||
|
||||
/* 商品列表 */
|
||||
export function $tbProduct(data) {
|
||||
return http.req('/api/tbProduct', {...data,shopId:uni.getStorageSync('shopId')}, 'GET')
|
||||
}
|
||||
|
||||
/* 添加商品 */
|
||||
export function $addProduct(data) {
|
||||
return http.req('/api/tbProduct', {...data,shopId:uni.getStorageSync('shopId')}, 'POST')
|
||||
}
|
||||
|
||||
/* 删除商品 */
|
||||
export function $delProduct(ids) {
|
||||
return http.req('/api/tbProduct', ids, 'DELETE')
|
||||
}
|
||||
|
||||
|
||||
/* 更新商品相关 */
|
||||
export function $updateProduct(data) {
|
||||
return http.req('/api/tbProduct', {...data,shopId:uni.getStorageSync('shopId')}, 'PUT')
|
||||
}
|
||||
/* 修改商品排序 */
|
||||
export function $upProSort(data) {
|
||||
return http.req('/api/tbProduct/upProSort', {...data,shopId:uni.getStorageSync('shopId')}, 'POST')
|
||||
}
|
||||
/* 商品详情(单个商品) */
|
||||
export function $getProductDetail(product,showLoading=true) {
|
||||
return http.req('/api/tbProduct/'+product, {shopId:uni.getStorageSync('shopId')}, 'GET',showLoading)
|
||||
}
|
||||
|
||||
/* 设置热销商品 */
|
||||
export function $goodsIsHot(data) {
|
||||
return http.req('/api/tbProduct/isHot', {...data,shopId:uni.getStorageSync('shopId')}, 'GET')
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 商品分类列表
|
||||
*/
|
||||
export function $tbShopCategory(data) {
|
||||
return http.req('/api/tbShopCategory', {...data,shopId:uni.getStorageSync('shopId')}, 'GET')
|
||||
}
|
||||
/**
|
||||
* 商品分类
|
||||
*/
|
||||
export const $productCategory=new $API('/api/tbShopCategory',http.req)
|
||||
|
||||
|
||||
/**
|
||||
* 更新商品库存状态
|
||||
*/
|
||||
export function $updateProductStatus(data){
|
||||
return http.req('/api/stock/productStatus', {...data,shopId:uni.getStorageSync('shopId')}, 'PUT')
|
||||
}
|
||||
|
||||
/**
|
||||
* 库存记录列表
|
||||
*/
|
||||
export function $getProductStockDetail(data){
|
||||
return http.req('/api/tbProductStockDetail/stock', {...data,shopId:uni.getStorageSync('shopId')}, 'POST')
|
||||
}
|
||||
|
||||
/**
|
||||
* 库存记录变动数量
|
||||
*/
|
||||
export function $getProductStockDetailSum(data){
|
||||
return http.req('/api/tbProductStockDetail/sum', {...data,shopId:uni.getStorageSync('shopId')}, 'GET')
|
||||
}
|
||||
/**
|
||||
* 新增盘点
|
||||
*/
|
||||
export function $addStocktakin(data){
|
||||
return http.req('/api/tbProductStocktakin', {...data,shopId:uni.getStorageSync('shopId')}, 'POST')
|
||||
}
|
||||
/**
|
||||
* 盘点记录查询
|
||||
*/
|
||||
export function $getStocktakin(data){
|
||||
return http.req('/api/tbProductStocktakin', {...data,shopId:uni.getStorageSync('shopId')}, 'GET')
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 上下架商品
|
||||
*/
|
||||
export function $updateGrounding(data){
|
||||
return http.req('/api/stock/grounding', {...data,shopId:uni.getStorageSync('shopId')}, 'PUT')
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* 商品单位列表 */
|
||||
export function $tbShopUnit(data) {
|
||||
return http.req('/api/tbShopUnit', {...data,shopId:uni.getStorageSync('shopId')}, 'GET')
|
||||
}
|
||||
|
||||
/* 商品规格 */
|
||||
export const $productSpec=new $API('/api/tbProductSpec',http.req)
|
||||
|
||||
|
||||
|
||||
225
http/yskApi/http.js
Normal file
225
http/yskApi/http.js
Normal file
@@ -0,0 +1,225 @@
|
||||
/**
|
||||
* HTTP的封装, 基于uni.request
|
||||
* 包括: 通用响应结果的处理 和 业务的增删改查函数
|
||||
*
|
||||
* @author terrfly
|
||||
* @site https://www.jeequan.com
|
||||
* @date 2021/12/16 18:35
|
||||
*/
|
||||
|
||||
// 导入全局属性
|
||||
import appConfig from '@/config/appConfig.js'
|
||||
import storageManage from '@/commons/utils/storageManage.js'
|
||||
import {
|
||||
sm4DecryptByResData
|
||||
} from '@/commons/utils/encryptUtil.js'
|
||||
import infoBox from "@/commons/utils/infoBox.js"
|
||||
import go from '@/commons/utils/go.js';
|
||||
let baseUrl = 'http://101.37.12.135:8080'
|
||||
// #ifdef H5
|
||||
baseUrl = '/server3/ysk'
|
||||
// #endif
|
||||
// #ifndef H5
|
||||
baseUrl = 'http://101.37.12.135:8080/ysk'
|
||||
// #endif
|
||||
// 多少 ms 以内, 不提示loading
|
||||
const loadingShowTime = 200
|
||||
|
||||
// 通用处理逻辑
|
||||
function commonsProcess(showLoading, httpReqCallback) {
|
||||
|
||||
// 判断是否请求完成(用作 是否loading )
|
||||
// 包括: 'ing', 'ingLoading', 'finish'
|
||||
let reqState = 'ing'
|
||||
|
||||
// 是否已经提示的错误信息
|
||||
let isShowErrorToast = false
|
||||
|
||||
|
||||
// 请求完成, 需要处理的动作
|
||||
let reqFinishFunc = () => {
|
||||
|
||||
if (reqState == 'ingLoading') { // 关闭loading弹层
|
||||
infoBox.hideLoading()
|
||||
}
|
||||
reqState = 'finish' // 请求完毕
|
||||
}
|
||||
|
||||
// 明确显示loading
|
||||
if (showLoading) {
|
||||
// xx ms内响应完成,不提示loading
|
||||
setTimeout(() => {
|
||||
if (reqState == 'ing') {
|
||||
reqState = 'ingLoading'
|
||||
infoBox.showLoading()
|
||||
}
|
||||
}, loadingShowTime)
|
||||
}
|
||||
|
||||
return httpReqCallback().then((httpData) => {
|
||||
reqFinishFunc(); // 请求完毕的动作
|
||||
|
||||
// 从http响应数据中解构响应数据 [ 响应码、 bodyData ]
|
||||
let {
|
||||
statusCode,
|
||||
data
|
||||
} = httpData
|
||||
// 避免混淆重新命名
|
||||
let bodyData = data
|
||||
if (statusCode == 500) {
|
||||
isShowErrorToast = true
|
||||
return Promise.reject(bodyData) // 跳转到catch函数
|
||||
}
|
||||
if (statusCode == 401) {
|
||||
// storageManage.token(null, true)
|
||||
// 提示信息
|
||||
isShowErrorToast = true
|
||||
// infoBox.showErrorToast('请登录').then(() => {
|
||||
// go.to("PAGES_LOGIN", {}, go.GO_TYPE_RELAUNCH)
|
||||
// })
|
||||
return Promise.reject(bodyData) // 跳转到catch函数
|
||||
}
|
||||
// http响应码不正确
|
||||
if (statusCode != 200 && statusCode != 204 && statusCode != 201) {
|
||||
isShowErrorToast = true
|
||||
infoBox.showErrorToast(data.message || '服务器异常')
|
||||
return Promise.reject(bodyData) // 跳转到catch函数
|
||||
}
|
||||
|
||||
// 业务响应异常
|
||||
if (bodyData.hasOwnProperty('code') && bodyData.code != 200) {
|
||||
isShowErrorToast = true
|
||||
infoBox.showToast(bodyData.msg)
|
||||
if (bodyData.code == 5005) { // 密码已过期, 直接跳转到更改密码页面
|
||||
uni.reLaunch({
|
||||
url: '/pageUser/setting/updatePwd'
|
||||
})
|
||||
}
|
||||
// if(bodyData.code == 500){ // 密码已过期, 直接跳转到更改密码页面
|
||||
// uni.redirectTo({url: '/pages/login/index'})
|
||||
// }
|
||||
return Promise.reject(bodyData)
|
||||
}
|
||||
|
||||
// 加密数据
|
||||
if (!bodyData.data && bodyData.encryptData) {
|
||||
|
||||
return Promise.resolve({
|
||||
bizData: sm4DecryptByResData(bodyData.encryptData),
|
||||
code: bodyData.code
|
||||
})
|
||||
}
|
||||
|
||||
// 构造请求成功的响应数据
|
||||
return Promise.resolve(bodyData)
|
||||
|
||||
}).catch(res => {
|
||||
if(res.code==401){
|
||||
storageManage.token(null, true)
|
||||
infoBox.showErrorToast('请登录').then(() => {
|
||||
go.to("PAGES_LOGIN", {}, go.GO_TYPE_RELAUNCH)
|
||||
})
|
||||
}
|
||||
if(res.code==500){
|
||||
storageManage.token(null, true)
|
||||
infoBox.showErrorToast('请登录').then(() => {
|
||||
go.to("PAGES_LOGIN", {}, go.GO_TYPE_RELAUNCH)
|
||||
})
|
||||
}
|
||||
// if(res&&res.msg){
|
||||
// infoBox.showErrorToast(res.msg)
|
||||
// }
|
||||
reqFinishFunc(); // 请求完毕的动作
|
||||
|
||||
// 如果没有提示错误, 那么此处提示 异常。
|
||||
if (!isShowErrorToast) {
|
||||
infoBox.showErrorToast(`请求网络异常`)
|
||||
}
|
||||
|
||||
return Promise.reject(res)
|
||||
|
||||
}).finally(() => { // finally 是 then结束后再执行, 此处不适用。 需要在请求完成后立马调用: reqFinishFunc()
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 默认 显示loading(控制 xxs 内 不提示loading )
|
||||
function req(uri, data, method = "GET", showLoading = true, extParams = {}) {
|
||||
let headerObject = {}
|
||||
// headerObject[appConfig.tokenKey] = storageManage.token()
|
||||
headerObject["satoken"] = storageManage.token()
|
||||
headerObject["content-type"] = 'application/json'
|
||||
|
||||
return commonsProcess(showLoading, () => {
|
||||
return uni.request(
|
||||
Object.assign({
|
||||
url: baseUrl + uri,
|
||||
data: data,
|
||||
method: method,
|
||||
header: headerObject
|
||||
}, extParams)
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 默认 显示loading(控制 xxs 内 不提示loading )
|
||||
function request(args) {
|
||||
const {
|
||||
url,
|
||||
data,
|
||||
params,
|
||||
method = "GET",
|
||||
showLoading = true,
|
||||
extParams = {}
|
||||
} = args
|
||||
let headerObject = {}
|
||||
// headerObject[appConfig.tokenKey] = storageManage.token()
|
||||
headerObject["satoken"] = storageManage.token()
|
||||
headerObject["content-type"] = 'application/json'
|
||||
|
||||
return commonsProcess(showLoading, () => {
|
||||
return uni.request(
|
||||
Object.assign({
|
||||
url: baseUrl + url,
|
||||
data: params||data,
|
||||
method: method,
|
||||
header: headerObject
|
||||
}, extParams)
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 上传
|
||||
function upload(uri, data, file, showLoading = true, extParams = {}) {
|
||||
// 放置token
|
||||
let headerObject = {}
|
||||
// headerObject[appConfig.tokenKey] = storageManage.token()
|
||||
headerObject["satoken"] = storageManage.token()
|
||||
|
||||
return commonsProcess(showLoading, () => {
|
||||
return uni.uploadFile(
|
||||
Object.assign({
|
||||
url: baseUrl + uri,
|
||||
formData: data,
|
||||
name: "file",
|
||||
filePath: file.path,
|
||||
header: headerObject
|
||||
}, extParams)
|
||||
).then((httpData) => {
|
||||
// uni.upload 返回bodyData 的是 string类型。 需要解析。
|
||||
httpData.data = JSON.parse(httpData.data)
|
||||
return Promise.resolve(httpData)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
req: req,
|
||||
request,
|
||||
upload: upload
|
||||
}
|
||||
13
http/yskApi/invoicing.js
Normal file
13
http/yskApi/invoicing.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import http from './http.js'
|
||||
import $API from '@/http/classApi.js'
|
||||
import appConfig from '@/config/appConfig.js'
|
||||
import {
|
||||
Base64
|
||||
} from 'js-base64'
|
||||
import infoBox from '@/commons/utils/infoBox.js'
|
||||
|
||||
/* 操作记录 */
|
||||
export function $getStockOperate(data) {
|
||||
return http.req('/api/tbProductStockOperate/list', {...data,shopId:uni.getStorageSync('shopId')}, 'POST')
|
||||
}
|
||||
|
||||
47
http/yskApi/shop-user.js
Normal file
47
http/yskApi/shop-user.js
Normal file
@@ -0,0 +1,47 @@
|
||||
// 用户管理
|
||||
import http from './http.js'
|
||||
import $API from '@/http/classApi.js'
|
||||
import appConfig from '@/config/appConfig.js'
|
||||
import {
|
||||
Base64
|
||||
} from 'js-base64'
|
||||
import infoBox from '@/commons/utils/infoBox.js'
|
||||
|
||||
const request=http.request
|
||||
|
||||
// 获取店铺会员二维码
|
||||
export function getwxacode(data) {
|
||||
return request({
|
||||
url: `/shop/storage/getwxacode`,
|
||||
method: "post",
|
||||
data
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 商家用户列表
|
||||
* @returns
|
||||
*/
|
||||
export function queryAllShopUser(params) {
|
||||
return request({
|
||||
url: `/api/tbShopUser/queryAllShopUser`,
|
||||
method: "get",
|
||||
params: {
|
||||
shopId: uni.getStorageSync('shopId'),
|
||||
...params
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 查询商家用户概述信息
|
||||
* @returns
|
||||
*/
|
||||
export function queryAllShopInfo(params) {
|
||||
return request({
|
||||
url: `/api/tbShopUser/summary`,
|
||||
method: "get",
|
||||
params: {
|
||||
shopId: uni.getStorageSync('shopId'),
|
||||
...params
|
||||
}
|
||||
});
|
||||
}
|
||||
13
http/yskApi/sku.js
Normal file
13
http/yskApi/sku.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import http from './http.js'
|
||||
import $API from '@/http/classApi.js'
|
||||
import appConfig from '@/config/appConfig.js'
|
||||
import {
|
||||
Base64
|
||||
} from 'js-base64'
|
||||
import infoBox from '@/commons/utils/infoBox.js'
|
||||
|
||||
/* 查询库存 */
|
||||
export function $getProductSku(productId) {
|
||||
return http.req('/api/stock/sku', {productId,shopId:uni.getStorageSync('shopId')}, 'GET')
|
||||
}
|
||||
|
||||
13
http/yskApi/table.js
Normal file
13
http/yskApi/table.js
Normal file
@@ -0,0 +1,13 @@
|
||||
// 桌台管理
|
||||
import http from './http.js'
|
||||
import $API from '@/http/classApi.js'
|
||||
import appConfig from '@/config/appConfig.js'
|
||||
import {
|
||||
Base64
|
||||
} from 'js-base64'
|
||||
import infoBox from '@/commons/utils/infoBox.js'
|
||||
|
||||
/* 台桌区域 */
|
||||
export const $tableArea=new $API('/api/tbShopArea',http.req)
|
||||
/* 台桌 */
|
||||
export const $table=new $API('/api/tbShopTable',http.req)
|
||||
Reference in New Issue
Block a user