| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- import { http } from '@/common/service/service.js'
- import { USER_INFO } from '@/common/util/constants.js'
- const BASE = '/memberPrepaidMerchant'
- /** 当前登录门店 ID */
- export function getMerchantId() {
- const info = uni.getStorageSync(USER_INFO) || {}
- return info.merchantId || ''
- }
- /** 获取本商户经纬度(共享门店列表按门店坐标算距离) */
- export function getMerchantLocation(merchantId = getMerchantId()) {
- if (!merchantId) {
- return Promise.reject(new Error('未获取到门店信息'))
- }
- return http
- .get('/merchant/localMerchantInfo/queryById', {
- params: { id: merchantId }
- })
- .then((res) => {
- if (res.data.code !== 200 || !res.data.result) {
- return Promise.reject(new Error(res.data.message || '获取门店信息失败'))
- }
- const { longitude, latitude } = res.data.result
- if (
- longitude === undefined ||
- longitude === null ||
- longitude === '' ||
- latitude === undefined ||
- latitude === null ||
- latitude === ''
- ) {
- return Promise.reject(new Error('门店未配置经纬度'))
- }
- return {
- longitude: Number(longitude),
- latitude: Number(latitude)
- }
- })
- }
- /** 格式化门店距离展示,如 746.00m / 3.24km */
- export function formatStoreDistance(item = {}) {
- if (item.distance == null || item.distance === '') {
- return item.distanceText || ''
- }
- const num = Number(item.distance)
- if (Number.isNaN(num)) {
- return String(item.distanceText || item.distance)
- }
- const text = Number.isInteger(num) ? String(num) : num.toFixed(2)
- const unit = item.distanceUnit || ''
- return unit ? `${text}${unit}` : text
- }
- /**
- * auditStatus: 0未申请 / 1待审核 / 2已通过 / 3已驳回
- * operationStatus: 0关闭 / 1开启
- * reapplyStatus: 0不适用 / 1禁止重新申请 / 2允许重新申请
- */
- const api = {
- /** 查询商户行业是否支持储值(true 时显示储值管理入口) */
- checkIndustryEligibility(merchantId = getMerchantId()) {
- return http.get(`${BASE}/industry/eligibility`, { params: { merchantId } })
- },
- /** 查询储值功能状态 */
- getFeatureStatus(merchantId = getMerchantId()) {
- return http.get(`${BASE}/feature/status`, { params: { merchantId } })
- },
- /** 当前生效协议 */
- getCurrentAgreement() {
- return http.get(`${BASE}/agreement/current`)
- },
- /** 当前或最近申请详情 */
- getApplication(merchantId = getMerchantId()) {
- return http.get(`${BASE}/feature/application`, { params: { merchantId } })
- },
- /** 提交开通申请 */
- applyFeature(data, merchantId = getMerchantId()) {
- return http.post(`${BASE}/feature/apply`, data, { params: { merchantId } })
- },
- /** 开启储值功能 */
- openFeature(merchantId = getMerchantId()) {
- return http.post(`${BASE}/feature/open`, {}, { params: { merchantId } })
- },
- /** 关闭储值功能 */
- closeFeature(data, merchantId = getMerchantId()) {
- return http.post(`${BASE}/feature/close`, data || {}, { params: { merchantId } })
- },
- /** 当前门店详情 */
- getCurrentStore(merchantId = getMerchantId()) {
- return http.get(`${BASE}/store/current`, { params: { merchantId } })
- },
- /**
- * 可添加共享门店分页
- * 必传 longitude / latitude,按距离由近到远
- */
- getShareableStores(params = {}) {
- return http.get(`${BASE}/store/shareable/page`, {
- params: {
- merchantId: getMerchantId(),
- pageNo: 1,
- pageSize: 10,
- ...params
- }
- })
- },
- /**
- * 已共享门店分页
- * 必传 longitude / latitude,按距离由近到远
- */
- getSharedStores(params = {}) {
- return http.get(`${BASE}/store/shared/page`, {
- params: {
- merchantId: getMerchantId(),
- pageNo: 1,
- pageSize: 10,
- ...params
- }
- })
- },
- /** 批量添加共享门店 */
- addSharedStores(sharedStoreIds, merchantId = getMerchantId()) {
- return http.post(
- `${BASE}/store/shared`,
- { sharedStoreIds },
- { params: { merchantId } }
- )
- },
- /** 移除共享门店 */
- removeSharedStore(sharedStoreId, merchantId = getMerchantId()) {
- return http.delete(`${BASE}/store/shared/${sharedStoreId}`, {}, { params: { merchantId } })
- },
- /** 首页概览 */
- getOverview(merchantId = getMerchantId()) {
- return http.get(`${BASE}/overview`, { params: { merchantId } })
- },
- /** 账户明细分页 */
- getLedgerPage(params = {}) {
- return http.get(`${BASE}/account/ledger/page`, {
- params: { merchantId: getMerchantId(), pageNo: 1, pageSize: 10, ...params }
- })
- },
- /** 账户明细详情 */
- getLedgerDetail(ledgerId, merchantId = getMerchantId()) {
- return http.get(`${BASE}/account/ledger/${ledgerId}/detail`, {
- params: { merchantId }
- })
- },
- /** 查询储值设置 */
- getRechargeConfig(merchantId = getMerchantId()) {
- return http.get(`${BASE}/recharge/config`, { params: { merchantId } })
- },
- /** 保存储值设置 */
- saveRechargeConfig(data, merchantId = getMerchantId()) {
- return http.put(`${BASE}/recharge/config`, data, { params: { merchantId } })
- },
- /** 可赠送优惠券分页 */
- getCouponPage(params = {}) {
- return http.get(`${BASE}/recharge/coupon/page`, {
- params: { merchantId: getMerchantId(), pageNo: 1, pageSize: 50, ...params }
- })
- }
- }
- export default api
|