index.vue 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <!-- -->
  2. <template>
  3. <div class='con' v-loading.fullscreen.lock="loading">
  4. <div class="h-header">
  5. <vcenter>
  6. <div class="h-input"><span>手机号:</span></div>
  7. <div>
  8. <el-input v-model="userName" placeholder="输入手机号清除"></el-input>
  9. </div>
  10. <div>
  11. <el-button :disabled="disabled" @click="search" type="primary">清除状态</el-button>
  12. </div>
  13. </vcenter>
  14. </div>
  15. </div>
  16. </template>
  17. <script>
  18. // 这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  19. // 例如:import 《组件名称》 from '《组件路径》';
  20. import vcenter from '@/components/vcenter'
  21. import { async } from 'q';
  22. export default {
  23. // import引入的组件需要注入到对象中才能使用
  24. components: {
  25. vcenter
  26. },
  27. data() {
  28. // 这里存放数据
  29. return {
  30. userName: '',
  31. disabled: true,
  32. loading:false,
  33. }
  34. },
  35. watch: {
  36. userName(value) {
  37. 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}$/;
  38. if (!value) {
  39. return this.disabled = true
  40. }
  41. if (!reg_tel.test(value)) {
  42. return this.disabled = true
  43. } else {
  44. return this.disabled = false
  45. }
  46. }
  47. },
  48. // 方法集合
  49. methods: {
  50. async search() {
  51. this.loading = true
  52. const res = await this.$http({
  53. method: 'post',
  54. data: {
  55. userName:this.userName,
  56. },
  57. url: '/loginOutByUser?userName='+this.userName,
  58. headers: {
  59. token: window.localStorage.getItem('zfb_token')
  60. }
  61. })
  62. this.loading = false
  63. if(res.code !== 200){
  64. // this.$message.error(res.message || res.error || '操作失败');
  65. }else{
  66. this.$message({message:'清除成功',type: 'success'});
  67. }
  68. }
  69. },
  70. // 生命周期 - 创建完成(可以访问当前this实例)
  71. created() {
  72. },
  73. // 生命周期 - 挂载完成(可以访问DOM元素)
  74. mounted() {
  75. },
  76. beforeCreate(){}, // 生命周期 - 创建之前
  77. beforeMount(){}, // 生命周期 - 挂载之前
  78. beforeUpdate(){}, // 生命周期 - 更新之前
  79. updated(){}, // 生命周期 - 更新之后
  80. beforeDestroy(){}, // 生命周期 - 销毁之前
  81. destroyed(){}, // 生命周期 - 销毁完成
  82. activated(){} // 如果页面有keep-alive缓存功能,这个函数会触发
  83. }
  84. </script>
  85. <style lang="scss" scoped>
  86. @import '@/assets/style/info.scss'
  87. </style>