Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
waihoyu committed Aug 7, 2018
1 parent abb007c commit e485527
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/components/event-bus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Vue from 'vue';
export var eventBus = new Vue();
38 changes: 36 additions & 2 deletions src/components/food/food.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
<split v-show="food.info"></split>
<div class="rating">
<h1 class="title">商品评价</h1>
<ratingselect :select-type="selectType" :only-content="onlyContent" :desc="desc" :ratings="food.ratings"></ratingselect>
<ratingselect @select-type="onSelectType" :only-content="onlyContent" :desc="desc" :ratings="food.ratings"></ratingselect>
<div class="rating-wrapper">
<ul v-show="food.ratings && food.ratings.length">
<li class="rating-item border-1px" v-for="(rating,index) in food.ratings" :key="index">
<li v-show= "needShow(rating.rateType, rating.text)" class="rating-item border-1px" v-for="(rating,index) in food.ratings" :key="index">
<div class="user">
<span class="name">{{rating.username}}</span>
<img width="12" height="12" src="rating.avatar" alt="" class="avatar">
Expand All @@ -61,10 +61,12 @@
import split from '@/components/split/split'
import Vue from 'vue'
import ratingselect from '@/components/ratingselect/ratingselect'
import { eventBus } from 'components/event-bus';
// const POSITIVE = 0
// const NEGATIVE = 1
const ALL = 2
export default {
data () {
return {
showFlag: false,
Expand All @@ -83,6 +85,9 @@
}
},
methods: {
onSelectType (type) {
this.selectType = type
},
show () {
this.selectType = ALL
this.onlyContent = true
Expand All @@ -105,6 +110,18 @@
}
this.$emit('cart-add', event.target);
Vue.set(this.food, 'count', 1)
},
needShow (type, text) {
if (this.onlyContent && !text) {
return false
}
if (this.selectType === ALL) {
return true
}
else
{
return type === this.selectType
}
}
},
components: {
Expand Down Expand Up @@ -243,5 +260,22 @@
border-radius 64px
.time
line-height 12px
margin-bottom 6px
line-height 12px
font-size 10px
color rgb(147, 153, 159)
.text
line-height 16px
font-size 12px
color rgb(7, 17, 27)
.icon-thumb_up,.icon-thumb_down
margin-right 4px
line-height 24px
font-size 12px
.icon-thumb_up
color rgb(0,60,220)
.icon-thumb_down
color rgb(147, 153, 159)
</style>
14 changes: 10 additions & 4 deletions src/components/ratingselect/ratingselect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,24 @@
</template>

<script type="text/ecmascript">
import { eventBus } from 'components/event-bus';
const POSITIVE = 0
const NEGATIVE = 1
const ALL = 2
export default {
data () {
return {
selectType: ALL
}
},
props: {
ratings: {
type: Array,
default () {
return []
}
},
selectType: {
selectType2: {
type: Number,
default: ALL
},
Expand Down Expand Up @@ -60,15 +66,15 @@
if (!event._constructed){
return
}
this.selectType = type
this.$dispatch('ratingtype.select', type)
this.selectType = type
this.$emit('select-type', type)
},
toggleContent (event) {
if (!event._constructed){
return
}
this.onlyContent = ! this.onlyContent
this.$dispatch('content.toggle', this.onlyContent)
// this.$emit('content.toggle', this.onlyContent)
}
}
}
Expand Down

0 comments on commit e485527

Please sign in to comment.