Commit 3728a2fe by 张立顺

feat 搜索功能修复

1 parent 3fbedd0f
......@@ -23,3 +23,4 @@ yarn-error.log*
*.njsproj
*.sln
*.sw*
!docs/reference/api/*.swagger.json
......@@ -3,3 +3,12 @@
跨项目迁移或较大重构开始前,必须创建迁移 manifest 并通过 `npm run check:migration -- --manifest <manifest> --phase pre`。完成后使用 `--phase post` 复核测试状态和未阻塞验证命令。
小型修复不强制使用该门禁。文档和测试的准备工作可以直接进行,不受门禁阻挡;门禁用于阻止尚未具备迁移证据的业务变更进入迁移阶段。
<!-- rop-api-contract-gate:start -->
## API 契约门禁
- 导入、对接或修改 ROP API 及其请求/响应参数前,先读取 `docs/reference/api/swagger-sources.json` 并同步 `develop` Swagger。
- 在线 Swagger 有定义时以最新契约为准;在线同步成功但未收录接口时,可按用户提供的完整契约实现并明确提示“Swagger 尚未收录”。
- 用户定义与 Swagger 冲突,或参数修改未出现在最新 Swagger 中时,必须先展示差异并取得确认。
- 任一候选网关未验证时不得写代码;仅可离线读取快照时,必须先展示同步时间并确认时效。
<!-- rop-api-contract-gate:end -->
import api from '~/api/api'
import {
buildLowPriceMerchantContext,
filterOrderMerchantOptions,
normalizeOrderMerchantOptions
} from './orderMerchantContext.helpers'
const MERCHANT_PAGE_SIZE = 10
const MERCHANT_SEARCH_DELAY = 300
const FULL_PAY_TYPE_LIST = [
{ label: '收款方为门店收款', value: '3' },
{ label: '收款方为嘀加且属于对公转账收款', value: '4' },
......@@ -60,7 +62,7 @@ Component({
},
merchantHeight: {
type: String,
value: '80%'
value: '50%'
},
includesChildHeight: {
type: String,
......@@ -89,6 +91,8 @@ Component({
merchantList: [],
filteredMerchantList: [],
merchantKeyword: '',
merchantPageNum: 1,
merchantHasMore: true,
selectedMerchantKey: '',
selectedMerchant: null,
merchantLoading: false,
......@@ -98,6 +102,7 @@ Component({
methods: {
openPresentation() {
if (this.properties.lowPriceMode) {
clearTimeout(this.merchantSearchTimer)
this.setData({
currentStep: 1,
infoData: {},
......@@ -105,6 +110,8 @@ Component({
merchantList: [],
filteredMerchantList: [],
merchantKeyword: '',
merchantPageNum: 1,
merchantHasMore: true,
selectedMerchantKey: '',
selectedMerchant: null,
merchantError: ''
......@@ -131,48 +138,108 @@ Component({
})
},
async loadOrderMerchantList() {
this.setData({ merchantLoading: true, merchantError: '' })
async loadOrderMerchantList({
reset = true,
keyword = this.data.merchantKeyword || ''
} = {}) {
if (!reset && (this.data.merchantLoading || !this.data.merchantHasMore)) {
return
}
const pageNum = reset ? 1 : this.data.merchantPageNum
const requestId = (this.merchantRequestId || 0) + 1
this.merchantRequestId = requestId
this.setData({
merchantLoading: true,
merchantError: '',
...(reset
? {
merchantList: [],
filteredMerchantList: [],
merchantPageNum: 1,
merchantHasMore: true
}
: {})
})
try {
const response = await api.getShopWithYqList({ sceneType: 1 })
const response = await api.getShopWithYqList({
pageNum,
pageSize: MERCHANT_PAGE_SIZE,
sceneType: 1,
merchantNameOrId: String(keyword).trim()
})
if (requestId !== this.merchantRequestId) return
if (response?.code != 0) {
throw new Error(response?.message || '下单门店加载失败')
}
const merchantList = normalizeOrderMerchantOptions(response?.data)
const pageList = normalizeOrderMerchantOptions(response?.data)
const previousList = reset ? [] : this.data.merchantList
const merchantMap = new Map(
previousList.map(item => [item.key, item])
)
pageList.forEach(item => merchantMap.set(item.key, item))
const merchantList = [...merchantMap.values()]
const pages = response?.data?.pages
const total = response?.data?.total
const merchantHasMore =
pages !== undefined && pages !== null
? pageNum < pages
: total !== undefined && total !== null
? merchantList.length < total
: pageList.length >= MERCHANT_PAGE_SIZE
this.setData({
merchantList,
filteredMerchantList: merchantList,
merchantLoading: false,
merchantPageNum: pageNum + 1,
merchantHasMore,
merchantError: merchantList.length ? '' : '暂无可选择的下单门店'
})
} catch (error) {
if (requestId !== this.merchantRequestId) return
const merchantError = error?.message || '下单门店加载失败,请稍后重试'
this.setData({
merchantList: [],
filteredMerchantList: [],
merchantLoading: false,
merchantError
})
this.setData(
reset
? {
merchantList: [],
filteredMerchantList: [],
merchantLoading: false,
merchantHasMore: false,
merchantError
}
: {
merchantLoading: false,
merchantError: ''
}
)
wx.$util.showToast(merchantError)
}
},
onMerchantKeywordInput(e) {
const merchantKeyword = e.detail.value || ''
this.setData({
merchantKeyword,
filteredMerchantList: filterOrderMerchantOptions(
this.data.merchantList,
merchantKeyword
)
})
this.setData({ merchantKeyword })
clearTimeout(this.merchantSearchTimer)
this.merchantRequestId = (this.merchantRequestId || 0) + 1
this.merchantSearchTimer = setTimeout(() => {
this.loadOrderMerchantList({
reset: true,
keyword: merchantKeyword
})
}, MERCHANT_SEARCH_DELAY)
},
clearMerchantKeyword() {
this.setData({
merchantKeyword: '',
filteredMerchantList: [...this.data.merchantList]
})
clearTimeout(this.merchantSearchTimer)
this.setData({ merchantKeyword: '' })
return this.loadOrderMerchantList({ reset: true, keyword: '' })
},
loadMoreOrderMerchantList() {
return this.loadOrderMerchantList({ reset: false })
},
chooseMerchant(e) {
......@@ -203,6 +270,8 @@ Component({
},
cancel() {
clearTimeout(this.merchantSearchTimer)
this.merchantRequestId = (this.merchantRequestId || 0) + 1
this.triggerEvent('cancel')
},
......
......@@ -168,6 +168,13 @@
padding: var(--fontSize64) 0;
}
.merchant-load-more {
color: #9B9B9E;
font-size: var(--fontSize24);
text-align: center;
padding: var(--fontSize20) 0;
}
.prompt_content {
padding: var(--fontSize24) 0;
font-size: var(--fontSize28);
......
......@@ -29,14 +29,19 @@
<view class="merchant-search">
<image class="merchant-search-icon" src="/images/search.png" />
<input value="{{ merchantKeyword }}"
placeholder="搜索"
placeholder="搜索门店名称/商户号"
bindinput="onMerchantKeywordInput" />
<image wx:if="{{ merchantKeyword }}"
class="merchant-clear-icon"
src="/images/clear.png"
bindtap="clearMerchantKeyword" />
</view>
<scroll-view class="merchant-list" scroll-y>
<scroll-view class="merchant-list"
scroll-y
enhanced="{{ true }}"
show-scrollbar="{{ false }}"
lower-threshold="100"
bindscrolltolower="loadMoreOrderMerchantList">
<view class="merchant-item {{ selectedMerchantKey == item.key ? 'selected' : '' }}"
wx:for="{{ filteredMerchantList }}"
wx:key="key"
......@@ -49,13 +54,19 @@
✓
</view>
</view>
<view class="merchant-state" wx:if="{{ merchantLoading }}">
<view class="merchant-state" wx:if="{{ merchantLoading && !merchantList.length }}">
门店加载中...
</view>
<view class="merchant-state"
wx:elif="{{ merchantError || !filteredMerchantList.length }}">
wx:elif="{{ merchantError || !merchantList.length }}">
{{ merchantError || '未搜索到匹配门店' }}
</view>
<view class="merchant-load-more" wx:elif="{{ merchantLoading }}">
加载中...
</view>
<view class="merchant-load-more" wx:elif="{{ !merchantHasMore }}">
没有更多了
</view>
</scroll-view>
</view>
<scroll-view class="payment-scroll"
......
......@@ -4,8 +4,8 @@
## 规模
- 节点:4255
- 关系:8122
- 节点:4256
- 关系:8127
- 未解析:91
## 节点类型
......@@ -18,7 +18,7 @@
| domain | 6 |
| endpoint | 234 |
| globalState | 32 |
| method | 2937 |
| method | 2938 |
| module | 365 |
| page | 72 |
| test | 81 |
......@@ -27,13 +27,13 @@
| 类型 | 数量 |
| --- | --- |
| bindsEvent | 939 |
| calls | 885 |
| bindsEvent | 940 |
| calls | 888 |
| callsApi | 221 |
| callsEndpoint | 332 |
| contains | 712 |
| coveredBy | 63 |
| declares | 2938 |
| declares | 2939 |
| definesApi | 332 |
| documentedBy | 60 |
| imports | 438 |
......
......@@ -23,7 +23,7 @@
四个审批状态页签、查看和“新建低价单”入口,不提供“扫码核销”入口。
点击列表“新建低价单”,先展示“选择下单门店”,从
`dj.api.smartcarlife.serviceMerchant.shopWithYqList`(`sceneType=1`)返回结果中搜索并单选 4S 店;选定后再进入
`dj.api.smartcarlife.serviceMerchant.shopWithYqList`(`sceneType=1`、`pageSize=10`)分页结果中单选 4S 店;低价单两步弹框使用半屏高度,门店列表填充剩余区域并可上滑触底继续加载,输入门店名称或商户号时通过 `merchantNameOrId` 重新查询;选定后再进入
“订单收款方式”。入口不执行来源项目中的日报、学习任务、异常订单或异常流水判断。
列表右下角入口使用产品提供的 56×56 本地图标 `/images/new-low-price-order.png`。
......
......@@ -105,7 +105,7 @@ flowchart LR
### 4.2 新建工单按钮门控
低价提单列表的“新建低价单”入口先以 `sceneType=1` 调用 `serviceMerchant.shopWithYqList`,选择当前账号关联的 4S 店,再展示收款方式,不先调用日报、学习任务、异常订单或异常流水锁单。路由参数固定携带 `skipOrderGuards=true`、`lowPriceFlag=1` 以及所选 `merchantId/yqMerchantId/sellerMerchantId`;嘀加二维码收款经过交易流水选择后也保留这些字段。工作台 [`workspace.js`](../../pages/tab/workspace/workspace.js) 仅保留“低价提单”列表入口,不显示“新增工单”。
低价提单列表的“新建低价单”入口先以 `sceneType=1` 调用 `serviceMerchant.shopWithYqList`,按 `pageNum`、`pageSize=10` 分页加载当前账号关联的 4S 店;低价单两个步骤统一使用 `50%` 半屏高度,门店列表填充弹框剩余区域并在触底后加载下一页;搜索时通过 `merchantNameOrId` 从第一页重新查询。选择门店后再展示收款方式,不先调用日报、学习任务、异常订单或异常流水锁单。路由参数固定携带 `skipOrderGuards=true`、`lowPriceFlag=1` 以及所选 `merchantId/yqMerchantId/sellerMerchantId`;嘀加二维码收款经过交易流水选择后也保留这些字段。工作台 [`workspace.js`](../../pages/tab/workspace/workspace.js) 仅保留“低价提单”列表入口,不显示“新增工单”。
创建页提交时先执行 `checkPhoneUseConfig()`,再执行必填、商品、VIN 和金额等本地订单校验;该提交模块不导入 `ModalToQueueControl`,因此不会调用 `checkDailyReport()`、`checkStudyTask()` 或 `checkOrderLockGate()`。列表撤销、详情标记错误等其他页面仍执行各自原有业务门控,公共 API 不做全局删除。
......@@ -436,7 +436,7 @@ flowchart TD
| `search` | `order.search.containPackageGoods.byArea` | 关键词、审批状态、`lowPriceFlag=1` | 低价提单列表;返回 `RpcPagination<GoodsOrderDTO>` |
| `statByStatus` | `order.statByApplyStatus` | 关键词、`lowPriceFlag=1` | 低价提单页签数量;返回 `totalCount/pendingCount/passCount/rejectCount` |
| `getYQList` | `serviceMerchant.curYqList` | 当前账号上下文 | 创建页非销售类人员选择园区店 |
| `getShopWithYqList` | `serviceMerchant.shopWithYqList` | `sceneType=1`、当前账号上下文 | 下单门店选择、低价单筛选门店 |
| `getShopWithYqList` | `serviceMerchant.shopWithYqList` | `sceneType=1`、`pageNum/pageSize`;下单门店搜索增加 `merchantNameOrId` | 下单门店分页选择、低价单筛选门店 |
### 11.2 目标保留的施工接口封装
......
......@@ -32,7 +32,7 @@
| ID | 场景 | 自动化证据 | 已覆盖 | 已执行 | 受数据阻塞 | 验收结论或解除条件 |
|---|---|---|---|---|---|---|
| AC-01 | 工作台“门店运营管理”隐藏“新增工单” | `workspace-source-contract.test.mjs` | 是 | 是 | 否 | 菜单数组不包含“新增工单”或 `openWorkOrderPrompt` 动作,“低价提单”为首个工单入口 |
| AC-02 | 点击新增工单先选择下单门店 | `low-price-api-contract.test.mjs`、`low-price-order-flow.test.mjs`、`direct-entry.test.mjs` | 是 | 是 | 否 | 以 `sceneType=1` 调用 `shopWithYqList`,返回当前账号关联的 4S/园区店;结果可搜索、单选,选中后再展示收款方式 |
| AC-02 | 点击新增工单先选择下单门店 | `low-price-api-contract.test.mjs`、`low-price-order-flow.test.mjs`、`direct-entry.test.mjs` | 是 | 是 | 否 | 低价单两步弹框统一使用 `50%` 半屏高度;以 `sceneType=1`、`pageSize=10` 调用 `shopWithYqList`,列表上滑触底后加载第 11 条;门店名称/商户号使用 `merchantNameOrId` 接口搜索,选中后再展示收款方式 |
| AC-03 | 未支付进入创建页 | `direct-entry.test.mjs` | 是 | 是 | 否 | `paymentMethod=1` 且携带 `skipOrderGuards=true` |
| AC-04 | 门店/对公/特殊收款进入创建页 | `direct-entry.test.mjs` | 是 | 是 | 否 | 保留所选 `paymentMethod` |
| AC-05 | 嘀加二维码收款先选交易流水 | `direct-entry.test.mjs` | 是 | 是 | 否 | 打开 `recordingOrderPopup` |
......
This diff could not be displayed because it is too large.
{
"schemaVersion": 1,
"configCenter": {
"endpoint": "https://config-center-backend.glsx.com.cn/glsxAdmin/config",
"moduleUrl": "dj-car-boutique-work-wechat",
"defaultEnv": "develop"
},
"sources": [
{
"id": "rop-dj-car-boutique",
"configKey": "axios",
"env": "develop",
"swaggerPath": "/swagger-rop/api-docs",
"snapshot": "docs/reference/api/rop-dj-car-boutique.swagger.json",
"sha256": "32ff930fb69aa3b2f10f10e27f225f14a50f16975b1068d09ab8935bda98b171",
"syncedAt": "2026-09-10T01:10:34.119Z",
"methodCount": 553
}
]
}
......@@ -19,7 +19,7 @@
`packageWorkspace` 页面,但当前工单详情不挂载退款组件,也不展示“工单信息”标题操作按钮。
工作台不展示“新增工单”菜单;用户从“低价提单”进入列表后点击“新建低价单”,先通过
`dj.api.smartcarlife.serviceMerchant.shopWithYqList`(必传 `sceneType=1`)选择当前账号关联的下单 4S 店,再展示收款方式,并传递
`dj.api.smartcarlife.serviceMerchant.shopWithYqList`(`sceneType=1`)分页选择当前账号关联的下单 4S 店;列表触底加载下一页,门店名称/商户号通过 `merchantNameOrId` 接口搜索。选中后再展示收款方式,并传递
`skipOrderGuards=true`、`lowPriceFlag=1` 及所选门店上下文。该链路不调用日报、学习任务、
异常订单或异常流水前置接口;创建页提交模块不加载该组公共守卫。手机号配置、表单、VIN、
价格与提交错误处理继续执行。
......@@ -140,7 +140,7 @@
| 业务用途 | 封装函数 | HTTP | ROP method | 关键入参 | 页面使用的返回字段 | 触发与状态 | 代码来源 |
| --------------------- | --------------------------- | ---- | ----------------------------------------------- | -------------------------------------------- | ---------------------------------------------- | ---------------------------------------------------------- | ------------------------------------------------------------------------ |
| 查询用户可用场景 | `getUserScene` | POST | `dj.api.smartcarlife.scene.config.getUserScene` | `sceneType`、`phone` | 场景数组中的 `name/staffName`、`baseSceneCode` | 初始化筛选项;条件 | `tabWorkOrder/pages/index/components/OrderScreen/OrderScreen.js`、`api/api.js` |
| 查询关联 4S/园区店 | `getShopWithYqList` | POST | `dj.api.smartcarlife.serviceMerchant.shopWithYqList` | `sceneType=1`、当前账号上下文 | 4S 店及所属园区店列表 | 新建低价单第一步、低价单模式初始化门店筛选;条件 | `components/orderPromptPop/orderPromptPop.js`、`tabWorkOrder/pages/index/components/StoreSelectPopup/StoreSelectPopup.js`、`api/api.js` |
| 查询关联 4S/园区店 | `getShopWithYqList` | POST | `dj.api.smartcarlife.serviceMerchant.shopWithYqList` | `sceneType=1`、`pageNum`;下单门店使用 `pageSize=10`,搜索传 `merchantNameOrId` | `RpcPagination<ShopYqRefDTO>`:`data.list/total/pages` | 新建低价单第一步分页/搜索、低价单模式初始化门店筛选;条件 | `components/orderPromptPop/orderPromptPop.js`、`tabWorkOrder/pages/index/components/StoreSelectPopup/StoreSelectPopup.js`、`api/api.js` |
| 查询园区店支付配置 | `getYqStoreConfig` | GET | `dj.api.smarcarlife.yqMerchantConfig.detail` | `yqMerchantId` | `supportPayTypes` | 非多门店筛选账号初始化支付方式时;条件 | `tabWorkOrder/pages/index/components/OrderScreen/OrderScreen.js`、`api/api.js` |
| 查询转化人员/销售人员 | `getConversionEmployeeList` | POST | `dj.api.smartcarlife.employee.getByMerchantId` | `merchantId`;销售人员额外传 `sceneList=[1]` | 员工数组中的 `uuid`、`staffName` 等 | 筛选组件打开或门店变化时;同一接口按两种人员口径调用;条件 | `tabWorkOrder/pages/index/components/OrderScreen/OrderScreen.js`、`api/api.js` |
......@@ -522,5 +522,5 @@ JavaScript 对象中后声明的同名键会覆盖前面的声明,因此应以
| `order.supplementOrder` | 新增 `lowPriceFlag`、`sellerMerchantId` | 流水补录提交 |
| `order.createWithPay` | 新增 `lowPriceFlag`、`sellerMerchantId` | 普通低价单提交 |
| `serviceMerchant.curYqList` | 保持返回当前账号可见园区店 | 创建页非销售类人员选择 |
| `serviceMerchant.shopWithYqList` | 必传 `sceneType=1`;返回值归一化为可搜索单选的当前账号关联 4S 店及所属园区 | 新建第一步“选择下单门店”、低价单筛选 |
| `serviceMerchant.shopWithYqList` | `sceneType=1`;按 `pageNum/pageSize` 返回分页数据,下单门店搜索传 `merchantNameOrId`;返回值归一化为可单选的当前账号关联 4S 店及所属园区 | 新建第一步“选择下单门店”、低价单筛选 |
| `order.detail` | 返回新增 `lowPriceFlag`,页面/编辑链路保留 | 工单详情和编辑回显 |
......@@ -34,8 +34,10 @@ async function loadOrderPromptComponent(api) {
},
api,
buildLowPriceMerchantContext: () => ({}),
clearTimeout,
filterOrderMerchantOptions,
normalizeOrderMerchantOptions,
setTimeout,
wx: {
$util: {
showToast() {}
......@@ -45,6 +47,25 @@ async function loadOrderPromptComponent(api) {
return componentConfig
}
function createOrderPromptInstance(componentConfig) {
const component = {
properties: {
lowPriceMode: true,
djQrOnlyMode: false
},
data: JSON.parse(JSON.stringify(componentConfig.data)),
setData(patch) {
Object.assign(this.data, patch)
}
}
Object.entries(componentConfig.methods).forEach(([name, method]) => {
component[name] = method.bind(component)
})
return component
}
async function loadStoreSelectComponent(api) {
const componentSource = await source(
'tabWorkOrder/pages/index/components/StoreSelectPopup/StoreSelectPopup.js'
......@@ -138,6 +159,246 @@ describe('低价单接口与页面接线契约', () => {
assert.equal(component.data.merchantError, '')
})
it('选择下单门店 11 条数据首屏加载 10 条并在触底后加载第 11 条', async () => {
const calls = []
const componentConfig = await loadOrderPromptComponent({
getShopWithYqList(params) {
calls.push({ ...params })
const total = 11
const pageNum = params?.pageNum || 1
const pageSize = params?.pageSize || 10
const start = (pageNum - 1) * pageSize + 1
const end = Math.min(pageNum * pageSize, total)
return Promise.resolve({
code: 0,
data: {
pageNum,
pageSize,
total,
pages: Math.ceil(total / pageSize),
list: Array.from(
{ length: Math.max(0, end - start + 1) },
(_, index) => {
const merchantId = start + index
return {
shopMerchantId: merchantId,
shopMerchantName: `4S 店${merchantId}`,
yqMerchantId: 100,
yqMerchantName: '园区甲'
}
}
)
}
})
}
})
const component = createOrderPromptInstance(componentConfig)
await component.loadOrderMerchantList()
assert.deepEqual(calls, [
{
pageNum: 1,
pageSize: 10,
sceneType: 1,
merchantNameOrId: ''
}
])
assert.equal(component.data.merchantList.length, 10)
assert.equal(component.data.merchantHasMore, true)
await component.loadMoreOrderMerchantList()
assert.deepEqual(calls, [
{
pageNum: 1,
pageSize: 10,
sceneType: 1,
merchantNameOrId: ''
},
{
pageNum: 2,
pageSize: 10,
sceneType: 1,
merchantNameOrId: ''
}
])
assert.equal(component.data.merchantList.length, 11)
assert.equal(component.data.merchantList[10].merchantName, '4S 店11')
assert.equal(component.data.merchantHasMore, false)
})
it('低价单两个步骤默认使用半屏高度', async () => {
const componentConfig = await loadOrderPromptComponent({})
assert.equal(componentConfig.properties.merchantHeight.value, '50%')
})
it('选择下单门店列表不再额外限制八行高度', async () => {
const componentStyle = await source(
'components/orderPromptPop/orderPromptPop.sass'
)
const merchantListStyle = componentStyle.match(
/\.merchant-list\s*\{([\s\S]*?)\}/
)?.[1]
assert.ok(merchantListStyle)
assert.doesNotMatch(merchantListStyle, /max-height:/)
})
it('选择下单门店输入搜索词后通过接口搜索名称或商户号', async () => {
const calls = []
const componentConfig = await loadOrderPromptComponent({
getShopWithYqList(params) {
calls.push({ ...params })
return Promise.resolve({
code: 0,
data: {
pageNum: 1,
pageSize: 10,
total: 1,
pages: 1,
list: [
{
shopMerchantId: 11,
shopMerchantName: '目标门店',
yqMerchantId: 100,
yqMerchantName: '园区甲'
}
]
}
})
}
})
const component = createOrderPromptInstance(componentConfig)
component.onMerchantKeywordInput({ detail: { value: '目标' } })
component.onMerchantKeywordInput({ detail: { value: '目标门店' } })
await new Promise(resolve => setTimeout(resolve, 350))
assert.deepEqual(calls, [
{
pageNum: 1,
pageSize: 10,
sceneType: 1,
merchantNameOrId: '目标门店'
}
])
assert.equal(component.data.merchantList.length, 1)
assert.equal(component.data.merchantList[0].merchantId, 11)
})
it('选择下单门店忽略晚返回的旧搜索结果', async () => {
const pending = new Map()
const componentConfig = await loadOrderPromptComponent({
getShopWithYqList(params) {
return new Promise(resolve => {
pending.set(params.merchantNameOrId, resolve)
})
}
})
const component = createOrderPromptInstance(componentConfig)
const oldRequest = component.loadOrderMerchantList({
reset: true,
keyword: '旧门店'
})
const newRequest = component.loadOrderMerchantList({
reset: true,
keyword: '新门店'
})
pending.get('新门店')({
code: 0,
data: {
pageNum: 1,
pageSize: 10,
total: 1,
pages: 1,
list: [
{
shopMerchantId: 12,
shopMerchantName: '新门店',
yqMerchantId: 100,
yqMerchantName: '园区甲'
}
]
}
})
await newRequest
pending.get('旧门店')({
code: 0,
data: {
pageNum: 1,
pageSize: 10,
total: 1,
pages: 1,
list: [
{
shopMerchantId: 13,
shopMerchantName: '旧门店',
yqMerchantId: 100,
yqMerchantName: '园区甲'
}
]
}
})
await oldRequest
assert.equal(component.data.merchantList.length, 1)
assert.equal(component.data.merchantList[0].merchantName, '新门店')
})
it('输入新关键词后立即忽略防抖开始前返回的旧结果', async () => {
let resolveOldRequest
const componentConfig = await loadOrderPromptComponent({
getShopWithYqList() {
return new Promise(resolve => {
resolveOldRequest = resolve
})
}
})
const component = createOrderPromptInstance(componentConfig)
const oldRequest = component.loadOrderMerchantList({
reset: true,
keyword: '旧门店'
})
component.onMerchantKeywordInput({ detail: { value: '新门店' } })
resolveOldRequest({
code: 0,
data: {
pageNum: 1,
pageSize: 10,
total: 1,
pages: 1,
list: [
{
shopMerchantId: 13,
shopMerchantName: '旧门店',
yqMerchantId: 100,
yqMerchantName: '园区甲'
}
]
}
})
await oldRequest
clearTimeout(component.merchantSearchTimer)
assert.equal(component.data.merchantKeyword, '新门店')
assert.equal(component.data.merchantList.length, 0)
})
it('选择下单门店列表将触底事件接到分页加载方法', async () => {
const templateSource = await source(
'components/orderPromptPop/orderPromptPop.wxml'
)
assert.match(
templateSource,
/class="merchant-list"[\s\S]*bindscrolltolower="loadMoreOrderMerchantList"/
)
})
it('低价单筛选按精品升级场景查询账号关联门店', async () => {
const componentConfig = await loadStoreSelectComponent({
getShopWithYqList(params) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!