Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
user
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
hooloo
mp
user
Commits
db8a9999
Commit
db8a9999
authored
Aug 25, 2022
by
songbingqi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复部分bug
parent
11511525
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
102 additions
and
41 deletions
+102
-41
components/menuAssembly/index.vue
+17
-12
components/shopCar/shopCar.vue
+3
-3
menuSubPackage/pages/goodsDetail/goodsDetail.vue
+10
-7
mineSubPackage/pages/userInfo/index.vue
+12
-2
pages/menu/menu.vue
+19
-16
pages/mine/mine.vue
+1
-1
utils/utils.js
+40
-0
No files found.
components/menuAssembly/index.vue
View file @
db8a9999
...
...
@@ -12,9 +12,9 @@
</scroll-view>
<scroll-view
class=
"nav-right"
:style=
"[heightStyle]"
:class=
"[shopCarFlag?'shopCarcss':'' ]"
scroll-y
:scroll-top=
"scrollTop"
@
scroll=
"scroll"
@
touchstart=
"openScroll"
scroll-with-animation
>
<view
v-for=
"(category,index) in classifyData"
:id=
"category.id"
:key=
"category.id"
class=
"box"
:style=
"[goodBottom]"
>
<view
v-for=
"(category,index) in classifyData"
:id=
"category.id"
:key=
"category.id"
class=
"box"
:style=
"[goodBottom
,scrollBottom
]"
>
<view
:style=
"loads"
class=
"right-title"
>
{{
category
.
name
}}
</view>
<view
class=
"nav-right-item"
v-for=
"item in category.goods"
:key=
"item.goodsId"
:style=
"[scrollBottom]"
>
<view
class=
"nav-right-item"
v-for=
"item in category.goods"
:key=
"item.goodsId"
>
<view
class=
"thumbnailBox"
>
<image
src=
"/static/imgs/aixin.png"
v-if=
"item.isRecommend == 1"
class=
"isRecommend"
/>
<image
@
click=
"cart(item, category)"
class=
"thumbnail"
v-if=
"item.pics.thumbnailApplet"
:src=
"item.pics.thumbnailApplet"
/>
...
...
@@ -33,7 +33,7 @@
<view
class=
"discount"
><text
class=
"moneyLog"
>
¥
</text>
{{
Utils
.
isInteger
(
getSku
(
item
).
discount
)
}}
</view>
<view
class=
"price"
v-if=
"getSku(item).price!=getSku(item).discount"
>
¥
<text
class=
"num"
>
{{
Utils
.
isInteger
(
getSku
(
item
).
price
)
}}
</text></view>
</view>
<view
class=
"addbox"
v-if=
"shopState"
>
<view
class=
"addbox"
v-if=
"shopState
&&isInRange
"
>
<image
v-if=
"getSku(item).state==1"
@
click
.
stop=
"cart(item, category)"
class=
"add"
:src=
"'../../static/imgs/jiahao.png'"
/>
<!--
<u-icon
class=
"add"
name=
"plus-circle-fill"
color=
"#0050F6"
@
click
.
stop=
"getallNum(item, category)"
size=
"22"
></u-icon>
-->
<div
v-if=
"getSku(item).state!=1"
style=
"color: #858585;font-size: 20rpx;margin-top:16rpx"
>
已售罄
</div>
...
...
@@ -53,7 +53,7 @@ import Utils from '@/utils/utils'
import
Order
from
'@/request/order'
export
default
{
name
:
'menuAssembly'
,
props
:[
'buied'
,
'shopState'
],
props
:[
'buied'
,
'shopState'
,
'isInRange'
],
data
()
{
return
{
scrollBottom
:
{
...
...
@@ -80,22 +80,28 @@ export default {
}
},
watch
:{
isInRange
(
val
)
{
if
(
!
val
)
{
this
.
scrollBottom
[
'--scroll-marginbottom'
]
=
131
+
'rpx'
}
else
{
this
.
scrollBottom
[
'--scroll-marginbottom'
]
=
0
+
'rpx'
}
},
shopState
(
val
)
{
if
(
!
val
)
{
this
.
scrollBottom
[
'--scroll-marginbottom'
]
=
1
00
+
'rpx'
this
.
scrollBottom
[
'--scroll-marginbottom'
]
=
1
31
+
'rpx'
}
else
{
this
.
scrollBottom
[
'--scroll-marginbottom'
]
=
0
+
'rpx'
}
console
.
log
(
this
.
scrollBottom
[
'--scroll-marginbottom'
])
},
goods
(
val
){
this
.
shopCarFlag
=
val
.
length
>
0
},
buied
(
val
)
{
if
(
val
){
this
.
heightStyle
[
'--scroll-height'
]
=
(
this
.
taBarHeight
+
1
00
)
+
'rpx'
this
.
heightStyle
[
'--scroll-height'
]
=
(
this
.
taBarHeight
+
1
22
)
+
'rpx'
}
else
{
this
.
heightStyle
[
'--scroll-height'
]
=
(
this
.
taBarHeight
)
+
'rpx'
this
.
heightStyle
[
'--scroll-height'
]
=
(
this
.
taBarHeight
+
22
)
+
'rpx'
}
}
},
...
...
@@ -145,7 +151,7 @@ export default {
mounted
(){
this
.
$nextTick
(()
=>
{
this
.
taBarHeight
=
uni
.
getStorageSync
(
'taBarHeight'
)
this
.
heightStyle
[
'--scroll-height'
]
=
(
this
.
taBarHeight
)
+
'rpx'
this
.
heightStyle
[
'--scroll-height'
]
=
(
this
.
taBarHeight
+
44
)
+
'rpx'
})
this
.
goods
=
uni
.
getStorageSync
(
'shopCarInfo'
)
||
[];
$EventBus
.
$on
(
'updateCar'
,
()
=>
{
...
...
@@ -260,10 +266,9 @@ export default {
icon
:
'none'
,
})
}
else
{
if
(
this
.
shopState
){
if
(
this
.
shopState
&&
this
.
isInRange
){
const
{
data
}
=
await
Order
.
checkSku
({
skuId
:
skuStatus
[
0
].
skuId
})
const
{
goods
}
=
data
.
data
console
.
log
(
goods
)
uni
.
setStorageSync
(
'goodsInfo'
,
JSON
.
stringify
({
...
goods
,
category
}));
}
else
{
uni
.
setStorageSync
(
'goodsInfo'
,
JSON
.
stringify
({
...
item
,
category
}));
...
...
@@ -518,7 +523,7 @@ export default {
width
:
150
rpx
;
height
:
150
rpx
;
}
.
nav-right-item
:last-child
{
.
box
:last-child
{
margin-bottom
:
var
(
--scroll-marginbottom
);
border-bottom
:
none
;
}
...
...
components/shopCar/shopCar.vue
View file @
db8a9999
...
...
@@ -85,8 +85,8 @@
@
getphonenumber=
"saveReserve"
>
结算
</button>
</view>
<view
class=
"shopClose"
v-if=
"!shopState"
:style=
"
{'bottom':shopCar+'rpx'}">
<view
class=
"content"
>
门店已休息
</view>
<view
class=
"shopClose"
v-if=
"!shopState
||!isInRange
"
:style=
"
{'bottom':shopCar+'rpx'}">
<view
class=
"content"
>
{{
!
shopState
?
"门店已休息"
:
"距离较远,门店暂停接单"
}}
</view>
</view>
<show-toast
ref=
"toast"
/>
</view>
...
...
@@ -98,7 +98,7 @@ import Menu from '@/request/menu';
import
User
from
'@/request/user'
;
import
Utils
from
'@/utils/utils'
export
default
{
props
:[
'shopState'
],
props
:[
'shopState'
,
'isInRange'
],
data
()
{
return
{
showShopCar
:
false
,
//是否弹出购物车列表
...
...
menuSubPackage/pages/goodsDetail/goodsDetail.vue
View file @
db8a9999
...
...
@@ -65,16 +65,16 @@
</view>
<view
v-if=
"size > 0"
class=
"good-select-cont"
>
<view>
<a
:class=
"!shopState?'good-select-btn1-close':'good-select-btn1'"
@
click=
"getallNum()"
v-if=
"userms"
>
<a
:class=
"!shopState
||!isInRange
?'good-select-btn1-close':'good-select-btn1'"
@
click=
"getallNum()"
v-if=
"userms"
>
立即购买
</a>
<button
v-if=
"!userms"
:class=
"!shopState?'good-select-btn1-close':'good-select-btn1'"
style=
"border-radius: 0;"
open-type=
"getPhoneNumber"
<button
v-if=
"!userms"
:class=
"!shopState
||!isInRange
?'good-select-btn1-close':'good-select-btn1'"
style=
"border-radius: 0;"
open-type=
"getPhoneNumber"
@
getphonenumber=
"getallNum"
>
立即购买
</button>
</view>
<span
:class=
"!shopState?'good-select-btn2-close':'good-select-btn2'"
@
click=
"shoppingCart"
type=
"default"
>
加入购物袋
</span>
<span
:class=
"!shopState
||!isInRange
?'good-select-btn2-close':'good-select-btn2'"
@
click=
"shoppingCart"
type=
"default"
>
加入购物袋
</span>
</view>
</view>
</view>
...
...
@@ -106,7 +106,8 @@ export default {
BottomSafeHeight
:
0
,
Utils
,
shopState
:
true
,
showSku
:[]
showSku
:[],
isInRange
:
true
}
},
onShow
()
{
...
...
@@ -114,6 +115,7 @@ export default {
uni
.
removeStorageSync
(
'goodsList'
);
this
.
BottomSafeHeight
=
uni
.
getStorageSync
(
'BottomSafeHeight'
)
this
.
shopState
=
JSON
.
parse
(
uni
.
getStorageSync
(
"shopState"
))
this
.
isInRange
=
uni
.
getStorageSync
(
"isInRange"
)
===
''
?
true
:
uni
.
getStorageSync
(
"isInRange"
)
},
mounted
(){
// 获取胶囊坐标位置
...
...
@@ -299,7 +301,7 @@ export default {
}
},
async
shoppingCart
()
{
if
(
!
this
.
shopState
){
if
(
!
this
.
shopState
&&!
this
.
isInRange
){
return
}
if
(
this
.
checkNum
(
'addShop'
)){
...
...
@@ -329,9 +331,10 @@ export default {
this
.
loginByPhoneNumber
(
e
);
return
}
if
(
!
this
.
shopState
){
if
(
!
this
.
shopState
&&!
this
.
isInRange
){
return
}
const
{
goods
}
=
this
;
const
{
data
}
=
await
Order
.
checkSku
({
skuId
:
goods
.
skuId
})
const
{
state
,
goods
:
newgoods
}
=
data
.
data
...
...
@@ -373,7 +376,7 @@ export default {
}
},
UseIt
(
ruleId
)
{
return
this
.
available
.
indexOf
(
ruleId
)
==
-
1
&&
this
.
shopState
return
this
.
available
.
indexOf
(
ruleId
)
==
-
1
&&
this
.
shopState
&&
this
.
isInRange
},
ShowIt
(
ruleId
)
{
return
this
.
showSku
.
indexOf
(
ruleId
)
!==
-
1
...
...
mineSubPackage/pages/userInfo/index.vue
View file @
db8a9999
...
...
@@ -156,6 +156,14 @@ export default {
this
.
userInfo
.
sex
=
sex
?
sex
?
1
:
0
:
gender
this
.
userInfo
.
name
=
userName
?
userName
:
nickName
this
.
userInfo
.
phone
=
phone
.
substr
(
0
,
3
)
+
"****"
+
phone
.
substr
(
7
)
const
{...
result
}
=
this
.
userInfoStorage
const
sendData
=
{
...
result
,
avatarUrl
}
Store
.
commit
(
'setUserInfo'
,
sendData
);
},
methods
:{
async
choseTime
(
e
)
{
...
...
@@ -166,6 +174,7 @@ export default {
const
{
data
}
=
await
Mine
.
editBirthdat
(
sendDate
)
const
{
code
}
=
data
if
(
code
===
200
){
this
.
canEditBirthday
=
false
this
.
showToast
({
title
:
'修改成功'
})
this
.
userInfo
.
birthday
=
e
.
value
}
...
...
@@ -192,7 +201,7 @@ export default {
async
save
()
{
const
{
customerName
,...
result
}
=
this
.
userInfoStorage
if
(
!
this
.
valate
){
const
{
sex
,
name
,
id
}
=
this
.
userInfo
const
{
sex
,
name
,
id
,
avatarUrl
}
=
this
.
userInfo
const
sendData
=
{
sex
:
Number
(
sex
)
===
0
?
false
:
true
,
userName
:
name
,
...
...
@@ -204,7 +213,8 @@ export default {
if
(
code
===
200
){
const
data
=
{
...
result
,
customerName
:
name
customerName
:
name
,
avatarUrl
}
Store
.
commit
(
'setUserInfo'
,
data
);
uni
.
setStorage
({
key
:
'userInfo'
,
data
:
data
});
...
...
pages/menu/menu.vue
View file @
db8a9999
...
...
@@ -14,7 +14,7 @@
</view>
<view
class=
"login-area"
>
<view
class=
"avatar"
>
<image
:src=
"'../../static/touxiang.png'"
></image>
<image
:src=
"
userInfo.avatarUrl?userInfo.avatarUrl:
'../../static/touxiang.png'"
></image>
</view>
<view
class=
"user-info"
@
click=
"goToMyPage(userms)"
>
<view
class=
"user-infocontent"
>
...
...
@@ -48,7 +48,7 @@
<view
class=
"barCode-dis"
>
点击二维码取单
</view>
</view>
</view>
<MenuAssembly
ref=
"MenuAssembly"
@
getallNum=
"getallNum"
:buied=
"buied"
:shopState=
"shopState"
/>
<MenuAssembly
ref=
"MenuAssembly"
@
getallNum=
"getallNum"
:buied=
"buied"
:shopState=
"shopState"
:isInRange=
"isInRange"
/>
<!--
<u-picker
@
cancel=
"show = false"
:show=
"show"
:immediateChange=
"true"
ref=
"uPicker"
:columns=
"columns"
@
confirm=
"confirm"
keyName=
"name"
@
change=
"changeHandler"
></u-picker>
-->
<AreaPicker
ref=
"AreaPicker"
/>
...
...
@@ -57,7 +57,7 @@
style=
"background:#fff;width: 200px;height: 200px; display:block; left:-800rpx;position:absolute;"
/>
<show-toast
ref=
"toast"
/>
<taBar
select=
"0"
></taBar>
<ShopCar
ref=
"shopbar"
:shopState=
"shopState"
/>
<ShopCar
ref=
"shopbar"
:shopState=
"shopState"
:isInRange=
"isInRange"
/>
</view>
</
template
>
<
script
>
...
...
@@ -84,7 +84,8 @@ export default {
classifyData
:
[],
customerName
:
''
,
loginInfo
:
""
,
img
:
''
img
:
''
,
isInRange
:
true
};
},
computed
:
{
...
...
@@ -171,9 +172,9 @@ export default {
},
methods
:
{
getShopMenus
(
params
)
{
$EventBus
.
$off
(
'getMenuList'
);
$EventBus
.
$on
(
'getMenuList'
,
(
data
)
=>
{
console
.
log
(
"shop:"
+
JSON
.
stringify
(
data
));
if
(
this
.
shopInfo
&&
this
.
shopInfo
.
id
!=
data
.
id
)
{
// 切换店铺清空购物车
uni
.
removeStorageSync
(
'shopCarInfo'
);
...
...
@@ -183,6 +184,19 @@ export default {
uni
.
setStorageSync
(
"shopInfo"
,
JSON
.
stringify
(
this
.
shopInfo
))
this
.
getMenuList
(
data
.
id
);
this
.
getHomeOrder
(
data
.
id
)
// 判断店铺是否在范围内
const
location
=
uni
.
getStorageSync
(
"location"
)
const
shopInfo
=
uni
.
getStorageSync
(
"shopInfo"
)
const
{
lat
:
latloc
,
lng
:
lngloc
}
=
location
const
{
lat
:
latshop
,
lng
:
lngshop
,
distance
:
shopdistanceshop
}
=
JSON
.
parse
(
shopInfo
)
const
distance
=
Utils
.
getDistances
(
latloc
,
lngloc
,
latshop
,
lngshop
)
if
(
!
shopdistanceshop
){
this
.
isInRange
=
true
}
else
{
console
.
log
(
parseInt
(
distance
.
distance_str
)
<
parseInt
(
shopdistanceshop
))
this
.
isInRange
=
parseInt
(
distance
.
distance_str
)
<
parseInt
(
shopdistanceshop
)
}
uni
.
setStorageSync
(
"isInRange"
,
this
.
isInRange
)
});
User
.
getShopInfo
(
params
);
},
...
...
@@ -251,17 +265,6 @@ export default {
this
.
showToast
({
"title"
:
"获取位置失败,请打开位置授权"
,
icon
:
'error'
})
}
})
// if (res.authSetting['scope.userLocation']) {
// console.log("以前允许授权位置");
// User.getLocation((state, params) => {
// if(state != 1){
// return;
// }
// callback && callback(params);
// });
// } else {
// }
}
})
},
...
...
pages/mine/mine.vue
View file @
db8a9999
...
...
@@ -9,7 +9,7 @@
<!--
<video
class=
"video"
autoplay
muted
loop
:controls=
"false"
:enable-progress-gesture=
"false"
objectFit=
'cover'
src=
"http://songclound.oss-cn-hongkong.aliyuncs.com/2022/06/27/e6582afb60924.mp4"
></video>
-->
<view
class=
"mod11"
@
click=
"goToPage('userInfo')"
>
<view
class=
"avatar"
>
<image
:src=
"'../../static/touxiang.png'"
></image>
<image
:src=
"
userInfo.avatarUrl?userInfo.avatarUrl:
'../../static/touxiang.png'"
></image>
</view>
<view
class=
"user-info"
>
<view
class=
"user-infocontent"
>
...
...
utils/utils.js
View file @
db8a9999
...
...
@@ -162,5 +162,45 @@ export default {
},
isInteger
(
value
)
{
return
parseFloat
(
Number
(
value
).
toFixed
(
2
))
},
// 计算经纬度之间的距离
// 根据经纬度计算距离,参数分别为第一点的纬度,经度;第二点的纬度,经度
getDistances
(
lat1
,
lng1
,
lat2
,
lng2
)
{
function
rad
(
d
)
{
return
d
*
Math
.
PI
/
180.0
;
}
var
radLat1
=
rad
(
lat1
);
var
radLat2
=
rad
(
lat2
);
var
a
=
radLat1
-
radLat2
;
var
b
=
rad
(
lng1
)
-
rad
(
lng2
);
var
s
=
2
*
Math
.
asin
(
Math
.
sqrt
(
Math
.
pow
(
Math
.
sin
(
a
/
2
),
2
)
+
Math
.
cos
(
radLat1
)
*
Math
.
cos
(
radLat2
)
*
Math
.
pow
(
Math
.
sin
(
b
/
2
),
2
)));
s
=
s
*
6378.137
;
// EARTH_RADIUS;
// 输出为公里
s
=
Math
.
round
(
s
*
10000
)
/
10000
;
var
distance
=
s
;
var
distance_str
=
""
;
if
(
parseInt
(
distance
)
>=
1
)
{
// distance_str = distance.toFixed(1) + "km";
distance_str
=
distance
.
toFixed
(
2
)
+
"km"
;
}
else
{
// distance_str = distance * 1000 + "m";
distance_str
=
(
distance
*
1000
).
toFixed
(
2
)
+
"m"
;
}
//s=s.toFixed(4);
// console.info('距离是', s);
// console.info('距离是', distance_str);
// return s;
//小小修改,这里返回对象
let
objData
=
{
distance
:
distance
,
distance_str
:
distance_str
}
return
objData
}
};
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