Skip to content

Commit

Permalink
add loading fix preventBug
Browse files Browse the repository at this point in the history
  • Loading branch information
tuwq committed May 15, 2018
1 parent 8e0c6ce commit 9042d33
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 10 deletions.
66 changes: 66 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
"mongoose": "^5.0.16",
"redis": "^2.8.0",
"style-loader": "^0.21.0",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.2",
"vee-validate": "^2.0.8",
"vue": "^2.5.2",
"vue-lazyload": "^1.2.3",
Expand Down
27 changes: 27 additions & 0 deletions src/base/loading.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<template>
<div class="loading">
<img width="24" height="24" src="../../static/loading/loading.gif">
<p class="desc">{{title}}</p>
</div>
</template>
<script type="text/ecmascript-6">
export default {
props: {
title: {
type: String,
default: '正在载入...'
}
}
}
</script>
<style lang="less" rel="stylesheet/less" type="text/less">
.loading {
width: 100%;
text-align: center;
}
.desc {
line-height: 20px;
font-size: 12px;
color: rgba(255, 255, 255, 0.5);
}
</style>
10 changes: 8 additions & 2 deletions src/pages/Detail/components/answers-list.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<template>
<div class="answers-wrapper">
<loading v-show="loading"></loading>
<div class="card">
<div class="list">
<div class="list-header">
Expand All @@ -22,7 +23,7 @@
</template>

<script type="text/ecmascript-6">
import loading from 'base/loading.vue'
import answer from 'detail_components/answer.vue'
import {mapMutations,mapGetters} from 'vuex';
import axios from 'axios'
Expand All @@ -35,10 +36,15 @@ import axios from 'axios'
no_more_data: {
type: Boolean,
default: false
},
loading: {
type: Boolean,
default: true
}
},
components: {
answer
answer,
loading
},
computed: {
...mapGetters([
Expand Down
6 changes: 5 additions & 1 deletion src/pages/Detail/components/detail-main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="main-left">
<div>
<answers-add></answers-add>
<answers-list :sum="sum" :no_more_data="no_more_data"></answers-list>
<answers-list :sum="sum" :no_more_data="no_more_data" :loading="loading"></answers-list>
</div>
</div>
<div class="main-right"></div>
Expand All @@ -24,6 +24,10 @@
no_more_data: {
type: Boolean,
default: false
},
loading: {
type: Boolean,
default: true
}
},
components: {
Expand Down
6 changes: 4 additions & 2 deletions src/pages/Detail/detail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<scroll-header slot="scroll-header"></scroll-header>
</d-header>
<div class="main-content">
<detail-main :sum="sum" :no_more_data="no_more_data"></detail-main>
<detail-main :sum="sum" :no_more_data="no_more_data" :loading="loading"></detail-main>
</div>
<div class="special">
<view-conversation></view-conversation>
Expand Down Expand Up @@ -37,7 +37,8 @@
pend: false, // 加载工作中
no_more_data: false, // 没有更多数据了
answerList: [],
sum: 0
sum: 0,
loading: true
}
},
components: {
Expand Down Expand Up @@ -76,6 +77,7 @@
limit: this.limit,
page: this.page
}).then((res)=> {
this.loading = false
this.sum = res.data.result.sum
if(res.data.result.count) {
this.answerList = this.answers.concat(res.data.result.answers)
Expand Down
10 changes: 8 additions & 2 deletions src/pages/Home/components/questions.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<template>
<div class="questions" v-if="questionList">

<loading v-show="loading"></loading>

<question v-for="(item,index) in questionList" :key="item._id" :item="item" :index="index"
:questionList="questionList"></question>
Expand All @@ -10,6 +12,7 @@

<script type="text/ecmascript-6">
import question from 'z_components/question.vue'
import loading from 'base/loading.vue'
import axios from 'axios'
export default {
data() {
Expand All @@ -18,11 +21,13 @@
questionList: [],
pend: false, // 加载工作中
no_more_data: false, // 没有更多数据了
page: 1
page: 1,
loading: true
}
},
components: {
question
question,
loading
},
methods: {
getQuestionList() {
Expand All @@ -31,6 +36,7 @@
limit: this.limit,
page: this.page
}).then((res)=> {
this.loading = false
if(res.data.result.count) {
this.questionList = this.questionList.concat(res.data.result.questions)
this.page++
Expand Down
5 changes: 2 additions & 3 deletions src/pages/People/components/edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@
<textarea class="textArea" ref="introduction" v-model="temp.info.introduction"></textarea>
<div class="ButtonGroup">
<button type="submit" class="button-blue submit save"
@click.stop="user.info.introduction=temp.info.introduction">保存</button>
@click.stop.prevent="user.info.introduction=temp.info.introduction">保存</button>
<button type="button" class="button-grey" style="margin-left: 16px;"
@click.stop="temp.info.introduction=user.info.introduction">取消</button>
@click.stop.prevent="temp.info.introduction=user.info.introduction">取消</button>
</div>
</div>
</div>
Expand Down Expand Up @@ -282,7 +282,6 @@ import axios from 'axios'
me.parent().parent().siblings().show();
me.parent().parent().siblings('div').children('.Field-text').show();
me.parent().parent().siblings('.Field-text').show();
})
})
$('.AddButton').each((index,el)=> {
Expand Down
Binary file added static/loading/loading.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9042d33

Please sign in to comment.