POST 请求
- methods: {
- isclick() {
- if (this.account == ""|| this.pwd =="") {
- this.$message.warning("请输入账号或密码");
- } else if (this.account && this.pwd) {
- let data = { account: this.account, password: this.pwd };
- this.$axios
- .post("/user/login/", data)
- .then(res => {
- if (res.data.status == 200) {
- this.$message.success(res.data.message);
- this.sendKey.userccount = res.data.account;
- this.sendKey.usertoken = res.data.token;
- // 登录成功产生 token 放到 store
- this.$store.commit("$_setStorage", res.data.token);
- this.$store.commit("$_setAccount", res.data.account);
- this.$router.push({ path: "/home" });
- } else if (res.data.status == 404) {
- this.$message.error(res.data.message);
- } else if (res.data.status == 400) {
- this.$message.error(res.data.message);
- }
- })
- .catch(err => {
- this.$message.error(err.message);
- });
- }
- }
- }
GET 请求
- get_allcase() {
- // 所有的 case
- // let all_type = "1";
- let data = {
- casetype: "1",
- modular_type: "0",
- case_name_type: "0",
- pagenum: 1
- };
- this.$axios
- .post("/case/getcase/", data)
- .then(res => {
- if (res.data.status == 200) {
- this.total_num = res.data.pagecount;
- // console.log(res.data);
- this.tableData = res.data.case_list;
- // console.log("处理成功");
- }
- })
- .catch(err => {
- this.$message.error(err.message);
- });
- }
来源: http://www.bubuko.com/infodetail-3345455.html