diff --git a/dist.rar b/dist.rar new file mode 100644 index 0000000..ab6516a Binary files /dev/null and b/dist.rar differ diff --git a/src/api/account.js b/src/api/account.js index 5b96f47..7c28267 100644 --- a/src/api/account.js +++ b/src/api/account.js @@ -1,4 +1,4 @@ -import { getAxios, postAxios } from '@/utils/axios.js' +import { getAxios, postAxios, downFile } from '@/utils/axios.js' export function apiGetCart() { return getAxios({ url: '/cgi-bin/cart/latest' }) @@ -18,3 +18,14 @@ export function dicts(data) { export function tkhostdetail(data) { return postAxios({ url: 'tkinfo/tkhostdetail', data }) } +//导出表格 +export function exporthosts(data) { + return postAxios({ url: 'export/hostsinfo', data }) +} +export function downList(url, data) { + return downFile(url, data) +} +//查询tk账号查询次数 +export function tkaccountuseinfo(data) { + return postAxios({ url: 'tkinfo/tkaccountuseinfo', data }) +} diff --git a/src/components/EChartsComponent.vue b/src/components/EChartsComponent.vue index 44e5211..bbb09c0 100644 --- a/src/components/EChartsComponent.vue +++ b/src/components/EChartsComponent.vue @@ -20,19 +20,25 @@ export default { dataType: { type: String, required: true + }, + time: { + type: String, + required: true } }, data() { return { seriesData: [], - num: 0 + num: 0, + inputTime: '', } }, mounted() { - + this.inputTime = this.time this.getTkhostdetail(); + console.log(this.getPrevious7Days(this.inputTime)) }, methods: { @@ -51,7 +57,7 @@ export default { data: [this.title] }, xAxis: { - data: [this.getCurrentDate()[0].slice(4), this.getCurrentDate()[1].slice(4), this.getCurrentDate()[2].slice(4), this.getCurrentDate()[3].slice(4), this.getCurrentDate()[4].slice(4), this.getCurrentDate()[5].slice(4), this.getCurrentDate()[6].slice(4)] + data: [this.getPrevious7Days(this.inputTime)[0].slice(4), this.getPrevious7Days(this.inputTime)[1].slice(4), this.getPrevious7Days(this.inputTime)[2].slice(4), this.getPrevious7Days(this.inputTime)[3].slice(4), this.getPrevious7Days(this.inputTime)[4].slice(4), this.getPrevious7Days(this.inputTime)[5].slice(4), this.getPrevious7Days(this.inputTime)[6].slice(4)] }, yAxis: {}, series: [ @@ -65,34 +71,36 @@ export default { ] }; myChart.setOption(option); + console.log(this.dataTime) + }, getTkhostdetail() { tkhostdetail({ hostId: this.id, dataType: this.dataType, - searchTimeStart: this.getCurrentDate()[0], - searchTimeEnd: this.getCurrentDate()[6] + searchTimeStart: this.getPrevious7Days(this.inputTime)[0], + searchTimeEnd: this.getPrevious7Days(this.inputTime)[6] }).then(res => { - // console.log("返回数据", res[0][this.getCurrentDate()[2]]) + // console.log("返回数据", res[0][this.getPrevious7Days(this.inputTime)[2]]) //echarts 数据初始化 this.seriesData = [ - res[0][this.getCurrentDate()[0]] == null ? 0 : Number(res[0][this.getCurrentDate()[0]][this.dataType]), - res[0][this.getCurrentDate()[1]] == null ? 0 : Number(res[0][this.getCurrentDate()[1]][this.dataType]), - res[0][this.getCurrentDate()[2]] == null ? 0 : Number(res[0][this.getCurrentDate()[2]][this.dataType]), - res[0][this.getCurrentDate()[3]] == null ? 0 : Number(res[0][this.getCurrentDate()[3]][this.dataType]), - res[0][this.getCurrentDate()[4]] == null ? 0 : Number(res[0][this.getCurrentDate()[4]][this.dataType]), - res[0][this.getCurrentDate()[5]] == null ? 0 : Number(res[0][this.getCurrentDate()[5]][this.dataType]), - res[0][this.getCurrentDate()[6]] == null ? 0 : Number(res[0][this.getCurrentDate()[6]][this.dataType]), + res[0][this.getPrevious7Days(this.inputTime)[0]] == null ? 0 : Number(res[0][this.getPrevious7Days(this.inputTime)[0]][this.dataType]), + res[0][this.getPrevious7Days(this.inputTime)[1]] == null ? 0 : Number(res[0][this.getPrevious7Days(this.inputTime)[1]][this.dataType]), + res[0][this.getPrevious7Days(this.inputTime)[2]] == null ? 0 : Number(res[0][this.getPrevious7Days(this.inputTime)[2]][this.dataType]), + res[0][this.getPrevious7Days(this.inputTime)[3]] == null ? 0 : Number(res[0][this.getPrevious7Days(this.inputTime)[3]][this.dataType]), + res[0][this.getPrevious7Days(this.inputTime)[4]] == null ? 0 : Number(res[0][this.getPrevious7Days(this.inputTime)[4]][this.dataType]), + res[0][this.getPrevious7Days(this.inputTime)[5]] == null ? 0 : Number(res[0][this.getPrevious7Days(this.inputTime)[5]][this.dataType]), + res[0][this.getPrevious7Days(this.inputTime)[6]] == null ? 0 : Number(res[0][this.getPrevious7Days(this.inputTime)[6]][this.dataType]), ] // this.seriesData = { - // [this.getCurrentDate()[0]]: res[0][this.getCurrentDate()[0]] == null ? 0 : res[0][this.getCurrentDate()[0]][this.dataType], - // [this.getCurrentDate()[1]]: res[0][this.getCurrentDate()[1]] == null ? 0 : res[0][this.getCurrentDate()[1]][this.dataType], - // [this.getCurrentDate()[2]]: res[0][this.getCurrentDate()[2]] == null ? 0 : res[0][this.getCurrentDate()[2]][this.dataType], - // [this.getCurrentDate()[3]]: res[0][this.getCurrentDate()[3]] == null ? 0 : res[0][this.getCurrentDate()[3]][this.dataType], - // [this.getCurrentDate()[4]]: res[0][this.getCurrentDate()[4]] == null ? 0 : res[0][this.getCurrentDate()[4]][this.dataType], - // [this.getCurrentDate()[5]]: res[0][this.getCurrentDate()[5]] == null ? 0 : res[0][this.getCurrentDate()[5]][this.dataType], - // [this.getCurrentDate()[6]]: res[0][this.getCurrentDate()[6]] == null ? 0 : res[0][this.getCurrentDate()[6]][this.dataType], + // [this.getPrevious7Days(this.inputTime)[0]]: res[0][this.getPrevious7Days(this.inputTime)[0]] == null ? 0 : res[0][this.getPrevious7Days(this.inputTime)[0]][this.dataType], + // [this.getPrevious7Days(this.inputTime)[1]]: res[0][this.getPrevious7Days(this.inputTime)[1]] == null ? 0 : res[0][this.getPrevious7Days(this.inputTime)[1]][this.dataType], + // [this.getPrevious7Days(this.inputTime)[2]]: res[0][this.getPrevious7Days(this.inputTime)[2]] == null ? 0 : res[0][this.getPrevious7Days(this.inputTime)[2]][this.dataType], + // [this.getPrevious7Days(this.inputTime)[3]]: res[0][this.getPrevious7Days(this.inputTime)[3]] == null ? 0 : res[0][this.getPrevious7Days(this.inputTime)[3]][this.dataType], + // [this.getPrevious7Days(this.inputTime)[4]]: res[0][this.getPrevious7Days(this.inputTime)[4]] == null ? 0 : res[0][this.getPrevious7Days(this.inputTime)[4]][this.dataType], + // [this.getPrevious7Days(this.inputTime)[5]]: res[0][this.getPrevious7Days(this.inputTime)[5]] == null ? 0 : res[0][this.getPrevious7Days(this.inputTime)[5]][this.dataType], + // [this.getPrevious7Days(this.inputTime)[6]]: res[0][this.getPrevious7Days(this.inputTime)[6]] == null ? 0 : res[0][this.getPrevious7Days(this.inputTime)[6]][this.dataType], // } this.initChart(); @@ -103,24 +111,58 @@ export default { }) }, - getCurrentDate() { - const dates = []; - const today = new Date(); + // getCurrentDate() { + // const dates = []; + // const today = new Date(); - for (let i = 6; i >= 0; i--) { - const date = new Date(today); - date.setDate(today.getDate() - i); + // for (let i = 6; i >= 0; i--) { + // const date = new Date(today); + // date.setDate(today.getDate() - i); - const year = date.getFullYear(); - const month = String(date.getMonth() + 1).padStart(2, '0'); - const day = String(date.getDate()).padStart(2, '0'); + // const year = date.getFullYear(); + // const month = String(date.getMonth() + 1).padStart(2, '0'); + // const day = String(date.getDate()).padStart(2, '0'); - dates.push(`${year}${month}${day}`); + // dates.push(`${year}${month}${day}`); + // } + + // return dates; + // }, + getPrevious7Days(dateStr) { + // 验证输入格式是否正确 + if (!/^\d{8}$/.test(dateStr)) { + console.error('输入的格式不是YYYYMMDD.'); + return []; } - return dates; + // 解析输入的日期字符串 + const year = parseInt(dateStr.substring(0, 4)); + const month = parseInt(dateStr.substring(4, 6)) - 1; // 月份从 0 开始 + const day = parseInt(dateStr.substring(6, 8)); + + // 创建日期对象 + const date = new Date(year, month, day); + + // 存储结果的数组 + const result = []; + + // 计算前 7 天的日期 + for (let i = 0; i <= 6; i++) { + const currentDate = new Date(date); + currentDate.setDate(date.getDate() - i); // 减去 i 天 + + // 格式化为 YYYYMMDD + const formattedDate = `${currentDate.getFullYear()}${(currentDate.getMonth() + 1).toString().padStart(2, '0')}${currentDate.getDate().toString().padStart(2, '0')}`; + result.push(formattedDate); + } + + // 按时间顺序排序(从最早到最晚) + result.sort((a, b) => a.localeCompare(b)); + + return result; } + } }; \ No newline at end of file diff --git a/src/utils/axios.js b/src/utils/axios.js index 7df0b93..0afebe2 100644 --- a/src/utils/axios.js +++ b/src/utils/axios.js @@ -11,11 +11,10 @@ const router = useRouter(); // 请求地址前缀 let baseURL = '' -console.log(process.env.NODE_ENV) if (process.env.NODE_ENV === 'development') { // 生产环境 baseURL = "http://120.26.251.180:8085/api/" - // baseURL = "http://192.168.0.100:8085/api/" + // baseURL = "http://192.168.0.108:8085/api/" } else { // 开发环境 baseURL = "" @@ -85,7 +84,6 @@ export function postAxios({ url, data }) { } } ).then(res => { - console.log(res) }).catch(err => { if (err.message == "Network Error") { // alert("网络错误,请检查网络连接") @@ -128,5 +126,38 @@ export function postAxios({ url, data }) { }) }) } +export const downFile = async (urlstr, data) => { + + // 发送请求,获取文件流 + const response = await axios.post(urlstr, data, { responseType: 'blob' }); + + // 获取文件名(如果后端设置了 Content-Disposition) + const contentDisposition = response.headers['content-disposition']; + let fileName = 'default-file-name'; // 默认文件名 + console.log(contentDisposition) + console.log(response) + if (contentDisposition) { + // 从响应头中提取文件名 + const fileNameMatch = contentDisposition.match(/filename="(.+)"/); + if (fileNameMatch && fileNameMatch.length > 1) { + fileName = fileNameMatch[1]; + } + } + + // 创建一个临时的下载链接 + const blob = new Blob([response.data], { type: response.headers['content-type'] }); + const url = window.URL.createObjectURL(blob); + const a = document.createElement('a'); + a.href = url; + a.download = fileName; // 设置下载的文件名 + a.click(); + + // 释放 URL 对象 + window.URL.revokeObjectURL(url); + + +} + + export default axios \ No newline at end of file diff --git a/src/utils/pythonBridge.js b/src/utils/pythonBridge.js index a6ae624..18315e2 100644 --- a/src/utils/pythonBridge.js +++ b/src/utils/pythonBridge.js @@ -47,18 +47,14 @@ export function usePythonBridge() { // 登录tk后台 const loginBackStage = (data) => { - return new Promise((resolve, reject) => { - if (bridge.value) { - bridge.value.loginBackStage(data, function (result) { - if (result) { - resolve(result); - } else { - reject(result); - } - - }); + if (bridge.value) { + if (data.index == 0) { + bridge.value.loginBackStage(JSON.stringify(data)); + } else if (data.index == 1) { + bridge.value.loginBackStageCopy(JSON.stringify(data)); } - }); + + } }; //跳转到主播页面 @@ -70,6 +66,31 @@ export function usePythonBridge() { }); } }; + + //查询登录状态 + const backStageloginStatus = () => { + return new Promise((resolve, reject) => { + if (bridge.value) { + bridge.value.backStageloginStatus(function (result) { + resolve(result); + }); + } + }); + + }; + //查询登录状态 + const backStageloginStatusCopy = () => { + return new Promise((resolve, reject) => { + if (bridge.value) { + bridge.value.backStageloginStatusCopy(function (result) { + resolve(result); + }); + } + }); + + }; + + // 在组件挂载时初始化桥接 onMounted(initBridge); @@ -78,6 +99,8 @@ export function usePythonBridge() { fetchDataCount, loginBackStage, loginTikTok, - givePyAnchorId + givePyAnchorId, + backStageloginStatus, + backStageloginStatusCopy }; } \ No newline at end of file diff --git a/src/utils/storage.js b/src/utils/storage.js index 8e3f1af..6dc01f9 100644 --- a/src/utils/storage.js +++ b/src/utils/storage.js @@ -26,9 +26,20 @@ export function getNumData() { return JSON.parse(localStorage.getItem('num')); } +// 导出一个函数,用于设置用户密码 export function setUserPass(userdata) { localStorage.setItem('userPass', JSON.stringify(userdata)); } +// 导出一个函数,用于获取用户密码 export function getUserPass() { return JSON.parse(localStorage.getItem('userPass')); +} + +// 用于设置tk账户密码 +export function setTkUser(userdata) { + localStorage.setItem('tkuser', JSON.stringify(userdata)); +} +// 用于获取tk账户密码 +export function getTkUser() { + return JSON.parse(localStorage.getItem('tkuser')); } \ No newline at end of file diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 31c78df..b56b654 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -45,7 +45,7 @@
- +
diff --git a/src/views/hosts/hostsList.vue b/src/views/hosts/hostsList.vue index a347b09..67556e2 100644 --- a/src/views/hosts/hostsList.vue +++ b/src/views/hosts/hostsList.vue @@ -10,11 +10,13 @@ style="margin-left: 50px;" /> 查询 + 导出Excel数据
- - + + - + + +