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
cacf36db
Commit
cacf36db
authored
Mar 16, 2020
by
程南
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
订阅消息
parent
3f732f13
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
1195 additions
and
1135 deletions
+1195
-1135
confirmOrder.js
src/pages/confirmOrder/confirmOrder.js
+870
-841
confirmOrder.wxml
src/pages/confirmOrder/confirmOrder.wxml
+2
-2
refund.js
src/pages/refund/refund.js
+321
-290
project.config.json
src/project.config.json
+2
-2
No files found.
src/pages/confirmOrder/confirmOrder.js
View file @
cacf36db
...
@@ -6,899 +6,927 @@ const utils = require('../../utils/util')
...
@@ -6,899 +6,927 @@ const utils = require('../../utils/util')
const
envInfo
=
require
(
'../../config/index'
).
envInfo
;
const
envInfo
=
require
(
'../../config/index'
).
envInfo
;
wxService
.
page
({
wxService
.
page
({
/**
/**
* 页面的初始数据
* 页面的初始数据
*/
*/
data
:
{
data
:
{
couponId
:
null
,
// 当前选中优惠券 id
couponId
:
null
,
// 当前选中优惠券 id
couponSettingId
:
null
,
// 当前选中plus优惠券 id
couponSettingId
:
null
,
// 当前选中plus优惠券 id
checkByPremium
:
false
,
checkByPremium
:
false
,
addressInfo
:
[],
addressInfo
:
[],
showSelectCoupon
:
false
,
showSelectCoupon
:
false
,
skuIds
:
[],
skuIds
:
[],
trolleySku2Buy
:
Array
,
trolleySku2Buy
:
Array
,
currentOrderList
:
Array
,
currentOrderList
:
Array
,
isSelect
:
false
,
isSelect
:
false
,
selectPrice
:
''
,
selectPrice
:
''
,
noSelectPrice
:
''
,
noSelectPrice
:
''
,
plusSpread
:
''
,
plusSpread
:
''
,
goodsAddress
:
false
,
goodsAddress
:
false
,
citys
:
null
,
citys
:
null
,
cityView
:
''
,
cityView
:
''
,
multiIndex
:
[
0
,
0
,
0
],
multiIndex
:
[
0
,
0
,
0
],
selectCityName
:
[
''
,
''
],
selectCityName
:
[
''
,
''
],
wxAddress
:
false
,
wxAddress
:
false
,
currentCoupon
:
''
,
currentCoupon
:
''
,
orderPrice
:
null
,
// 订单金额
orderPrice
:
null
,
// 订单金额
orderInitPrice
:
0
,
orderInitPrice
:
0
,
plusMemberPrice
:
0
,
// plus 默认价
plusMemberPrice
:
0
,
// plus 默认价
plusMemberName
:
''
,
plusMemberName
:
''
,
defalutCoupon
:
''
,
defalutCoupon
:
''
,
defalutCouponId
:
''
,
// 默认第一项
defalutCouponId
:
''
,
// 默认第一项
addressId
:
''
,
// 收货地址id
addressId
:
''
,
// 收货地址id
totalGoodsPrice
:
0
,
totalGoodsPrice
:
0
,
buyerRemark
:
''
,
//备注信息
buyerRemark
:
''
,
//备注信息
currentType
:
'delivery'
,
//delivery 快递 selfPickUp 门店自提
currentType
:
'delivery'
,
//delivery 快递 selfPickUp 门店自提
storeInfo
:
{
storeInfo
:
{
storeName
:
''
,
storeName
:
''
,
storeId
:
''
,
storeId
:
''
,
storeAddress
:
''
,
storeAddress
:
''
,
storeCode
:
''
storeCode
:
''
},
orderStoreInfo
:
null
,
},
},
orderStoreInfo
:
null
,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad
:
function
(
options
)
{
wx
.
hideShareMenu
();
this
.
getMyLocationInfo
();
console
.
log
(
this
.
data
)
},
////获取位置信息并获取附近门店信息
getMyLocationInfo
(
cb
)
{
let
_this
=
this
;
if
(
!
envInfo
.
isNeedGetLocation
)
{
return
;
}
//获取本地缓存的地址信息
/**
let
myLocation
=
wx
.
getStorageSync
(
'myLocation'
)
?
wx
.
getStorageSync
(
'myLocation'
)
:
null
;
* 生命周期函数--监听页面加载
if
(
!
myLocation
){
*/
wx
.
getLocation
({
onLoad
:
function
(
options
)
{
type
:
'wgs84'
,
wx
.
hideShareMenu
();
success
(
res
)
{
this
.
getMyLocationInfo
();
const
latitude
=
res
.
latitude
},
const
longitude
=
res
.
longitude
////获取位置信息并获取附近门店信息
let
obj
=
{
getMyLocationInfo
(
cb
)
{
latitude
:
latitude
,
let
_this
=
this
;
longitude
:
longitude
,
if
(
!
envInfo
.
isNeedGetLocation
)
{
}
return
;
wx
.
setStorageSync
(
'myLocation'
,
obj
);
_this
.
getMyStoreInfoByPosition
(
latitude
,
longitude
);
}
}
});
return
;
//获取本地缓存的地址信息
}
let
myLocation
=
wx
.
getStorageSync
(
'myLocation'
)
?
wx
.
getStorageSync
(
'myLocation'
)
:
null
;
if
(
!
myLocation
)
{
wx
.
getLocation
({
type
:
'wgs84'
,
success
(
res
)
{
const
latitude
=
res
.
latitude
const
longitude
=
res
.
longitude
let
obj
=
{
latitude
:
latitude
,
longitude
:
longitude
,
}
wx
.
setStorageSync
(
'myLocation'
,
obj
);
_this
.
getMyStoreInfoByPosition
(
latitude
,
longitude
);
}
});
return
;
}
this
.
getMyStoreInfoByPosition
(
myLocation
.
latitude
,
myLocation
.
longitude
);
this
.
getMyStoreInfoByPosition
(
myLocation
.
latitude
,
myLocation
.
longitude
);
},
},
//获取附近门店信息
//获取附近门店信息
getMyStoreInfoByPosition
(
latitude
,
longitude
){
getMyStoreInfoByPosition
(
latitude
,
longitude
)
{
wxService
.
post
(
`/sale/trade/buyer/getMemberStore?latitude=
${
latitude
}
&longitude=
${
longitude
}
`
).
then
(
res
=>
{
wxService
.
post
(
`/sale/trade/buyer/getMemberStore?latitude=
${
latitude
}
&longitude=
${
longitude
}
`
).
then
(
res
=>
{
if
(
res
){
if
(
res
)
{
if
(
res
.
data
.
result
==
0
)
{
if
(
res
.
data
.
result
==
0
)
{
let
obj
=
res
.
data
.
data
?
res
.
data
.
data
:
null
;
let
obj
=
res
.
data
.
data
?
res
.
data
.
data
:
null
;
if
(
obj
)
{
if
(
obj
)
{
this
.
data
.
orderStoreInfo
=
{
this
.
data
.
orderStoreInfo
=
{
storeId
:
obj
.
storeId
,
storeId
:
obj
.
storeId
,
storeInfo
:
obj
.
storeInfo
storeInfo
:
obj
.
storeInfo
}
}
}
}
}
}
});
},
/**
* 生命周期函数--监听页面显示
*/
onShow
:
function
()
{
let
pages
=
getCurrentPages
();
let
currPage
=
pages
[
pages
.
length
-
1
];
const
{
trolleySku2Buy
}
=
this
.
options
;
let
tradeDto
=
{
trolleySku2Buy
:
JSON
.
parse
(
trolleySku2Buy
)
}
}
}
});
},
/**
* 生命周期函数--监听页面显示
*/
onShow
:
function
()
{
let
pages
=
getCurrentPages
();
let
currPage
=
pages
[
pages
.
length
-
1
];
const
{
trolleySku2Buy
}
=
this
.
options
;
let
tradeDto
=
{
trolleySku2Buy
:
JSON
.
parse
(
trolleySku2Buy
)
}
// 下单 && 计算优惠价
// 下单 && 计算优惠价
this
.
setData
({
this
.
setData
({
trolleySku2Buy
:
tradeDto
.
trolleySku2Buy
trolleySku2Buy
:
tradeDto
.
trolleySku2Buy
},
()
=>
{
},
()
=>
{
this
.
initCitys
()
this
.
initCitys
()
// 地址列表
// 地址列表
if
(
this
.
data
.
currentType
==
'delivery'
){
if
(
this
.
data
.
currentType
==
'delivery'
)
{
this
.
getAddressList
()
this
.
getAddressList
()
}
}
else
{
else
{
// 获取本地选择的门店信息
// 获取本地选择的门店信息
this
.
getLocalStoreInfo
();
this
.
getLocalStoreInfo
();
}
}
});
});
//获取备注信息
this
.
getLocalRemarkInfo
();
},
//获取备注信息
//获取备注信息
this
.
getLocalRemarkInfo
();
getLocalRemarkInfo
()
{
},
this
.
data
.
buyerRemark
=
wx
.
getStorageSync
(
'orderRemark'
);
this
.
setData
({
//获取备注信息
buyerRemark
:
this
.
data
.
buyerRemark
getLocalRemarkInfo
(){
})
this
.
data
.
buyerRemark
=
wx
.
getStorageSync
(
'orderRemark'
);
},
this
.
setData
({
buyerRemark
:
this
.
data
.
buyerRemark
})
},
//输入备注
onTapInputRemark
(){
wx
.
navigateTo
({
url
:
'/pages/remark/remark'
,
});
},
onUnload
(){
wx
.
removeStorageSync
(
'orderRemark'
);
wx
.
removeStorageSync
(
'choosedStoreInfo'
);
},
//获取本地选择的门店信息
getLocalStoreInfo
(){
let
storeInfo
=
wx
.
getStorageSync
(
'choosedStoreInfo'
)
?
wx
.
getStorageSync
(
'choosedStoreInfo'
)
:
null
;
if
(
storeInfo
){
this
.
data
.
storeInfo
.
storeId
=
storeInfo
.
id
;
this
.
data
.
storeInfo
.
storeName
=
storeInfo
.
name
;
this
.
data
.
storeInfo
.
storeAddress
=
storeInfo
.
storeFullAddress
;
this
.
data
.
storeInfo
.
storeCode
=
storeInfo
.
code
;
}
else
{
this
.
data
.
storeInfo
=
{
storeName
:
''
,
storeId
:
''
,
storeAddress
:
''
,
storeCode
:
''
,
}
}
this
.
setData
({
//输入备注
storeInfo
:
this
.
data
.
storeInfo
onTapInputRemark
()
{
});
wx
.
navigateTo
({
url
:
'/pages/remark/remark'
,
const
{
memberId
}
=
wx
.
getStorageSync
(
'_baseUserInfo'
);
const
{
trolleySku2Buy
,
checkByPremium
}
=
this
.
data
;
let
params
=
{
checkByPremium
,
trolleySku2Buy
};
params
.
orderType
=
4
;
params
.
storeId
=
this
.
data
.
storeInfo
.
storeId
;
this
.
calPreferentialPrice
(
params
)
},
//切换tab
onTapChangeType
(
e
){
let
type
=
e
.
currentTarget
.
dataset
.
type
;
this
.
setData
({
currentType
:
type
});
if
(
type
==
'delivery'
){
this
.
getAddressList
()
}
else
{
this
.
getLocalStoreInfo
();
}
},
//选择门店去
onTapSelectStore
(){
wx
.
navigateTo
({
url
:
'/subPackage/page/pages/chooseStore/chooseStore?isFrom=order'
,
});
},
//订单备注输入
onBuyerRemarkInput
(
e
){
this
.
data
.
buyerRemark
=
e
.
detail
.
value
;
this
.
setData
({
buyerRemark
:
this
.
data
.
buyerRemark
});
},
// select 传过来
updateCoupon
(
e
)
{
// faceAmount 抵用多少钱(分) 1 抵用券 2 折扣券
if
(
!
e
.
detail
)
{
this
.
setData
({
defalutCoupon
:
0
,
couponId
:
''
,
couponSettingId
:
''
,
defalutCouponId
:
''
,
currentCoupon
:
0
,
},()
=>
{
this
.
setPayPrice
();
});
return
}
const
{
faceAmount
,
type
,
id
,
couponDiscount
,
sid
}
=
e
.
detail
const
{
defalutCouponId
}
=
this
.
data
const
{
orderPrice
}
=
this
.
data
// couponId---id couponSettingId --sid
let
finCouponId
=
id
?
id
:
sid
let
finCouponName
=
id
?
'couponId'
:
'couponSettingId'
;
if
(
type
==
1
)
{
this
.
setData
({
defalutCoupon
:
true
,
defalutCouponId
:
finCouponId
?
''
:
defalutCouponId
,
[
finCouponName
]
:
finCouponId
,
// couponId: id,
haveCoupon
:
true
,
currentCoupon
:
`
${
faceAmount
/
100
}
元`
})
}
else
if
(
type
==
2
)
{
// let discounPrice = (faceAmount / 100) * (orderPrice)
// let spread = Math.round(orderPrice - discounPrice)
this
.
setData
({
defalutCoupon
:
true
,
[
finCouponName
]
:
finCouponId
,
defalutCouponId
:
finCouponId
?
''
:
defalutCouponId
,
// couponId: id,
haveCoupon
:
true
,
currentCoupon
:
`
${
couponDiscount
}
元`
});
}
// 实付款
this
.
setPayPrice
();
},
setPayPrice
()
{
const
{
currentCoupon
,
orderInitPrice
,
isSelect
,
plusMemberPrice
,
defalutCoupon
}
=
this
.
data
let
newCurrentCoupon
=
currentCoupon
?
currentCoupon
:
0
let
orderCoupon
=
parseFloat
(
newCurrentCoupon
)
// 优惠券价格
let
plusPrice
=
isSelect
?
plusMemberPrice
:
0
// plus
let
calCouponPrice
=
orderCoupon
?
orderCoupon
:
defalutCoupon
// 实际价格 - 优惠价 + plus
this
.
setData
({
// orderPrice: Math.round(orderInitPrice - orderCoupon)
// orderPrice: orderInitPrice - orderCoupon + plusPrice
orderPrice
:
orderInitPrice
-
calCouponPrice
+
plusPrice
})
},
//提交按钮
formSubmit
(
e
)
{
//判断是不是开卡了
if
(
this
.
data
.
orderingMustOpenCard
){
let
baseInfo
=
wx
.
getStorageSync
(
'_baseUserInfo'
);
if
(
!
baseInfo
){
wx
.
showToast
({
title
:
'你还未登录,请先去登录'
,
icon
:
'none'
});
});
return
;
},
}
let
memberActivateStatus
=
baseInfo
.
memberActivateStatus
;
if
(
!
memberActivateStatus
){
wx
.
showModal
({
title
:
'下单开卡提示'
,
content
:
'对不起,需要您先开卡后才能下单,点击确定去开卡'
,
showCancel
:
true
,
confirmText
:
'确定'
,
confirmColor
:
'#cb3c3c'
,
success
:
function
(
res
){
if
(
res
.
confirm
){
//跳去开卡
wxService
.
openCard
();
}
else
if
(
res
.
cancel
){
}
onUnload
()
{
}
wx
.
removeStorageSync
(
'orderRemark'
);
})
wx
.
removeStorageSync
(
'choosedStoreInfo'
);
},
return
;
//获取本地选择的门店信息
}
getLocalStoreInfo
()
{
}
let
storeInfo
=
wx
.
getStorageSync
(
'choosedStoreInfo'
)
?
wx
.
getStorageSync
(
'choosedStoreInfo'
)
:
null
;
//判断是不是快递配送
if
(
storeInfo
)
{
if
(
this
.
data
.
currentType
==
'delivery'
){
this
.
data
.
storeInfo
.
storeId
=
storeInfo
.
id
;
const
{
goodsAddress
}
=
this
.
data
this
.
data
.
storeInfo
.
storeName
=
storeInfo
.
name
;
// 保存地址 && 支付
this
.
data
.
storeInfo
.
storeAddress
=
storeInfo
.
storeFullAddress
;
if
(
goodsAddress
)
{
this
.
data
.
storeInfo
.
storeCode
=
storeInfo
.
code
;
if
(
!
e
.
detail
.
value
.
name
)
{
wx
.
showToast
({
title
:
`请输入姓名`
,
icon
:
'none'
})
return
false
;
}
if
(
!
e
.
detail
.
value
.
phone
)
{
wx
.
showToast
({
title
:
`请输入电话`
,
icon
:
'none'
})
return
false
;
}
}
if
(
!
this
.
data
.
cityView
)
{
else
{
wx
.
showToast
({
this
.
data
.
storeInfo
=
{
title
:
`请选择地区`
,
storeName
:
''
,
icon
:
'none'
storeId
:
''
,
})
storeAddress
:
''
,
return
false
;
storeCode
:
''
,
}
}
if
(
!
e
.
detail
.
value
.
address
)
{
wx
.
showToast
({
title
:
`请输入详细地址`
,
icon
:
'none'
})
return
false
;
}
}
const
{
memberId
}
=
wx
.
getStorageSync
(
'_baseUserInfo'
)
this
.
setData
({
this
.
setData
({
params
:
{
storeInfo
:
this
.
data
.
storeInfo
userId
:
memberId
,
name
:
e
.
detail
.
value
.
name
,
phone
:
e
.
detail
.
value
.
phone
,
province
:
this
.
data
.
params
.
province
,
city
:
this
.
data
.
params
.
city
,
district
:
this
.
data
.
params
.
district
,
address
:
e
.
detail
.
value
.
address
,
type
:
this
.
data
.
isSelect
?
1
:
0
}
});
});
wx
.
showLoading
({
const
{
memberId
}
=
wx
.
getStorageSync
(
'_baseUserInfo'
);
title
:
'加载中'
const
{
trolleySku2Buy
,
checkByPremium
}
=
this
.
data
;
let
params
=
{
checkByPremium
,
trolleySku2Buy
};
params
.
orderType
=
4
;
params
.
storeId
=
this
.
data
.
storeInfo
.
storeId
;
this
.
calPreferentialPrice
(
params
)
},
//切换tab
onTapChangeType
(
e
)
{
let
type
=
e
.
currentTarget
.
dataset
.
type
;
this
.
setData
({
currentType
:
type
});
});
wxService
.
post
(
`/member/addressManage/save`
,
this
.
data
.
params
).
then
(
res
=>
{
if
(
type
==
'delivery'
)
{
const
{
result
}
=
res
.
data
this
.
getAddressList
()
if
(
result
==
0
)
{
}
wx
.
hideLoading
()
else
{
wx
.
showToast
({
this
.
getLocalStoreInfo
();
title
:
`保存成功`
,
}
icon
:
'none'
},
//选择门店去
onTapSelectStore
()
{
wx
.
navigateTo
({
url
:
'/subPackage/page/pages/chooseStore/chooseStore?isFrom=order'
,
});
},
//订单备注输入
onBuyerRemarkInput
(
e
)
{
this
.
data
.
buyerRemark
=
e
.
detail
.
value
;
this
.
setData
({
buyerRemark
:
this
.
data
.
buyerRemark
});
},
// select 传过来
updateCoupon
(
e
)
{
// faceAmount 抵用多少钱(分) 1 抵用券 2 折扣券
if
(
!
e
.
detail
)
{
this
.
setData
({
defalutCoupon
:
0
,
couponId
:
''
,
couponSettingId
:
''
,
defalutCouponId
:
''
,
currentCoupon
:
0
,
},
()
=>
{
this
.
setPayPrice
();
});
});
return
this
.
data
.
addressId
=
res
.
data
.
data
;
}
const
{
faceAmount
,
type
,
id
,
couponDiscount
,
sid
}
=
e
.
detail
const
{
defalutCouponId
}
=
this
.
data
const
{
orderPrice
}
=
this
.
data
// couponId---id couponSettingId --sid
let
finCouponId
=
id
?
id
:
sid
let
finCouponName
=
id
?
'couponId'
:
'couponSettingId'
;
if
(
type
==
1
)
{
this
.
setData
({
this
.
setData
({
addressId
:
this
.
data
.
addressId
defalutCoupon
:
true
,
defalutCouponId
:
finCouponId
?
''
:
defalutCouponId
,
[
finCouponName
]:
finCouponId
,
// couponId: id,
haveCoupon
:
true
,
currentCoupon
:
`
${
faceAmount
/
100
}
元`
})
}
else
if
(
type
==
2
)
{
// let discounPrice = (faceAmount / 100) * (orderPrice)
// let spread = Math.round(orderPrice - discounPrice)
this
.
setData
({
defalutCoupon
:
true
,
[
finCouponName
]:
finCouponId
,
defalutCouponId
:
finCouponId
?
''
:
defalutCouponId
,
// couponId: id,
haveCoupon
:
true
,
currentCoupon
:
`
${
couponDiscount
}
元`
});
});
}
// 调起支付
// 实付款
this
.
handelGobuy
()
this
.
setPayPrice
();
}
},
})
setPayPrice
()
{
}
else
{
const
{
currentCoupon
,
orderInitPrice
,
isSelect
,
plusMemberPrice
,
defalutCoupon
}
=
this
.
data
// 调起支付
let
newCurrentCoupon
=
currentCoupon
?
currentCoupon
:
0
this
.
handelGobuy
()
let
orderCoupon
=
parseFloat
(
newCurrentCoupon
)
// 优惠券价格
}
let
plusPrice
=
isSelect
?
plusMemberPrice
:
0
// plus
}
let
calCouponPrice
=
orderCoupon
?
orderCoupon
:
defalutCoupon
else
{
this
.
handelGobuy
()
// 实际价格 - 优惠价 + plus
}
},
initCitys
()
{
let
cityData
=
[];
//热风地址库特殊处理
if
(
envInfo
.
brandId
==
2010
)
{
//由于地址框太大了,现在先用热风的一个
cityData
=
city
.
default
;
}
else
{
cityData
=
city
.
default
;
}
let
province
=
[]
let
cityList
=
[]
let
district
=
[]
cityData
.
forEach
((
item
)
=>
{
province
.
push
(
item
.
value
)
})
cityData
[
0
].
children
.
forEach
((
cityItem
)
=>
{
cityList
.
push
(
cityItem
.
value
)
cityItem
.
children
.
forEach
((
districtItem
)
=>
{
district
.
push
(
districtItem
.
value
)
})
})
this
.
setData
({
citys
:
[
province
,
cityList
,
district
]
})
},
bindMultiPickerChange
(
e
)
{
const
citys
=
this
.
data
.
citys
const
multiIndex
=
e
.
detail
.
value
if
(
citys
)
{
const
cityView
=
[
citys
[
0
][
multiIndex
[
0
]],
citys
[
1
][
multiIndex
[
1
]],
citys
[
2
][
multiIndex
[
2
]]].
join
(
' '
)
this
.
setData
({
multiIndex
,
cityView
,
'params.province'
:
citys
[
0
][
multiIndex
[
0
]],
'params.city'
:
citys
[
1
][
multiIndex
[
1
]],
'params.district'
:
citys
[
2
][
multiIndex
[
2
]]
})
}
},
bindMultiPickerColumnChange
(
e
)
{
const
detail
=
e
.
detail
const
index
=
detail
.
value
let
cityName
=
''
let
cityData
=
city
.
default
let
province
=
[]
let
cityList
=
[]
let
district
=
[]
switch
(
detail
.
column
)
{
case
0
:
cityName
=
this
.
data
.
citys
[
0
][
index
]
this
.
data
.
selectCityName
[
0
]
=
cityName
cityData
.
forEach
((
item
)
=>
{
if
(
item
.
value
==
cityName
)
{
item
.
children
.
forEach
((
cityItem
)
=>
{
cityList
.
push
(
cityItem
.
value
)
cityItem
.
children
.
forEach
((
districtItem
)
=>
{
district
.
push
(
districtItem
.
value
)
})
})
}
})
this
.
setData
({
this
.
setData
({
'citys[1]'
:
cityList
,
// orderPrice: Math.round(orderInitPrice - orderCoupon)
'citys[2]'
:
district
// orderPrice: orderInitPrice - orderCoupon + plusPrice
orderPrice
:
orderInitPrice
-
calCouponPrice
+
plusPrice
})
})
break
},
case
1
:
//提交按钮
cityName
=
this
.
data
.
citys
[
1
][
index
]
formSubmit
(
e
)
{
this
.
data
.
selectCityName
[
1
]
=
cityName
//判断是不是开卡了
cityData
.
forEach
((
item
)
=>
{
if
(
this
.
data
.
orderingMustOpenCard
)
{
item
.
children
.
forEach
((
cityItem
)
=>
{
let
baseInfo
=
wx
.
getStorageSync
(
'_baseUserInfo'
);
if
(
cityName
==
cityItem
.
value
)
{
if
(
!
baseInfo
)
{
cityItem
.
children
.
forEach
((
districtItem
)
=>
{
wx
.
showToast
({
district
.
push
(
districtItem
.
value
)
title
:
'你还未登录,请先去登录'
,
})
icon
:
'none'
});
return
;
}
}
})
})
this
.
setData
({
'citys[2]'
:
[...
district
]
})
break
default
:
break
}
},
//勾选购买vip时
handelChangeSelectVip
()
{
this
.
setData
({
isSelect
:
!
this
.
data
.
isSelect
},
()
=>
{
const
{
isSelect
}
=
this
.
data
this
.
setData
({
checkByPremium
:
isSelect
,
defalutCoupon
:
0
,
couponId
:
''
,
couponSettingId
:
''
,
defalutCouponId
:
''
},
()
=>
{
const
{
trolleySku2Buy
,
checkByPremium
,
addressId
,
addressInfo
}
=
this
.
data
let
params
=
{
let
memberActivateStatus
=
baseInfo
.
memberActivateStatus
;
checkByPremium
,
if
(
!
memberActivateStatus
)
{
trolleySku2Buy
,
wx
.
showModal
({
title
:
'下单开卡提示'
,
content
:
'对不起,需要您先开卡后才能下单,点击确定去开卡'
,
showCancel
:
true
,
confirmText
:
'确定'
,
confirmColor
:
'#cb3c3c'
,
success
:
function
(
res
)
{
if
(
res
.
confirm
)
{
//跳去开卡
wxService
.
openCard
();
}
else
if
(
res
.
cancel
)
{
}
}
})
return
;
}
}
}
//判断是不是快递配送
// 增加门店自提和快递配送判断
if
(
this
.
data
.
currentType
==
'delivery'
)
{
if
(
this
.
data
.
currentType
==
'delivery'
)
{
params
.
addressId
=
addressId
?
addressId
:
addressInfo
.
id
// 微信地址 or 地址id
const
{
goodsAddress
}
=
this
.
data
params
.
orderType
=
1
;
// 保存地址 && 支付
if
(
goodsAddress
)
{
if
(
!
e
.
detail
.
value
.
name
)
{
wx
.
showToast
({
title
:
`请输入姓名`
,
icon
:
'none'
})
return
false
;
}
if
(
!
e
.
detail
.
value
.
phone
)
{
wx
.
showToast
({
title
:
`请输入电话`
,
icon
:
'none'
})
return
false
;
}
if
(
!
this
.
data
.
cityView
)
{
wx
.
showToast
({
title
:
`请选择地区`
,
icon
:
'none'
})
return
false
;
}
if
(
!
e
.
detail
.
value
.
address
)
{
wx
.
showToast
({
title
:
`请输入详细地址`
,
icon
:
'none'
})
return
false
;
}
const
{
memberId
}
=
wx
.
getStorageSync
(
'_baseUserInfo'
)
this
.
setData
({
params
:
{
userId
:
memberId
,
name
:
e
.
detail
.
value
.
name
,
phone
:
e
.
detail
.
value
.
phone
,
province
:
this
.
data
.
params
.
province
,
city
:
this
.
data
.
params
.
city
,
district
:
this
.
data
.
params
.
district
,
address
:
e
.
detail
.
value
.
address
,
type
:
this
.
data
.
isSelect
?
1
:
0
}
});
wx
.
showLoading
({
title
:
'加载中'
});
wxService
.
post
(
`/member/addressManage/save`
,
this
.
data
.
params
).
then
(
res
=>
{
const
{
result
}
=
res
.
data
if
(
result
==
0
)
{
wx
.
hideLoading
()
wx
.
showToast
({
title
:
`保存成功`
,
icon
:
'none'
});
this
.
data
.
addressId
=
res
.
data
.
data
;
this
.
setData
({
addressId
:
this
.
data
.
addressId
});
// 调起支付
this
.
handelGobuy
()
}
})
}
else
{
// 调起支付
this
.
handelGobuy
()
}
}
}
else
{
else
{
params
.
orderType
=
4
;
this
.
handelGobuy
()
params
.
storeId
=
this
.
data
.
storeInfo
.
storeId
;
}
}
},
this
.
calPreferentialPrice
(
params
)
// 重新计算优惠价
initCitys
()
{
// 获取默认付费会员设置
let
cityData
=
[];
this
.
getPremiumDefault
()
//热风地址库特殊处理
})
if
(
envInfo
.
brandId
==
2010
)
{
});
//由于地址框太大了,现在先用热风的一个
},
cityData
=
city
.
default
;
// /premium/getDefault
getPremiumDefault
()
{
wx
.
showLoading
({
title
:
'加载中'
})
wxService
.
get
(
`/sale/premium/getDefault`
).
then
(
res
=>
{
if
(
res
)
{
const
{
result
,
data
}
=
res
.
data
if
(
result
==
0
)
{
wx
.
hideLoading
()
this
.
setData
({
plusMemberPrice
:
data
.
price
,
plusMemberName
:
data
.
name
},
()
=>
{
// 实付款
this
.
setPayPrice
()
})
}
}
}
else
{
})
cityData
=
city
.
default
;
},
// 默认地址
selectAddress
()
{
wxService
.
router
(
'/pages/myAddress/myAddress?isFrom=order'
)
},
// 计算优惠价
calPreferentialPrice
(
params
)
{
wx
.
showLoading
({
title
:
'加载中'
});
wxService
.
post
(
`/sale/trade/buyer/preview`
,
params
).
then
(
res
=>
{
if
(
res
)
{
const
{
result
,
data
}
=
res
.
data
if
(
result
==
0
)
{
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
;
// 初始化商品价格
const
{
isSelect
}
=
this
.
data
if
(
isSelect
){
this
.
setData
({
selectPrice
:
sum
})
}
else
{
this
.
setData
({
noSelectPrice
:
sum
})
}
//获取优惠券信息
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
:[];
// id / couponSettingId
this
.
setData
({
currentOrderList
:
data
,
defalutCoupon
:
defalutCoupon
,
defalutCouponId
:
defalutCouponId
,
couponSettingId
:
couponSettingId
,
orderInitPrice
:
data
.
amount
,
totalGoodsPrice
:
this
.
data
.
totalGoodsPrice
},
()
=>
{
// 实付款
this
.
setPayPrice
()
})
}
}
}
})
},
//跳转购买
handelGobuy
()
{
// 第一项 defalutCouponId couponId/
const
{
isSelect
,
defalutCoupon
,
trolleySku2Buy
,
couponId
,
couponSettingId
,
addressId
,
addressInfo
,
defalutCouponId
,
}
=
this
.
data
;
let
finCouponName
,
finCouponId
if
(
!
defalutCoupon
)
{
finCouponName
=
'couponId'
finCouponId
=
''
}
else
{
// 当前选中 哪一个id couponSettingId
// 默认券存在 id settingId
let
currentCouponId
// couponId / 第一项 id
if
(
defalutCouponId
)
{
finCouponId
=
defalutCouponId
finCouponName
=
'couponId'
}
else
{
currentCouponId
=
couponId
?
couponId
:
couponSettingId
finCouponName
=
couponId
?
'couponId'
:
'couponSettingId'
finCouponId
=
currentCouponId
}
}
let
params
=
{
[
finCouponName
]:
finCouponId
,
// couponId: couponId? couponId : defalutCouponId,
trolleySku2Buy
,
buyerRemark
:
this
.
data
.
buyerRemark
,
}
//判断是快递下单还是自提下单
let
province
=
[]
if
(
this
.
data
.
currentType
==
'delivery'
){
let
cityList
=
[]
params
.
orderType
=
1
;
let
district
=
[]
params
.
addressId
=
addressId
?
addressId
:
addressInfo
.
id
// 微信地址 or 地址id
cityData
.
forEach
((
item
)
=>
{
province
.
push
(
item
.
value
)
})
cityData
[
0
].
children
.
forEach
((
cityItem
)
=>
{
cityList
.
push
(
cityItem
.
value
)
cityItem
.
children
.
forEach
((
districtItem
)
=>
{
district
.
push
(
districtItem
.
value
)
})
})
//判断addressId是不是有
this
.
setData
({
if
(
!
params
.
addressId
)
{
citys
:
[
province
,
cityList
,
district
]
wx
.
showToast
({
title
:
'请添加地址或选择地址'
,
icon
:
'none'
})
})
return
;
},
}
bindMultiPickerChange
(
e
)
{
}
const
citys
=
this
.
data
.
citys
else
{
const
multiIndex
=
e
.
detail
.
value
params
.
orderType
=
4
;
if
(
citys
)
{
params
.
storeId
=
this
.
data
.
storeInfo
.
storeId
;
const
cityView
=
[
citys
[
0
][
multiIndex
[
0
]],
citys
[
1
][
multiIndex
[
1
]],
citys
[
2
][
multiIndex
[
2
]]].
join
(
' '
)
params
.
storeCode
=
this
.
data
.
storeInfo
.
storeCode
;
params
.
storeName
=
this
.
data
.
storeInfo
.
storeName
;
this
.
setData
({
if
(
!
params
.
storeId
){
multiIndex
,
wx
.
showToast
({
cityView
,
title
:
'门店自提需要选择门店'
,
'params.province'
:
citys
[
0
][
multiIndex
[
0
]],
icon
:
'none'
'params.city'
:
citys
[
1
][
multiIndex
[
1
]],
'params.district'
:
citys
[
2
][
multiIndex
[
2
]]
})
}
},
bindMultiPickerColumnChange
(
e
)
{
const
detail
=
e
.
detail
const
index
=
detail
.
value
let
cityName
=
''
let
cityData
=
city
.
default
let
province
=
[]
let
cityList
=
[]
let
district
=
[]
switch
(
detail
.
column
)
{
case
0
:
cityName
=
this
.
data
.
citys
[
0
][
index
]
this
.
data
.
selectCityName
[
0
]
=
cityName
cityData
.
forEach
((
item
)
=>
{
if
(
item
.
value
==
cityName
)
{
item
.
children
.
forEach
((
cityItem
)
=>
{
cityList
.
push
(
cityItem
.
value
)
cityItem
.
children
.
forEach
((
districtItem
)
=>
{
district
.
push
(
districtItem
.
value
)
})
})
}
})
this
.
setData
({
'citys[1]'
:
cityList
,
'citys[2]'
:
district
})
break
case
1
:
cityName
=
this
.
data
.
citys
[
1
][
index
]
this
.
data
.
selectCityName
[
1
]
=
cityName
cityData
.
forEach
((
item
)
=>
{
item
.
children
.
forEach
((
cityItem
)
=>
{
if
(
cityName
==
cityItem
.
value
)
{
cityItem
.
children
.
forEach
((
districtItem
)
=>
{
district
.
push
(
districtItem
.
value
)
})
}
})
})
this
.
setData
({
'citys[2]'
:
[...
district
]
})
break
default
:
break
}
},
//勾选购买vip时
handelChangeSelectVip
()
{
this
.
setData
({
isSelect
:
!
this
.
data
.
isSelect
},
()
=>
{
const
{
isSelect
}
=
this
.
data
this
.
setData
({
checkByPremium
:
isSelect
,
defalutCoupon
:
0
,
couponId
:
''
,
couponSettingId
:
''
,
defalutCouponId
:
''
},
()
=>
{
const
{
trolleySku2Buy
,
checkByPremium
,
addressId
,
addressInfo
}
=
this
.
data
let
params
=
{
checkByPremium
,
trolleySku2Buy
,
}
// 增加门店自提和快递配送判断
if
(
this
.
data
.
currentType
==
'delivery'
)
{
params
.
addressId
=
addressId
?
addressId
:
addressInfo
.
id
// 微信地址 or 地址id
params
.
orderType
=
1
;
}
else
{
params
.
orderType
=
4
;
params
.
storeId
=
this
.
data
.
storeInfo
.
storeId
;
}
this
.
calPreferentialPrice
(
params
)
// 重新计算优惠价
// 获取默认付费会员设置
this
.
getPremiumDefault
()
})
});
},
// /premium/getDefault
getPremiumDefault
()
{
wx
.
showLoading
({
title
:
'加载中'
})
})
return
;
wxService
.
get
(
`/sale/premium/getDefault`
).
then
(
res
=>
{
}
if
(
res
)
{
}
const
{
result
,
data
}
=
res
.
data
if
(
result
==
0
)
{
wx
.
hideLoading
()
this
.
setData
({
plusMemberPrice
:
data
.
price
,
plusMemberName
:
data
.
name
},
()
=>
{
// 实付款
this
.
setPayPrice
()
})
}
}
})
},
// 默认地址
selectAddress
()
{
wxService
.
router
(
'/pages/myAddress/myAddress?isFrom=order'
)
},
// 计算优惠价
calPreferentialPrice
(
params
)
{
wx
.
showLoading
({
title
:
'加载中'
});
this
.
getBill
(
params
)
// 下单
wxService
.
post
(
`/sale/trade/buyer/preview`
,
params
).
then
(
res
=>
{
},
if
(
res
)
{
// 下单
const
{
result
,
data
}
=
res
.
data
getBill
(
params
)
{
if
(
result
==
0
)
{
let
_this
=
this
;
wx
.
hideLoading
()
wx
.
showLoading
({
let
skuList
=
data
.
tradePreviewSkus
title
:
'正在下单..'
});
let
sum
=
0
skuList
.
forEach
((
item
,
index
)
=>
{
const
{
isSelect
}
=
this
.
data
;
// item.price
//增加订单备注信息
sum
+=
skuList
[
index
].
price
*
skuList
[
index
].
count
;
params
.
buyerRemark
=
this
.
data
.
buyerRemark
;
});
//下单之前先做校验
this
.
checkOrder
(
params
).
then
(
result
=>
{
this
.
data
.
totalGoodsPrice
=
sum
;
if
(
result
){
// 初始化商品价格
let
data
=
result
.
data
.
data
?
result
.
data
.
data
:
[];
const
{
isSelect
}
=
this
.
data
if
(
data
.
length
==
0
){
this
.
order
(
isSelect
,
params
);
if
(
isSelect
)
{
this
.
setData
({
selectPrice
:
sum
})
}
else
{
this
.
setData
({
noSelectPrice
:
sum
})
}
//获取优惠券信息
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
:
[];
// id / couponSettingId
this
.
setData
({
currentOrderList
:
data
,
defalutCoupon
:
defalutCoupon
,
defalutCouponId
:
defalutCouponId
,
couponSettingId
:
couponSettingId
,
orderInitPrice
:
data
.
amount
,
totalGoodsPrice
:
this
.
data
.
totalGoodsPrice
},
()
=>
{
// 实付款
this
.
setPayPrice
()
})
}
}
})
},
//跳转购买
handelGobuy
()
{
// 第一项 defalutCouponId couponId/
const
{
isSelect
,
defalutCoupon
,
trolleySku2Buy
,
couponId
,
couponSettingId
,
addressId
,
addressInfo
,
defalutCouponId
,
}
=
this
.
data
;
let
finCouponName
,
finCouponId
if
(
!
defalutCoupon
)
{
finCouponName
=
'couponId'
finCouponId
=
''
}
else
{
// 当前选中 哪一个id couponSettingId
// 默认券存在 id settingId
let
currentCouponId
// couponId / 第一项 id
if
(
defalutCouponId
)
{
finCouponId
=
defalutCouponId
finCouponName
=
'couponId'
}
else
{
currentCouponId
=
couponId
?
couponId
:
couponSettingId
finCouponName
=
couponId
?
'couponId'
:
'couponSettingId'
finCouponId
=
currentCouponId
}
}
}
else
{
//有商品限购了,组织提示语
let
params
=
{
let
tips
=
'根据限购规则以下商品限购:
\
r
\
n'
;
[
finCouponName
]:
finCouponId
,
let
tempObj
=
data
[
0
];
// couponId: couponId? couponId : defalutCouponId,
//每人限购
trolleySku2Buy
,
if
(
tempObj
.
limitType
==
1
){
buyerRemark
:
this
.
data
.
buyerRemark
,
tips
=
`商品"
${
tempObj
.
productName
}
"每人限购
${
tempObj
.
limitNum
}
件`
;
}
//每次限购
else
if
(
tempObj
.
limitType
==
2
){
tips
=
`商品"
${
tempObj
.
productName
}
"每次限购
${
tempObj
.
limitNum
}
件`
;
}
wx
.
showModal
({
title
:
'商品限购提醒'
,
content
:
tips
,
confirmText
:
'好的'
,
confirmColor
:
'#cb3c3c'
,
showCancel
:
false
,
success
(
confirm
){
if
(
confirm
.
confirm
){
wx
.
navigateBack
({
delta
:
1
});
}
},
})
}
}
}
});
},
//下单
order
(
isSelect
,
params
){
if
(
this
.
data
.
orderStoreInfo
){
if
(
this
.
data
.
orderStoreInfo
.
storeId
){
params
.
storeId
=
this
.
data
.
orderStoreInfo
.
storeId
;
}
if
(
this
.
data
.
orderStoreInfo
.
storeInfo
){
params
.
storeInfo
=
this
.
data
.
orderStoreInfo
.
storeInfo
;
}
}
let
_this
=
this
;
//判断是快递下单还是自提下单
let
url
=
isSelect
?
'/sale/payment/merged/buyer/bill'
:
'/sale/trade/buyer/bill'
if
(
this
.
data
.
currentType
==
'delivery'
)
{
wxService
.
post
(
`
${
url
}
`
,
params
).
then
(
res
=>
{
params
.
orderType
=
1
;
if
(
res
)
{
params
.
addressId
=
addressId
?
addressId
:
addressInfo
.
id
// 微信地址 or 地址id
const
{
result
,
data
}
=
res
.
data
wx
.
removeStorageSync
(
'choosedStoreInfo'
);
//判断addressId是不是有
wx
.
removeStorageSync
(
'orderRemark'
);
if
(
!
params
.
addressId
)
{
if
(
result
==
0
)
{
wx
.
showToast
({
delete
data
.
appId
title
:
'请添加地址或选择地址'
,
let
amount
=
data
.
amount
||
0
icon
:
'none'
wx
.
requestPayment
(
Object
.
assign
({
})
success
(
res
)
{
return
;
wx
.
hideLoading
()
// 支付成功页面
wx
.
redirectTo
({
url
:
`/subPackage/page/pages/paymentStatus/paymentStatus?status=S&amount=
${
amount
}
&type=
${
_this
.
data
.
currentType
}
`
,
});
},
fail
(
res
)
{
wx
.
hideLoading
();
wx
.
showToast
({
title
:
'支付已取消'
,
icon
:
'none'
});
if
(
_this
.
data
.
currentType
==
'delivery'
)
{
wx
.
redirectTo
({
url
:
'/pages/order/order'
,
});
}
else
{
wx
.
redirectTo
({
url
:
'/subPackage/page/pages/selfPickUpOrderList/selfPickUpOrderList'
,
});
}
}
}
},
data
.
wxParams
));
}
}
}
else
{
});
params
.
orderType
=
4
;
},
params
.
storeId
=
this
.
data
.
storeInfo
.
storeId
;
//校验订单中商品限购情况
params
.
storeCode
=
this
.
data
.
storeInfo
.
storeCode
;
checkOrder
(
params
){
params
.
storeName
=
this
.
data
.
storeInfo
.
storeName
;
return
wxService
.
post
(
`/sale/trade/buyer/bill/before/check`
,
params
);
if
(
!
params
.
storeId
)
{
},
wx
.
showToast
({
// 获取地址列表
title
:
'门店自提需要选择门店'
,
getAddressList
()
{
icon
:
'none'
const
{
memberId
}
=
wx
.
getStorageSync
(
'_baseUserInfo'
);
})
const
{
trolleySku2Buy
,
checkByPremium
}
=
this
.
data
;
return
;
let
params
=
{
checkByPremium
,
trolleySku2Buy
};
params
.
orderType
=
1
;
wxService
.
post
(
`/member/addressManage/getall`
,
{
userId
:
memberId
}).
then
(
res
=>
{
if
(
!
res
)
return
false
;
let
hasDefalut
=
wx
.
getStorageSync
(
'_defalutAddress'
);
let
{
result
,
data
}
=
res
.
data
if
(
result
==
0
)
{
//看看本地是不是有已经选择的地址了
if
(
!
hasDefalut
){
// 无
//看一下地址列表中是不是有默认地址
let
defaultInAddressList
=
null
;
data
=
data
?
data
:
[];
data
.
forEach
(
item
=>
{
item
.
fullArea
=
item
.
province
+
' '
+
item
.
city
+
' '
+
item
.
district
if
(
item
.
type
==
1
)
{
defaultInAddressList
=
item
}
}
});
if
(
defaultInAddressList
){
this
.
data
.
addressId
=
defaultInAddressList
?
defaultInAddressList
.
id
:
''
;
this
.
data
.
addressInfo
=
defaultInAddressList
;
params
.
addressId
=
this
.
data
.
addressId
;
}
this
.
setData
({
addressInfo
:
this
.
data
.
addressInfo
,
addressId
:
this
.
data
.
addressId
,
goodsAddress
:
params
.
addressId
?
false
:
true
,
});
}
}
else
{
// 有已经选择的地址了
let
defaultInAddressList
=
null
;
this
.
getBill
(
params
)
// 下单
//判断地址列表中是不是已经把这个地址删除了
},
let
id
=
hasDefalut
.
id
;
// 下单
let
filterArr
=
data
.
filter
(
item
=>
item
.
id
==
id
);
getBill
(
params
)
{
if
(
filterArr
.
length
>
0
)
{
let
_this
=
this
;
defaultInAddressList
=
hasDefalut
wx
.
showLoading
({
}
title
:
'正在下单..'
else
{
// 无
});
//此时已经没有 看看是不是有默认地址 有则默认选中
data
=
data
?
data
:
[];
const
{
isSelect
}
=
this
.
data
;
data
.
forEach
(
item
=>
{
//增加订单备注信息
item
.
fullArea
=
item
.
province
+
' '
+
item
.
city
+
' '
+
item
.
district
params
.
buyerRemark
=
this
.
data
.
buyerRemark
;
if
(
item
.
type
==
1
)
{
//下单之前先做校验
defaultInAddressList
=
item
this
.
checkOrder
(
params
).
then
(
result
=>
{
}
if
(
result
)
{
});
let
data
=
result
.
data
.
data
?
result
.
data
.
data
:
[];
}
if
(
data
.
length
==
0
)
{
this
.
order
(
isSelect
,
params
);
if
(
defaultInAddressList
)
{
}
this
.
data
.
addressId
=
defaultInAddressList
?
defaultInAddressList
.
id
:
''
;
else
{
this
.
data
.
addressInfo
=
defaultInAddressList
;
//有商品限购了,组织提示语
params
.
addressId
=
this
.
data
.
addressId
;
let
tips
=
'根据限购规则以下商品限购:
\
r
\
n'
;
}
let
tempObj
=
data
[
0
];
//每人限购
this
.
setData
({
if
(
tempObj
.
limitType
==
1
)
{
addressInfo
:
this
.
data
.
addressInfo
,
tips
=
`商品"
${
tempObj
.
productName
}
"每人限购
${
tempObj
.
limitNum
}
件`
;
addressId
:
this
.
data
.
addressId
,
}
goodsAddress
:
params
.
addressId
?
false
:
true
,
//每次限购
});
else
if
(
tempObj
.
limitType
==
2
)
{
tips
=
`商品"
${
tempObj
.
productName
}
"每次限购
${
tempObj
.
limitNum
}
件`
;
}
wx
.
showModal
({
title
:
'商品限购提醒'
,
content
:
tips
,
confirmText
:
'好的'
,
confirmColor
:
'#cb3c3c'
,
showCancel
:
false
,
success
(
confirm
)
{
if
(
confirm
.
confirm
)
{
wx
.
navigateBack
({
delta
:
1
});
}
},
})
}
}
});
},
//下单
order
(
isSelect
,
params
)
{
if
(
this
.
data
.
orderStoreInfo
)
{
if
(
this
.
data
.
orderStoreInfo
.
storeId
)
{
params
.
storeId
=
this
.
data
.
orderStoreInfo
.
storeId
;
}
if
(
this
.
data
.
orderStoreInfo
.
storeInfo
)
{
params
.
storeInfo
=
this
.
data
.
orderStoreInfo
.
storeInfo
;
}
}
}
this
.
calPreferentialPrice
(
params
)
let
_this
=
this
;
}
let
url
=
isSelect
?
'/sale/payment/merged/buyer/bill'
:
'/sale/trade/buyer/bill'
}).
finally
(()
=>
{});
wxService
.
post
(
`
${
url
}
`
,
params
).
then
(
res
=>
{
},
if
(
res
)
{
//获取微信地址
const
{
result
,
data
}
=
res
.
data
chooseWxAddress
()
{
let
tradeId
=
data
.
tradeId
;
const
{
memberId
}
=
wx
.
getStorageSync
(
'_baseUserInfo'
)
wx
.
removeStorageSync
(
'choosedStoreInfo'
);
wx
.
chooseAddress
({
wx
.
removeStorageSync
(
'orderRemark'
);
success
:
(
res
)
=>
{
if
(
result
==
0
)
{
res
.
name
=
res
.
userName
delete
data
.
appId
res
.
phone
=
res
.
telNumber
let
amount
=
data
.
amount
||
0
res
.
fullArea
=
res
.
provinceName
+
res
.
cityName
+
res
.
countyName
wx
.
requestPayment
(
Object
.
assign
({
res
.
address
=
res
.
detailInfo
success
(
res
)
{
this
.
setData
({
wx
.
hideLoading
()
goodsAddress
:
false
,
// 支付成功页面
wxAddress
:
true
,
let
baseUserInfo
=
wx
.
getStorageSync
(
'_baseUserInfo'
);
addressInfo
:
res
,
wxService
.
post
(
`
${
'/merchant/message/wxSubMsgMapping/getListByParams'
}
`
,
{
params
:
{
scenarioIds
:
[
'ordersend'
,
'ordersign'
],
userId
:
memberId
,
sourceFrom
:
2
,
name
:
res
.
userName
,
switchType
:
3
phone
:
res
.
telNumber
,
}).
then
(
res
=>
{
province
:
res
.
provinceName
,
let
tempArr
=
res
.
data
.
data
;
city
:
res
.
cityName
,
let
tempids
=
[];
district
:
res
.
countyName
,
tempArr
.
map
(
item
=>
{
address
:
res
.
detailInfo
,
tempids
.
push
(
item
.
templateId
);
type
:
0
})
}
wx
.
requestSubscribeMessage
({
tmplIds
:
tempids
,
success
:
(
res
)
=>
{
for
(
let
i
=
0
;
i
<
tempArr
.
length
;
i
++
){
wxService
.
post
(
`
${
'/merchant/message/wxSubMsgSubscride/member/subscribe'
}
`
,
{
businessId
:
tradeId
,
memberId
:
baseUserInfo
.
memberId
,
scenarioId
:
tempArr
[
i
].
scenarioId
,
templateId
:
tempArr
[
i
].
templateId
}).
then
(
resp
=>
{
})
}
},
complete
:
(
res
)
=>
{
wx
.
redirectTo
({
url
:
`/subPackage/page/pages/paymentStatus/paymentStatus?status=S&amount=
${
amount
}
&type=
${
_this
.
data
.
currentType
}
`
,
});
}
})
})
},
fail
(
res
)
{
wx
.
hideLoading
();
wx
.
showToast
({
title
:
'支付已取消'
,
icon
:
'none'
});
if
(
_this
.
data
.
currentType
==
'delivery'
)
{
wx
.
redirectTo
({
url
:
'/pages/order/order'
,
});
}
else
{
wx
.
redirectTo
({
url
:
'/subPackage/page/pages/selfPickUpOrderList/selfPickUpOrderList'
,
});
}
}
},
data
.
wxParams
));
}
}
});
});
},
//校验订单中商品限购情况
checkOrder
(
params
)
{
return
wxService
.
post
(
`/sale/trade/buyer/bill/before/check`
,
params
);
},
// 获取地址列表
getAddressList
()
{
const
{
memberId
}
=
wx
.
getStorageSync
(
'_baseUserInfo'
);
const
{
trolleySku2Buy
,
checkByPremium
}
=
this
.
data
;
let
params
=
{
checkByPremium
,
trolleySku2Buy
};
params
.
orderType
=
1
;
wxService
.
post
(
`/member/addressManage/getall`
,
{
userId
:
memberId
}).
then
(
res
=>
{
if
(
!
res
)
return
false
;
let
hasDefalut
=
wx
.
getStorageSync
(
'_defalutAddress'
);
let
{
result
,
data
}
=
res
.
data
if
(
result
==
0
)
{
//看看本地是不是有已经选择的地址了
if
(
!
hasDefalut
)
{
// 无
//看一下地址列表中是不是有默认地址
let
defaultInAddressList
=
null
;
data
=
data
?
data
:
[];
data
.
forEach
(
item
=>
{
item
.
fullArea
=
item
.
province
+
' '
+
item
.
city
+
' '
+
item
.
district
if
(
item
.
type
==
1
)
{
defaultInAddressList
=
item
}
});
if
(
defaultInAddressList
)
{
this
.
data
.
addressId
=
defaultInAddressList
?
defaultInAddressList
.
id
:
''
;
this
.
data
.
addressInfo
=
defaultInAddressList
;
params
.
addressId
=
this
.
data
.
addressId
;
}
this
.
setData
({
addressInfo
:
this
.
data
.
addressInfo
,
addressId
:
this
.
data
.
addressId
,
goodsAddress
:
params
.
addressId
?
false
:
true
,
});
}
else
{
// 有已经选择的地址了
let
defaultInAddressList
=
null
;
//判断地址列表中是不是已经把这个地址删除了
let
id
=
hasDefalut
.
id
;
let
filterArr
=
data
.
filter
(
item
=>
item
.
id
==
id
);
if
(
filterArr
.
length
>
0
)
{
defaultInAddressList
=
hasDefalut
}
else
{
// 无
//此时已经没有 看看是不是有默认地址 有则默认选中
data
=
data
?
data
:
[];
data
.
forEach
(
item
=>
{
item
.
fullArea
=
item
.
province
+
' '
+
item
.
city
+
' '
+
item
.
district
if
(
item
.
type
==
1
)
{
defaultInAddressList
=
item
}
});
}
if
(
defaultInAddressList
)
{
this
.
data
.
addressId
=
defaultInAddressList
?
defaultInAddressList
.
id
:
''
;
this
.
data
.
addressInfo
=
defaultInAddressList
;
params
.
addressId
=
this
.
data
.
addressId
;
}
this
.
setData
({
addressInfo
:
this
.
data
.
addressInfo
,
addressId
:
this
.
data
.
addressId
,
goodsAddress
:
params
.
addressId
?
false
:
true
,
});
}
this
.
calPreferentialPrice
(
params
)
}
}).
finally
(()
=>
{
});
},
//获取微信地址
chooseWxAddress
()
{
const
{
memberId
}
=
wx
.
getStorageSync
(
'_baseUserInfo'
)
wx
.
chooseAddress
({
success
:
(
res
)
=>
{
res
.
name
=
res
.
userName
res
.
phone
=
res
.
telNumber
res
.
fullArea
=
res
.
provinceName
+
res
.
cityName
+
res
.
countyName
res
.
address
=
res
.
detailInfo
this
.
setData
({
goodsAddress
:
false
,
wxAddress
:
true
,
addressInfo
:
res
,
params
:
{
userId
:
memberId
,
name
:
res
.
userName
,
phone
:
res
.
telNumber
,
province
:
res
.
provinceName
,
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
)
{
console
.
log
(
err
)
}
})
})
},
//选择优惠券
},
selectCoupon
()
{
fail
:
function
(
err
)
{
this
.
setData
({
console
.
log
(
err
)
showSelectCoupon
:
true
}
})
})
}
},
//选择优惠券
selectCoupon
()
{
this
.
setData
({
showSelectCoupon
:
true
})
}
});
});
\ No newline at end of file
src/pages/confirmOrder/confirmOrder.wxml
View file @
cacf36db
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
data-type="selfPickUp" bindtap="onTapChangeType">门店自提</view>
data-type="selfPickUp" bindtap="onTapChangeType">门店自提</view>
</view>
</view>
<form
bindsubmit="formSubmit"
>
<form>
<!-- 快递地址 -->
<!-- 快递地址 -->
<view class="address-wrap" wx:if="{{currentType == 'delivery'}}">
<view class="address-wrap" wx:if="{{currentType == 'delivery'}}">
<block wx:if="{{goodsAddress}}">
<block wx:if="{{goodsAddress}}">
...
@@ -244,7 +244,7 @@
...
@@ -244,7 +244,7 @@
<text class="cost-label">实付款:</text>
<text class="cost-label">实付款:</text>
<text class="cost-price">¥{{utils.numberFormat(orderPrice)}}</text>
<text class="cost-price">¥{{utils.numberFormat(orderPrice)}}</text>
</view>
</view>
<button
form-type="s
ubmit" class="theme-color">立即购买</button>
<button
bind:tap="formS
ubmit" class="theme-color">立即购买</button>
</view>
</view>
</form>
</form>
</view>
</view>
...
...
src/pages/refund/refund.js
View file @
cacf36db
...
@@ -6,318 +6,350 @@ const envInfo = require('../../config/index').envInfo
...
@@ -6,318 +6,350 @@ const envInfo = require('../../config/index').envInfo
wxService
.
page
({
wxService
.
page
({
/**
data
:
{
* 页面的初始数据
imageDomain
:
''
,
*/
refundCreateDto
:
{
data
:
{
reason
:
""
,
// 原因
imageDomain
:
''
,
skuList
:
[],
refundCreateDto
:
{
tradeId
:
0
,
reason
:
""
,
// 原因
proofImgUrls
:
[]
//凭证
skuList
:
[],
},
tradeId
:
0
,
refundMark
:
''
,
proofImgUrls
:
[]
//凭证
cartList
:
[],
curType
:
{
// 当前选择原因
value
:
0
,
name
:
'请选择'
},
// 所有退货原因
resonType
:
[],
refundAmount
:
0
,
checkedColor
:
'rgb(203, 60, 60)'
,
pics
:
[],
id
:
''
,
returnOrder
:
0
},
},
refundMark
:
''
,
submitRefund
()
{
cartList
:
[],
var
selectGoods
=
this
.
data
.
cartList
.
filter
(
item
=>
item
.
checked
)
curType
:
{
// 当前选择原因
if
(
selectGoods
.
length
==
0
)
{
value
:
0
,
wx
.
showToast
({
name
:
'请选择'
title
:
'请选择退款商品'
,
icon
:
'none'
})
return
false
}
if
(
this
.
data
.
curType
.
value
==
0
)
{
wx
.
showToast
({
title
:
'请选择退款原因'
,
icon
:
'none'
})
return
false
}
let
skulist
=
[];
selectGoods
.
forEach
(
item
=>
{
const
{
skuId
,
count
}
=
item
;
skulist
.
push
({
skuId
,
count
})
});
this
.
reFundPreview
({
tradeId
:
this
.
data
.
id
,
skuList
:
skulist
})
var
refundCreateDto
=
this
.
data
.
refundCreateDto
refundCreateDto
.
reason
=
this
.
data
.
curType
.
name
// 退款原因
refundCreateDto
.
remark
=
this
.
data
.
refundMark
// 说明备注
refundCreateDto
.
skuList
=
selectGoods
.
map
(
function
(
item
)
{
return
{
amount
:
item
.
amount
,
count
:
item
.
count
,
skuId
:
item
.
skuId
}
})
this
.
handelRequestRefund
(
refundCreateDto
)
},
},
// 所有退货原因
//创建退款
resonType
:
[],
handelRequestRefund
(
params
)
{
refundAmount
:
0
,
let
_self
=
this
;
checkedColor
:
'rgb(203, 60, 60)'
,
wx
.
showLoading
({
pics
:
[],
title
:
'加载中'
,
id
:
''
,
mask
:
true
returnOrder
:
0
})
},
wxService
.
post
(
'/sale/refund/buyer/create'
,
params
).
then
(
res
=>
{
submitRefund
()
{
if
(
res
)
{
var
selectGoods
=
this
.
data
.
cartList
.
filter
(
item
=>
item
.
checked
)
const
{
result
,
data
}
=
res
.
data
if
(
selectGoods
.
length
==
0
)
{
if
(
result
==
0
)
{
wx
.
showToast
({
wx
.
hideLoading
()
title
:
'请选择退款商品'
,
icon
:
'none'
})
return
false
}
if
(
this
.
data
.
curType
.
value
==
0
)
{
wx
.
showToast
({
title
:
'请选择退款原因'
,
icon
:
'none'
})
return
false
}
let
skulist
=
[];
let
baseUserInfo
=
wx
.
getStorageSync
(
'_baseUserInfo'
);
selectGoods
.
forEach
(
item
=>
{
wxService
.
post
(
`
${
'/merchant/message/wxSubMsgMapping/getListByParams'
}
`
,
{
const
{
skuId
,
count
}
=
item
;
scenarioIds
:
[
'orderrefundfinsh'
,
'orderrefundcheck'
],
skulist
.
push
({
sourceFrom
:
2
,
skuId
,
switchType
:
3
count
}).
then
(
res
=>
{
})
let
tempArr
=
res
.
data
.
data
;
});
let
tempids
=
[];
tempArr
.
map
(
item
=>
{
tempids
.
push
(
item
.
templateId
);
})
wx
.
requestSubscribeMessage
({
tmplIds
:
tempids
,
success
:
(
res
)
=>
{
for
(
let
i
=
0
;
i
<
tempArr
.
length
;
i
++
){
wxService
.
post
(
`
${
'/merchant/message/wxSubMsgSubscride/member/subscribe'
}
`
,
{
businessId
:
_self
.
data
.
id
,
memberId
:
baseUserInfo
.
memberId
,
scenarioId
:
tempArr
[
i
].
scenarioId
,
templateId
:
tempArr
[
i
].
templateId
}).
then
(
resp
=>
{
})
}
},
complete
:
(
res
)
=>
{
wx
.
showToast
({
title
:
'申请退款成功'
,
});
// 订单列表
setTimeout
(()
=>
{
// wxService.router(`/pages/order/order`).search({params})
wx
.
navigateBack
({
delta
:
1
});
},
2000
)
}
})
})
this
.
reFundPreview
({
tradeId
:
this
.
data
.
id
,
skuList
:
skulist
})
var
refundCreateDto
=
this
.
data
.
refundCreateDto
refundCreateDto
.
reason
=
this
.
data
.
curType
.
name
// 退款原因
refundCreateDto
.
remark
=
this
.
data
.
refundMark
// 说明备注
refundCreateDto
.
skuList
=
selectGoods
.
map
(
function
(
item
)
{
return
{
amount
:
item
.
amount
,
}
count
:
item
.
count
,
}
skuId
:
item
.
skuId
})
}
})
},
this
.
handelRequestRefund
(
refundCreateDto
)
//获取退款原因列表
},
getReasonList
()
{
//创建退款
wx
.
showLoading
({
handelRequestRefund
(
params
)
{
title
:
'加载中'
,
wx
.
showLoading
({
mask
:
true
title
:
'加载中'
,
})
mask
:
true
const
refundReason
=
{}
})
wxService
.
post
(
'/sale/refund/reason/buyer/sortAll'
,
refundReason
).
then
(
res
=>
{
wxService
.
post
(
'/sale/refund/buyer/create'
,
params
).
then
(
res
=>
{
if
(
res
)
{
if
(
res
)
{
const
{
result
,
data
}
=
res
.
data
const
{
result
,
data
}
=
res
.
data
if
(
result
==
0
)
{
if
(
result
==
0
)
{
wx
.
hideLoading
()
wx
.
hideLoading
()
wx
.
showToast
({
let
newReasonList
=
[];
title
:
'申请退款成功'
,
data
.
forEach
((
item
,
index
)
=>
{
});
const
{
reason
}
=
item
;
// 订单列表
newReasonList
.
push
({
setTimeout
(()
=>
{
name
:
reason
,
// wxService.router(`/pages/order/order`).search({params})
value
:
index
+
1
wx
.
navigateBack
({
})
delta
:
1
});
});
this
.
setData
({
},
2000
)
resonType
:
newReasonList
})
}
}
})
},
// 上传图片
_uploadImg
(
e
)
{
if
(
e
.
detail
)
{
this
.
data
.
refundCreateDto
.
proofImgUrls
.
push
(
e
.
detail
)
this
.
setData
({
'refundCreateDto.proofImgUrls'
:
this
.
data
.
refundCreateDto
.
proofImgUrls
})
}
}
}
},
})
},
checkPro
(
e
)
{
//获取退款原因列表
var
index
=
e
.
currentTarget
.
dataset
.
index
getReasonList
()
{
const
{
cartList
}
=
this
.
data
wx
.
showLoading
({
if
(
cartList
[
index
].
checked
)
{
title
:
'加载中'
,
cartList
[
index
].
checked
=
false
mask
:
true
}
else
{
})
cartList
[
index
].
checked
=
true
const
refundReason
=
{}
}
wxService
.
post
(
'/sale/refund/reason/buyer/sortAll'
,
refundReason
).
then
(
res
=>
{
this
.
setData
({
if
(
res
)
{
cartList
const
{
result
,
data
}
=
res
.
data
},
()
=>
{
if
(
result
==
0
)
{
this
.
getReturnPrice
()
wx
.
hideLoading
()
})
},
changeRemark
(
event
)
{
// 备注
this
.
setData
({
refundMark
:
event
.
detail
.
value
})
},
selectType
:
function
(
event
)
{
// 选择退货类型
this
.
setData
({
curType
:
this
.
data
.
resonType
[
event
.
detail
.
value
]
})
},
minusNum
:
function
(
e
)
{
// 减少数量
var
cartList
=
this
.
data
.
cartList
var
index
=
e
.
currentTarget
.
dataset
.
index
let
proNum
=
cartList
[
index
].
count
let
newReasonList
=
[];
if
(
proNum
>
1
)
{
data
.
forEach
((
item
,
index
)
=>
{
proNum
--
const
{
reason
}
=
item
;
}
else
{
newReasonList
.
push
({
wx
.
showToast
({
name
:
reason
,
title
:
'数量不能为0'
,
value
:
index
+
1
icon
:
'none'
})
})
});
return
false
this
.
setData
({
}
resonType
:
newReasonList
cartList
[
index
].
count
=
proNum
})
this
.
setData
({
cartList
:
cartList
},
()
=>
{
this
.
getReturnPrice
()
this
.
editOk
(
cartList
[
index
])
//调用完成
})
},
//新增数量
addNum
:
function
(
e
)
{
// 增加数量
var
index
=
e
.
currentTarget
.
dataset
.
index
var
cartList
=
this
.
data
.
cartList
var
proNum
=
cartList
[
index
].
count
;
if
(
proNum
<
cartList
[
index
].
canRefundNum
)
{
proNum
++
}
else
{
wx
.
showToast
({
title
:
'退单数量不能大于当前商品购买数量'
,
icon
:
'none'
});
return
;
}
}
}
})
},
// 上传图片
_uploadImg
(
e
)
{
if
(
e
.
detail
)
{
this
.
data
.
refundCreateDto
.
proofImgUrls
.
push
(
e
.
detail
)
this
.
setData
({
'refundCreateDto.proofImgUrls'
:
this
.
data
.
refundCreateDto
.
proofImgUrls
})
}
},
checkPro
(
e
)
{
cartList
[
index
].
count
=
proNum
var
index
=
e
.
currentTarget
.
dataset
.
index
this
.
setData
({
const
{
cartList
}
=
this
.
data
cartList
:
cartList
if
(
cartList
[
index
].
checked
)
{
},
()
=>
{
cartList
[
index
].
checked
=
false
this
.
getReturnPrice
()
}
else
{
this
.
editOk
(
cartList
[
index
])
//调用完成
cartList
[
index
].
checked
=
true
})
}
this
.
setData
({
cartList
},()
=>
{
this
.
getReturnPrice
()
})
},
changeRemark
(
event
)
{
// 备注
this
.
setData
({
refundMark
:
event
.
detail
.
value
})
},
selectType
:
function
(
event
)
{
// 选择退货类型
this
.
setData
({
curType
:
this
.
data
.
resonType
[
event
.
detail
.
value
]
})
},
minusNum
:
function
(
e
)
{
// 减少数量
var
cartList
=
this
.
data
.
cartList
var
index
=
e
.
currentTarget
.
dataset
.
index
let
proNum
=
cartList
[
index
].
count
if
(
proNum
>
1
)
{
},
proNum
--
blurNum
:
function
(
e
)
{
// 输入数量
}
else
{
var
newNum
=
e
.
detail
.
value
wx
.
showToast
({
var
cartList
=
this
.
data
.
cartList
title
:
'数量不能为0'
,
var
index
=
e
.
currentTarget
.
dataset
.
index
icon
:
'none'
var
refundNum
=
cartList
[
index
].
count
})
return
false
}
cartList
[
index
].
count
=
proNum
this
.
setData
({
cartList
:
cartList
},
()
=>
{
this
.
getReturnPrice
()
this
.
editOk
(
cartList
[
index
])
//调用完成
})
},
//新增数量
addNum
:
function
(
e
)
{
// 增加数量
var
index
=
e
.
currentTarget
.
dataset
.
index
var
cartList
=
this
.
data
.
cartList
var
proNum
=
cartList
[
index
].
count
;
if
(
proNum
<
cartList
[
index
].
canRefundNum
){
proNum
++
}
else
{
wx
.
showToast
({
title
:
'退单数量不能大于当前商品购买数量'
,
icon
:
'none'
});
return
;
}
cartList
[
index
].
count
=
proNum
if
(
newNum
===
''
||
newNum
===
'0'
)
{
this
.
setData
({
newNum
=
1
cartList
:
cartList
}
else
{
},
()
=>
{
newNum
=
parseInt
(
newNum
)
this
.
getReturnPrice
()
if
(
newNum
>
refundNum
)
{
this
.
editOk
(
cartList
[
index
])
//调用完成
newNum
=
refundNum
})
}
else
{
newNum
=
newNum
}
}
cartList
[
index
].
count
=
newNum
},
this
.
setData
({
blurNum
:
function
(
e
)
{
// 输入数量
cartList
:
cartList
var
newNum
=
e
.
detail
.
value
},
()
=>
{
var
cartList
=
this
.
data
.
cartList
this
.
getReturnPrice
()
var
index
=
e
.
currentTarget
.
dataset
.
index
this
.
editOk
(
cartList
[
index
])
//调用完成
var
refundNum
=
cartList
[
index
].
count
})
},
editOk
(
cartPro
)
{
let
skulist
=
[];
const
{
skuId
,
count
}
=
cartPro
;
skulist
.
push
({
skuId
,
count
})
if
(
newNum
===
''
||
newNum
===
'0'
)
{
this
.
reFundPreview
({
newNum
=
1
tradeId
:
this
.
data
.
id
,
}
else
{
skuList
:
skulist
newNum
=
parseInt
(
newNum
)
})
// 退款预览
if
(
newNum
>
refundNum
)
{
},
newNum
=
refundNum
getReturnPrice
()
{
}
else
{
var
cartList
=
this
.
data
.
cartList
newNum
=
newNum
var
returnPrice
=
0
}
}
cartList
[
index
].
count
=
newNum
this
.
setData
({
for
(
let
i
=
0
;
i
<
cartList
.
length
;
i
++
)
{
cartList
:
cartList
if
(
cartList
[
i
].
checked
)
{
},
()
=>
{
returnPrice
+=
cartList
[
i
].
paySkuPrice
*
(
cartList
[
i
].
count
?
cartList
[
i
].
count
:
1
)
this
.
getReturnPrice
()
}
this
.
editOk
(
cartList
[
index
])
//调用完成
}
})
},
editOk
(
cartPro
){
let
skulist
=
[];
const
{
skuId
,
count
}
=
cartPro
;
skulist
.
push
({
skuId
,
count
})
this
.
reFundPreview
({
tradeId
:
this
.
data
.
id
,
skuList
:
skulist
})
// 退款预览
},
getReturnPrice
()
{
var
cartList
=
this
.
data
.
cartList
var
returnPrice
=
0
for
(
let
i
=
0
;
i
<
cartList
.
length
;
i
++
)
{
let
tempPrice
=
parseInt
(
returnPrice
*
100
);
if
(
cartList
[
i
].
checked
)
{
returnPrice
+=
cartList
[
i
].
paySkuPrice
*
(
cartList
[
i
].
count
?
cartList
[
i
].
count
:
1
)
}
}
let
tempPrice
=
parseInt
(
returnPrice
*
100
);
this
.
setData
({
returnOrder
:
parseFloat
(
tempPrice
/
100
).
toFixed
(
2
)
})
},
this
.
setData
({
/**
returnOrder
:
parseFloat
(
tempPrice
/
100
).
toFixed
(
2
)
* 生命周期函数--监听页面加载
})
*/
},
onLoad
:
function
(
options
)
{
wx
.
hideShareMenu
();
const
{
params
}
=
options
;
let
detail
=
JSON
.
parse
(
params
)
/**
// item.checked
* 生命周期函数--监听页面加载
detail
.
skuVOList
.
forEach
(
item
=>
{
*/
item
.
checked
=
false
;
onLoad
:
function
(
options
)
{
let
paySkuPrice
=
parseInt
(
item
.
amount
*
100
/
item
.
totalCount
);
wx
.
hideShareMenu
();
item
.
paySkuPrice
=
(
paySkuPrice
/
100
).
toFixed
(
2
);
const
{
params
}
=
options
;
});
let
detail
=
JSON
.
parse
(
params
)
// item.checked
detail
.
skuVOList
.
forEach
(
item
=>
{
item
.
checked
=
false
;
let
paySkuPrice
=
parseInt
(
item
.
amount
*
100
/
item
.
totalCount
);
item
.
paySkuPrice
=
(
paySkuPrice
/
100
).
toFixed
(
2
);
});
this
.
setData
({
this
.
setData
({
id
:
detail
.
id
,
id
:
detail
.
id
,
cartList
:
detail
.
skuVOList
,
cartList
:
detail
.
skuVOList
,
refundAmount
:
detail
.
payAmount
,
refundAmount
:
detail
.
payAmount
,
'refundCreateDto.tradeId'
:
detail
.
id
'refundCreateDto.tradeId'
:
detail
.
id
},
()
=>
{
},
()
=>
{
// 退款原因列表 /refund/reason/buyer/sortAll
// 退款原因列表 /refund/reason/buyer/sortAll
this
.
getReasonList
()
this
.
getReasonList
()
})
})
},
},
/**
/**
* 生命周期函数--监听页面初次渲染完成
* 生命周期函数--监听页面初次渲染完成
*/
*/
onReady
:
function
()
{
onReady
:
function
()
{
},
},
/**
* 生命周期函数--监听页面显示
*/
onShow
:
function
()
{
},
//退款prever
reFundPreview
(
cartPro
=
{})
{
const
params
=
{
...
cartPro
}
wx
.
showLoading
({
title
:
'加载中'
,
mask
:
true
})
wxService
.
post
(
`/sale/refund/buyer/preview`
,
params
).
then
(
res
=>
{
if
(
res
)
{
const
{
result
,
data
}
=
res
.
data
if
(
result
==
0
)
{
wx
.
hideLoading
()
}
}
})
},
/**
* 生命周期函数--监听页面显示
*/
onShow
:
function
()
{
},
//退款prever
reFundPreview
(
cartPro
=
{})
{
const
params
=
{...
cartPro
}
wx
.
showLoading
({
title
:
'加载中'
,
mask
:
true
})
wxService
.
post
(
`/sale/refund/buyer/preview`
,
params
).
then
(
res
=>
{
if
(
res
)
{
const
{
result
,
data
}
=
res
.
data
if
(
result
==
0
)
{
wx
.
hideLoading
()
}
}
})
},
});
});
\ No newline at end of file
src/project.config.json
View file @
cacf36db
...
@@ -43,7 +43,7 @@
...
@@ -43,7 +43,7 @@
"list"
:
[]
"list"
:
[]
},
},
"miniprogram"
:
{
"miniprogram"
:
{
"current"
:
80
,
"current"
:
-1
,
"list"
:
[
"list"
:
[
{
{
"id"
:
-1
,
"id"
:
-1
,
...
@@ -149,7 +149,7 @@
...
@@ -149,7 +149,7 @@
"id"
:
16
,
"id"
:
16
,
"name"
:
"商品详情页"
,
"name"
:
"商品详情页"
,
"pathName"
:
"pages/productDetail/productDetail"
,
"pathName"
:
"pages/productDetail/productDetail"
,
"query"
:
"id=6
86861371018723328
"
,
"query"
:
"id=6
47096699302580224
"
,
"scene"
:
null
"scene"
:
null
},
},
{
{
...
...
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