1. 特色方
This commit is contained in:
@@ -375,6 +375,29 @@ export async function getOrdlist(params) {
|
||||
return normalizeXkApiResponse(data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取待支付商品订单列表(首页提醒用)
|
||||
*/
|
||||
export async function fetchUnpaidProductOrderListApi(params = {}) {
|
||||
const storeId = params.store_id || uni.getStorageSync('store_id') || '11001';
|
||||
const res = await getOrdlist({
|
||||
method: 'post',
|
||||
data: {
|
||||
store_id: storeId,
|
||||
type: 'unpaid',
|
||||
page: 1,
|
||||
...params,
|
||||
},
|
||||
});
|
||||
if (res.data?.errcode != 0) {
|
||||
return [];
|
||||
}
|
||||
const list = res.data?.data?.list || [];
|
||||
return list.filter(
|
||||
(item) => item.status === 0 && item.is_pay === 0 && item.cancel_status === 0
|
||||
);
|
||||
}
|
||||
|
||||
// v1/product-order/list
|
||||
export async function getToken(params) {
|
||||
let data = await http('/oldApi/v1/user/login-platform', params)
|
||||
|
||||
@@ -8,3 +8,22 @@ import {post} from './http'
|
||||
export async function getRegisterListApi(params) {
|
||||
return await post('/register/list', params, 3)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取待支付挂号列表(首页提醒用)
|
||||
* @param params
|
||||
* @returns {Promise<Array>}
|
||||
*/
|
||||
export async function fetchUnpaidRegisterListApi(params = {}) {
|
||||
const storeId = params.store_id || uni.getStorageSync('store_id') || '11001';
|
||||
const res = await post('/register/list?pageSize=100', {
|
||||
store_id: storeId,
|
||||
page: 1,
|
||||
...params,
|
||||
}, 3);
|
||||
if (res.data?.code !== 0 && res.data?.code !== '0') {
|
||||
return [];
|
||||
}
|
||||
const list = res.data?.result?.list || [];
|
||||
return list.filter((item) => item.status === 0 && item.is_cancel !== 1);
|
||||
}
|
||||
|
||||
@@ -147,6 +147,9 @@ function request(url, params, method = 0) {
|
||||
} else if (url.indexOf('/xkApi/store/list') !== -1) {
|
||||
url = url.replace('/xkApi/store/list', '/guest/guest-home/store-list');
|
||||
baseURL = envUrls.xkApi;
|
||||
} else if (url.indexOf('/xkApi/special-prescription/') !== -1) {
|
||||
url = url.replace('/xkApi/special-prescription/', '/guest/guest-special-prescription/');
|
||||
baseURL = envUrls.xkApi;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
92
request/api/specialPrescription.js
Normal file
92
request/api/specialPrescription.js
Normal file
@@ -0,0 +1,92 @@
|
||||
import { get, post } from './http'
|
||||
|
||||
export const SPECIAL_PRESCRIPTION_STORAGE_KEY = 'special_prescription_register_context'
|
||||
|
||||
/**
|
||||
* 首页特色方配置
|
||||
* @param params {{ store_id?: number|string }}
|
||||
*/
|
||||
export async function getSpecialPrescriptionHomeApi(params) {
|
||||
return await get('/special-prescription/home', params, 3)
|
||||
}
|
||||
|
||||
/**
|
||||
* 特色方列表页配置
|
||||
* @param params {{ store_id?: number|string }}
|
||||
*/
|
||||
export async function getSpecialPrescriptionListPageApi(params) {
|
||||
return await get('/special-prescription/list-page', params, 3)
|
||||
}
|
||||
|
||||
/**
|
||||
* 特色方列表
|
||||
* @param params {{ store_id?: number|string, category_id?: number, name?: string, page?: number, pageSize?: number }}
|
||||
*/
|
||||
export async function getSpecialPrescriptionListApi(params) {
|
||||
return await get('/special-prescription/list', params, 3)
|
||||
}
|
||||
|
||||
/**
|
||||
* 特色方详情
|
||||
* @param params {{ id: number|string, store_id?: number|string }}
|
||||
*/
|
||||
export async function getSpecialPrescriptionDetailApi(params) {
|
||||
return await get('/special-prescription/detail', params, 3)
|
||||
}
|
||||
|
||||
/**
|
||||
* 特色方分类
|
||||
*/
|
||||
export async function getSpecialPrescriptionCategoriesApi(params = {}) {
|
||||
return await get('/special-prescription/categories', params, 3)
|
||||
}
|
||||
|
||||
/**
|
||||
* 挂号成功后创建选方记录
|
||||
* @param params {{ register_id, special_prescription_id, dose_count, store_id, doctor_id }}
|
||||
*/
|
||||
export async function createSpecialPrescriptionPatientRecordApi(params) {
|
||||
return await post('/special-prescription/create-patient-record', params, 3)
|
||||
}
|
||||
|
||||
export function saveSpecialPrescriptionRegisterContext(ctx) {
|
||||
if (!ctx || !ctx.special_prescription_id) return
|
||||
uni.setStorageSync(SPECIAL_PRESCRIPTION_STORAGE_KEY, {
|
||||
special_prescription_id: ctx.special_prescription_id,
|
||||
dose_count: ctx.dose_count || 1,
|
||||
doctor_id: ctx.doctor_id || '',
|
||||
})
|
||||
}
|
||||
|
||||
export function getSpecialPrescriptionRegisterContext() {
|
||||
return uni.getStorageSync(SPECIAL_PRESCRIPTION_STORAGE_KEY) || null
|
||||
}
|
||||
|
||||
export function clearSpecialPrescriptionRegisterContext() {
|
||||
uni.removeStorageSync(SPECIAL_PRESCRIPTION_STORAGE_KEY)
|
||||
}
|
||||
|
||||
/**
|
||||
* 挂号成功后绑定特色方选方记录(幂等,失败不阻断流程)
|
||||
* @param registerId
|
||||
*/
|
||||
export async function tryCreateSpecialPrescriptionPatientRecord(registerId) {
|
||||
if (!registerId) return
|
||||
const ctx = getSpecialPrescriptionRegisterContext()
|
||||
if (!ctx || !ctx.special_prescription_id) return
|
||||
|
||||
try {
|
||||
const res = await createSpecialPrescriptionPatientRecordApi({
|
||||
register_id: registerId,
|
||||
special_prescription_id: ctx.special_prescription_id,
|
||||
dose_count: ctx.dose_count || 1,
|
||||
store_id: uni.getStorageSync('store_id') || '11001',
|
||||
doctor_id: ctx.doctor_id,
|
||||
})
|
||||
if (res.data?.code === 0 || res.data?.code === '0') {
|
||||
clearSpecialPrescriptionRegisterContext()
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('tryCreateSpecialPrescriptionPatientRecord', e)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user