Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
ming-order
Overview
Overview
Details
Activity
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
fengzhaoyu
ming-order
Commits
7acdc51f
Commit
7acdc51f
authored
Oct 28, 2019
by
fengzhaoyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MOD:修改为带三方 加载完一遍后从本地加载
parent
a6022fbb
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
324 additions
and
80 deletions
+324
-80
workspace.xml
.idea/workspace.xml
+31
-2
menu.html
menu.html
+293
-78
No files found.
.idea/workspace.xml
View file @
7acdc51f
...
...
@@ -2,7 +2,6 @@
<project
version=
"4"
>
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"3f11f0c2-4f1a-448b-9322-b444722d73f2"
name=
"Default Changelist"
comment=
""
>
<change
afterPath=
"$PROJECT_DIR$/img/null.png"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/workspace.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/menu.html"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/menu.html"
afterDir=
"false"
/>
</list>
...
...
@@ -28,7 +27,7 @@
<property
name=
"DefaultHtmlFileTemplate"
value=
"HTML File"
/>
<property
name=
"SHARE_PROJECT_CONFIGURATION_FILES"
value=
"true"
/>
<property
name=
"WebServerToolWindowFactoryState"
value=
"false"
/>
<property
name=
"last_opened_file_path"
value=
"$PROJECT_DIR$/
img
"
/>
<property
name=
"last_opened_file_path"
value=
"$PROJECT_DIR$/
../ming-pig-ui
"
/>
<property
name=
"node.js.detected.package.eslint"
value=
"true"
/>
<property
name=
"node.js.detected.package.tslint"
value=
"true"
/>
<property
name=
"node.js.path.for.package.eslint"
value=
"project"
/>
...
...
@@ -84,6 +83,14 @@
<workItem
from=
"1571285097218"
duration=
"20273000"
/>
<workItem
from=
"1571371461255"
duration=
"4370000"
/>
<workItem
from=
"1571383513641"
duration=
"738000"
/>
<workItem
from=
"1571388882584"
duration=
"7770000"
/>
<workItem
from=
"1571573594477"
duration=
"3422000"
/>
<workItem
from=
"1571577062150"
duration=
"8888000"
/>
<workItem
from=
"1571620196296"
duration=
"3819000"
/>
<workItem
from=
"1571653093792"
duration=
"618000"
/>
<workItem
from=
"1571706768993"
duration=
"606000"
/>
<workItem
from=
"1571822161624"
duration=
"908000"
/>
<workItem
from=
"1572225197346"
duration=
"945000"
/>
</task>
<servers
/>
</component>
...
...
@@ -103,4 +110,25 @@
</map>
</option>
</component>
<component
name=
"XDebuggerManager"
>
<breakpoint-manager>
<breakpoints>
<line-breakpoint
enabled=
"true"
type=
"javascript"
>
<url>
file://$PROJECT_DIR$/menu.html
</url>
<line>
134
</line>
<option
name=
"timeStamp"
value=
"1"
/>
</line-breakpoint>
<line-breakpoint
enabled=
"true"
type=
"javascript"
>
<url>
file://$PROJECT_DIR$/menu.html
</url>
<line>
297
</line>
<option
name=
"timeStamp"
value=
"2"
/>
</line-breakpoint>
<line-breakpoint
enabled=
"true"
type=
"javascript"
>
<url>
file://$PROJECT_DIR$/menu.html
</url>
<line>
304
</line>
<option
name=
"timeStamp"
value=
"3"
/>
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
</project>
\ No newline at end of file
menu.html
View file @
7acdc51f
...
...
@@ -19,7 +19,7 @@
<li
v-cloak
v-for=
" (category, index) in categorys"
:key=
"category.productCategoryId"
@
click=
"selectClass(category,index)"
:style =
'
selectIndex == index
? selectStyle: "" '
>
:style =
'
defaultSelected == category.productCategoryId
? selectStyle: "" '
>
{{category.productCategoryName}}
</li>
</ul>
...
...
@@ -27,12 +27,12 @@
<!-- 点菜-->
<div
class=
"menu"
>
<ul
v-if=
"isProduct"
>
<li
v-for=
"(
menu,index) in defaultProduct"
:key=
"menu.productId"
@
click=
"addCar(menu
,index)"
v-cloak
>
<li
v-for=
"(
product,index) in products"
:key=
"product.productId"
@
click=
"addCar(product
,index)"
v-cloak
>
<div
class=
"imgContainer"
>
<img
:src=
'url'
alt=
""
ref=
"img"
>
</div>
<div
class=
"name"
>
{{
menu
.productName}}
</div>
<div
class=
"price"
>
¥{{
menu
.productPrice}}
</div>
<div
class=
"name"
>
{{
product
.productName}}
</div>
<div
class=
"price"
>
¥{{
product
.productPrice}}
</div>
</li>
</ul>
<ul
v-else
class=
"noProduct"
>
...
...
@@ -79,9 +79,10 @@
</body>
<script>
// 获取orgId
var
orgId
=
window
.
android
.
getOrgId
()
localStorage
.
setItem
(
'orgId'
,
orgId
)
// localStorage.setItem('orgId','ding9ddd48137390507735c2f4657eb6378f')
// var orgId = window.android.getOrgId()
// localStorage.setItem('orgId',orgId)
localStorage
.
setItem
(
'orgId'
,
'ding9ddd48137390507735c2f4657eb6378f'
)
// localStorage.setItem('orgId','ding9d')
// axios.defaults.baseURL = 'http://192.168.1.101:9999/mingpay-phone' // 本地钱
axios
.
defaults
.
baseURL
=
'https://gateway.mingwork.com/mingpay-phone'
// beta环境
...
...
@@ -106,109 +107,126 @@
}
Vue
.
prototype
.
$http
=
$http
var
order
=
new
Vue
({
el
:
'#gen'
,
data
:
{
url
:
'img/null.png'
,
urls
:
[],
categorys
:
[],
// 菜单分类
defaultProduct
:
[],
// 默认展示的菜
selectIndex
:
'0'
,
// 左侧选中类别的index,用来做选项卡判断
categorys
:
[],
// 所有的分类
products
:
[],
//所有的产品
url
:
'img/null.png'
,
isCategorys
:
true
,
// 是否有菜品分类 默认有
defaultSelected
:
''
,
// 选中左侧分类的id
selectStyle
:
{
'font-family'
:
'PingFangSC-Medium'
,
'border-right'
:
'5px solid red'
,
'background-color'
:
' #FFDEDE'
,
'color'
:
' #E60012'
},
//左侧菜单分类列表选中时的样式
carList
:
[],
// 所有加入购物车的列表数据
allNum
:
0
,
// 购物车里商品总数
allPrice
:
0
,
// 购物车里商品总价格
isDisplay
:
true
,
// 菜品分类是否展示隐藏 默认展示
isUp
:
true
,
//菜品是否上架 菜品上架
isCategorys
:
true
,
// 有没有分类
isProduct
:
true
// 有无菜品
isProduct
:
true
,
carList
:
[],
// 加入购物车的数据
allNum
:
0
,
// 所有的数量
allPrice
:
0
// 所有的价格
},
created
()
{
let
data
=
{
let
orgId
=
{
orgId
:
localStorage
.
getItem
(
'orgId'
)
}
this
.
$http
.
request
(
'/v1/product/list_product_category'
,
'POST'
,
data
).
then
(
res
=>
{
// 左侧分类是否展示
res
.
data
.
data
.
forEach
((
item
)
=>
{
if
(
item
.
isDisplay
==
"DISPLAY"
)
{
this
.
$http
.
request
(
'/v1/product/list_product_category'
,
'POST'
,
orgId
)
.
then
(
res
=>
{
if
(
res
.
data
.
resultCode
==
0
)
{
res
.
data
.
data
.
forEach
((
item
,
index
)
=>
{
if
(
item
.
isDisplay
==
'DISPLAY'
)
{
this
.
categorys
.
push
(
item
)
}
})
// 左侧有分类的情况下
if
(
this
.
categorys
.
length
!=
0
)
{
return
this
.
$http
.
request
(
'/v1/product/list_product'
,
'post'
,{
productCategoryId
:
this
.
categorys
[
0
].
productCategoryId
})
.
then
(
e
=>
{
if
(
e
.
data
.
data
.
length
!=
0
)
{
this
.
isProduct
=
true
e
.
data
.
data
.
forEach
((
product
)
=>
{
// 菜品是否展示
if
(
product
.
productStatus
==
'UP'
)
{
this
.
defaultProduct
.
push
(
product
)
if
(
this
.
categorys
.
length
==
0
)
{
this
.
isCategorys
=
false
}
else
{
this
.
defaultSelected
=
this
.
categorys
[
0
].
productCategoryId
let
productCategoryId
=
{
productCategoryId
:
this
.
categorys
[
0
].
productCategoryId
}
this
.
$http
.
request
(
'/v1/product/list_product'
,
'post'
,
productCategoryId
)
.
then
(
products
=>
{
if
(
products
.
data
.
resultCode
==
0
)
{
let
data
=
[]
products
.
data
.
data
.
forEach
((
item
,
index
)
=>
{
if
(
item
.
productStatus
==
'UP'
)
{
data
.
push
(
item
)
}
})
this
.
preLoad
(
this
.
defaultProduct
)
if
(
data
.
length
==
0
)
{
this
.
isProduct
=
false
this
.
categorys
[
0
].
data
=
data
}
else
{
this
.
isProduct
=
false
this
.
categorys
[
0
].
data
=
data
this
.
products
=
data
this
.
preLoad
(
this
.
products
)
}
}
})
.
catch
(
fail
=>
{
console
.
log
(
'fail'
,
fail
)
})
}
// 左侧没有分类的情况下
}
else
{
this
.
isCategorys
=
false
return
console
.
log
(
'err'
,
res
)
}
})
},
mounted
()
{
window
.
clearCar
=
this
.
clearCar
const
that
=
this
setTimeout
(
function
(
res
)
{
var
product
=
JSON
.
parse
(
JSON
.
stringify
(
that
.
defaultProduct
))
product
.
forEach
((
item
,
index
)
=>
{
var
img
=
new
Image
()
var
urls
=
[]
urls
[
index
]
=
item
.
productIcon
img
.
src
=
urls
[
index
]
img
.
onload
=
function
()
{
that
.
$refs
.
img
[
index
].
src
=
urls
[
index
]
}
.
catch
(
err
=>
{
console
.
log
(
'err'
,
err
)
})
},
500
)
},
methods
:{
// 选菜的类别的点击事件
selectClass
:
function
(
menu
,
index
)
{
if
(
this
.
selectIndex
!=
index
)
{
this
.
selectIndex
=
index
this
.
defaultProduct
=
[]
this
.
$http
.
request
(
'/v1/product/list_product'
,
'post'
,{
productCategoryId
:
menu
.
productCategoryId
})
.
then
(
res
=>
{
if
(
res
.
data
.
data
.
length
!=
0
)
{
methods
:
{
// 选择分类
selectClass
:
function
(
category
,
index
)
{
if
(
category
.
productCategoryId
!=
this
.
defaultSelected
)
{
this
.
defaultSelected
=
category
.
productCategoryId
// 数据加载过一次,直接从本地拿
if
(
category
.
data
)
{
this
.
products
=
category
.
data
if
(
category
.
data
.
length
==
0
)
{
this
.
isProduct
=
false
}
else
{
this
.
isProduct
=
true
res
.
data
.
data
.
forEach
(
product
=>
{
if
(
product
.
productStatus
==
'UP'
)
{
this
.
defaultProduct
.
push
(
product
)
this
.
preLoad
(
this
.
products
)
}
})
this
.
preLoad
(
this
.
defaultProduct
)
}
// 本地没有数据,请求保存到本地
else
{
let
productCategoryId
=
{
productCategoryId
:
category
.
productCategoryId
}
this
.
$http
.
request
(
'/v1/product/list_product'
,
'post'
,
productCategoryId
)
.
then
(
products
=>
{
if
(
products
.
data
.
resultCode
==
0
)
{
let
data
=
[]
products
.
data
.
data
.
forEach
((
item
,
index
)
=>
{
if
(
item
.
productStatus
==
'UP'
)
{
data
.
push
(
item
)
}
})
if
(
data
.
length
==
0
)
{
this
.
isProduct
=
false
this
.
categorys
[
index
].
data
=
data
}
else
{
this
.
isProduct
=
true
this
.
categorys
[
index
].
data
=
data
this
.
products
=
data
this
.
preLoad
(
this
.
products
)
}
}
})
.
catch
(
err
=>
{
console
.
log
(
err
)
.
catch
(
fail
=>
{
console
.
log
(
'fail'
,
fail
)
})
}
}
},
// 点击加入购物车列表e
addCar
:
function
(
e
)
{
...
...
@@ -228,7 +246,6 @@
return
}
})
// 购物车不存在这个商品新加一条数据
if
(
!
flag
)
{
gooodinfo
.
count
=
1
...
...
@@ -237,13 +254,10 @@
//计算总数量 总价格
this
.
allNum
=
this
.
allNum
+
1
this
.
allPrice
=
((
this
.
allPrice
*
100
+
gooodinfo
.
productPrice
*
100
)
/
100
).
toFixed
(
2
)
// 让最后加入右侧购物车列表的菜进入视野
setTimeout
(()
=>
{
this
.
$refs
.
foodItem
[
this
.
carList
.
length
-
1
].
scrollIntoView
()
},
0
)
},
// 清空购物车
clearCar
:
function
()
{
...
...
@@ -280,6 +294,7 @@
// 向设备端发送详情账单
window
.
android
.
pay
(
JSON
.
stringify
(
setData
),
this
.
allPrice
)
},
// 预加载
preLoad
:
function
(
product
)
{
product
.
forEach
((
item
,
index
)
=>
{
const
that
=
this
...
...
@@ -290,12 +305,211 @@
img
.
onload
=
function
()
{
setTimeout
(
function
()
{
that
.
$refs
.
img
[
index
].
src
=
urls
[
index
]
},
50
0
)
},
0
)
}
})
}
},
mounted
()
{
// 清空购物车方法暴露给window
window
.
clearCar
=
this
.
clearCar
}
})
// var order = new Vue({
// el: '#gen',
// data: {
// url: 'img/null.png',
// urls: [],
// defaultProduct: [], // 默认展示的菜
// allProducts:[], // 所有的 分类 菜
// selectIndex: '0', // 左侧选中类别的index,用来做选项卡判断
// selectStyle: {
// 'font-family': 'PingFangSC-Medium',
// 'border-right': '5px solid red',
// 'background-color':' #FFDEDE',
// 'color': ' #E60012'
// }, //左侧菜单分类列表选中时的样式
// carList: [],// 所有加入购物车的列表数据
// allNum: 0, // 购物车里商品总数
// allPrice: 0 ,// 购物车里商品总价格
// isDisplay: true, // 菜品分类是否展示隐藏 默认展示
// isUp: true, //菜品是否上架 菜品上架
// isCategorys: true, // 有没有分类
// isProduct: true // 有无菜品
// },
// created() {
// let data = {
// orgId: localStorage.getItem('orgId')
// }
// this.$http.request('/v1/product/list_product_category','POST',data).then(res => {
// // 左侧分类是否展示
// res.data.data.forEach((item) => {
// if(item.isDisplay == "DISPLAY") {
// this.allProducts.push(item)
// }
// })
// console.log(this.allProducts,' this.allProducts11111111111')
// // 左侧有分类的情况下
// if(this.allProducts.length != 0) {
// return this.$http.request('/v1/product/list_product','post',{ productCategoryId: this.allProducts[0].productCategoryId })
// .then(e => {
// if( e.data.data.length != 0) {
// this.isProduct = true
// e.data.data.forEach((product) => {
// // 菜品是否展示
// if(product.productStatus == 'UP') {
// this.defaultProduct.push(product)
// }
// })
// this.allProducts[0].data = this.defaultProduct
// }
// else {
// this.isProduct = false
// }
//
// })
// }
// // 左侧没有分类的情况下
// else {
// this.isCategorys = false
// return
// }
// })
// },
// mounted() {
// window.clearCar = this.clearCar
// const that = this
// setTimeout(function (res) {
// var product = JSON.parse(JSON.stringify(that.defaultProduct))
// product.forEach((item,index) => {
// var img = new Image()
// var urls = []
// urls[index] = item.productIcon
// img.src = urls[index]
// img.onload = function () {
// that.$refs.img[index].src = urls[index]
// }
// })
// },500)
// },
// methods:{
// // 选菜的类别的点击事件
// selectClass:function (menu,index) {
// if( this.selectIndex != index) {
// this.selectIndex = index
// this.defaultProduct = []
// this.$http.request('/v1/product/list_product','post',{productCategoryId: menu.productCategoryId})
// .then(res => {
// if(res.data.data.length != 0) {
// this.isProduct = true
// res.data.data.forEach(product => {
// if(product.productStatus == 'UP') {
// this.defaultProduct.push(product)
// }
// })
// this.preLoad(this.defaultProduct)
// }
// else {
// this.isProduct = false
// }
// })
// .catch(err => {
// console.log(err)
// })
// }
// },
// // 点击加入购物车列表e
// addCar:function (e) {
// // 假设在购物车中没有找到商品
// var flag = false
// let gooodinfo = {
// productId: e.productId,
// productName: e.productName,
// productPrice: e.productPrice,
// count: 0
// }
// // 判断购物车里是否已经存在商品
// this.carList.some((item,index) => {
// if(gooodinfo.productId == item.productId ) {
// item.count += parseInt(gooodinfo.count) + 1
// flag = true
// return
// }
// })
//
// // 购物车不存在这个商品新加一条数据
// if (!flag) {
// gooodinfo.count = 1
// this.carList.push(gooodinfo)
// }
// //计算总数量 总价格
// this.allNum = this.allNum + 1
// this.allPrice = ((this.allPrice*100 + gooodinfo.productPrice*100)/100).toFixed(2)
//
// // 让最后加入右侧购物车列表的菜进入视野
// setTimeout(() => {
// this.$refs.foodItem[this.carList.length - 1].scrollIntoView()
// },0)
//
//
// },
// // 清空购物车
// clearCar:function() {
// this.carList = [];
// this.allNum = 0
// this.allPrice = 0
// },
// // 减少购物车的数量
// reduce:function(index) {
// this.allPrice = ((this.allPrice*100 - this.carList[index].productPrice*100)/100).toFixed(2)
// this.carList[index].count = this.carList[index].count - 1
// // 购物车里的商品数量减少到小于等于0时,从购物车里删除这条信息
// if(this.carList[index].count
<=
0
)
{
// this.carList.splice(index,1)
// }
// this.allNum = this.allNum - 1
// },
// // 增加购物车的数量
// add:function(index) {
// this.carList[index].count = this.carList[index].count + 1
// this.allNum = this.allNum + 1
// this.allPrice = ((this.allPrice*100 + this.carList[index].productPrice*100)/100).toFixed(2)
// },
// // 结账
// checkout: function () {
// let setData = []
// this.carList.forEach(item => {
// setData.push({
// productId: item.productId,
// productQuantity: item.count
// })
//
// })
// // 向设备端发送详情账单
// window.android.pay(JSON.stringify(setData),this.allPrice)
// },
// preLoad: function(product) {
// product.forEach((item,index) => {
// const that = this
// var img = new Image()
// var urls = []
// urls[index] = item.productIcon
// img.src = urls[index]
// img.onload = function () {
// setTimeout(function () {
// that.$refs.img[index].src = urls[index]
// },0)
// }
// })
// }
// },
// })
</script>
</html>
\ No newline at end of file
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