Skip to content

Commit

Permalink
更新vuex跟axios
Browse files Browse the repository at this point in the history
  • Loading branch information
jamielhf committed Nov 22, 2016
1 parent 6070933 commit c29ce0c
Show file tree
Hide file tree
Showing 33 changed files with 676 additions and 1,190 deletions.
5 changes: 5 additions & 0 deletions pet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ vue学习项目 宠物领养
<code>
npm i && npm run dev
</code>

>1.0.3
>修改了vue-resource,使用axios
>修改vuex,写法更规范点
786 changes: 28 additions & 758 deletions pet/dist/build.js

Large diffs are not rendered by default.

48 changes: 0 additions & 48 deletions pet/json.json

This file was deleted.

86 changes: 0 additions & 86 deletions pet/json1.json

This file was deleted.

71 changes: 0 additions & 71 deletions pet/json2.json

This file was deleted.

2 changes: 1 addition & 1 deletion pet/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "demo2",
"version": "1.0.2",
"version": "1.0.3",
"description": "宠物领养社区",
"main": "index.js",
"scripts": {
Expand Down
64 changes: 64 additions & 0 deletions pet/src/api/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* Created by linhaifeng on 2016/11/16.
*/
import axios from 'axios';

export default {

/*
* 获取首页列表信息
* */
indexGetList:function (cb) {

axios.get('/index/getList').then(function (res) {
if(res.data.data.code ==1000){

cb(res.data.data.data);
}

});

},
/*
* 获取首页图片
* */
indexGetImg:function (cb) {
axios.get('/index/getImgList').then(function (res) {
if(res.data.data.code ==1000){
cb(res.data.data.data);
}

});
},
/*
* 获取文章详情
* @param id 文章id
* */
articleGetContent:function (id,cb) {
axios.get('/article/getData',{
"articleId":id
}).then(function (res) {
if(res.data.data.code ==1000){
cb(res.data.data.data[0]);
}
})
},
/*
* 提交评论
* @param id 文章id
* */
articleSubmit:function (val,uid,rname,aid,commentId,cb) {
axios.get('/article/submit',{val:val,uid:uid,rid:rname,aid:aid,commentId:commentId}).then(function (res) {
console.log(val);
if(res.data.data.code ==1000){
cb(res.data.data.data[0]);
}})

}




};


18 changes: 10 additions & 8 deletions pet/src/app.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@

<template>
<div class="com-app">
<com-header ></com-header>

<com-header :commData = "commConf" ></com-header>
<transition :name="transitionName" >

<router-view class="child-view"></router-view>

</transition>
<com-footer v-show="isFooter"></com-footer>

<com-footer v-show="commConf.isFooter"></com-footer>

</div>
</template>
Expand Down Expand Up @@ -41,6 +39,9 @@ require('./css/style.scss');
if(this.$route.name==undefined){
this.$router.push('index');
}
this.$store.commit('COMM_CONF',{isFooter:true});
},
watch: {
'$route' (to, from) {
Expand All @@ -50,9 +51,10 @@ require('./css/style.scss');
}
},
computed:{
isFooter:function () {
return this.$store.state.comm.indexConf.isFooter;
}
commConf:function () {
return this.$store.getters.commConf
},
},
components:{
comHeader:Header,
Expand Down
Loading

0 comments on commit c29ce0c

Please sign in to comment.