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
372ab1e2
Commit
372ab1e2
authored
Aug 31, 2022
by
宋冰琦
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复部分bug
parent
4557923c
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
207 additions
and
80 deletions
+207
-80
App.vue
+1
-1
components/menuAssembly/index.vue
+4
-2
menuSubPackage/pages/goodsDetail/goodsDetail.vue
+57
-52
mineSubPackage/pages/userInfo/index.vue
+15
-9
orderSubPackage/pages/settlement/index.vue
+21
-7
pages/menu/menu.vue
+23
-1
pages/mine/mine.vue
+5
-3
request/index.js
+1
-1
request/menu/index.js
+17
-1
request/user/index.js
+42
-1
store/modules/user.js
+6
-2
utils/utils.js
+15
-0
No files found.
App.vue
View file @
372ab1e2
...
...
@@ -24,7 +24,7 @@ export default {
// }
// })
Store
.
commit
(
'setAuthorization'
,
uni
.
getStorageSync
(
'Authorization'
))
Store
.
commit
(
'setUserInfo'
,
uni
.
getStorageSync
(
'
u
serInfo'
))
Store
.
commit
(
'setUserInfo'
,
uni
.
getStorageSync
(
'
U
serInfo'
))
// uni.showLoading({
// title: '加载中...',
// mask:true
...
...
components/menuAssembly/index.vue
View file @
372ab1e2
...
...
@@ -371,7 +371,7 @@ export default {
height
:
calc
(
100vh
-
var
(
--scroll-height
));
overflow
:
auto
;
width
:
585.21
rpx
;
padding-top
:
42
rpx
;
//
padding-top
:
42
rpx
;
}
.buiedcss
{
height
:
calc
(
100vh
-
376
rpx
-
183
rpx
);
...
...
@@ -533,7 +533,9 @@ export default {
}
}
.box
:first-child
{
margin-top
:
40
rpx
;
}
.box
:last-child
{
//
padding-bottom
:
var
(
--good-bottom
);
padding-bottom
:
200
rpx
;
...
...
menuSubPackage/pages/goodsDetail/goodsDetail.vue
View file @
372ab1e2
...
...
@@ -326,63 +326,68 @@ export default {
}
},
async
getallNum
(
e
)
{
const
gosettleFun
=
async
()
=>
{
const
{
goods
}
=
this
;
const
{
data
}
=
await
Order
.
checkSku
({
skuId
:
goods
.
skuId
})
const
{
state
,
goods
:
newgoods
}
=
data
.
data
const
newInfo
=
JSON
.
parse
(
JSON
.
stringify
(
newgoods
))
newInfo
.
category
=
this
.
goodInfo
.
category
this
.
goodInfo
=
{...
newInfo
}
this
.
initInfo
(
this
.
goodInfo
)
if
(
state
==
2
){
this
.
showToast
({
title
:
'本商品已经售罄'
,
icon
:
'none'
});
// this.getMenuList()
return
;
}
else
{
goods
.
num
=
this
.
size
Utils
.
addGoods
(
goods
)
uni
.
navigateTo
({
url
:
`/orderSubPackage/pages/settlement/index?buyType=1&goodsList=1`
})
const
gosettleFun
=
async
()
=>
{
const
{
goods
}
=
this
;
const
{
data
}
=
await
Order
.
checkSku
({
skuId
:
goods
.
skuId
})
const
{
state
,
goods
:
newgoods
}
=
data
.
data
const
newInfo
=
JSON
.
parse
(
JSON
.
stringify
(
newgoods
))
newInfo
.
category
=
this
.
goodInfo
.
category
this
.
goodInfo
=
{...
newInfo
}
this
.
initInfo
(
this
.
goodInfo
)
if
(
state
==
2
){
this
.
showToast
({
title
:
'本商品已经售罄'
,
icon
:
'none'
});
// this.getMenuList()
return
;
}
else
{
goods
.
num
=
this
.
size
Utils
.
addGoods
(
goods
)
uni
.
navigateTo
({
url
:
`/orderSubPackage/pages/settlement/index?buyType=1&goodsList=1`
})
}
}
const
checkLocak
=
()
=>
{
uni
.
authorize
({
scope
:
'scope.userLocation'
,
success
:
()
=>
{
//1.1 允许授权
console
.
log
(
"允许授权位置"
);
gosettleFun
()
},
fail
:
(
err
)
=>
{
//1.2 拒绝授权
wx
.
exitMiniProgram
({
success
:
(
res
)
=>
{
}
})
console
.
log
(
"获取位置失败"
)
uni
.
showModal
({
content
:
'检测到您没打开地理位置权限,是否去设置打开?'
,
confirmText
:
"确认"
,
cancelText
:
'取消'
,
success
:
(
res
)
=>
{
if
(
res
.
confirm
)
{
uni
.
openSetting
({
//opensetting是调起设置页面的
success
:
(
res
)
=>
{
console
.
log
(
res
)
if
(
res
.
authSetting
[
'scope.userLocation'
]
==
true
){
//判断res.authsetting的值是true还是false
gosettleFun
()
}
else
{
// console.log("什么也不做");
}
}
})
}
else
{
console
.
log
(
'取消'
);
return
false
;
}
}
})
}
})
}
}
let
Authorization
=
uni
.
getStorageSync
(
'Authorization'
);
if
(
!
Authorization
)
{
this
.
loginByPhoneNumber
(
e
);
uni
.
authorize
({
scope
:
'scope.userLocation'
,
success
:
()
=>
{
//1.1 允许授权
console
.
log
(
"允许授权位置"
);
settleMentFunc
()
},
fail
:
(
err
)
=>
{
//1.2 拒绝授权
wx
.
exitMiniProgram
({
success
:
(
res
)
=>
{
}
})
console
.
log
(
"获取位置失败"
)
uni
.
showModal
({
content
:
'检测到您没打开地理位置权限,是否去设置打开?'
,
confirmText
:
"确认"
,
cancelText
:
'取消'
,
success
:
(
res
)
=>
{
if
(
res
.
confirm
)
{
uni
.
openSetting
({
//opensetting是调起设置页面的
success
:
(
res
)
=>
{
console
.
log
(
res
)
if
(
res
.
authSetting
[
'scope.userLocation'
]
==
true
){
//判断res.authsetting的值是true还是false
gosettleFun
()
}
else
{
// console.log("什么也不做");
}
}
})
}
else
{
console
.
log
(
'取消'
);
return
false
;
}
}
})
}
})
checkLocak
()
return
}
else
{
checkLocak
()
}
if
(
!
this
.
shopState
||!
this
.
isInRange
){
return
...
...
mineSubPackage/pages/userInfo/index.vue
View file @
372ab1e2
...
...
@@ -86,7 +86,7 @@ export default {
return
years
+
'.'
+
month
+
'.'
+
days
},
userInfoStorage
()
{
return
this
.
$store
.
state
.
user
.
userInfo
;
return
uni
.
getStorageSync
(
'UserInfo'
)
;
},
systemBarHeight
(){
return
this
.
$store
.
state
.
user
.
systemBarHeight
...
...
@@ -170,10 +170,11 @@ export default {
const
{...
result
}
=
this
.
userInfoStorage
const
sendData
=
{
...
result
,
avatarUrl
:
''
,
avatarUrl
,
canEditBirthday
:
this
.
canEditBirthday
}
Store
.
commit
(
'setUserInfo'
,
sendData
);
this
.
save
(
false
)
}
else
{
const
{
avatarUrl
,
birthday
,
id
,
phone
,
sex
,
customerName
,
canEditBirthday
}
=
this
.
userInfoStorage
this
.
canEditBirthday
=
canEditBirthday
...
...
@@ -208,10 +209,11 @@ export default {
const
{
userInfo
}
=
res
const
Info
=
{
avatarUrl
:
userInfo
.
avatarUrl
,
nickName
:
userInfo
.
nickName
//
nickName:userInfo.nickName
}
this
.
userInfo
.
avatarUrl
=
Info
.
avatarUrl
this
.
userInfo
.
name
=
Info
.
nickName
// this.userInfo.name = Info.nickName
this
.
save
(
false
)
}
})
},
...
...
@@ -233,7 +235,7 @@ export default {
}
})
},
async
save
()
{
async
save
(
isReturn
=
true
)
{
const
{
customerName
,...
result
}
=
this
.
userInfoStorage
if
(
!
this
.
valate
){
const
{
sex
,
name
,
id
,
avatarUrl
}
=
this
.
userInfo
...
...
@@ -245,8 +247,10 @@ export default {
console
.
log
(
sendData
)
await
Mine
.
editUserAvatar
({
avatarUrl
:
avatarUrl
,
id
})
const
{
data
}
=
await
Mine
.
editUserInfo
(
sendData
)
console
.
log
(
data
)
const
{
code
=
0
}
=
data
if
(
code
===
200
){
this
.
showToast
({
title
:
'保存成功'
})
const
data
=
{
...
result
,
customerName
:
name
,
...
...
@@ -256,10 +260,12 @@ export default {
}
Store
.
commit
(
'setUserInfo'
,
data
);
uni
.
setStorage
({
key
:
'userInfo'
,
data
:
data
});
this
.
showToast
({
title
:
'保存成功'
})
wx
.
navigateBack
({
delta
:
1
});
uni
.
setStorageSync
(
'UserInfo'
,
data
)
if
(
isReturn
){
wx
.
navigateBack
({
delta
:
1
});
}
}
}
}
...
...
orderSubPackage/pages/settlement/index.vue
View file @
372ab1e2
...
...
@@ -159,7 +159,7 @@ export default {
// 商品详情页点击立即支付进入
if
(
option
.
goodsList
)
{
console
.
log
(
'详情进入'
)
this
.
getMessageFlag
()
//
this.getMessageFlag()
const
shopData
=
uni
.
getStorageSync
(
'shopData'
);
this
.
shopData
=
shopData
this
.
buyType
=
3
;
...
...
@@ -177,14 +177,23 @@ export default {
if
(
q
)
{
console
.
log
(
'扫码进入'
,
q
)
uni
.
setStorageSync
(
"selectFlag"
,
false
)
this
.
getMessageFlag
()
//
this.getMessageFlag()
this
.
saveGetTicket
()
User
.
getLocation
((
state
,
params
)
=>
{
uni
.
removeStorageSync
(
'shopCarInfo'
);
$EventBus
.
$emit
(
'updateCar'
);
let
id
=
decodeURIComponent
(
q
).
split
(
'?'
)[
1
].
split
(
'='
)[
1
];
// let id = q;
Menu
.
getScreenShopCar
(
id
,
params
).
then
(
res
=>
{
// let id = decodeURIComponent(q).split('?')[1].split('=')[1];
const
optionDecode
=
Utils
.
getUrlParams2
(
decodeURIComponent
(
q
))
this
.
optionDecode
=
optionDecode
const
loginInfo
=
uni
.
getStorageSync
(
"loginInfo"
)
const
{
id
,
recognizePerson
}
=
optionDecode
const
openid
=
loginInfo
?
JSON
.
parse
(
loginInfo
).
openid
:
""
const
sendData
=
{}
if
(
recognizePerson
){
sendData
.
faceInfoId
=
recognizePerson
,
sendData
.
openid
=
openid
}
Menu
.
getScreenShopCar
(
id
,
params
,
sendData
).
then
(
res
=>
{
const
data
=
JSON
.
parse
(
res
.
data
.
data
);
console
.
log
(
data
);
this
.
shopData
=
data
.
shop
;
...
...
@@ -202,7 +211,7 @@ export default {
// 购物车点击进入
if
(
uni
.
getStorageSync
(
'shopCarInfo'
).
length
!=
0
)
{
console
.
log
(
'购物车进入'
)
this
.
getMessageFlag
()
//
this.getMessageFlag()
console
.
log
(
uni
.
getStorageSync
(
'shopCarInfo'
))
const
shopData
=
uni
.
getStorageSync
(
'shopData'
);
this
.
shopData
=
shopData
...
...
@@ -256,7 +265,8 @@ export default {
sendMsgFlag1
:
false
,
sendMsgFlag2
:
false
,
sendMsgFlag3
:
false
}
},
optionDecode
:{}
}
},
computed
:
{
...
...
@@ -379,6 +389,10 @@ export default {
getPhoneNumber
(
e
)
{
if
(
e
.
detail
.
errMsg
==
'getPhoneNumber:ok'
)
{
e
.
loginInfo
=
this
.
loginInfo
const
{
recognizePerson
}
=
this
.
optionDecode
if
(
recognizePerson
)
{
e
.
faceInfoId
=
recognizePerson
}
User
.
getPhoneNumber
(
e
);
}
else
if
(
e
.
detail
.
errMsg
==
"getPhoneNumber:fail user deny"
)
{
this
.
showToast
({
title
:
'已拒绝手机号授权'
,
icon
:
'error'
})
...
...
pages/menu/menu.vue
View file @
372ab1e2
...
...
@@ -70,6 +70,7 @@ import ShopCar from '../../components/shopCar/shopCar.vue'
import
Utils
from
'@/utils/utils'
import
Menu
from
'@/request/menu'
import
{
$EventBus
}
from
'@/utils/EventBus'
;
import
Store
from
'@/store'
;
import
Order
from
'@/request/order'
import
OrderQrCode
from
'@/components/OrderQrCode'
...
...
@@ -140,7 +141,28 @@ export default {
// this.img = 'https://s3.bmp.ovh/imgs/2022/07/02/2cfab823b35322e3.gif'
// }
},
onLoad
:
async
function
()
{
onLoad
:
async
function
(
option
)
{
// 通过扫码进入
const
{
q
}
=
option
if
(
q
){
const
optionDecode
=
Utils
.
getUrlParams2
(
decodeURIComponent
(
q
))
console
.
log
(
Utils
.
getUrlParams2
(
decodeURIComponent
(
q
)),
this
.
userInfo
)
const
{
num
,
serial_no
,
source
}
=
optionDecode
if
(
source
&&
this
.
userms
)
{
const
sendData
=
{
phone
:
this
.
userInfo
.
phoneNumber
,
user_id
:
this
.
userInfo
.
id
,
source
:
source
,
param
:
JSON
.
stringify
({
serial_no
,
num
})
}
Menu
.
sendUserCoupon
(
sendData
)
}
else
{
Store
.
commit
(
'setMenuOption'
,
optionDecode
);
}
}
uni
.
getSetting
({
success
:
(
res
)
=>
{
// 已经授权位置不获取默认店铺
...
...
pages/mine/mine.vue
View file @
372ab1e2
...
...
@@ -135,10 +135,12 @@ export default {
if
(
e
.
detail
.
errMsg
==
'getPhoneNumber:ok'
)
{
e
.
loginInfo
=
this
.
loginInfo
User
.
getPhoneNumber
(
e
,
async
()
=>
{
const
{
data
:
couponData
}
=
await
User
.
getCouponNum
()
this
.
tickNum
=
couponData
?.
data
||
0
setTimeout
(
async
()
=>
{
const
{
data
:
couponData
}
=
await
User
.
getCouponNum
()
this
.
tickNum
=
couponData
?.
data
||
0
},
1000
);
});
}
else
if
(
e
.
detail
.
errMsg
==
"getPhoneNumber:fail user deny"
)
{
this
.
showToast
({
title
:
'已拒绝手机号授权'
,
icon
:
'error'
})
}
...
...
request/index.js
View file @
372ab1e2
...
...
@@ -65,7 +65,7 @@ module.exports = (vm) => {
uni
.
hideLoading
();
/* 对响应成功做点什么 可使用async await 做异步操作*/
if
(
response
.
data
.
code
!==
200
)
{
if
(
response
.
data
.
code
!==
200
&&
response
.
data
.
code
!==
0
)
{
const
phoneNumber
=
uni
.
getStorageSync
(
'phoneNumber'
);
if
(
response
.
data
.
code
==
401
&&
phoneNumber
)
{
User
.
getAuthorization
(
phoneNumber
);
...
...
request/menu/index.js
View file @
372ab1e2
...
...
@@ -18,11 +18,12 @@ export default {
});
},
// 获取点单屏幕的订单信息
getScreenShopCar
(
key
,
location
)
{
getScreenShopCar
(
key
,
location
,
sendData
)
{
return
uni
.
$u
.
http
.
post
(
'/application/getData'
,
{
key
,
location
,
...
sendData
})
.
then
((
res
)
=>
{
return
res
;
...
...
@@ -125,5 +126,20 @@ export default {
});
return
err
;
});
},
// 首页调用发送优惠券接口
sendUserCoupon
(
data
)
{
return
uni
.
$u
.
http
.
post
(
'/v1/issue/user/coupon'
,
data
)
.
then
((
res
)
=>
{
return
res
;
})
.
catch
((
err
)
=>
{
context
.
showToast
({
title
:
'服务器错误'
,
icon
:
'none'
,
});
return
err
;
});
}
};
request/user/index.js
View file @
372ab1e2
...
...
@@ -59,6 +59,7 @@ export default {
encryptedData
:
res
.
encryptedData
,
})
.
then
((
res
)
=>
{
console
.
log
(
res
,
'resssssssss'
)
const
{
statusCode
,
data
}
=
res
;
const
{
code
,
token
,
phoneNumber
}
=
data
;
if
(
statusCode
==
200
&&
data
&&
code
==
200
)
{
...
...
@@ -99,6 +100,7 @@ export default {
if
(
code
){
this
.
getOpenId
(
code
).
then
((
res
)
=>
{
const
loginInfo
=
res
.
data
.
msg
uni
.
setStorageSync
(
'loginInfo'
,
loginInfo
)
resolve
(
loginInfo
)
})
}
...
...
@@ -107,22 +109,28 @@ export default {
})
},
loginDecrypt
(
res
){
const
{
faceInfoId
}
=
res
.
data
return
uni
.
$u
.
http
.
post
(
'/weixin/decrypt '
,
{
session_key
:
res
.
loginInfo
.
session_key
,
openId
:
res
.
loginInfo
.
openid
,
encryptedData
:
res
.
data
,
iv
:
res
.
iv
,
faceInfoId
,
source
:
3
})
},
// 手机号授权登录
getPhoneNumber
(
res
,
callback
)
{
console
.
log
(
res
)
uni
.
setStorage
({
key
:
'userPhoneInfo'
,
data
:
res
});
Store
.
commit
(
'setUserPhoneInfo'
,
res
);
uni
.
setStorage
({
key
:
'phoneInfo'
,
data
:
res
});
const
loginInfo
=
res
.
loginInfo
const
iv
=
res
.
detail
.
iv
const
data
=
res
.
detail
.
encryptedData
if
(
res
.
faceInfoId
){
data
.
faceInfoId
=
res
.
faceInfoId
}
wx
.
checkSession
({
success
:
(
res
)
=>
{
console
.
log
(
'seeion未过期'
)
...
...
@@ -136,6 +144,23 @@ export default {
}
})
},
// 首页调用发送优惠券接口
sendUserCoupon
(
data
)
{
return
uni
.
$u
.
http
.
post
(
'/v1/issue/user/coupon'
,
data
)
.
then
((
res
)
=>
{
Store
.
commit
(
'setMenuOption'
,
{});
return
res
;
})
.
catch
((
err
)
=>
{
context
.
showToast
({
title
:
'服务器错误'
,
icon
:
'none'
,
});
Store
.
commit
(
'setMenuOption'
,
{});
return
err
;
});
},
// 获取用户信息
getUserInfo
(
data
)
{
return
uni
.
$u
.
http
...
...
@@ -143,9 +168,10 @@ export default {
.
then
((
res
)
=>
{
console
.
log
(
res
,
data
)
const
{
birthday
,
createTime
,
id
,
phone
,
sex
,
userName
,
avatarUrl
}
=
res
.
data
.
data
const
{
avatarUrl
:
localAvatarUrl
}
=
uni
.
getStorageSync
(
'UserInfo'
)
const
sendData
=
{
...
data
,
avatarUrl
:
avatarUrl
,
avatarUrl
:
avatarUrl
||
localAvatarUrl
,
sex
:
sex
?
1
:
0
,
customerName
:
userName
,
phone
:
phone
.
substr
(
0
,
3
)
+
"****"
+
phone
.
substr
(
7
),
...
...
@@ -159,6 +185,21 @@ export default {
sendData
.
birthday
=
Date
.
parse
(
birthday
)
}
Store
.
commit
(
'setUserInfo'
,
sendData
);
uni
.
setStorageSync
(
'UserInfo'
,
sendData
)
const
MenuOption
=
Store
.
state
.
user
.
menuOption
if
(
JSON
.
stringify
(
MenuOption
)
!==
'{}'
)
{
const
{
num
,
serial_no
,
source
}
=
MenuOption
const
sendDataOption
=
{
phone
:
sendData
.
phoneNumber
,
user_id
:
sendData
.
id
,
source
:
source
,
param
:
JSON
.
stringify
({
serial_no
,
num
})
}
this
.
sendUserCoupon
(
sendDataOption
)
}
})
.
catch
((
err
)
=>
{
context
.
showToast
({
title
:
'服务器错误'
,
icon
:
'none'
});
...
...
store/modules/user.js
View file @
372ab1e2
...
...
@@ -6,7 +6,8 @@ const user = {
userPhoneInfo
:
null
,
shopInfo
:
null
,
//店铺信息
orderId
:
null
,
//扫码进入时携带的订单id
systemBarHeight
:
{}
//设备头部高度信息
systemBarHeight
:
{},
//设备头部高度信息
menuOption
:
{}
},
mutations
:
{
// 保存扫码进入时携带的订单id
...
...
@@ -23,9 +24,12 @@ const user = {
},
// 设置用户允许昵称头像授权时的信息
setUserInfo
(
state
,
userInfo
)
{
console
.
log
(
userInfo
)
state
.
userInfo
=
userInfo
;
},
// 设置扫码进入的优惠券信息
setMenuOption
(
state
,
data
)
{
state
.
menuOption
=
data
},
// 授权手机号时允许后的信息
setUserPhoneInfo
(
state
,
userPhoneInfo
)
{
state
.
userPhoneInfo
=
userPhoneInfo
;
...
...
utils/utils.js
View file @
372ab1e2
...
...
@@ -215,4 +215,19 @@ export default {
delta
:
1
});
},
// 解析url参数
getUrlParams2
(
url
)
{
// 通过 ? 分割获取后面的参数字符串
let
urlStr
=
url
.
split
(
'?'
)[
1
]
// 创建空对象存储参数
let
obj
=
{};
// 再通过 & 将每一个参数单独分割出来
let
paramsArr
=
urlStr
.
split
(
'&'
)
for
(
let
i
=
0
,
len
=
paramsArr
.
length
;
i
<
len
;
i
++
){
// 再通过 = 将每一个参数分割为 key:value 的形式
let
arr
=
paramsArr
[
i
].
split
(
'='
)
obj
[
arr
[
0
]]
=
arr
[
1
];
}
return
obj
}
};
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