From 5208fc8e7b82589c4e13316569a99878928346d5 Mon Sep 17 00:00:00 2001 From: maziyang <2049865907@qq.com> Date: Thu, 23 Oct 2025 13:21:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 2 +- index.html | 24 +++++++++++++++--------- src/api/member.js | 4 ++-- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/.env.development b/.env.development index 6af2eb3..5794ede 100644 --- a/.env.development +++ b/.env.development @@ -2,4 +2,4 @@ VITE_APP_ENV=development # 测试环境 API -VITE_API_BASE_URL=https://hwjb.homilychart.com/dbqbApi \ No newline at end of file +VITE_API_BASE_URL=https://dbqb.nfdxy.net/activityApi \ No newline at end of file diff --git a/index.html b/index.html index 5dcbccd..216fb17 100644 --- a/index.html +++ b/index.html @@ -76,6 +76,7 @@ // 导入API函数 import { getImageApi, acceptCardApi } from './src/api/member.js'; + const userAgent = navigator.userAgent; // 获取弹窗元素 const landingImage = document.getElementById('landingImage'); const popupImage = document.getElementById('popupImage'); @@ -114,11 +115,14 @@ // 获取图片方法 async function getImage() { try { - const res = await getImageApi(); + const res = await getImageApi({ + id:3 + }); + console.log(res.data) if (res.code == 200 && res.data) { return { - landingImageUrl: res.data.landingImage, - popupImageUrl: res.data.popupImage + landingImageUrl: res.data.list[0].landing_page, + popupImageUrl: res.data.list[0].landing_page_popup }; } else { console.warn('网络错误,请稍后重试'); @@ -126,16 +130,17 @@ } } catch (error) { console.error('网络错误,请稍后重试'); - return { - landingImageUrl: './assent/8折页面.png', - popupImageUrl: './assent/弹窗样式2.png' - }; + return null } } // 加载 window.onload = async function () { try { + await acceptCardApi({ + user_info:userAgent, + state: 0, + }); // 缓存 const cachedImage = getLandingImageFromCache(); @@ -184,6 +189,7 @@ // 关闭弹窗并发送数据 async function closePopupAndSendData() { + if (!isClickable) { return; } @@ -194,9 +200,9 @@ // 发送页面打开时间到后端 try { await acceptCardApi({ - openTime: pageOpenTime, + user_info:userAgent, + state: 1, }); - console.log('发送成功', pageOpenTime); } catch (error) { console.error('发送失败', pageOpenTime); } diff --git a/src/api/member.js b/src/api/member.js index a487561..09e9aa9 100644 --- a/src/api/member.js +++ b/src/api/member.js @@ -7,7 +7,7 @@ const API_BASE_URL = import.meta.env.VITE_API_BASE_URL; // 获取图片 export function getImageApi(data) { return request({ - url: `${API_BASE_URL}/api/getImage`, + url: `${API_BASE_URL}/api/activity/get`, method: "post", data: data, }); @@ -16,7 +16,7 @@ export function getImageApi(data) { // 用户点击收下 export function acceptCardApi(data) { return request({ - url: `${API_BASE_URL}/api/acceptCard`, + url: `${API_BASE_URL}/api/activity/detail/add`, method: "post", data: data, });