Browse Source

Merge branch 'dev' of http://gogs.gzzzyd.com/xiaowenhua/vueDataV into dev

wll8 5 months ago
parent
commit
916e6c335c

+ 26 - 27
mm/mm.config.js

@@ -21,13 +21,13 @@ module.exports = async (util) => {
     port: 8100,
     port: 8100,
     testPort: 8105,
     testPort: 8105,
     replayPort: 8101,
     replayPort: 8101,
-    watch: [`./api/`],
+    watch: [`./apix/`],
     proxy: {
     proxy: {
-      '/': `http://192.168.1.196:8088/`, // 后端接口主域
+      '/': `http://192.168.1.70:8088/`, // 后端接口主域
       '/anything/intercept': [`origin`, `127.0.0.1`], // 修改接口返回的数据
       '/anything/intercept': [`origin`, `127.0.0.1`], // 修改接口返回的数据
     },
     },
-    apiX: {
-      'get /api/currentWeather': util.side({
+    api: {
+      'get /apix/currentWeather': util.side({
         tags: [`公用`],
         tags: [`公用`],
         summary: `当前天气`,
         summary: `当前天气`,
         async action(req, res) {
         async action(req, res) {
@@ -89,7 +89,7 @@ module.exports = async (util) => {
           }
           }
         },
         },
       }),
       }),
-      'get /api/mapOfTongren': util.side({
+      'get /apix/mapOfTongren': util.side({
         tags: [`公用`],
         tags: [`公用`],
         summary: `铜仁地图数据`,
         summary: `铜仁地图数据`,
         async action(req, res) {
         async action(req, res) {
@@ -107,7 +107,7 @@ module.exports = async (util) => {
           )
           )
         },
         },
       }),
       }),
-      'get /api/realTimeStatistics': util.side({
+      'get /apix/realTimeStatistics': util.side({
         tags: [`综合总览`],
         tags: [`综合总览`],
         summary: `实时统计`,
         summary: `实时统计`,
         async action(req, res) {
         async action(req, res) {
@@ -126,7 +126,7 @@ module.exports = async (util) => {
           )
           )
         },
         },
       }),
       }),
-      'get /api/analysisOfTransplantYieldInVariousRegions': util.side({
+      'get /apix/analysisOfTransplantYieldInVariousRegions': util.side({
         tags: [`综合总览`],
         tags: [`综合总览`],
         summary: `各区域移栽产量分析`,
         summary: `各区域移栽产量分析`,
         async action(req, res) {
         async action(req, res) {
@@ -144,7 +144,7 @@ module.exports = async (util) => {
           )
           )
         },
         },
       }),
       }),
-      'get /api/weatherForecast': util.side({
+      'get /apix/weatherForecast': util.side({
         tags: [`综合总览`, `种值分析详情`],
         tags: [`综合总览`, `种值分析详情`],
         summary: `天气预报, 实时天气`,
         summary: `天气预报, 实时天气`,
         async action(req, res) {
         async action(req, res) {
@@ -171,7 +171,7 @@ module.exports = async (util) => {
           )
           )
         },
         },
       }),
       }),
-      'get /api/transplantAreaInEachRegion': util.side({
+      'get /apix/transplantAreaInEachRegion': util.side({
         tags: [`综合总览`],
         tags: [`综合总览`],
         summary: `各区域移栽面积`,
         summary: `各区域移栽面积`,
         async action(req, res) {
         async action(req, res) {
@@ -190,7 +190,7 @@ module.exports = async (util) => {
           )
           )
         },
         },
       }),
       }),
-      'get /api/analysisOfTransplantingSituation': util.side({
+      'get /apix/analysisOfTransplantingSituation': util.side({
         tags: [`综合总览`],
         tags: [`综合总览`],
         summary: `移栽情况分析`,
         summary: `移栽情况分析`,
         async action(req, res) {
         async action(req, res) {
@@ -212,7 +212,7 @@ module.exports = async (util) => {
           )
           )
         },
         },
       }),
       }),
-      'get /api/transplantTrendAnalysis': util.side({
+      'get /apix/transplantTrendAnalysis': util.side({
         tags: [`综合总览`, `种值分析详情`],
         tags: [`综合总览`, `种值分析详情`],
         summary: `移栽趋势分析, 月度移栽趋势`,
         summary: `移栽趋势分析, 月度移栽趋势`,
         async action(req, res) {
         async action(req, res) {
@@ -250,17 +250,16 @@ module.exports = async (util) => {
             .description(`搜索项`),
             .description(`搜索项`),
         },
         },
         async action(req, res, next) {
         async action(req, res, next) {
-          res.redirect(req.originalUrl.replace(`/api`, ``))
+          res.redirect(req.originalUrl.replace(`/apix`, ``))
         },
         },
       }),
       }),
       'get /api/base/:id': util.side({
       'get /api/base/:id': util.side({
         tags: [`增删改查`, `种植分析`, `种值分析详情`],
         tags: [`增删改查`, `种植分析`, `种值分析详情`],
         summary: `基地详情`,
         summary: `基地详情`,
         schema: {
         schema: {
-          path: joi
-            .object({
-              id: joi.string(),
-            })
+          path: joi.object({
+            id: joi.string(),
+          }),
         },
         },
         async action(req, res, next) {
         async action(req, res, next) {
           res.redirect(req.originalUrl.replace(`/api`, ``))
           res.redirect(req.originalUrl.replace(`/api`, ``))
@@ -278,10 +277,10 @@ module.exports = async (util) => {
             .description(`搜索项`),
             .description(`搜索项`),
         },
         },
         async action(req, res, next) {
         async action(req, res, next) {
-          res.redirect(req.originalUrl.replace(`/api`, ``))
+          res.redirect(req.originalUrl.replace(`/apix`, ``))
         },
         },
       }),
       }),
-      'get /api/transplantAreaInEachRegion2': util.side({
+      'get /apix/transplantAreaInEachRegion2': util.side({
         tags: [`种植分析`],
         tags: [`种植分析`],
         summary: `各区域移栽面积`,
         summary: `各区域移栽面积`,
         async action(req, res, next) {
         async action(req, res, next) {
@@ -291,10 +290,10 @@ module.exports = async (util) => {
                 'data|10': [
                 'data|10': [
                   {
                   {
                     名称: `@county`,
                     名称: `@county`,
-                    已移: `@integer(9, 9e4)`,
+                    已移: `@integer(9, 9e4)`,
                     未移栽: `@integer(9, 9e4)`,
                     未移栽: `@integer(9, 9e4)`,
                     比率() {
                     比率() {
-                      return (this.已移载 / (this.已移载 + this.未移栽)) * 100
+                      return (this.已移栽 / (this.已移栽 + this.未移栽)) * 100
                     },
                     },
                   },
                   },
                 ],
                 ],
@@ -303,7 +302,7 @@ module.exports = async (util) => {
           )
           )
         },
         },
       }),
       }),
-      'get /api/trendOfTransplantQuantityThisMonth': util.side({
+      'get /apix/trendOfTransplantQuantityThisMonth': util.side({
         tags: [`种植分析`, `种值分析详情`],
         tags: [`种植分析`, `种值分析详情`],
         summary: `本月移栽数量趋势`,
         summary: `本月移栽数量趋势`,
         async action(req, res, next) {
         async action(req, res, next) {
@@ -329,7 +328,7 @@ module.exports = async (util) => {
           )
           )
         },
         },
       }),
       }),
-      'get /api/thisYearsTransplantingDataTrend': util.side({
+      'get /apix/thisYearsTransplantingDataTrend': util.side({
         tags: [`种植分析`, `种值分析详情`],
         tags: [`种植分析`, `种值分析详情`],
         summary: `本年移栽数据趋势, 年度移栽趋势`,
         summary: `本年移栽数据趋势, 年度移栽趋势`,
         async action(req, res, next) {
         async action(req, res, next) {
@@ -355,21 +354,21 @@ module.exports = async (util) => {
           )
           )
         },
         },
       }),
       }),
-      'get /api/analysisOfAnnualTransplantArea': util.side({
+      'get /apix/analysisOfAnnualTransplantArea': util.side({
         tags: [`种植分析`, `种值分析详情`],
         tags: [`种植分析`, `种值分析详情`],
         summary: `年度移栽面积分析`,
         summary: `年度移栽面积分析`,
         async action(req, res, next) {
         async action(req, res, next) {
-          res.redirect(`/api/thisYearsTransplantingDataTrend`)
+          res.redirect(`/apix/thisYearsTransplantingDataTrend`)
         },
         },
       }),
       }),
-      'get /api/monthlyTransplantationAreaAnalysis': util.side({
+      'get /apix/monthlyTransplantationAreaAnalysis': util.side({
         tags: [`种植分析`, `种值分析详情`],
         tags: [`种植分析`, `种值分析详情`],
         summary: `月度移栽面积分析`,
         summary: `月度移栽面积分析`,
         async action(req, res, next) {
         async action(req, res, next) {
-          res.redirect(`/api/trendOfTransplantQuantityThisMonth`)
+          res.redirect(`/apix/trendOfTransplantQuantityThisMonth`)
         },
         },
       }),
       }),
-      'get /api/transplantData': util.side({
+      'get /apix/transplantData': util.side({
         tags: [`种值分析详情`],
         tags: [`种值分析详情`],
         summary: `移栽数据`,
         summary: `移栽数据`,
         async action(req, res) {
         async action(req, res) {

+ 1 - 1
src/components/bgBox/index.vue

@@ -107,7 +107,7 @@ export default {
           fn: this.currentTime,
           fn: this.currentTime,
         },
         },
         {
         {
-          time: 1000 * 5,
+          time: 1000 * 3600,
           fn: this.currentWeather,
           fn: this.currentWeather,
         },
         },
       ],
       ],

+ 13 - 11
src/http/index.js

@@ -10,6 +10,10 @@ const api = window.axios.create({
 // request拦截器
 // request拦截器
 api.interceptors.request.use(
 api.interceptors.request.use(
   (options) => {
   (options) => {
+    if (!options.url.includes(`/api/login`)) {
+      // 判断请求是否是登录接口
+      options.headers.Authorization = `Bearer ` + localStorage.getItem(`token`) // 如果不是登录接口,就给请求头里面设置token
+    }
     options.baseURL = config.baseApi
     options.baseURL = config.baseApi
     return options
     return options
   },
   },
@@ -21,12 +25,16 @@ api.interceptors.request.use(
 api.interceptors.response.use(
 api.interceptors.response.use(
   (response) => {
   (response) => {
     const data = response.data
     const data = response.data
-    if (util.isType(data, `blob`)) {
-      return response
-    } else if (data.data === undefined) {
-      return data
+    if ([`2`, `3`].includes(String(data.code || response.status)[0])) {
+      if (util.isType(data, `blob`)) {
+        return response
+      } else if (data.data === undefined) {
+        return data
+      } else {
+        return response.data.data
+      }
     } else {
     } else {
-      return response.data.data
+      return Promise.reject(data.msg || data)
     }
     }
   },
   },
   (error) => {
   (error) => {
@@ -42,17 +50,11 @@ export { api }
 
 
 /**
 /**
 key 是监听的键
 key 是监听的键
-
 api 是 get 请求的地址
 api 是 get 请求的地址
 当 api 是函数时直接运行函数
 当 api 是函数时直接运行函数
-
 arg 是 get 请求参数
 arg 是 get 请求参数
 可以通过 this.$apiObj.键名.arg = {} 修改参数
 可以通过 this.$apiObj.键名.arg = {} 修改参数
-
-
 time 是更新频率
 time 是更新频率
-
-
 */
 */
 const apiObj = {
 const apiObj = {
   // 当前天气
   // 当前天气

+ 4 - 2
src/views/Login.vue

@@ -78,7 +78,7 @@ export default {
   data() {
   data() {
     return {
     return {
       userName: `admin`,
       userName: `admin`,
-      userPwd: `123456`,
+      userPwd: `admin123`,
       visible: false,
       visible: false,
       modalContent: `这是一段自定义模态框消息`,
       modalContent: `这是一段自定义模态框消息`,
     }
     }
@@ -98,11 +98,13 @@ export default {
           userPwd: this.userPwd,
           userPwd: this.userPwd,
         })
         })
         .then((res) => {
         .then((res) => {
+          localStorage.setItem(`token`, res.token)
           this.$router.push({
           this.$router.push({
             path: `/page1`,
             path: `/page1`,
           })
           })
         })
         })
-        .catch(() => {
+        .catch((xx) => {
+          console.log(`xxx`, xx)
           this.$Toast({
           this.$Toast({
             content: `请输入正确的用户名和密码`,
             content: `请输入正确的用户名和密码`,
             type: `error`,
             type: `error`,

+ 6 - 7
src/views/page1/index.vue

@@ -76,7 +76,6 @@
 <script>
 <script>
 import mapOfTongren from '@/http/mapOfTongren.json'
 import mapOfTongren from '@/http/mapOfTongren.json'
 import bgBox from '@/components/bgBox/index.vue'
 import bgBox from '@/components/bgBox/index.vue'
-import { screenSize } from '@/assets/js/utils'
 import cake from '@/components/Customize/cake'
 import cake from '@/components/Customize/cake'
 import cylindricalHistogram from '@/components/Customize/cylindricalHistogram'
 import cylindricalHistogram from '@/components/Customize/cylindricalHistogram'
 import weatherForecast from '@/components/Customize/weatherForecast'
 import weatherForecast from '@/components/Customize/weatherForecast'
@@ -152,27 +151,27 @@ export default {
     this.$util.autoVueFn(
     this.$util.autoVueFn(
       [
       [
         {
         {
-          time: 1000 * 5,
+          time: 1000 * 3600,
           fn: this.getWeatherForecast,
           fn: this.getWeatherForecast,
         },
         },
         {
         {
-          time: 1000 * 5,
+          time: 1000 * 3600,
           fn: this.getAnalysisOfTransplantYieldInVariousRegions,
           fn: this.getAnalysisOfTransplantYieldInVariousRegions,
         },
         },
         {
         {
-          time: 1000 * 5,
+          time: 1000 * 3600,
           fn: this.getTransplantAreaInEachRegion,
           fn: this.getTransplantAreaInEachRegion,
         },
         },
         {
         {
-          time: 1000 * 5,
+          time: 1000 * 3600,
           fn: this.getAnalysisOfTransplantingSituation,
           fn: this.getAnalysisOfTransplantingSituation,
         },
         },
         {
         {
-          time: 1000 * 5,
+          time: 1000 * 3600,
           fn: this.getStatistics,
           fn: this.getStatistics,
         },
         },
         {
         {
-          time: 1000 * 5,
+          time: 1000 * 3600,
           fn: this.getTrendAnalysis,
           fn: this.getTrendAnalysis,
         },
         },
       ],
       ],

+ 8 - 6
src/views/page2/index.vue

@@ -85,15 +85,15 @@ export default {
     this.$util.autoVueFn(
     this.$util.autoVueFn(
       [
       [
         {
         {
-          time: 1000 * 5,
+          time: 1000 * 3600,
           fn: this.getAnalysisOfTransplantingSituation,
           fn: this.getAnalysisOfTransplantingSituation,
         },
         },
         {
         {
-          time: 1000 * 5,
+          time: 1000 * 3600,
           fn: this.getTrendOfTransplantQuantityThisMonth,
           fn: this.getTrendOfTransplantQuantityThisMonth,
         },
         },
         {
         {
-          time: 1000 * 5,
+          time: 1000 * 3600,
           fn: this.getThisYearsTransplantingDataTrend,
           fn: this.getThisYearsTransplantingDataTrend,
         },
         },
       ],
       ],
@@ -112,7 +112,7 @@ export default {
       console.log(`val`, val)
       console.log(`val`, val)
     },
     },
     getTrendOfTransplantQuantityThisMonth() {
     getTrendOfTransplantQuantityThisMonth() {
-      this.$http.get(`/api/trendOfTransplantQuantityThisMonth`).then((res) => {
+      this.$http.get(`/api/transplantTrendAnalysis`).then((res) => {
         const area = []
         const area = []
         const dataArray = {
         const dataArray = {
           LastYear: [],
           LastYear: [],
@@ -160,10 +160,12 @@ export default {
           Done: [],
           Done: [],
           Percentage: [],
           Percentage: [],
         }
         }
-        const date = res.sort((a, b) => b.已移载 - a.已移载)
+        console.log(res)
+
+        const date = res.sort((a, b) => b.已移栽 - a.已移栽)
         date.forEach((element) => {
         date.forEach((element) => {
           area.push(element.名称.slice(0, 2))
           area.push(element.名称.slice(0, 2))
-          dataArray.Done.push(element.已移)
+          dataArray.Done.push(element.已移)
         })
         })
         this.HorizontalArea = area
         this.HorizontalArea = area
         this.HorizontalArray = dataArray
         this.HorizontalArray = dataArray

+ 1 - 1
src/views/page2/leftBox.vue

@@ -45,7 +45,7 @@ export default {
   methods: {
   methods: {
     async searchFn() {
     async searchFn() {
       console.log(`search`, this.leftBox.input)
       console.log(`search`, this.leftBox.input)
-      const data = await this.$http.get(`/api/getAllDistrict`)
+      const data = await this.$http.get(`/api/base`)
       this.leftBox.list = []
       this.leftBox.list = []
       this.$nextTick(() => {
       this.$nextTick(() => {
         this.leftBox.list = data
         this.leftBox.list = data

+ 6 - 6
src/views/page3/index.vue

@@ -212,27 +212,27 @@ export default {
     this.$util.autoVueFn(
     this.$util.autoVueFn(
       [
       [
         {
         {
-          time: 1000 * 5,
+          time: 1000 * 3600,
           fn: this.getTrendOfTransplantQuantityThisMonth,
           fn: this.getTrendOfTransplantQuantityThisMonth,
         },
         },
         {
         {
-          time: 1000 * 5,
+          time: 1000 * 3600,
           fn: this.getThisYearsTransplantingDataTrend,
           fn: this.getThisYearsTransplantingDataTrend,
         },
         },
         {
         {
-          time: 1000 * 5,
+          time: 1000 * 3600,
           fn: this.getMonthlyTransplantationAreaAnalysis,
           fn: this.getMonthlyTransplantationAreaAnalysis,
         },
         },
         {
         {
-          time: 1000 * 5,
+          time: 1000 * 3600,
           fn: this.getAnalysisOfAnnualTransplantArea,
           fn: this.getAnalysisOfAnnualTransplantArea,
         },
         },
         {
         {
-          time: 1000 * 5,
+          time: 1000 * 3600,
           fn: this.getStatistics,
           fn: this.getStatistics,
         },
         },
         {
         {
-          time: 1000 * 5,
+          time: 1000 * 3600,
           fn: this.getWeatherForecast,
           fn: this.getWeatherForecast,
         },
         },
       ],
       ],