login-test.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <div>
  3. <avue-form ref="form" v-model="form" :option="option" @submit="submit">
  4. <template slot-scope="scope" slot="menuForm">
  5. <el-button @click="test1">test1</el-button>
  6. <el-button @click="test2">test2</el-button>
  7. <el-button @click="test3">test3</el-button>
  8. </template>
  9. </avue-form>
  10. </div>
  11. </template>
  12. <script>
  13. import {testLogin, findAllUser, findByCn} from "../../api/user";
  14. import {testNotice} from "../../api/desk/notice";
  15. export default {
  16. name: "login-test",
  17. data() {
  18. return {
  19. form: {},
  20. option: {
  21. column: [
  22. {
  23. label: "账号",
  24. prop: "account",
  25. span:8
  26. },
  27. {
  28. label: "密码",
  29. prop: "password",
  30. type:'password',
  31. span:8
  32. },
  33. ]
  34. }
  35. }
  36. },
  37. methods: {
  38. submit(){
  39. testLogin(this.form).then(res => {
  40. console.log('testLogin')
  41. console.log(res)
  42. this.$Log.primary('testLogin' + res)
  43. this.$alert("驗證成功!")
  44. });
  45. },
  46. test1(){
  47. findAllUser(this.form).then(res => {
  48. console.log('findAllUser')
  49. console.log(res)
  50. this.$Log.primary('findAllUser' + res)
  51. });
  52. },
  53. test2(){
  54. let account = this.encryptByDES(this.form.account, "cyzh2020");
  55. console.log(account)
  56. findByCn(account).then(res => {
  57. console.log('findByCn')
  58. console.log(res)
  59. this.$Log.primary('findByCn' + res)
  60. });
  61. },
  62. test3(){
  63. testNotice("123").then(res => {
  64. console.log('testNotice');
  65. console.log(res)
  66. });
  67. },
  68. encryptByDES(message, key){
  69. var keyHex = CryptoJS.enc.Utf8.parse(key);
  70. var encrypted = CryptoJS.DES.encrypt(message, keyHex, {
  71. mode: CryptoJS.mode.ECB,
  72. padding: CryptoJS.pad.Pkcs7
  73. });
  74. return encrypted.ciphertext.toString();
  75. },
  76. decryptByDES(ciphertext, key){
  77. var keyHex = CryptoJS.enc.Utf8.parse(key);
  78. var decrypted = CryptoJS.DES.decrypt({
  79. ciphertext: CryptoJS.enc.Hex.parse(ciphertext)
  80. }, keyHex, {
  81. mode: CryptoJS.mode.ECB,
  82. padding: CryptoJS.pad.Pkcs7
  83. });
  84. var result_value = decrypted.toString(CryptoJS.enc.Utf8);
  85. return result_value;
  86. }
  87. },
  88. }
  89. </script>
  90. <style scoped>
  91. </style>