|
|
@@ -9,6 +9,51 @@ export function getMerchantId() {
|
|
|
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开启
|
|
|
@@ -55,17 +100,33 @@ const api = {
|
|
|
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 }
|
|
|
+ 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 }
|
|
|
+ params: {
|
|
|
+ merchantId: getMerchantId(),
|
|
|
+ pageNo: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ ...params
|
|
|
+ }
|
|
|
})
|
|
|
},
|
|
|
|