Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
dj-car-boutique-work-wechat
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
1
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 57d4c042
authored
Jun 30, 2026
by
张立顺
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix bug
1 parent
de8bdac7
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
380 additions
and
118 deletions
components/CustomerInfo/CustomerInfo.js
components/CustomerInfo/CustomerInfo.wxml
components/CustomerInfo/CustomerInfo.wxss
components/CustomerInfo/customerInfo.pagination.js
packageDynamicForm/services/today-plan-date.js
packageDynamicForm/tests/today-plan-date.test.mjs
tabWorkOrder/pages/createOrder/createOrder.wxml
tabWorkOrder/pages/createOrder/createOrderPageLock.wxs
tabWorkOrder/pages/createOrder/services/pagePopupLock.js
tabWorkOrder/pages/createOrder/tests/pagePopupLock.test.mjs
tests/customerInfo.pagination.test.mjs
components/CustomerInfo/CustomerInfo.js
View file @
57d4c04
// components/CarBrands/CarBrands.js
/**
* @file 客户档案选择弹框:分页拉取工单客户列表,不调 setData 外的页面实例。
*/
import
api
from
'../../api/api.js'
import
api
from
'../../api/api.js'
// import carLifeApi from '~/packageEquity/carEquityApi'
const
{
DEFAULT_PAGE_SIZE
,
canLoadMorePage
,
mapCustomerListWithCarType
}
=
require
(
'./customerInfo.pagination.js'
)
let
isNum
,
num
,
y
,
time
Component
({
Component
({
/**
* 组件的属性列表
*/
properties
:
{
properties
:
{
show
:
{
show
:
{
type
:
Boolean
,
type
:
Boolean
,
observer
:
function
(
n
)
{
observer
(
n
)
{
let
{
if
(
n
)
{
isFirst
wx
.
$util
.
pointRecord
(
19
)
}
=
this
.
data
n
&&
wx
.
$util
.
pointRecord
(
19
)
if
(
n
&&
isFirst
)
{
this
.
init
()
this
.
init
()
this
.
setData
({
return
isFirst
:
false
})
}
}
this
.
resetList
()
this
.
setData
({
orderInfo
:
{}
})
}
}
},
},
merchantId
:
{
merchantId
:
{
type
:
Number
,
type
:
Number
,
observer
:
function
(
n
)
{
observer
(
n
)
{
if
(
n
)
{
if
(
n
)
{
// 销售顾问切换门店
获取新的
顾客数据
// 销售顾问切换门店
时重新拉取
顾客数据
this
.
init
()
this
.
init
()
}
}
}
}
...
@@ -35,115 +34,157 @@ Component({
...
@@ -35,115 +34,157 @@ Component({
apiType
:
Number
apiType
:
Number
},
},
/**
* 组件的初始数据
*/
data
:
{
data
:
{
orderInfo
:
{},
orderInfo
:
{},
// storageData: null,
customerList
:
[],
customerList
:
[],
isFirst
:
true
pageNum
:
1
,
total
:
0
,
nothing
:
false
,
keyword
:
''
,
loading
:
false
},
},
pageLifetimes
:
{
pageLifetimes
:
{
show
:
function
()
{
},
show
()
{
},
hide
:
function
()
{
}
hide
()
{
}
},
},
/**
* 组件的方法列表
*/
methods
:
{
methods
:
{
/** 阻止弹框列表滚到底后 touchmove 穿透到底层页面 */
noScroll
()
{},
/**
* 首次打开 / 搜索 / 切换门店入口,重置后加载第一页
* @param {string} [keyword] 搜索关键字
*/
init
(
keyword
)
{
init
(
keyword
)
{
// console.log('getBrandList')
const
{
apiType
}
=
this
.
data
// console.log(storageData)
if
(
apiType
==
2
)
{
let
{
this
.
loadCustomerFileList
(
keyword
)
merchantId
,
return
apiType
}
}
=
this
.
data
this
.
resetList
(
keyword
)
let
userInfo
=
wx
.
$util
.
getUserInfo
()
this
.
loadList
()
let
params
=
{
},
merchantId
:
merchantId
||
userInfo
?.
shopMerchantId
,
pageSize
:
999999
,
/**
* 重置分页状态(搜索或重新筛选时)
* @param {string} [keyword]
*/
resetList
(
keyword
=
''
)
{
this
.
setData
({
pageNum
:
1
,
pageNum
:
1
,
// upgradeFinishFlag: 'R',
total
:
0
,
nothing
:
false
,
keyword
:
keyword
||
''
,
customerList
:
[]
})
},
/**
* 按当前 pageNum 请求一页并追加到 customerList
*/
loadList
()
{
const
{
merchantId
,
pageNum
,
keyword
,
loading
}
=
this
.
data
if
(
loading
)
return
const
userInfo
=
wx
.
$util
.
getUserInfo
()
const
params
=
{
merchantId
:
merchantId
||
userInfo
?.
shopMerchantId
,
pageNum
,
pageSize
:
20
,
statusList
:
[
1
],
statusList
:
[
1
],
// ...data
keyword
keyword
}
}
this
.
setData
({
loading
:
true
})
wx
.
$util
.
showLoading
()
api
.
getWorkPackageGoodsList
(
params
).
then
((
res
)
=>
{
wx
.
$util
.
hideLoading
()
const
{
data
,
code
}
=
res
let
{
customerList
,
total
}
=
this
.
data
if
(
code
==
0
&&
data
)
{
total
=
data
.
total
||
0
const
pageItems
=
mapCustomerListWithCarType
(
data
.
list
||
[])
customerList
=
pageNum
===
1
?
pageItems
:
customerList
.
concat
(
pageItems
)
}
const
nothing
=
!
canLoadMorePage
(
total
,
pageNum
,
DEFAULT_PAGE_SIZE
)
this
.
setData
({
customerList
,
total
,
nothing
,
loading
:
false
})
}).
catch
(()
=>
{
wx
.
$util
.
hideLoading
()
this
.
setData
({
loading
:
false
})
})
},
/**
* apiType=2 时走客户档案独立接口,保持原全量逻辑
* @param {string} [keyword]
*/
loadCustomerFileList
(
keyword
)
{
const
{
merchantId
}
=
this
.
data
const
userInfo
=
wx
.
$util
.
getUserInfo
()
let
customerList
=
[]
let
customerList
=
[]
//客户线索1.1 、2.1客户列表
wx
.
$util
.
showLoading
()
wx
.
$util
.
showLoading
()
if
(
apiType
==
2
)
api
.
getCustomerFileList
({
api
.
getCustomerFileList
({
currentPage
:
1
,
currentPage
:
1
,
merchantId
:
merchantId
||
userInfo
?.
shopMerchantId
,
merchantId
:
merchantId
||
userInfo
?.
shopMerchantId
,
pageSize
:
999999
,
pageSize
:
999999
,
search
:
keyword
,
search
:
keyword
}).
then
(({
code
,
data
})
=>
{
}).
then
(({
code
,
data
})
=>
{
wx
.
$util
.
hideLoading
()
wx
.
$util
.
hideLoading
()
if
(
code
==
0
&&
data
?.
list
.
length
)
{
if
(
code
==
0
&&
data
?.
list
?
.
length
)
{
data
.
list
.
map
(
item
=>
{
data
.
list
.
forEach
((
item
)
=>
{
customerList
.
push
({
customerList
.
push
({
customer
:
item
,
customer
:
item
,
carType
:
`
${
item
.
carBrand
||
''
}
-
${
item
.
carChildsBrandName
||
''
}
-
${
item
.
carSeriesName
||
''
}
`
carType
:
`
${
item
.
carBrand
||
''
}
-
${
item
.
carChildsBrandName
||
''
}
-
${
item
.
carSeriesName
||
''
}
`
})
})
})
})
}
}
this
.
setData
({
this
.
setData
({
customerList
})
customerList
}).
catch
(()
=>
{
})
})
else
api
.
getWorkPackageGoodsList
(
params
).
then
(
res
=>
{
wx
.
$util
.
hideLoading
()
wx
.
$util
.
hideLoading
()
// console.log(res)
// this.setCar(res.data, changeMerchantId)
// console.log(res)
let
{
data
,
code
}
=
res
if
(
code
==
0
&&
data
?.
list
.
length
)
{
data
.
list
=
data
.
list
.
map
(
item
=>
{
if
(
item
.
customer
&&
item
.
customer
.
carSeriesName
)
{
item
.
carType
=
`
${
item
.
customer
.
carBrand
||
''
}
-
${
item
.
customer
.
carChildsBrandName
||
''
}
-
${
item
.
customer
.
carSeriesName
||
''
}
`
}
return
item
})
customerList
=
data
.
list
}
this
.
setData
({
customerList
})
})
})
},
},
searchCar
(
e
)
{
searchCar
(
e
)
{
let
{
const
{
value
}
=
e
.
detail
value
}
=
e
.
detail
this
.
init
(
value
)
this
.
init
(
value
)
},
},
/** scroll-view 触底加载下一页 */
scrolltolower
()
{
const
{
total
,
pageNum
,
nothing
,
loading
}
=
this
.
data
if
(
loading
||
nothing
)
return
if
(
canLoadMorePage
(
total
,
pageNum
,
DEFAULT_PAGE_SIZE
))
{
this
.
setData
({
pageNum
:
pageNum
+
1
},
()
=>
this
.
loadList
())
}
else
{
this
.
setData
({
nothing
:
true
})
}
},
choose
(
e
)
{
choose
(
e
)
{
let
{
const
{
item
,
index
}
=
e
.
currentTarget
.
dataset
item
,
let
{
customerList
}
=
this
.
data
index
customerList
=
customerList
.
map
((
row
)
=>
{
}
=
e
.
currentTarget
.
dataset
row
.
active
=
false
console
.
log
(
item
,
index
)
return
row
let
{
customerList
}
=
this
.
data
customerList
=
customerList
.
map
(
item
=>
{
item
.
active
=
false
return
item
})
})
customerList
[
index
].
active
=
true
customerList
[
index
].
active
=
true
le
t
orderInfo
=
item
cons
t
orderInfo
=
item
orderInfo
.
orderSource
=
4
orderInfo
.
orderSource
=
4
// delete orderInfo.orderCode
const
deleteList
=
[
'associateOrderCode'
,
'merchantDistributionList'
,
'expenseCategoryList'
,
'profitAllocatinList'
]
// 去除掉错误订单对应的关联码
for
(
let
i
=
0
;
i
<
deleteList
.
length
;
i
++
)
{
// delete orderInfo.associateOrderCode
// 'orderCode',
let
deleteList
=
[
'associateOrderCode'
,
'merchantDistributionList'
,
'expenseCategoryList'
,
'profitAllocatinList'
]
for
(
var
i
=
0
;
i
<
deleteList
.
length
;
i
++
)
{
// console.log(arr[i])
delete
orderInfo
[
deleteList
[
i
]]
delete
orderInfo
[
deleteList
[
i
]]
}
}
this
.
setData
({
this
.
setData
({
...
@@ -151,22 +192,16 @@ Component({
...
@@ -151,22 +192,16 @@ Component({
orderInfo
orderInfo
})
})
},
},
confirm
()
{
confirm
()
{
let
{
const
{
orderInfo
,
customerList
}
=
this
.
data
orderInfo
,
const
flag
=
customerList
.
some
((
item
)
=>
item
.
active
)
customerList
}
=
this
.
data
let
flag
=
customerList
.
some
(
item
=>
{
return
item
.
active
})
if
(
!
flag
)
{
if
(
!
flag
)
{
return
wx
.
$util
.
showToast
(
'请选择客户'
)
return
wx
.
$util
.
showToast
(
'请选择客户'
)
}
}
this
.
triggerEvent
(
'confirm'
,
orderInfo
)
this
.
triggerEvent
(
'confirm'
,
orderInfo
)
this
.
setData
({
this
.
setData
({
show
:
false
})
show
:
false
})
}
}
}
}
})
\ No newline at end of file
\ No newline at end of file
})
components/CustomerInfo/CustomerInfo.wxml
View file @
57d4c04
<popup title="选择客户" show="{{show}}" bindconfirm="confirm" height="90%">
<popup title="选择客户" show="{{show}}" bindconfirm="confirm" height="90%">
<view class="car-brands-box">
<view class="car-brands-box">
<search-input bindsearch="searchCar" />
<search-input bindsearch="searchCar" />
<view class="car-brands">
<view class="car-brands"
catchtouchmove="noScroll"
>
<view class="label title y-center">
<view class="label title y-center">
<span class="labelName">姓名</span>
<span class="labelName">姓名</span>
<span class="labelPhone">| 手机号</span>
<span class="labelPhone">| 手机号</span>
</view>
</view>
<scroll-view style="height: calc(100% - var(--fontSize88))" scroll-y
scroll-into-view="{{letter}}
">
<scroll-view style="height: calc(100% - var(--fontSize88))" scroll-y
enhanced="{{ true }}" show-scrollbar="{{ false }}" scroll-into-view="{{letter}}" bindscrolltolower="scrolltolower" lower-threshold="100
">
<block wx:if="{{customerList.length > 0}}">
<block wx:if="{{customerList.length > 0}}">
<view class="box">
<view class="box">
<block wx:for="{{customerList}}" wx:for-item="item" wx:key="ind" wx:for-index="ind">
<block wx:for="{{customerList}}" wx:for-item="item" wx:key="ind" wx:for-index="ind">
...
@@ -18,19 +18,21 @@
...
@@ -18,19 +18,21 @@
<view>)</view>
<view>)</view>
</span>
</span>
<span class="phone">{{item.customer.customerPhone}}</span>
<span class="phone">{{item.customer.customerPhone}}</span>
<!-- {{c.name}} {{c.active?'active':''}} {{c.isTitle?'title':''}} -->
<view class="icon">
<view class="icon">
<image src="../images/choose.png" />
<image src="../images/choose.png" />
</view>
</view>
</view>
</view>
</block>
</block>
</view>
</view>
<block wx:if="{{ nothing }}">
<view class="list-nothing">到底了~</view>
</block>
</block>
</block>
<block wx:if="{{
brandList.length <= 0
}}">
<block wx:if="{{
customerList.length <= 0 && !loading
}}">
<view class="nothing">暂无数据</view>
<view class="nothing">暂无数据</view>
</block>
</block>
</scroll-view>
</scroll-view>
<view class='tips' hidden='{{!showTip}}'>{{letter}}</view>
<view class='tips' hidden='{{!showTip}}'>{{letter}}</view>
</view>
</view>
</view>
</view>
</popup>
\ No newline at end of file
\ No newline at end of file
</popup>
components/CustomerInfo/CustomerInfo.wxss
View file @
57d4c04
...
@@ -145,4 +145,11 @@
...
@@ -145,4 +145,11 @@
padding: var(--fontSize100);
padding: var(--fontSize100);
text-align: center;
text-align: center;
color: #999;
color: #999;
}
.list-nothing {
padding: var(--fontSize32) 0 var(--fontSize48);
text-align: center;
font-size: var(--fontSize24);
color: #999;
}
}
\ No newline at end of file
\ No newline at end of file
components/CustomerInfo/customerInfo.pagination.js
0 → 100644
View file @
57d4c04
/**
* @file 客户档案弹框分页纯函数,供 CustomerInfo 组件与单测复用。
*/
/** 客户档案弹框每页条数 */
const
DEFAULT_PAGE_SIZE
=
20
/**
* 是否还能加载下一页(与工单首页 onReachBottom 判断一致)
* @param {number} total 总条数
* @param {number} pageNum 当前已加载页码
* @param {number} [pageSize=20] 每页条数
* @returns {boolean}
*/
function
canLoadMorePage
(
total
,
pageNum
,
pageSize
=
DEFAULT_PAGE_SIZE
)
{
if
(
!
total
||
!
pageNum
)
return
false
return
Math
.
ceil
(
total
/
pageSize
)
>
pageNum
}
/**
* 为订单列表项补充车型展示字段
* @param {Array} list 接口返回的 list
* @returns {Array}
*/
function
mapCustomerListWithCarType
(
list
)
{
if
(
!
list
?.
length
)
return
[]
return
list
.
map
((
item
)
=>
{
if
(
item
.
customer
?.
carSeriesName
)
{
item
.
carType
=
`
${
item
.
customer
.
carBrand
||
''
}
-
${
item
.
customer
.
carChildsBrandName
||
''
}
-
${
item
.
customer
.
carSeriesName
||
''
}
`
}
return
item
})
}
module
.
exports
=
{
DEFAULT_PAGE_SIZE
,
canLoadMorePage
,
mapCustomerListWithCarType
}
packageDynamicForm/services/today-plan-date.js
View file @
57d4c04
...
@@ -73,7 +73,7 @@ function formatPlanStoreDateLabel(dateStr) {
...
@@ -73,7 +73,7 @@ function formatPlanStoreDateLabel(dateStr) {
}
}
/**
/**
* 是否可切换日期(
今日 ±
7 天)
* 是否可切换日期(
过去含今天共 7 天;未来最多 +
7 天)
* @param {string} currentDateStr
* @param {string} currentDateStr
* @param {number} offset -1 前一天 / +1 后一天
* @param {number} offset -1 前一天 / +1 后一天
* @returns {boolean}
* @returns {boolean}
...
@@ -89,13 +89,15 @@ function canShiftPlanStoreDate(currentDateStr, offset) {
...
@@ -89,13 +89,15 @@ function canShiftPlanStoreDate(currentDateStr, offset) {
}
}
/**
/**
* 判断日期是否在可选范围内
* 判断日期是否在可选范围内
(过去含今天共 PLAN_STORE_DATE_RANGE_DAYS 天;未来最多 +PLAN_STORE_DATE_RANGE_DAYS 天)
* @param {string} dateStr
* @param {string} dateStr
* @returns {boolean}
* @returns {boolean}
*/
*/
function
isPlanStoreDateInRange
(
dateStr
)
{
function
isPlanStoreDateInRange
(
dateStr
)
{
const
diff
=
diffPlanStoreDaysFromToday
(
dateStr
)
const
diff
=
diffPlanStoreDaysFromToday
(
dateStr
)
return
diff
>=
-
PLAN_STORE_DATE_RANGE_DAYS
&&
diff
<=
PLAN_STORE_DATE_RANGE_DAYS
// 含当天共 N 天 → 最早偏移 -(N-1)
const
pastMinDiff
=
-
(
PLAN_STORE_DATE_RANGE_DAYS
-
1
)
return
diff
>=
pastMinDiff
&&
diff
<=
PLAN_STORE_DATE_RANGE_DAYS
}
}
/**
/**
...
...
packageDynamicForm/tests/today-plan-date.test.mjs
View file @
57d4c04
...
@@ -22,14 +22,22 @@ describe('today-plan-date', () => {
...
@@ -22,14 +22,22 @@ describe('today-plan-date', () => {
assert.match(label, /月/)
assert.match(label, /月/)
})
})
it('IT-PLAN-DATE-002: isPlanStoreDateInRange
allows ±7 days
', () => {
it('IT-PLAN-DATE-002: isPlanStoreDateInRange
past 7 days incl today, future +7
', () => {
const dPlus = new Date()
const dPlus = new Date()
dPlus.setDate(dPlus.getDate() + 7)
dPlus.setDate(dPlus.getDate() + 7)
const plus7 = timeUtil.formatDateStr(dPlus)
const plus7 = timeUtil.formatDateStr(dPlus)
assert.equal(isPlanStoreDateInRange(plus7), true)
assert.equal(isPlanStoreDateInRange(plus7), true)
const dMinus = new Date()
const dMinus6 = new Date()
dMinus.setDate(dMinus.getDate() - 8)
dMinus6.setDate(dMinus6.getDate() - 6)
const minus8 = timeUtil.formatDateStr(dMinus)
const minus6 = timeUtil.formatDateStr(dMinus6)
assert.equal(isPlanStoreDateInRange(minus6), true)
const dMinus7 = new Date()
dMinus7.setDate(dMinus7.getDate() - 7)
const minus7 = timeUtil.formatDateStr(dMinus7)
assert.equal(isPlanStoreDateInRange(minus7), false)
const dMinus8 = new Date()
dMinus8.setDate(dMinus8.getDate() - 8)
const minus8 = timeUtil.formatDateStr(dMinus8)
assert.equal(isPlanStoreDateInRange(minus8), false)
assert.equal(isPlanStoreDateInRange(minus8), false)
})
})
...
...
tabWorkOrder/pages/createOrder/createOrder.wxml
View file @
57d4c04
<wxs src="../../index.wxs" module="filter" />
<wxs src="../../index.wxs" module="filter" />
<wxs src="./createOrderPageLock.wxs" module="pageLock" />
<page-meta page-style="{{ pageLock.isPagePopupVisible({ showOrderpop: showOrderpop, staffPickerBox: staffPickerBox, subShopMerchantBox: subShopMerchantBox, carBrandBox: carBrandBox, showRemark: showRemark, couponBox: couponBox, goodsBox: goodsBox, skuGoodsBox: skuGoodsBox, customerInfoBox: customerInfoBox, showSource: showSource, showSceneSelect: showSceneSelect, orderTypeBox: orderTypeBox, packageBox: packageBox, minPriceApprovalPopup: minPriceApprovalPopup, minPriceApprovalSheet: minPriceApprovalSheet }) ? 'overflow: hidden;' : '' }}" />
<block wx:if="{{ flag }}">
<block wx:if="{{ flag }}">
<!-- <scroll-view class="container"scroll-y style="height:{{windowHeight}}px">-->
<!-- <scroll-view class="container"scroll-y style="height:{{windowHeight}}px">-->
<!-- {{isFullSucreen?'isFullSucreen': ''}}
<!-- {{isFullSucreen?'isFullSucreen': ''}}
...
@@ -824,7 +826,7 @@ value="{{ orderObj.remark }}"
...
@@ -824,7 +826,7 @@ value="{{ orderObj.remark }}"
<sub-shop-merchant
<sub-shop-merchant
show="{{ subShopMerchantBox }}"
show="{{ subShopMerchantBox }}"
title="选择二级流量方"
title="选择二级流量方"
selectedSelesMerchantId="{{ orderObj.merchantId }}"
selectedSelesMerchantId="{{ orderObj.merchantId
|| ''
}}"
selectedCustomerInfo="{{ orderObj.customer.customerId || '' }}"
selectedCustomerInfo="{{ orderObj.customer.customerId || '' }}"
selectedSubShopMerchantId="{{ orderObj.subShopMerchantId || '' }}"
selectedSubShopMerchantId="{{ orderObj.subShopMerchantId || '' }}"
/>
/>
...
@@ -832,7 +834,7 @@ value="{{ orderObj.remark }}"
...
@@ -832,7 +834,7 @@ value="{{ orderObj.remark }}"
show="{{ carBrandBox }}"
show="{{ carBrandBox }}"
bindconfirm="chooseCar"
bindconfirm="chooseCar"
carSeriesId="{{ orderObj.customer.carSeriesId || '' }}"
carSeriesId="{{ orderObj.customer.carSeriesId || '' }}"
merchantId="{{ orderObj.merchantId ||
undefined
}}"
merchantId="{{ orderObj.merchantId ||
0
}}"
/>
/>
<remark-popup
<remark-popup
wx:if="{{ showRemark }}"
wx:if="{{ showRemark }}"
...
@@ -848,9 +850,9 @@ value="{{ orderObj.remark }}"
...
@@ -848,9 +850,9 @@ value="{{ orderObj.remark }}"
class="coupon"
class="coupon"
orderCreateType="{{ orderCreateType }}"
orderCreateType="{{ orderCreateType }}"
bindconfirm="chooseCoupon"
bindconfirm="chooseCoupon"
merchantId="{{ orderObj.merchantId }}"
merchantId="{{ orderObj.merchantId
|| 0
}}"
customerPhone="{{ orderObj.customer.customerPhone }}"
customerPhone="{{ orderObj.customer.customerPhone }}"
yqMerchantId="{{ orderObj.sellerMerchantId }}"
yqMerchantId="{{ orderObj.sellerMerchantId
|| 0
}}"
selectPayType="{{ orderObj.selectPayType }}"
selectPayType="{{ orderObj.selectPayType }}"
returnFun="{{ returnFun }}"
returnFun="{{ returnFun }}"
/>
/>
...
...
tabWorkOrder/pages/createOrder/createOrderPageLock.wxs
0 → 100644
View file @
57d4c04
/**
* createOrder 弹框打开时锁定底层页面滚动(与 services/pagePopupLock.js 逻辑一致)
*/
function isPagePopupVisible(state) {
return !!(
state.showOrderpop ||
state.staffPickerBox ||
state.subShopMerchantBox ||
state.carBrandBox ||
state.showRemark ||
state.couponBox ||
state.goodsBox ||
state.skuGoodsBox ||
state.customerInfoBox ||
state.showSource ||
state.showSceneSelect ||
state.orderTypeBox ||
state.packageBox ||
(state.minPriceApprovalPopup && state.minPriceApprovalPopup.show) ||
(state.minPriceApprovalSheet && state.minPriceApprovalSheet.show)
)
}
module.exports = {
isPagePopupVisible: isPagePopupVisible
}
tabWorkOrder/pages/createOrder/services/pagePopupLock.js
0 → 100644
View file @
57d4c04
/**
* @file createOrder 弹层打开时锁定底层页面滚动:聚合各弹框 visible 状态。
*/
/** 顶层弹框开关字段(与 createOrder.wxml 中 show 绑定一致) */
const
PAGE_POPUP_KEYS
=
[
'showOrderpop'
,
'staffPickerBox'
,
'subShopMerchantBox'
,
'carBrandBox'
,
'showRemark'
,
'couponBox'
,
'goodsBox'
,
'skuGoodsBox'
,
'customerInfoBox'
,
'showSource'
,
'showSceneSelect'
,
'orderTypeBox'
,
'packageBox'
]
/** setData 嵌套路径前缀,变更时需同步 pagePopupVisible */
const
NESTED_POPUP_PREFIXES
=
[
'minPriceApprovalPopup'
,
'minPriceApprovalSheet'
]
/**
* 是否存在任一弹框打开
* @param {object} data 页面 data
* @returns {boolean}
*/
function
computePagePopupVisible
(
data
)
{
if
(
!
data
)
return
false
return
!!
(
data
.
showOrderpop
||
data
.
staffPickerBox
||
data
.
subShopMerchantBox
||
data
.
carBrandBox
||
data
.
showRemark
||
data
.
couponBox
||
data
.
goodsBox
||
data
.
skuGoodsBox
||
data
.
customerInfoBox
||
data
.
showSource
||
data
.
showSceneSelect
||
data
.
orderTypeBox
||
data
.
packageBox
||
data
.
minPriceApprovalPopup
?.
show
||
data
.
minPriceApprovalSheet
?.
show
)
}
/**
* 本次 setData 是否涉及弹框开关(需重算 pagePopupVisible)
* @param {object} updates setData 入参
* @returns {boolean}
*/
function
shouldSyncPagePopup
(
updates
)
{
if
(
!
updates
||
typeof
updates
!==
'object'
)
return
false
return
Object
.
keys
(
updates
).
some
((
key
)
=>
{
if
(
PAGE_POPUP_KEYS
.
includes
(
key
))
return
true
if
(
NESTED_POPUP_PREFIXES
.
includes
(
key
))
return
true
return
NESTED_POPUP_PREFIXES
.
some
((
prefix
)
=>
key
.
startsWith
(
`
${
prefix
}
.`
))
})
}
module
.
exports
=
{
PAGE_POPUP_KEYS
,
computePagePopupVisible
,
shouldSyncPagePopup
}
tabWorkOrder/pages/createOrder/tests/pagePopupLock.test.mjs
0 → 100644
View file @
57d4c04
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import { createRequire } from 'node:module'
const require = createRequire(import.meta.url)
const {
computePagePopupVisible,
shouldSyncPagePopup
} = require('../services/pagePopupLock.js')
describe('pagePopupLock', () => {
it('computePagePopupVisible is false when no popup open', () => {
assert.equal(computePagePopupVisible({ customerInfoBox: false }), false)
})
it('computePagePopupVisible is true when any popup open', () => {
assert.equal(computePagePopupVisible({ customerInfoBox: true }), true)
assert.equal(
computePagePopupVisible({ minPriceApprovalPopup: { show: true } }),
true
)
})
it('shouldSyncPagePopup detects popup field updates', () => {
assert.equal(shouldSyncPagePopup({ customerInfoBox: true }), true)
assert.equal(shouldSyncPagePopup({ 'minPriceApprovalPopup.show': false }), true)
assert.equal(shouldSyncPagePopup({ orderObj: {} }), false)
assert.equal(shouldSyncPagePopup({ pagePopupVisible: true }), false)
})
})
tests/customerInfo.pagination.test.mjs
0 → 100644
View file @
57d4c04
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import { createRequire } from 'node:module'
const require = createRequire(import.meta.url)
const {
DEFAULT_PAGE_SIZE,
canLoadMorePage,
mapCustomerListWithCarType
} = require('../components/CustomerInfo/customerInfo.pagination.js')
describe('customerInfo.pagination', () => {
it('DEFAULT_PAGE_SIZE is 20', () => {
assert.equal(DEFAULT_PAGE_SIZE, 20)
})
it('canLoadMorePage matches index onReachBottom logic with pageSize 20', () => {
assert.equal(canLoadMorePage(25, 1), true)
assert.equal(canLoadMorePage(25, 2), false)
assert.equal(canLoadMorePage(40, 2), false)
assert.equal(canLoadMorePage(41, 2), true)
assert.equal(canLoadMorePage(0, 1), false)
})
it('mapCustomerListWithCarType builds carType from customer fields', () => {
const list = mapCustomerListWithCarType([
{
customer: {
carBrand: '宝马',
carChildsBrandName: '华晨宝马',
carSeriesName: '3系'
}
}
])
assert.equal(list[0].carType, '宝马-华晨宝马-3系')
})
it('mapCustomerListWithCarType skips items without carSeriesName', () => {
const list = mapCustomerListWithCarType([{ customer: { carBrand: '宝马' } }])
assert.equal(list[0].carType, undefined)
})
})
Write
Preview
Markdown
is supported
Attach a file
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 post a comment