Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
7
7-Eleven
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
高淑倩
7-Eleven
Commits
bf352663
Commit
bf352663
authored
Mar 26, 2020
by
谢中龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改地址提示相关
parent
52b2d6d1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
247 additions
and
189 deletions
+247
-189
addAddress.js
src/pages/addAddress/addAddress.js
+74
-62
cart.js
src/pages/cart/cart.js
+7
-16
confirmOrder.js
src/pages/confirmOrder/confirmOrder.js
+166
-111
No files found.
src/pages/addAddress/addAddress.js
View file @
bf352663
...
@@ -30,6 +30,7 @@ wxService.page({
...
@@ -30,6 +30,7 @@ wxService.page({
address
:
''
,
address
:
''
,
type
:
1
type
:
1
},
},
pageFrom
:
''
,
},
},
/**
/**
...
@@ -38,6 +39,8 @@ wxService.page({
...
@@ -38,6 +39,8 @@ wxService.page({
onLoad
:
function
(
options
)
{
onLoad
:
function
(
options
)
{
wx
.
hideShareMenu
()
wx
.
hideShareMenu
()
if
(
options
&&
options
.
id
){
if
(
options
&&
options
.
id
){
this
.
data
.
id
=
options
.
id
;
this
.
data
.
pageFrom
=
options
.
from
;
wx
.
setNavigationBarTitle
({
wx
.
setNavigationBarTitle
({
title
:
'编辑地址'
title
:
'编辑地址'
})
})
...
@@ -50,8 +53,6 @@ wxService.page({
...
@@ -50,8 +53,6 @@ wxService.page({
title
:
'新增地址'
title
:
'新增地址'
})
})
}
}
},
},
/**
/**
* 生命周期函数--监听页面显示
* 生命周期函数--监听页面显示
...
@@ -99,6 +100,13 @@ wxService.page({
...
@@ -99,6 +100,13 @@ wxService.page({
}).
then
(
res
=>
{
}).
then
(
res
=>
{
const
{
result
,
data
}
=
res
.
data
const
{
result
,
data
}
=
res
.
data
if
(
result
==
0
)
{
if
(
result
==
0
)
{
//从订单那边直接过来的
if
(
this
.
data
.
pageFrom
==
'order'
){
this
.
data
.
cityView
=
''
;
}
else
{
this
.
data
.
cityView
=
data
.
province
+
' '
+
data
.
city
+
' '
+
data
.
district
;
}
this
.
setData
({
this
.
setData
({
params
:
{
params
:
{
userId
:
data
.
userId
,
userId
:
data
.
userId
,
...
@@ -111,20 +119,8 @@ wxService.page({
...
@@ -111,20 +119,8 @@ wxService.page({
type
:
data
.
type
type
:
data
.
type
},
},
isSelect
:
data
.
type
,
isSelect
:
data
.
type
,
cityView
:
data
.
province
+
' '
+
data
.
city
+
' '
+
data
.
district
cityView
:
this
.
data
.
cityView
})
});
// wxService.getC1().then((c1) => {
// return wxService.Promise.all([wxService.Promise.resolve(c1), wxService.getC2ByC1('北京'), wxService.getC3ByC2('北京北京市')])
// }).then(res => {
// const citys = res.map(item => {
// return [...item]
// })
// this.setData({
// citys
// })
// })
}
}
}).
finally
(()
=>
{
}).
finally
(()
=>
{
})
})
...
@@ -159,24 +155,26 @@ wxService.page({
...
@@ -159,24 +155,26 @@ wxService.page({
case
0
:
case
0
:
cityName
=
this
.
data
.
citys
[
0
][
index
]
cityName
=
this
.
data
.
citys
[
0
][
index
]
this
.
data
.
selectCityName
[
0
]
=
cityName
this
.
data
.
selectCityName
[
0
]
=
cityName
cityData
.
forEach
((
item
)
=>
{
//获取省份下的城市
if
(
item
.
value
==
cityName
){
cityList
=
cityData
[
index
].
children
.
map
(
item
=>
{
item
.
children
.
forEach
((
cityItem
)
=>
{
return
item
.
value
;
cityList
.
push
(
cityItem
.
value
)
});
cityItem
.
children
.
forEach
((
districtItem
)
=>
{
district
.
push
(
districtItem
.
value
)
//获取区
})
if
(
cityList
.
length
>
0
){
})
district
=
cityData
[
index
].
children
[
0
].
children
.
map
(
item
=>
{
}
return
item
.
value
})
});
}
this
.
setData
({
this
.
setData
({
'citys[1]'
:
cityList
,
'citys[1]'
:
cityList
,
'citys[2]'
:
district
'citys[2]'
:
district
})
})
break
break
case
1
:
case
1
:
cityName
=
this
.
data
.
citys
[
1
][
index
]
cityName
=
this
.
data
.
citys
[
1
][
index
]
;
this
.
data
.
selectCityName
[
1
]
=
cityName
this
.
data
.
selectCityName
[
1
]
=
cityName
;
cityData
.
forEach
((
item
)
=>
{
cityData
.
forEach
((
item
)
=>
{
item
.
children
.
forEach
((
cityItem
)
=>
{
item
.
children
.
forEach
((
cityItem
)
=>
{
if
(
cityName
==
cityItem
.
value
)
{
if
(
cityName
==
cityItem
.
value
)
{
...
@@ -246,48 +244,61 @@ wxService.page({
...
@@ -246,48 +244,61 @@ wxService.page({
address
:
e
.
detail
.
value
.
address
,
address
:
e
.
detail
.
value
.
address
,
type
:
this
.
data
.
isSelect
?
1
:
0
type
:
this
.
data
.
isSelect
?
1
:
0
}
}
})
});
wx
.
showLoading
({
wx
.
showLoading
({
title
:
'加载中'
title
:
'加载中'
})
})
if
(
this
.
data
.
addressId
){
if
(
this
.
data
.
addressId
){
this
.
setData
({
this
.
setData
({
'params.id'
:
this
.
data
.
id
'params.id'
:
this
.
data
.
id
})
},()
=>
{
wxService
.
post
(
`/member/addressManage/update`
,
this
.
data
.
params
).
then
(
res
=>
{
this
.
sureUpdateAddress
(
this
.
data
.
params
);
const
{
result
,
data
}
=
res
.
data
if
(
result
==
0
)
{
wx
.
hideLoading
()
wx
.
showToast
({
title
:
`修改成功`
,
icon
:
'none'
})
wx
.
navigateBack
({
delta
:
1
})
}
}).
finally
(()
=>
{
wx
.
hideLoading
()
})
})
}
else
{
}
else
{
wxService
.
post
(
`/member/addressManage/save`
,
this
.
data
.
params
).
then
(
res
=>
{
this
.
sureAddAddress
(
this
.
data
.
params
);
const
{
result
,
data
}
=
res
.
data
}
if
(
result
==
0
)
{
},
wx
.
hideLoading
()
//新增保存地址
wx
.
showToast
({
sureAddAddress
(
params
){
title
:
`保存成功`
,
wxService
.
post
(
`/member/addressManage/save`
,
params
).
then
(
res
=>
{
icon
:
'none'
const
{
result
,
data
}
=
res
.
data
})
if
(
result
==
0
)
{
wx
.
navigateBack
({
delta
:
1
})
}
}).
finally
(()
=>
{
wx
.
hideLoading
()
wx
.
hideLoading
()
})
wx
.
showToast
({
title
:
`保存成功`
,
icon
:
'none'
})
wx
.
navigateBack
({
delta
:
1
})
}
}).
finally
(()
=>
{
wx
.
hideLoading
()
})
},
//更新地址
sureUpdateAddress
(
params
){
wxService
.
post
(
`/member/addressManage/update`
,
params
).
then
(
res
=>
{
const
{
result
,
data
}
=
res
.
data
if
(
result
==
0
)
{
wx
.
hideLoading
()
wx
.
showToast
({
title
:
`修改成功`
,
icon
:
'none'
});
}
if
(
this
.
data
.
pageFrom
==
'order'
){
params
.
fullArea
=
params
.
province
+
' '
+
params
.
city
+
' '
+
params
.
district
;
}
wx
.
setStorageSync
(
'_defalutAddress'
,
params
);
}
wx
.
navigateBack
({
delta
:
1
})
}
}).
finally
(()
=>
{
wx
.
hideLoading
()
})
},
})
})
\ No newline at end of file
src/pages/cart/cart.js
View file @
bf352663
...
@@ -44,6 +44,11 @@ wxService.page({
...
@@ -44,6 +44,11 @@ wxService.page({
selected
:
2
selected
:
2
})
})
}
}
this
.
setData
({
checkAll
:
false
,
});
this
.
init
()
this
.
init
()
},
},
...
@@ -53,23 +58,9 @@ wxService.page({
...
@@ -53,23 +58,9 @@ wxService.page({
})
})
// 1556108807316001
// 1556108807316001
// 1556108807316000
// 1556108807316000
this
.
getCartList
()
this
.
getCartList
();
// const trolleySku = {
// count: 1,
// skuId: '1556108807316000'
// }
// // 加入购物车
// wxService.post('/sale/trolley/put', trolleySku).then(res => {
// if (res) {
// const { result } = res.data
// if (result == 0) {
// wx.hideLoading()
// this.getCartList()
// }
// }
// })
},
},
// 查询 /trolley/query
// 查询 /trolley/query
getCartList
()
{
getCartList
()
{
wx
.
showLoading
({
wx
.
showLoading
({
...
...
src/pages/confirmOrder/confirmOrder.js
View file @
bf352663
...
@@ -570,83 +570,88 @@ wxService.page({
...
@@ -570,83 +570,88 @@ wxService.page({
},
},
// 计算优惠价
// 计算优惠价
calPreferentialPrice
(
params
)
{
calPreferentialPrice
(
params
)
{
wx
.
showLoading
({
wx
.
showLoading
({
title
:
'加载中'
title
:
'加载中'
});
});
wxService
.
post
(
`/sale/trade/buyer/preview`
,
params
).
then
(
res
=>
{
//如果有couponId需要在预览接口传过去
if
(
res
)
{
if
(
this
.
data
.
couponId
){
const
{
result
,
data
}
=
res
.
data
params
.
couponId
=
this
.
data
.
couponId
;
if
(
result
==
0
)
{
}
wx
.
hideLoading
()
let
skuList
=
data
.
tradePreviewSkus
;
wxService
.
post
(
`/sale/trade/buyer/preview`
,
params
).
then
(
res
=>
{
let
sum
=
0
if
(
res
)
{
skuList
.
forEach
((
item
,
index
)
=>
{
const
{
result
,
data
}
=
res
.
data
// item.price
if
(
result
==
0
)
{
sum
+=
skuList
[
index
].
price
*
skuList
[
index
].
count
;
wx
.
hideLoading
()
});
let
skuList
=
data
.
tradePreviewSkus
;
let
sum
=
0
skuList
.
forEach
((
item
,
index
)
=>
{
// item.price
sum
+=
skuList
[
index
].
price
*
skuList
[
index
].
count
;
});
this
.
data
.
totalGoodsPrice
=
sum
;
this
.
data
.
totalGoodsPrice
=
sum
;
// 初始化商品价格
// 初始化商品价格
const
{
isSelect
}
=
this
.
data
const
{
isSelect
}
=
this
.
data
if
(
isSelect
)
{
if
(
isSelect
)
{
this
.
setData
({
selectPrice
:
sum
})
}
else
{
this
.
setData
({
noSelectPrice
:
sum
})
}
//如果没有couponId则认为是第一次进来没有自己选择优惠券
if
(
!
this
.
data
.
couponId
)
{
//获取优惠券信息
let
defalutCoupon
=
data
&&
data
.
couponDiscountPreviews
.
length
&&
data
.
couponDiscountPreviews
[
0
].
couponSettingDTO
.
type
==
1
?
data
&&
data
.
couponDiscountPreviews
.
length
&&
data
.
couponDiscountPreviews
[
0
].
couponSettingDTO
.
faceAmount
/
100
:
data
&&
data
.
couponDiscountPreviews
.
length
&&
data
.
couponDiscountPreviews
[
0
]
&&
data
.
couponDiscountPreviews
[
0
].
couponDiscount
;
let
defalutCouponId
=
data
&&
data
.
couponDiscountPreviews
.
length
&&
data
.
couponDiscountPreviews
[
0
]
&&
data
.
couponDiscountPreviews
[
0
].
couponDTOS
[
0
]
&&
data
.
couponDiscountPreviews
[
0
].
couponDTOS
[
0
].
id
||
''
;
let
couponSettingId
=
data
&&
data
.
couponDiscountPreviews
.
length
&&
data
.
couponDiscountPreviews
[
0
]
&&
data
.
couponDiscountPreviews
[
0
].
couponDTOS
[
0
]
&&
data
.
couponDiscountPreviews
[
0
].
couponDTOS
[
0
].
couponSettingId
||
''
;
data
.
couponDiscountPreviews
=
data
.
couponDiscountPreviews
?
data
.
couponDiscountPreviews
:
[];
this
.
data
.
couponDiscountPreviews
=
data
.
couponDiscountPreviews
;
// id / couponSettingId
this
.
setData
({
this
.
setData
({
currentOrderList
:
data
,
selectPrice
:
sum
couponDiscountPreviews
:
this
.
data
.
couponDiscountPreviews
,
defalutCoupon
:
defalutCoupon
,
defalutCouponId
:
defalutCouponId
,
couponSettingId
:
couponSettingId
,
orderInitPrice
:
data
.
amount
,
totalGoodsPrice
:
this
.
data
.
totalGoodsPrice
},
()
=>
{
// 实付款
this
.
setPayPrice
()
})
})
}
}
else
{
else
{
//重新调用之后 不刷新优惠券列表
this
.
setData
({
this
.
setData
({
currentOrderList
:
data
,
noSelectPrice
:
sum
defalutCoupon
:
this
.
data
.
defalutCoupon
,
defalutCouponId
:
this
.
data
.
defalutCouponId
,
couponSettingId
:
this
.
data
.
couponSettingId
,
orderInitPrice
:
data
.
amount
,
totalGoodsPrice
:
this
.
data
.
totalGoodsPrice
},
()
=>
{
// 实付款
this
.
setPayPrice
()
})
})
}
}
}
//如果没有couponId则认为是第一次进来没有自己选择优惠券
}
if
(
!
this
.
data
.
couponId
)
{
})
//获取优惠券信息
let
defalutCoupon
=
data
&&
data
.
couponDiscountPreviews
.
length
&&
data
.
couponDiscountPreviews
[
0
].
couponSettingDTO
.
type
==
1
?
data
&&
data
.
couponDiscountPreviews
.
length
&&
data
.
couponDiscountPreviews
[
0
].
couponSettingDTO
.
faceAmount
/
100
:
data
&&
data
.
couponDiscountPreviews
.
length
&&
data
.
couponDiscountPreviews
[
0
]
&&
data
.
couponDiscountPreviews
[
0
].
couponDiscount
;
let
defalutCouponId
=
data
&&
data
.
couponDiscountPreviews
.
length
&&
data
.
couponDiscountPreviews
[
0
]
&&
data
.
couponDiscountPreviews
[
0
].
couponDTOS
[
0
]
&&
data
.
couponDiscountPreviews
[
0
].
couponDTOS
[
0
].
id
||
''
;
let
couponSettingId
=
data
&&
data
.
couponDiscountPreviews
.
length
&&
data
.
couponDiscountPreviews
[
0
]
&&
data
.
couponDiscountPreviews
[
0
].
couponDTOS
[
0
]
&&
data
.
couponDiscountPreviews
[
0
].
couponDTOS
[
0
].
couponSettingId
||
''
;
data
.
couponDiscountPreviews
=
data
.
couponDiscountPreviews
?
data
.
couponDiscountPreviews
:
[];
this
.
data
.
couponDiscountPreviews
=
data
.
couponDiscountPreviews
;
// id / couponSettingId
this
.
setData
({
currentOrderList
:
data
,
couponDiscountPreviews
:
this
.
data
.
couponDiscountPreviews
,
defalutCoupon
:
defalutCoupon
,
defalutCouponId
:
defalutCouponId
,
couponSettingId
:
couponSettingId
,
orderInitPrice
:
data
.
amount
,
totalGoodsPrice
:
this
.
data
.
totalGoodsPrice
},
()
=>
{
// 实付款
this
.
setPayPrice
()
})
}
else
{
//重新调用之后 不刷新优惠券列表
this
.
setData
({
currentOrderList
:
data
,
defalutCoupon
:
this
.
data
.
defalutCoupon
,
defalutCouponId
:
this
.
data
.
defalutCouponId
,
couponSettingId
:
this
.
data
.
couponSettingId
,
orderInitPrice
:
data
.
amount
,
totalGoodsPrice
:
this
.
data
.
totalGoodsPrice
},
()
=>
{
// 实付款
this
.
setPayPrice
()
})
}
}
}
});
},
},
//跳转购买
//跳转购买
handelGobuy
()
{
handelGobuy
()
{
...
@@ -934,8 +939,8 @@ wxService.page({
...
@@ -934,8 +939,8 @@ wxService.page({
}
}
//校验当前选择的地址是否还有效 (判断是否是老地址,如果是的话 弹出提示,让用户去修改地址)
//校验当前选择的地址是否还有效 (判断是否是老地址,如果是的话 弹出提示,让用户去修改地址)
console
.
log
(
this
.
data
.
addressId
)
//校验地址库
console
.
log
(
this
.
data
.
addressInfo
)
this
.
validateAddress
();
this
.
calPreferentialPrice
(
params
)
this
.
calPreferentialPrice
(
params
)
}
}
...
@@ -946,45 +951,48 @@ wxService.page({
...
@@ -946,45 +951,48 @@ wxService.page({
const
{
memberId
}
=
wx
.
getStorageSync
(
'_baseUserInfo'
)
const
{
memberId
}
=
wx
.
getStorageSync
(
'_baseUserInfo'
)
wx
.
chooseAddress
({
wx
.
chooseAddress
({
success
:
(
res
)
=>
{
success
:
(
res
)
=>
{
res
.
name
=
res
.
userName
res
.
name
=
res
.
userName
res
.
phone
=
res
.
telNumber
res
.
phone
=
res
.
telNumber
res
.
fullArea
=
res
.
provinceName
+
res
.
cityName
+
res
.
countyName
res
.
fullArea
=
res
.
provinceName
+
res
.
cityName
+
res
.
countyName
res
.
address
=
res
.
detailInfo
res
.
address
=
res
.
detailInfo
;
this
.
setData
({
res
.
city
=
res
.
cityName
;
goodsAddress
:
false
,
res
.
district
=
res
.
countyName
;
wxAddress
:
true
,
res
.
province
=
res
.
provinceName
;
addressInfo
:
res
,
this
.
setData
({
params
:
{
goodsAddress
:
false
,
userId
:
memberId
,
wxAddress
:
true
,
name
:
res
.
userName
,
addressInfo
:
res
,
phone
:
res
.
telNumber
,
params
:
{
province
:
res
.
provinceName
,
userId
:
memberId
,
city
:
res
.
cityName
,
name
:
res
.
userName
,
district
:
res
.
countyName
,
phone
:
res
.
telNumber
,
address
:
res
.
detailInfo
,
province
:
res
.
provinceName
,
type
:
0
city
:
res
.
cityName
,
}
district
:
res
.
countyName
,
});
address
:
res
.
detailInfo
,
type
:
0
}
});
wxService
.
post
(
`/member/addressManage/save`
,
this
.
data
.
params
).
then
(
res
=>
{
wxService
.
post
(
`/member/addressManage/save`
,
this
.
data
.
params
).
then
(
res
=>
{
const
{
result
,
data
}
=
res
.
data
const
{
result
,
data
}
=
res
.
data
if
(
result
==
0
)
{
if
(
result
==
0
)
{
wx
.
hideLoading
();
wx
.
hideLoading
();
this
.
data
.
addressInfo
.
fullArea
=
this
.
data
.
addressInfo
.
provinceName
+
' '
+
this
.
data
.
addressInfo
.
fullArea
=
this
.
data
.
addressInfo
.
provinceName
+
' '
+
this
.
data
.
addressInfo
.
cityName
+
' '
+
this
.
data
.
addressInfo
.
countyName
this
.
data
.
addressInfo
.
cityName
+
' '
+
this
.
data
.
addressInfo
.
countyName
this
.
data
.
addressInfo
.
id
=
data
;
this
.
data
.
addressInfo
.
id
=
data
;
wx
.
setStorageSync
(
'_defalutAddress'
,
this
.
data
.
addressInfo
)
wx
.
setStorageSync
(
'_defalutAddress'
,
this
.
data
.
addressInfo
)
this
.
setData
({
this
.
setData
({
addressId
:
data
,
addressId
:
data
,
goodsAddress
:
true
,
goodsAddress
:
true
,
},
()
=>
{
},
()
=>
{
this
.
getAddressList
();
this
.
getAddressList
();
})
})
}
}
}).
finally
(()
=>
{
}).
finally
(()
=>
{
wx
.
hideLoading
()
wx
.
hideLoading
()
})
})
},
},
fail
:
function
(
err
)
{
fail
:
function
(
err
)
{
console
.
log
(
err
)
console
.
log
(
err
)
...
@@ -997,5 +1005,51 @@ wxService.page({
...
@@ -997,5 +1005,51 @@ wxService.page({
this
.
setData
({
this
.
setData
({
showSelectCoupon
:
true
showSelectCoupon
:
true
})
})
}
},
//校验地址库 原因是地址库发生过改变 老用户之前维护过地址 但是地址可能对不上影响邮费 若发现地址不对这里强制提示用户去更新
validateAddress
(){
if
(
this
.
data
.
addressId
){
let
province
=
this
.
data
.
addressInfo
.
province
,
cityName
=
this
.
data
.
addressInfo
.
city
,
district
=
this
.
data
.
addressInfo
.
district
;
let
defaultCities
=
city
.
default
;
//先处理省份
let
filterProvince
=
defaultCities
.
filter
(
item
=>
item
.
value
==
province
);
if
(
filterProvince
.
length
==
0
){
//省份地址维护不对 提示用户去改
this
.
showEditAddressModal
(
this
.
data
.
addressId
);
}
else
{
//檢查市
let
filterCity
=
filterProvince
[
0
].
children
.
filter
(
item
=>
item
.
value
==
cityName
);
if
(
filterCity
.
length
==
0
){
//市维护的地址不对 提示用户去修改
this
.
showEditAddressModal
(
this
.
data
.
addressId
);
}
else
{
//检查区是否正确
let
filterDistinct
=
filterCity
[
0
].
children
.
filter
(
item
=>
item
.
value
==
district
);
if
(
filterDistinct
.
length
==
0
){
//区维护的地址不对 提示用户去修改
this
.
showEditAddressModal
(
this
.
data
.
addressId
);
}
}
}
}
},
//展示地址修改弹框
showEditAddressModal
(
addressId
){
wx
.
showModal
({
title
:
'地址更改提示'
,
content
:
`您好,因地址库的修改,您当前的收货地址需要重新编辑才可下单,请先编辑此地址。感谢您的配合~`
,
showCancel
:
false
,
confirmText
:
'去更改'
,
confirmColor
:
'#cb3c3c'
,
success
(
res
)
{
if
(
res
.
confirm
)
{
wxService
.
router
(
`/pages/addAddress/addAddress?id=
${
addressId
}
&from=order`
)
}
}
})
},
});
});
\ 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