Bladeren bron

修改清除页面

tangning 3 jaren geleden
bovenliggende
commit
10468acdcc
6 gewijzigde bestanden met toevoegingen van 115 en 2 verwijderingen
  1. 9 0
      build/webpack.dev.conf.js
  2. 1 1
      config/index.js
  3. 91 0
      src/pages/clean/index.vue
  4. 6 0
      src/pages/layout/aside.vue
  5. 6 0
      src/router/index.js
  6. 2 1
      src/utils/http.js

+ 9 - 0
build/webpack.dev.conf.js

@@ -42,6 +42,15 @@ const devWebpackConfig = merge(baseWebpackConfig, {
     quiet: true, // necessary for FriendlyErrorsPlugin
     watchOptions: {
       poll: config.dev.poll,
+    },
+    proxy: {
+      '/api': {
+        target: 'https://admin.zhifangbao.com',
+        changeOrigin: true,
+        pathRewrite: {     // 如果接口本身没有/api需要通过pathRewrite来重写了地址,这里把/api转成‘ ’
+          "^/api": ""
+        }
+      },
     }
   },
   plugins: [

+ 1 - 1
config/index.js

@@ -23,7 +23,7 @@ module.exports = {
     // Use Eslint Loader?
     // If true, your code will be linted during bundling and
     // linting errors and warnings will be shown in the console.
-    useEslint: true,
+    useEslint: false,
     // If true, eslint errors and warnings will also be shown in the error overlay
     // in the browser.
     showEslintErrorsInOverlay: false,

+ 91 - 0
src/pages/clean/index.vue

@@ -0,0 +1,91 @@
+<!--  -->
+<template>
+  <div class='con' v-loading.fullscreen.lock="loading">
+    <div class="h-header">
+      <vcenter>
+        <div class="h-input"><span>手机号:</span></div>
+        <div>
+          <el-input v-model="userName" placeholder="输入手机号清除"></el-input>
+        </div>
+        <div>
+          <el-button :disabled="disabled" @click="search" type="primary">清除状态</el-button>
+        </div>
+      </vcenter>
+    </div>
+  </div>
+</template>
+
+<script>
+// 这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
+// 例如:import 《组件名称》 from '《组件路径》';
+import vcenter from '@/components/vcenter'
+import { async } from 'q';
+
+export default {
+  // import引入的组件需要注入到对象中才能使用
+  components: {
+    vcenter
+  },
+  data() {
+    // 这里存放数据
+    return {
+      userName: '',
+      disabled: true,
+      loading:false,
+    }
+  },
+  watch: {
+    userName(value) {
+      const reg_tel = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;
+      if (!value) {
+        return this.disabled = true
+      }
+      if (!reg_tel.test(value)) {
+        return this.disabled = true
+      } else {
+        return this.disabled = false
+      }
+    }
+  },
+  // 方法集合
+  methods: {
+    async search() {
+      this.loading = true
+      const res = await this.$http({
+        method: 'post',
+        data: {
+          userName:this.userName,
+        },
+        url: '/loginOutByUser?userName='+this.userName,
+        headers: {
+          token: window.localStorage.getItem('zfb_token')
+        }
+      })
+      this.loading = false
+      if(res.code !== 200){
+          // this.$message.error(res.message || res.error || '操作失败');
+      }else{
+          this.$message({message:'清除成功',type: 'success'});
+      }
+    }
+  },
+  // 生命周期 - 创建完成(可以访问当前this实例)
+  created() {
+
+  },
+  // 生命周期 - 挂载完成(可以访问DOM元素)
+  mounted() {
+  },
+  beforeCreate(){}, // 生命周期 - 创建之前
+  beforeMount(){}, // 生命周期 - 挂载之前
+  beforeUpdate(){}, // 生命周期 - 更新之前
+  updated(){}, // 生命周期 - 更新之后
+  beforeDestroy(){}, // 生命周期 - 销毁之前
+  destroyed(){}, // 生命周期 - 销毁完成
+  activated(){} // 如果页面有keep-alive缓存功能,这个函数会触发
+}
+</script>
+
+<style lang="scss" scoped>
+@import '@/assets/style/info.scss'
+</style>

+ 6 - 0
src/pages/layout/aside.vue

@@ -84,6 +84,12 @@ const aside = [{
   icon: 'icon-xinxifabu',
   url: '/download',
   isShow: false
+}, {
+  name: '清除登陆状态',
+  id: '5',
+  icon: 'icon-delete-solid',
+  url: '/clean',
+  isShow: false
 }]
 export default {
 

+ 6 - 0
src/router/index.js

@@ -55,6 +55,12 @@ const router = new Router({
           name: '场景下载',
           component: () => import('@/pages/download'),
           meta: {index: '4'}
+        },
+        {
+          path: '/clean',
+          name: '清除登陆状态',
+          component: () => import('@/pages/clean'),
+          meta: {index: '4'}
         }
       ]
     },

+ 2 - 1
src/utils/http.js

@@ -5,7 +5,8 @@ import router from '../router'
 var isProduction = process.env.NODE_ENV === 'production'
 // const serverName = isProduction ? '' : 'http://192.168.0.207:7081/'
 
-const serverName = isProduction ? '' : 'https://admin.zhifangbao.com/'
+// const serverName = isProduction ? '' : 'https://admin.zhifangbao.com/'
+const serverName = isProduction ? '' : '/api'
 
 const vue = new Vue()