Просмотр исходного кода

【历史回顾】对接接口

任一存 2 лет назад
Родитель
Сommit
7cfb58ec3a
4 измененных файлов с 44 добавлено и 414 удалено
  1. 10 20
      public/chart.html
  2. 10 20
      public/chart4app.html
  3. 0 329
      public/history.js
  4. 24 45
      src/api.js

+ 10 - 20
public/chart.html

@@ -19,7 +19,6 @@
   <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
   <script type="text/javascript" src="https://cdn.staticfile.org/echarts/5.4.2/echarts.min.js"></script>
   <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
-  <script src="./history.js"></script>
 
   <script type="text/javascript">
     const timeList = [
@@ -54,26 +53,17 @@
     async function showChart(timeIdx) {
       myChart.clear()
       
-      // const res = await axios({
-      //   method: 'post',
-      //   url: `https://sit-shgybwg.4dage.com/api/show/history/pageList`,
-      //   headers: {
-      //     "Content-Type": "application/json",
-      //   },
-      //   data: {
-      //     stage: timeList[timeIdx]
-      //   },
-      // })
-      // const corpList = res.data.data.records
-      const corpList = historyRawData['阶段任务信息'][timeIdx].children.map((item) => {
-        return {
-          companyName: item['品牌'],
-          description: item['简介'],
-          id: item['序号'],
-          name: item['名称'],
-          story: item['故事'],
-        }
+      const res = await axios({
+        method: 'post',
+        url: `https://sit-shgybwg.4dage.com/api/show/history/pageList`,
+        headers: {
+          "Content-Type": "application/json",
+        },
+        data: {
+          stage: timeList[timeIdx]
+        },
       })
+      const corpList = res.data.data.records
 
       dataForRender.nodes = [
         {

+ 10 - 20
public/chart4app.html

@@ -22,7 +22,6 @@
   <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
   <script type="text/javascript" src="https://cdn.staticfile.org/echarts/5.4.2/echarts.min.js"></script>
   <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
-  <script src="./history.js"></script>
 
   <script type="text/javascript">
     const timeList = [
@@ -57,26 +56,17 @@
     async function showChart(timeIdx) {
       myChart.clear()
       
-      // const res = await axios({
-      //   method: 'post',
-      //   url: `https://sit-shgybwg.4dage.com/api/show/history/pageList`,
-      //   headers: {
-      //     "Content-Type": "application/json",
-      //   },
-      //   data: {
-      //     stage: timeList[timeIdx]
-      //   },
-      // })
-      // const corpList = res.data.data.records
-      const corpList = historyRawData['阶段任务信息'][timeIdx].children.map((item) => {
-        return {
-          companyName: item['品牌'],
-          description: item['简介'],
-          id: item['序号'],
-          name: item['名称'],
-          story: item['故事'],
-        }
+      const res = await axios({
+        method: 'post',
+        url: `https://sit-shgybwg.4dage.com/api/show/history/pageList`,
+        headers: {
+          "Content-Type": "application/json",
+        },
+        data: {
+          stage: timeList[timeIdx]
+        },
       })
+      const corpList = res.data.data.records
 
       dataForRender.nodes = [
         {

Разница между файлами не показана из-за своего большого размера
+ 0 - 329
public/history.js


+ 24 - 45
src/api.js

@@ -1,5 +1,4 @@
 import axios from "axios"
-import historyRawData from "@/assets/mock/history.json"
 
 // axios({
 //   method: 'post',
@@ -39,57 +38,37 @@ export default {
       return res.data.data.records
     })
   },
-  // getHistoryList({
-  //   pageNum = 0,
-  //   pageSize = 0,
-  //   searchKey = '',
-  //   stage = '',
-  // } = {}) {
-  //   return axios({
-  //     method: 'post',
-  //     url: `${process.env.VUE_APP_API_ORIGIN}/api/show/history/pageList`,
-  //     headers: {
-  //       "Content-Type": "application/json",
-  //     },
-  //     data: {
-  //       pageNum,
-  //       pageSize,
-  //       searchKey,
-  //       stage,
-  //     },
-  //   }).then((res) => {
-  //     return res.data.data.records
-  //   })
-  // },
   getHistoryList({
     pageNum = 0,
     pageSize = 0,
     searchKey = '',
     stage = '',
   } = {}) {
-    const ret = historyRawData['阶段任务信息'].find((item) => {
-      return item['所属阶段'] === stage
-    }).children.map((item) => {
-      return {
-        companyName: item['品牌'],
-        description: item['简介'],
-        id: item['序号'],
-        name: item['名称'],
+    return axios({
+      method: 'post',
+      url: `${process.env.VUE_APP_API_ORIGIN}/api/show/history/pageList`,
+      headers: {
+        "Content-Type": "application/json",
+      },
+      data: {
+        pageNum,
+        pageSize,
+        searchKey,
         stage,
-        story: item['故事'],
-      }
+      },
+    }).then((res) => {
+      return res.data.data.records
     })
-    return Promise.resolve(ret)
   },
-  // getHistoryDetail(id) {
-  //   return axios({
-  //     method: 'get',
-  //     url: `${process.env.VUE_APP_API_ORIGIN}/api/show/history/detail/${id}`,
-  //     headers: {
-  //       "Content-Type": "application/json",
-  //     },
-  //   }).then((res) => {
-  //     return res.data.data
-  //   })
-  // }
+  getHistoryDetail(id) {
+    return axios({
+      method: 'get',
+      url: `${process.env.VUE_APP_API_ORIGIN}/api/show/history/detail/${id}`,
+      headers: {
+        "Content-Type": "application/json",
+      },
+    }).then((res) => {
+      return res.data.data
+    })
+  }
 }