Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
wxh-order-h5
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李俊赕
wxh-order-h5
Commits
b99bf594
Commit
b99bf594
authored
May 26, 2020
by
ljd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
保存配置
parent
6de10459
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
159 additions
and
4 deletions
+159
-4
.editorconfig
web/.editorconfig
+1
-1
.eslintrc.js
web/.eslintrc.js
+4
-2
goods.vue
web/src/views/haier/components/goods.vue
+148
-0
vue.config.js
web/vue.config.js
+6
-1
No files found.
web/.editorconfig
View file @
b99bf594
[*.{js,jsx,ts,tsx,vue}]
[*.{js,jsx,ts,tsx,vue}]
indent_style = space
indent_style = space
indent_size =
2
indent_size =
4
trim_trailing_whitespace = true
trim_trailing_whitespace = true
insert_final_newline = true
insert_final_newline = true
web/.eslintrc.js
View file @
b99bf594
...
@@ -9,8 +9,10 @@ module.exports = {
...
@@ -9,8 +9,10 @@ module.exports = {
node
:
true
,
node
:
true
,
es6
:
true
es6
:
true
},
},
extends
:
[
'plugin:vue/recommended'
,
'eslint:recommended'
],
extends
:
[
"plugin:vue/essential"
,
"@vue/standard"
],
// add your custom rules here
// add your custom rules here
//it is base on https://github.com/vuejs/eslint-config-vue
//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
//vue/max-attributes-per-line强制每行的最大属性数https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/max-attributes-per-line.md
...
...
web/src/views/haier/components/goods.vue
0 → 100644
View file @
b99bf594
<
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
web/vue.config.js
View file @
b99bf594
...
@@ -4,9 +4,14 @@ function resolve(dir){
...
@@ -4,9 +4,14 @@ function resolve(dir){
}
}
module
.
exports
=
{
module
.
exports
=
{
devServer
:
{
devServer
:
{
overlay
:
{
warnings
:
true
,
errors
:
true
},
proxy
:
'http://localhost:8080'
proxy
:
'http://localhost:8080'
},
},
lintOnSave
:
true
,
lintOnSave
:
process
.
env
.
NODE_ENV
!==
'production'
,
chainWebpack
:(
config
)
=>
{
chainWebpack
:(
config
)
=>
{
// 设置别名
// 设置别名
config
.
resolve
.
alias
config
.
resolve
.
alias
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment