瀏覽代碼

接口对接

twt 2 年之前
父節點
當前提交
3547c23afa
共有 10 個文件被更改,包括 554 次插入54 次删除
  1. 15 0
      .env.development
  2. 6 0
      .env.production
  3. 8 0
      .env.staging
  4. 22 1
      config/index.js
  5. 45 5
      package-lock.json
  6. 1 0
      package.json
  7. 1 1
      src/main.js
  8. 192 47
      src/page/index.vue
  9. 154 0
      src/utils/index.js
  10. 110 0
      src/utils/request.js

+ 15 - 0
.env.development

@@ -0,0 +1,15 @@
+# just a flag
+ENV = 'development'
+
+# base api
+VUE_APP_BASE_API = '/dev-api'
+TIME_OUT = '999999'
+
+# vue-cli uses the VUE_CLI_BABEL_TRANSPILE_MODULES environment variable,
+# to control whether the babel-plugin-dynamic-import-node plugin is enabled.
+# It only does one thing by converting all import() to require().
+# This configuration can significantly increase the speed of hot updates,
+# when you have a large number of pages.
+# Detail:  https://github.com/vuejs/vue-cli/blob/dev/packages/@vue/babel-preset-app/index.js
+
+VUE_CLI_BABEL_TRANSPILE_MODULES = true

+ 6 - 0
.env.production

@@ -0,0 +1,6 @@
+# just a flag
+ENV = 'production'
+
+# base api
+VUE_APP_BASE_API = 'http://apidms.66km.com'
+TIME_OUT = '999999'

+ 8 - 0
.env.staging

@@ -0,0 +1,8 @@
+NODE_ENV = production
+
+# just a flag
+ENV = 'staging'
+
+# base api
+VUE_APP_BASE_API = 'http://api.dms.66km.com.cn'
+TIME_OUT = '999999'

+ 22 - 1
config/index.js

@@ -19,7 +19,28 @@ module.exports = {
     errorOverlay: true,
     notifyOnErrors: true,
     poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-
-
+    proxy: {
+         // change xxx-api/login => mock/login
+         // detail: https://cli.vuejs.org/config/#devserver-proxy
+         [process.env.VUE_APP_BASE_API]: {
+           //target: `http://58.56.15.138:20201/`,
+         // target: `http://192.168.0.121:20187/`,
+           target:`http://api.dms.66km.com.cn/`,
+           timeout: 8640000,
+           changeOrigin: true,
+           pathRewrite: {
+             ['^' + process.env.VUE_APP_BASE_API]: ''
+           }
+         }/* ,
+    
+         '/api/*': {
+                   target: 'http://58.56.15.138:20132/',
+                   pathRewrite: {'^/api' : '/'},
+                   changeOrigin: true
+               }
+    */
+       
+       },
 
     /**
      * Source Maps

+ 45 - 5
package-lock.json

@@ -299,6 +299,11 @@
         "babel-runtime": "6.x"
       }
     },
+    "asynckit": {
+      "version": "0.4.0",
+      "resolved": "https://registry.npmmirror.com/asynckit/-/asynckit-0.4.0.tgz",
+      "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
+    },
     "atob": {
       "version": "2.1.2",
       "resolved": "https://registry.npmmirror.com/atob/-/atob-2.1.2.tgz",
@@ -332,6 +337,16 @@
         }
       }
     },
+    "axios": {
+      "version": "1.1.2",
+      "resolved": "https://registry.npmmirror.com/axios/-/axios-1.1.2.tgz",
+      "integrity": "sha512-bznQyETwElsXl2RK7HLLwb5GPpOLlycxHCtrpDR/4RqqBzjARaOTo3jz4IgtntWUYee7Ne4S8UHd92VCuzPaWA==",
+      "requires": {
+        "follow-redirects": "^1.15.0",
+        "form-data": "^4.0.0",
+        "proxy-from-env": "^1.1.0"
+      }
+    },
     "babel-code-frame": {
       "version": "6.26.0",
       "resolved": "https://registry.npmmirror.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz",
@@ -1880,6 +1895,14 @@
       "integrity": "sha512-ENwblkFQpqqia6b++zLD/KUWafYlVY/UNnAp7oz7LY7E924wmpye416wBOmvv/HMWzl8gL1kJlfvId/1Dg176w==",
       "dev": true
     },
+    "combined-stream": {
+      "version": "1.0.8",
+      "resolved": "https://registry.npmmirror.com/combined-stream/-/combined-stream-1.0.8.tgz",
+      "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
+      "requires": {
+        "delayed-stream": "~1.0.0"
+      }
+    },
     "commander": {
       "version": "2.17.1",
       "resolved": "https://registry.npmmirror.com/commander/-/commander-2.17.1.tgz",
@@ -3294,6 +3317,11 @@
         }
       }
     },
+    "delayed-stream": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmmirror.com/delayed-stream/-/delayed-stream-1.0.0.tgz",
+      "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ=="
+    },
     "depd": {
       "version": "2.0.0",
       "resolved": "https://registry.npmmirror.com/depd/-/depd-2.0.0.tgz",
@@ -4185,8 +4213,7 @@
     "follow-redirects": {
       "version": "1.15.2",
       "resolved": "https://registry.npmmirror.com/follow-redirects/-/follow-redirects-1.15.2.tgz",
-      "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==",
-      "dev": true
+      "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA=="
     },
     "for-in": {
       "version": "1.0.2",
@@ -4194,6 +4221,16 @@
       "integrity": "sha512-7EwmXrOjyL+ChxMhmG5lnW9MPt1aIeZEwKhQzoBUdTV0N3zuwWDZYVJatDvZ2OyzPUvdIAZDsCetk3coyMfcnQ==",
       "dev": true
     },
+    "form-data": {
+      "version": "4.0.0",
+      "resolved": "https://registry.npmmirror.com/form-data/-/form-data-4.0.0.tgz",
+      "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
+      "requires": {
+        "asynckit": "^0.4.0",
+        "combined-stream": "^1.0.8",
+        "mime-types": "^2.1.12"
+      }
+    },
     "forwarded": {
       "version": "0.2.0",
       "resolved": "https://registry.npmmirror.com/forwarded/-/forwarded-0.2.0.tgz",
@@ -5882,14 +5919,12 @@
     "mime-db": {
       "version": "1.52.0",
       "resolved": "https://registry.npmmirror.com/mime-db/-/mime-db-1.52.0.tgz",
-      "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
-      "dev": true
+      "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg=="
     },
     "mime-types": {
       "version": "2.1.35",
       "resolved": "https://registry.npmmirror.com/mime-types/-/mime-types-2.1.35.tgz",
       "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
-      "dev": true,
       "requires": {
         "mime-db": "1.52.0"
       }
@@ -9103,6 +9138,11 @@
         "ipaddr.js": "1.9.1"
       }
     },
+    "proxy-from-env": {
+      "version": "1.1.0",
+      "resolved": "https://registry.npmmirror.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
+      "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
+    },
     "prr": {
       "version": "1.0.1",
       "resolved": "https://registry.npmmirror.com/prr/-/prr-1.0.1.tgz",

+ 1 - 0
package.json

@@ -10,6 +10,7 @@
     "build": "node build/build.js"
   },
   "dependencies": {
+    "axios": "^1.1.2",
     "element-ui": "^2.15.10",
     "vue": "^2.5.2",
     "vue-router": "^3.0.1"

+ 1 - 1
src/main.js

@@ -8,7 +8,7 @@ Vue.use(ElementUI);
 import router from './router'
 
 Vue.config.productionTip = false
-
+console.log(process.env.VUE_APP_BASE_URL);
 /* eslint-disable no-new */
 new Vue({
   el: '#app',

+ 192 - 47
src/page/index.vue

@@ -2,7 +2,7 @@
   <div class="hello">
      <div class="top">
        <div class="vinBtn">VIN</div>
-       <input type="text" placeholder="请输入17位车架号查询" class="vinsearch">
+       <input type="text" v-model="vin" placeholder="请输入17位车架号查询" class="vinsearch" @keyup.enter="keyup">
        <div class="barndBox">
           当前品牌:
           <div class="barnd">
@@ -14,8 +14,9 @@
        </div>
      </div>
      <div class="toConfigure">
-       车辆配置:<span class="span1">BYD6490STHEV(尊荣型)</span>  > 车型: <span class="span1">东风本田2016思域 </span> 总组:<span class="span1">车身及车身附件</span>
-       <span>>子组:<span class="span1">电磁阀1.5L</span></span>
+       车辆配置:<span class="span1">{{carConfigName}}</span>  > 车型: <span class="span1">{{brand_name}}</span>
+        总组:<span class="span1">{{zzName}}</span>
+       <span>>子组:<span class="span1">--</span></span>
      </div>
      <div class="main">
        <!-- 总组-->
@@ -24,7 +25,8 @@
            <div class="sx"></div>
            <div class="leftTitle">总组</div>
          </div>
-         <div class="mainLeftLine" v-for="(item,index) in 5">{{index}}发动机</div>
+         <div class="mainLeftLine"  :class="{mainLeftLineActive:zzIndex==index}"
+          v-for="(item,index) in zlist" @click="zzClick(index,item)">{{item.caption}}</div>
        </div>
        <!-- 车辆配置-->
        <div class="mainLeft" v-if="carConfig">
@@ -32,8 +34,8 @@
            <div class="sx"></div>
            <div class="leftTitle">选择车辆配置</div>
          </div>
-         <div class="mainLeftLine" v-for="(item,index) in 5" @click="carConfigClick(index)"
-         :class="{mainLeftLineActive:carConfigIndex==index}">左舵,天窗,皮革座椅</div>
+         <div class="mainLeftLine" v-for="(item,index) in restrains" @click="carConfigClick(index,item)"
+         :class="{mainLeftLineActive:carConfigIndex==index}">{{item.combine_cp}}</div>
        </div>
        <div class="mainRight1" v-if="groupShow">
          <div class="mainRightTop">
@@ -45,14 +47,14 @@
            </div>
          </div>
          <div class="mainRightCont">
-           <div class="mainRightLine" v-for="(item,index) in 8">
+           <div class="mainRightLine" v-for="(item,index) in childrenList" @click="childrenClick(item)">
              <div class="mainRightLineImgBox">
-               <img class="mainRightLineImg" src="http://img2.nanxinwang.com/ds/resources/app/byd/v1/873fed186c14da3d7ea2a3fb97f5af05.png?x-oss-process=style/constrain_550_adp_jpg" alt="">
+               <img class="mainRightLineImg" :src="item.image_url.replace(/90/g, '320')" alt="">
              </div>
              <div class="mainRightLineMsBox">
-               <div class="mainRightLineName">节气门1.5L</div>
-               <div class="mainRightLineZm">组名:EA-90B-12QW2A</div>
-               <div class="mainRightLineRemarks">备注:这是备注这是备注这是备注这是备注</div>
+               <div class="mainRightLineName">{{item.caption}}</div>
+               <div class="mainRightLineZm">组名:{{item.group_no}}</div>
+               <div class="mainRightLineRemarks">备注:{{item.remark}}</div>
              </div>
 
            </div>
@@ -64,44 +66,45 @@
 
    <!-- 子组件详情-->
       <div class="childrenMain" v-if="childrenShow">
-         <div class="childrenMainLeft">
-            <img class="childrenImg" src="http://img2.nanxinwang.com/ds/resources/app/byd/v1/873fed186c14da3d7ea2a3fb97f5af05.png?x-oss-process=style/constrain_550_adp_jpg" alt="">
+         <div class="childrenMainLeft" ref="childrenMainLeft">
+            <img class="childrenImg" :src="image_info.pic_url" alt="">
          </div>
          <div class="childrenMainRight">
             <el-table
                 class="el-table"
-                :data="tableData"
+                :data="rows"
+                :max-height="childrenHeight"
                 stripe   border
                 style="width: 100%">
                 <el-table-column
-                  prop="a1"
+                  prop="refernum"
                   label="位置"
                   width="50"
                   >
                 </el-table-column>
                 <el-table-column
-                  prop="a2"
+                  prop="extened[0]"
                   label="零件号"
                  >
                 </el-table-column>
                 <el-table-column
-                  prop="a3"
+                  prop="description"
                   label="名称">
                 </el-table-column>
                 <el-table-column
-                  prop="a4"
+                  prop="remark"
                   label="备注">
                 </el-table-column>
                 <el-table-column
-                  prop="a5"
+                  prop="qty"
                   label="用量">
                 </el-table-column>
                 <el-table-column
-                  prop="a6"
+                  prop="partnum[0]"
                   label="型号">
                 </el-table-column>
                 <el-table-column
-                  prop="a7"
+                  prop="price"
                   label="4S价">
                 </el-table-column>
               </el-table>
@@ -113,6 +116,7 @@
 </template>
 
 <script>
+  import { fetchPost, fetchGet, fetchPut, fetchDelete, baseURL } from '@/utils/request'
 export default {
   name: 'HelloWorld',
   data () {
@@ -120,34 +124,173 @@ export default {
        groupShow:false,  //总组的显示
        carConfig:false,   //车辆配置的显示
        carConfigIndex:-1,
-       childrenShow:true,
-       tableData:[
-         {
-           a1:1,
-           a2:'16400-59B-003',
-           a3:'节气门总成',
-           a4:'这是备注这是备注这是备注这是备...',
-           a5:'005',
-           a6:'GL345-876',
-           a7:'¥2698.00'
-         },
-         {
-           a1:2,
-           a2:'16400-59B-003',
-           a3:'节气门总成',
-           a4:'备注',
-           a5:'005',
-           a6:'GL345-876',
-           a7:'¥2698.00'
-         }
-       ]
+       childrenShow:false,
+       children:'',
+       vin:'LVHFC1663G6003140',
+       restrains:'',
+       brand_name:'',
+       access_time:'',
+       param:'',
+       token:'',
+       carConfigName:'',
+       zlist:'',
+       zzIndex:0,
+       zzName:'',
+       childrenList:'',
+       image_info:'',
+       rows:'',
+       zzTime:'',
+       childrenHeight:'',
     }
   },
   methods:{
-    carConfigClick(index){
-      this.carConfigIndex=index
+    carConfigClick(index,item){
+      this.carConfigIndex=index;
+      this.param=item.param;
+      this.token=item.token;
+      this.carConfigName=item.combine_cp;
+      this.getcarVinGroupPc()
+    },
+    keyup(){
+     // console.log(this.vin);LVHFC1663G6003140
+      fetchGet('/advancedEpc/getVinGroupPc', {
+        vin:this.vin
+       }).then(res => {
+         console.log(res.data.number);
+         if(res.data.number==200||res.data.number==5212){
+              this.brand_name=res.data.result.brand_name;
+              this.access_time=res.data.result.access_time;
+              if(res.data.result.restrains.length>0){
+                this.restrains=res.data.result.restrains;
+                this.groupShow=false;
+                this.carConfig=true;
+                this.childrenShow=false;
+              }
+         }else{
+           this.$message({
+                  message: res.data.message,
+                  type: 'warning'
+            });
+         }
+         //console.log(res)
+          //if(res.data.number)
+       }).catch(err => {
+          console.log('????111')
+
+       })
+    },
+    getcarVinGroupPc(){
+      fetchGet('/advancedEpc/getVinGroupPc', {
+        vin:this.vin,
+        access_time:this.access_time,
+        param:this.param,
+        token:this.token
+       }).then(res => {
+         console.log(res.data.number);
+         if(res.data.number==200||res.data.number==5212){
+               this.brand_name=res.data.result.brand_name;
+               this.access_time=res.data.result.access_time;
+               this.zzTime=res.data.result.access_time;
+               if(res.data.result.restrains.length>0){
+                 this.restrains=res.data.result.restrains;
+                 this.groupShow=false;
+                 this.carConfig=true;
+                 this.childrenShow=false;
+               }else{
+                 this.zlist=res.data.result.list;
+                 this.groupShow=true;
+                 this.carConfig=false;
+                 this.zzName=this.zlist[0].caption;
+                 this.param=this.zlist[0].param;
+                 this.token=this.zlist[0].token;
+                 this.getSubgroupPc()
+               }
+         }else{
+           this.$message({
+                  message: res.data.message,
+                  type: 'warning'
+            });
+         }
+
+       }).catch(err => {
+
+
+       })
+    },
+    zzClick(index,item){
+      this.zzIndex=index;
+      this.param=item.param;
+      this.token=item.token;
+      this.zzName=item.caption;
+      this.getSubgroupPc()
+    },
+    getSubgroupPc(){
+      fetchGet('/advancedEpc/getSubgroupPc', {
+        vin:this.vin,
+        access_time:this.zzTime,
+        param:this.param,
+        token:this.token
+       }).then(res => {
+         console.log(res.data.number);
+         if(res.data.number==200||res.data.number==5212){
+             this.childrenList=res.data.result.list;
+             this.access_time=res.data.result.access_time;
+         }else{
+           this.$message({
+                  message: res.data.message,
+                  type: 'warning'
+            });
+         }
+         }).catch(err => {
+
+
+         })
+    },
+    childrenClick(item){
+      this.param=item.param;
+      this.token=item.token;
+      this.getPartsPc();
+      this.groupShow=false;
+      this.carConfig=false;
+      this.childrenShow=true;
+       setTimeout(() => {
+        this.childrenHeight = this.$refs.childrenMainLeft.offsetHeight // 高度
+
+       // console.log(this.childrenHeight)
+       }, 500)
+
+    },
+    getPartsPc(){
+      fetchGet('/advancedEpc/getPartsPc', {
+        vin:this.vin,
+        access_time:this.access_time,
+        param:this.param,
+        token:this.token
+       }).then(res => {
+
+         if(res.data.number==200||res.data.number==5212){
+             //this.childrenList=res.data.result.list;
+             this.access_time=res.data.result.access_time;
+            //  console.log(res.data.result.list.image_info)
+             this.image_info=res.data.result.list.image_info[0];
+
+             this.rows=res.data.result.list.rows
+         }else{
+           this.$message({
+                  message: res.data.message,
+                  type: 'warning'
+            });
+         }
+         }).catch(err => {
+
+
+         })
     }
-  }
+}
+
+
+
+
 }
 </script>
 
@@ -324,7 +467,7 @@ color: #333333;padding-left: 10px;padding-right: 20px;
    border-radius: 4px;
    border: 1px solid #EEEEEE;
    margin: 1vw;
-
+  cursor: pointer;
  }
  .mainRightLineImgBox {
    /*图片容器宽高各220px,容器水平居中,图片水平垂直居中*/
@@ -335,11 +478,12 @@ color: #333333;padding-left: 10px;padding-right: 20px;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #EEEEEE;
+   overflow: hidden;
  }
  .mainRightLineImg {
    /*图片宽高各200px*/
   width: 100%;
-  height: 180px;
+
  }
  .mainRightCont{
    display: flex;
@@ -389,6 +533,7 @@ color: #333333;padding-left: 10px;padding-right: 20px;
       display: flex;
       align-items: center;
       justify-content: center;
+      overflow: hidden;
  }
  .childrenMainRight{
    height: calc(100vh - 200px );

+ 154 - 0
src/utils/index.js

@@ -0,0 +1,154 @@
+/**
+ * Created by PanJiaChen on 16/11/18.
+ */
+
+/**
+ * Parse the time to string
+ * @param {(Object|string|number)} time
+ * @param {string} cFormat
+ * @returns {string}
+ */
+export function parseTime(time, cFormat) {
+  if (arguments.length === 0) {
+    return null
+  }
+  const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
+  let date
+  if (typeof time === 'object') {
+    date = time
+  } else {
+    if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
+      time = parseInt(time)
+    }
+    if ((typeof time === 'number') && (time.toString().length === 10)) {
+      time = time * 1000
+    }
+    date = new Date(time)
+  }
+  const formatObj = {
+    y: date.getFullYear(),
+    m: date.getMonth() + 1,
+    d: date.getDate(),
+    h: date.getHours(),
+    i: date.getMinutes(),
+    s: date.getSeconds(),
+    a: date.getDay()
+  }
+  const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
+    let value = formatObj[key]
+    // Note: getDay() returns 0 on Sunday
+    if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value] }
+    if (result.length > 0 && value < 10) {
+      value = '0' + value
+    }
+    return value || 0
+  })
+  return time_str
+}
+
+/**
+ * @param {number} time
+ * @param {string} option
+ * @returns {string}
+ */
+export function formatTime(time, option) {
+  if (('' + time).length === 10) {
+    time = parseInt(time) * 1000
+  } else {
+    time = +time
+  }
+  const d = new Date(time)
+  const now = Date.now()
+
+  const diff = (now - d) / 1000
+
+  if (diff < 30) {
+    return '刚刚'
+  } else if (diff < 3600) {
+    // less 1 hour
+    return Math.ceil(diff / 60) + '分钟前'
+  } else if (diff < 3600 * 24) {
+    return Math.ceil(diff / 3600) + '小时前'
+  } else if (diff < 3600 * 24 * 2) {
+    return '1天前'
+  }
+  if (option) {
+    return parseTime(time, option)
+  } else {
+    return (
+      d.getMonth() +
+      1 +
+      '月' +
+      d.getDate() +
+      '日' +
+      d.getHours() +
+      '时' +
+      d.getMinutes() +
+      '分'
+    )
+  }
+}
+
+/**
+ * @param {string} url
+ * @returns {Object}
+ */
+export function param2Obj(url) {
+  const search = url.split('?')[1]
+  if (!search) {
+    return {}
+  }
+  return JSON.parse(
+    '{"' +
+    decodeURIComponent(search)
+      .replace(/"/g, '\\"')
+      .replace(/&/g, '","')
+      .replace(/=/g, '":"')
+      .replace(/\+/g, ' ') +
+    '"}'
+  )
+}
+
+/**
+ * Check if an element has a class
+ * @param {HTMLElement} elm
+ * @param {string} cls
+ * @returns {boolean}
+ */
+export function hasClass(ele, cls) {
+  return !!ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'))
+}
+
+/**
+ * Add class to element
+ * @param {HTMLElement} elm
+ * @param {string} cls
+ */
+export function addClass(ele, cls) {
+  if (!hasClass(ele, cls)) ele.className += ' ' + cls
+}
+
+/**
+ * Remove class from element
+ * @param {HTMLElement} elm
+ * @param {string} cls
+ */
+export function removeClass(ele, cls) {
+  if (hasClass(ele, cls)) {
+    const reg = new RegExp('(\\s|^)' + cls + '(\\s|$)')
+    ele.className = ele.className.replace(reg, ' ')
+  }
+}
+
+/**
+ * 深度合并对象
+ * @param FirstOBJ
+ * @param SecondOBJ
+ * @returns {*}
+ */
+export const deepObjectMerge = function(FirstOBJ, SecondOBJ) {
+  for (var key in SecondOBJ) {
+    FirstOBJ[key] = FirstOBJ[key] && FirstOBJ[key].toString() === '[object Object]' ? deepObjectMerge(FirstOBJ[key], SecondOBJ[key]) : FirstOBJ[key] = SecondOBJ[key]
+  }
+  return FirstOBJ
+}

+ 110 - 0
src/utils/request.js

@@ -0,0 +1,110 @@
+import axios from 'axios'
+//import store from '@/store'
+
+//"build": "node build/build.js"
+axios.defaults.timeout = 8640000000 // 响应时间
+axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'
+//axios.defaults.headers.post['Content-Type'] = 'application/json'
+
+//axios.defaults.baseURL = process.env.VUE_APP_BASE_API // 配置接口地址
+axios.defaults.baseURL = 'http://api.dms.66km.com.cn/' // 配置接口地址
+// POST传参序列化(添加请求拦截器)
+axios.interceptors.request.use((conf) => {
+ // console.log(conf)
+  // 在发送请求之前做某件事
+
+  // if (store.getters.token) {
+  //   conf.headers['token'] = getToken()
+  // }
+  return conf
+}, (error) => {
+  Message.error(error)
+  return Promise.reject(error)
+})
+
+// 返回状态判断(添加响应拦截器)
+axios.interceptors.response.use((res) => {
+ if (res.data.code === 0) {
+  // console.log(res)
+   return Promise.resolve(res.data)
+
+ } else {
+   alert(res.data.msg)
+ }
+  return Promise.reject(res.data)
+
+}, (error) => {
+  Message.error(error)
+  return Promise.reject(error)
+})
+
+export function fetchPost(url, params, options = {}) {
+  return new Promise((resolve, reject) => {
+    axios.post(url, params, options)
+      .then(response => {
+        resolve(response)
+      }, err => {
+        console.log(err)
+        reject(err)
+      })
+      .catch((error) => {
+        console.log(error)
+        reject(error)
+      })
+  })
+}
+export function fetchPut(url, params, options = {}) {
+  return new Promise((resolve, reject) => {
+    axios.put(url, params, options)
+      .then(response => {
+        resolve(response)
+      }, err => {
+        reject(err)
+      })
+      .catch((error) => {
+        reject(error)
+      })
+  })
+}
+
+export function fetchGet(url, param,response) {
+  return new Promise((resolve, reject) => {
+      axios.get(url, { params: param })
+        .then(response => {
+
+          resolve(response)
+        }, err => {
+          reject(err)
+        })
+        .catch((error) => {
+          reject(error)
+        })
+    })
+}
+export function fetchGetblob(url, param,response) {
+  if(response=='blob'){
+   // axios.defaults.responseType='blob'
+  }
+  return new Promise((resolve, reject) => {
+    console.log(response)
+    axios.get(url, { params: param, responseType: 'blob' }
+   // ,{responseType: 'arraybuffer',},
+    )
+      .then(response => {
+        resolve(response)
+      }, err => {
+        reject(err)
+      })
+      .catch((error) => {
+        reject(error)
+      })
+  })
+}
+
+
+
+
+export const baseURL = process.env.VUE_APP_BASE_API
+
+export default axios.create()
+//export default axios2.create()