Skip to content

Commit

Permalink
Merge pull request #4 from xiaoshiguang123/dev
Browse files Browse the repository at this point in the history
⚡ 封装axios 修改部分重复代码
  • Loading branch information
12ain authored Nov 5, 2019
2 parents 894e32b + 72bb3fe commit 1085e51
Show file tree
Hide file tree
Showing 36 changed files with 477 additions and 427 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@

1. 添加路由守卫,不登录无法随意跳转页面

### 2019.11.4

1. 开始优化项目结构,修改部分冗余代码.
2. 封装axios
3. 预计升级项目所需依赖.(暂时搁置)

### 完成所有功能

## 目前出现的BUG及解决方法
Expand Down
52 changes: 52 additions & 0 deletions src/api/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
export default {
api:{
user:{
login: "/user/login",
register: "/user/register",
update: "/user/update"
},
test:{
updateTest: "/test/updateTest",
deleteTest:"/test/deleteTest",
insertTest:"/test/insertTest",
checkcollege: "/test/checkcollege",
insertTest :"/test/insertTest"

},
testtell:{
updateTell: "/testtell/updateTell",
checkTell: "/testtell/checkTell",
deleteTell:"/testtell/deleteTell",
insertTell:"/testtell/insertTell",
updateTell:"/testtell/updateTell"

},
lf:{
testAllLost:"/lf/testAllLost",
testAllFound:"/lf/testAllFound",
testDeleteTo:"/lf/testDeleteTo",
testAllThing:"/lf/testAllThing",
testDeleteTo:"/lf/testDeleteTo",
testInsertTo :"/lf/testInsertTo",
testUpdateTo :"/lf/testUpdateTo"
},
record:{
wwmessmy:"/record/wwmessmy",
wymessmy:"/record/wymessmy",
deleteTo:"/record/deleteTo",
delByW:"/record/delByW",
rmess:"/record/rmess",
rmessmy:"/record/rmessmy",
insertTo: "/record/insertTo",
updateTo: "/record/updateTo"
},
trade:{
rmess:"/trade/rmess",
deleteTo:"/trade/deleteTo",
rmessmy:"/trade/rmessmy",
deleteTo:"/trade/deleteTo",
insertTo :"/trade/insertTo",
updateTo:"trade/updateTo"
}
}
}
2 changes: 0 additions & 2 deletions src/components/admin/admin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
</template>

<script>
import Vue from "vue";
import store from "../../store/store";
import { mapState, mapMutations } from "vuex";
export default {
components: {
Expand Down
18 changes: 7 additions & 11 deletions src/components/admin/changeEntrance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
</template>

<script>
import { Toast } from 'mint-ui';
import store from "../../store/store";
import axios from 'axios';
import qs from 'Qs';
import { mapState, mapMutations } from "vuex";
import mUpLoader from "../common/UpLoader"
export default {
Expand Down Expand Up @@ -59,22 +55,22 @@ export default {
this.userentrance.tcollege = this.entranceList.tcollege
},
submitEntrance(){
axios.post("/test/updateTest",
qs.stringify({
this.http.post(this.ports.api.test.updateTest,
{
tid: this.userentrance.tid,
tname: this.userentrance.tname,
turl: this.userentrance.turl,
tcollege: this.userentrance.tcollege,
}))
.then(res => {
}
,res => {
// console.log(res);
if (res.data.status == '0') {
Toast(res.data.msg);
this.$toast(res.data.msg);
this.$router.back(-1)
} else {
Toast(res.data.msg);
this.$toast(res.data.msg);
}
})
})
}
},
components: {
Expand Down
6 changes: 1 addition & 5 deletions src/components/admin/changeInformation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@
</template>

<script>
import { Toast } from 'mint-ui';
import store from "../../store/store";
import axios from 'axios';
import qs from 'Qs';
import { mapState, mapMutations } from "vuex";
import mUpLoader from "../common/UpLoader"
export default {
Expand All @@ -33,7 +29,7 @@ export default {
return {
testList: [],
usertest: {},
usersrc: 'http://47.94.10.228/testtell/updateTell',
usersrc: this.http.BASE_URL + this.ports.api.testtell.updateTell,
isAdmin:false,
isRepair:false,
};
Expand Down
48 changes: 20 additions & 28 deletions src/components/admin/manageEntrance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,7 @@
</template>

<script>
import Vue from 'vue'
import { CellSwipe,Toast } from 'mint-ui';
Vue.component(CellSwipe.name, CellSwipe, Toast);
import store from "../../store/store";
import { mapState, mapMutations } from "vuex";
import axios from 'axios';
import qs from 'Qs';
import mUpLoader from "../common/UpLoader";
export default {
components: {
Expand All @@ -48,7 +42,7 @@ export default {
},
data() {
return {
src:'http://47.94.10.228/test/insertTest',
src:this.http.BASE_URL + this.ports.api.test.insertTest,
popupVisible:false, // 显示添加组件
testList:[], // 所有考试信息列表
tid:'',
Expand Down Expand Up @@ -82,7 +76,7 @@ created() {
if(action == 'confirm'){
this.$router.push({ name:'changeEntrance', params: { EntranceList: this.Entranceitem }})
}else{
console.log('取消')
// console.log('取消')
}
})
},
Expand All @@ -100,7 +94,7 @@ created() {
// console.log(this.id)
this.delList(this.tid)
}else{
console.log('取消')
// console.log('取消')
}
})
},
Expand All @@ -118,51 +112,49 @@ created() {
this.updateentrance(this.entranceItem)
},
getList(){
axios
.post("/test/checktest")
axios.post("/test/checktest")
.then(res => {
// console.log(res);
if (res.data.status == '0') {
this.testList = res.data.list
// Toast(res.data.msg);
// this.$toast(res.data.msg);
} else {
Toast(res.data.msg);
this.$toast(res.data.msg);
}
})
},
delList(){
axios
.post("/test/deleteTest",
qs.stringify({
this.http
.post(this.ports.api.test.deleteTest,
{
tid: this.tid,
}))
.then(res => {
},res => {
// console.log(res);
if (res.data.status == '0') {
Toast(res.data.msg);
this.$toast(res.data.msg);
this.getList();
} else {
Toast(res.data.msg);
this.$toast(res.data.msg);
}
})
})
},
submitNew(){
axios
.post("/test/insertTest",
qs.stringify({
this.http
.post(this.ports.api.test.insertTest,
{
tname: this.newtestList.tname,
turl: this.newtestList.turl,
tcollege: this.newtestList.tcollege,
}))
.then(res => {
},
res => {
// console.log(res);
if (res.data.status == '0') {
Toast(res.data.msg);
this.$toast(res.data.msg);
this.getList();
this.popupVisible=false;
} else {
Toast(res.data.msg);
this.$toast(res.data.msg);
}
})
},
Expand Down
43 changes: 18 additions & 25 deletions src/components/admin/manageInformation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,7 @@
</template>

<script>
import Vue from 'vue'
import { CellSwipe,Toast } from 'mint-ui';
Vue.component(CellSwipe.name, CellSwipe, Toast);
import store from "../../store/store";
import { mapState, mapMutations } from "vuex";
import axios from 'axios';
import qs from 'Qs';
import mUpLoader from "../common/UpLoader";
export default {
components: {
Expand All @@ -50,7 +44,7 @@ export default {
},
data() {
return {
src:'http://47.94.10.228/testtell/insertTell',
src:this.http.BASE_URL + this.ports.api.testtell.insertTell,
popupVisible:false, // 显示添加组件
testList:[], // 所有考试信息列表
testItem:[],
Expand Down Expand Up @@ -85,7 +79,7 @@ created() {
if(action == 'confirm'){
this.$router.push({ name:'changeInformation', params: { informationList: this.informationitem }})
}else{
console.log('取消')
// console.log('取消')
}
})
},
Expand All @@ -103,7 +97,7 @@ created() {
// console.log(this.id)
this.delList(this.testid)
}else{
console.log('取消')
// console.log('取消')
}
})
},
Expand All @@ -122,37 +116,36 @@ created() {
this.updateinformation(this.informationItem)
},
getList(){
axios
.post("/testtell/checkTell",
qs.stringify({
udept:window.localStorage.getItem('udept')}
))
.then(res => {
this.http
.post(this.ports.api.testtell.checkTell,
{
udept:window.localStorage.getItem('udept')
},
res => {
// console.log(res);
if (res.data.status == '0') {
this.testList = res.data.list
// Toast(res.data.msg);
// this.$toast(res.data.msg);
} else {
Toast(res.data.msg);
this.$toast(res.data.msg);
}
})
},
delList(){
axios
.post("/testtell/deleteTell",
qs.stringify({
this.http.post(this.ports.api.testtell.deleteTell,
{
testid: this.testid,
}))
.then(res => {
}
,res => {
// console.log(res);
if (res.data.status == '0') {
Toast(res.data.msg);
this.$toast(res.data.msg);
this.getList();
} else {
Toast(res.data.msg);
this.$toast(res.data.msg);
}
})
})
},
}
}
Expand Down
Loading

0 comments on commit 1085e51

Please sign in to comment.