front
This commit is contained in:
parent
4f871d20f1
commit
06240f1708
22
app/main.py
22
app/main.py
|
@ -157,6 +157,7 @@ async def tg_intgr_get(request: Request):
|
||||||
logger.info(e)
|
logger.info(e)
|
||||||
return {"status": "error"}
|
return {"status": "error"}
|
||||||
|
|
||||||
|
|
||||||
def extract_id(params):
|
def extract_id(params):
|
||||||
json_strings = params.get("PLACEMENT_OPTIONS", [])
|
json_strings = params.get("PLACEMENT_OPTIONS", [])
|
||||||
for json_str in json_strings:
|
for json_str in json_strings:
|
||||||
|
@ -166,7 +167,8 @@ def extract_id(params):
|
||||||
return data["ID"]
|
return data["ID"]
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
print(f"Ошибка: Некорректная JSON-строка - {json_str}")
|
print(f"Ошибка: Некорректная JSON-строка - {json_str}")
|
||||||
|
|
||||||
|
|
||||||
def get_task_by_deal(deal_id):
|
def get_task_by_deal(deal_id):
|
||||||
select = [
|
select = [
|
||||||
"ID",
|
"ID",
|
||||||
|
@ -187,9 +189,10 @@ def get_task_by_deal(deal_id):
|
||||||
task_data = requests.get(get_task_hook + f"&start={limit}")
|
task_data = requests.get(get_task_hook + f"&start={limit}")
|
||||||
task_data_json = task_data.json()
|
task_data_json = task_data.json()
|
||||||
result += task_data_json["result"]["tasks"]
|
result += task_data_json["result"]["tasks"]
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
@app.post("/deal_tab")
|
@app.post("/deal_tab")
|
||||||
async def deal_tab(
|
async def deal_tab(
|
||||||
request: Request,
|
request: Request,
|
||||||
|
@ -204,10 +207,9 @@ async def deal_tab(
|
||||||
result = parse_qs(b_str)
|
result = parse_qs(b_str)
|
||||||
q = [DOMAIN, PROTOCOL, LANG, APP_SID]
|
q = [DOMAIN, PROTOCOL, LANG, APP_SID]
|
||||||
|
|
||||||
|
|
||||||
deal_id = extract_id(result)
|
deal_id = extract_id(result)
|
||||||
if not deal_id:
|
if not deal_id:
|
||||||
raise('not deal id')
|
raise ("not deal id")
|
||||||
deal_id = 49
|
deal_id = 49
|
||||||
|
|
||||||
result = get_task_by_deal(deal_id)
|
result = get_task_by_deal(deal_id)
|
||||||
|
@ -226,6 +228,7 @@ async def deal_tab(
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
return {"status": "error"}
|
return {"status": "error"}
|
||||||
|
|
||||||
|
|
||||||
@app.post("/widget/deal_tab/{deal_id}")
|
@app.post("/widget/deal_tab/{deal_id}")
|
||||||
async def deal_tab(request: Request, deal_id):
|
async def deal_tab(request: Request, deal_id):
|
||||||
try:
|
try:
|
||||||
|
@ -235,7 +238,11 @@ async def deal_tab(request: Request, deal_id):
|
||||||
parts = WEBHOOK.split("/")
|
parts = WEBHOOK.split("/")
|
||||||
domain = f"https://{parts[2]}"
|
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:
|
except Exception as e:
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
return {"status": "error"}
|
return {"status": "error"}
|
||||||
|
@ -262,8 +269,9 @@ async def handle_widget_post(request: Request):
|
||||||
deal_id = 49
|
deal_id = 49
|
||||||
logger.info(result)
|
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():
|
if html_file.exists():
|
||||||
html_content = html_file.read_text()
|
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 HTMLResponse(content=html_content, status_code=200)
|
||||||
return {"error": "Nuxt.js page not found"}, 404
|
return {"error": "Nuxt.js page not found"}, 404
|
||||||
|
|
|
@ -10,7 +10,8 @@ export default defineNuxtConfig({
|
||||||
|
|
||||||
runtimeConfig: {
|
runtimeConfig: {
|
||||||
public: {
|
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(() => {
|
onMounted(() => {
|
||||||
const deal_id = route.query.deal_id
|
const deal_id = config.public.data_deal_id
|
||||||
if (!deal_id) return
|
if (!deal_id) return
|
||||||
|
|
||||||
loadData(parseInt(deal_id as string))
|
loadData(deal_id)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
|
Loading…
Reference in New Issue