| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <template>
- <div>
- <avue-form ref="form" v-model="form" :option="option" @submit="submit">
- <template slot-scope="scope" slot="menuForm">
- <el-button @click="test1">test1</el-button>
- <el-button @click="test2">test2</el-button>
- <el-button @click="test3">test3</el-button>
- </template>
- </avue-form>
- </div>
- </template>
- <script>
- import {testLogin, findAllUser, findByCn} from "../../api/user";
- import {testNotice} from "../../api/desk/notice";
- export default {
- name: "login-test",
- data() {
- return {
- form: {},
- option: {
- column: [
- {
- label: "账号",
- prop: "account",
- span:8
- },
- {
- label: "密码",
- prop: "password",
- type:'password',
- span:8
- },
- ]
- }
- }
- },
- methods: {
- submit(){
- testLogin(this.form).then(res => {
- console.log('testLogin')
- console.log(res)
- this.$Log.primary('testLogin' + res)
- this.$alert("驗證成功!")
- });
- },
- test1(){
- findAllUser(this.form).then(res => {
- console.log('findAllUser')
- console.log(res)
- this.$Log.primary('findAllUser' + res)
- });
- },
- test2(){
- let account = this.encryptByDES(this.form.account, "cyzh2020");
- console.log(account)
- findByCn(account).then(res => {
- console.log('findByCn')
- console.log(res)
- this.$Log.primary('findByCn' + res)
- });
- },
- test3(){
- testNotice("123").then(res => {
- console.log('testNotice');
- console.log(res)
- });
- },
- encryptByDES(message, key){
- var keyHex = CryptoJS.enc.Utf8.parse(key);
- var encrypted = CryptoJS.DES.encrypt(message, keyHex, {
- mode: CryptoJS.mode.ECB,
- padding: CryptoJS.pad.Pkcs7
- });
- return encrypted.ciphertext.toString();
- },
- decryptByDES(ciphertext, key){
- var keyHex = CryptoJS.enc.Utf8.parse(key);
- var decrypted = CryptoJS.DES.decrypt({
- ciphertext: CryptoJS.enc.Hex.parse(ciphertext)
- }, keyHex, {
- mode: CryptoJS.mode.ECB,
- padding: CryptoJS.pad.Pkcs7
- });
- var result_value = decrypted.toString(CryptoJS.enc.Utf8);
- return result_value;
- }
- },
- }
- </script>
- <style scoped>
- </style>
|