front
This commit is contained in:
parent
4f871d20f1
commit
06240f1708
16
app/main.py
16
app/main.py
|
@ -157,6 +157,7 @@ async def tg_intgr_get(request: Request):
|
|||
logger.info(e)
|
||||
return {"status": "error"}
|
||||
|
||||
|
||||
def extract_id(params):
|
||||
json_strings = params.get("PLACEMENT_OPTIONS", [])
|
||||
for json_str in json_strings:
|
||||
|
@ -167,6 +168,7 @@ def extract_id(params):
|
|||
except json.JSONDecodeError:
|
||||
print(f"Ошибка: Некорректная JSON-строка - {json_str}")
|
||||
|
||||
|
||||
def get_task_by_deal(deal_id):
|
||||
select = [
|
||||
"ID",
|
||||
|
@ -190,6 +192,7 @@ def get_task_by_deal(deal_id):
|
|||
|
||||
return result
|
||||
|
||||
|
||||
@app.post("/deal_tab")
|
||||
async def deal_tab(
|
||||
request: Request,
|
||||
|
@ -204,10 +207,9 @@ async def deal_tab(
|
|||
result = parse_qs(b_str)
|
||||
q = [DOMAIN, PROTOCOL, LANG, APP_SID]
|
||||
|
||||
|
||||
deal_id = extract_id(result)
|
||||
if not deal_id:
|
||||
raise('not deal id')
|
||||
raise ("not deal id")
|
||||
deal_id = 49
|
||||
|
||||
result = get_task_by_deal(deal_id)
|
||||
|
@ -226,6 +228,7 @@ async def deal_tab(
|
|||
logger.error(e)
|
||||
return {"status": "error"}
|
||||
|
||||
|
||||
@app.post("/widget/deal_tab/{deal_id}")
|
||||
async def deal_tab(request: Request, deal_id):
|
||||
try:
|
||||
|
@ -235,7 +238,11 @@ async def deal_tab(request: Request, deal_id):
|
|||
parts = WEBHOOK.split("/")
|
||||
domain = f"https://{parts[2]}"
|
||||
|
||||
return {"status": "success", "result": result, "format": {"domain": domain, "statuses": statuses}}
|
||||
return {
|
||||
"status": "success",
|
||||
"result": result,
|
||||
"format": {"domain": domain, "statuses": statuses},
|
||||
}
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
return {"status": "error"}
|
||||
|
@ -262,8 +269,9 @@ async def handle_widget_post(request: Request):
|
|||
deal_id = 49
|
||||
logger.info(result)
|
||||
|
||||
html_file = NUXT_DIST / f"/deal/index.html?deal_id={deal_id}"
|
||||
html_file = NUXT_DIST / f"/deal/index.html"
|
||||
if html_file.exists():
|
||||
html_content = html_file.read_text()
|
||||
html_content = html_content.replace("data_deal_id:0", f"data_deal_id:{deal_id}")
|
||||
return HTMLResponse(content=html_content, status_code=200)
|
||||
return {"error": "Nuxt.js page not found"}, 404
|
||||
|
|
|
@ -10,7 +10,8 @@ export default defineNuxtConfig({
|
|||
|
||||
runtimeConfig: {
|
||||
public: {
|
||||
apiBase: process.env.NODE_ENV == 'development' ? 'http://localhost:8000' : ''
|
||||
apiBase: process.env.NODE_ENV == 'development' ? 'http://localhost:8000' : '',
|
||||
data_deal_id: 0
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -67,10 +67,10 @@ const columns = [{
|
|||
|
||||
|
||||
onMounted(() => {
|
||||
const deal_id = route.query.deal_id
|
||||
const deal_id = config.public.data_deal_id
|
||||
if (!deal_id) return
|
||||
|
||||
loadData(parseInt(deal_id as string))
|
||||
loadData(deal_id)
|
||||
})
|
||||
</script>
|
||||
<template>
|
||||
|
|
Loading…
Reference in New Issue