Commit b99bf594 authored by ljd's avatar ljd

保存配置

parent 6de10459
[*.{js,jsx,ts,tsx,vue}]
indent_style = space
indent_size = 2
indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true
......@@ -9,8 +9,10 @@ module.exports = {
node: true,
es6: true
},
extends: ['plugin:vue/recommended', 'eslint:recommended'],
extends: [
"plugin:vue/essential",
"@vue/standard"
],
// add your custom rules here
//it is base on https://github.com/vuejs/eslint-config-vue
//vue/max-attributes-per-line强制每行的最大属性数https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/max-attributes-per-line.md
......
<template>
<div class="goods">
<div class="menu-wrapper" ref = "menuWrapper">
<ul>
<li v-for = "(item, index) in goods" class = "menu-item" :class="{'current':currentIndex === index}" :key= "index" @click="selectMenu(index, $event)" >
<span class="text border-1px">
<span v-show="item.type >0" class="icon" :class="classMap[item.type]"></span>{{item.name}}
</span>
</li>
</ul>
</div>
<div class="foods-wrapper" ref = "foodsWrapper">
<ul>
<li v-for="(item, index) in goods" class="food-list food-list-hook" :key="index">
<h1 class="title">{{item.name}}</h1>
<ul>
<li @click = "selectFood(food, $event)" v-for="(food, index) in item.foods" class="food-item border-1px" :key="index">
<div class="icon">
<img width="57" height="57" :src="food.icon" alt="">
</div>
<div class="content">
<h2 class="name">{{food.name}}</h2>
<p class="desc">{{food.description}}</p>
<div class="extra">
<span class="count">月售{{food.sellCount}}份</span><span>好评率{{food.rating}}%</span>
</div>
<div class="price">
<span class="now">¥{{food.price}}</span>
<span v-show="food.oldPrice" class="old">¥{{food.oldPrice}}</span>
</div>
<div class="cartcontrol-wrapper">
<cartcontrol :food="food" v-on:cart-add="_cartAdd"/>
</div>
</div>
</li>
</ul>
</li>
</ul>
</div>
</div>
</template>
<script>
export default {
props: {
seller:{
type:Object
}
},
data(){
return {
goods: [],
listHeight: [],
scrollY: 0,
selectedFood:{}
}
},
computed: {
currentIndex () {
for (let i = 0; i < this.listHeight.length; i++) {
let height1 = this.listHeight[i]
let height2 = this.listHeight[i + 1]
if (!height2 || (this.scrollY >= height1 && this.scrollY < height2)) {
return i
}
}
return 0
},
selectFoods () {
let foods = []
this.goods.forEach((good) => {
good.foods.forEach((food) => {
if (food.count) {
foods.push(food)
}
})
})
return foods
}
},
created(){
this.classMap = ['decrease', 'discount', 'special', 'invoice', 'guarantee'];
this.$http.get('api/goods').then(response => {
response = response.body
if (response.errno === ERR_OK) {
this.goods = response.data
this.$nextTick(() => {
this._initScroll ()
this._calculateHeight()
})
}
})
},
methods: {
selectFood (food, event) {
if (!event._constructed){
return
}
this.selectedFood = food
this.$refs.food.show()
},
selectMenu (index, event) {
if (!event._constructed){
return
}
let foodList = this.$refs.foodsWrapper.getElementsByClassName('food-list-hook')
let el = foodList[index]
this.foodsScroll.scrollToElement(el, 300)
},
_drop (target) {
this.nextTick(() => {
this.$refs.shopcart._drop(target)
})
},
_initScroll () {
this.menuScroll = new BScroll(this.$refs.menuWrapper,{
click: true
})
this.foodsScroll = new BScroll(this.$refs.foodsWrapper,{
probeType: 3,
click: true
})
this.foodsScroll.on('scroll', (pos) => {
this.scrollY = Math.abs(Math.round(pos.y))
})
},
_calculateHeight () {
let foodList = this.$refs.foodsWrapper.getElementsByClassName('food-list-hook')
var height = 0
this.listHeight.push(height)
for (let i = 0; i < foodList.length; i++) {
let item = foodList[i]
height += item.clientHeight
this.listHeight.push(height)
}
},
_cartAdd (event) {
this.$nextTick(() => {
 this.$refs['shopcart'].drop(event)
});
}
},
components:{
shopcart,
cartcontrol,
food
}
}
</script>
\ No newline at end of file
......@@ -4,9 +4,14 @@ function resolve(dir){
}
module.exports = {
devServer: {
overlay: {
warnings: true,
errors: true
},
proxy: 'http://localhost:8080'
},
lintOnSave: true,
lintOnSave: process.env.NODE_ENV !== 'production',
chainWebpack:(config)=>{
// 设置别名
config.resolve.alias
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment