Commit 4166c5af by 李伟康

feat(boutique,order-popup): 优化订单弹窗与确认页逻辑

1.  为确认订单页添加低价单场景下的按钮适配
2.  完善客户选择弹窗的分页加载、数据过滤与空状态提示
3.  重构弹窗混入代码风格与逻辑,添加滚动加载方法
1 parent 136cc55c
<template>
<view class="customer-list">
<template v-for="(i, index) in listData">
<view
:key="index"
@click="choose(i)"
:class="['item flex', { active: checkActive(i) }]"
>
<view class="sprite-icon icon-tag-checked"></view>
<view class="info flex text-hide">
<template v-if="i.customerName || (i.customer && i.customer.customerName)">
{{ i.customerName || (i.customer && i.customer.customerName) }}
</template>
<template v-if="i.carSeriesName || i.carType">
<view class="car-model text-hide">({{ i.carType ? i.carType : i.carChildsBrandName + '-' + i.carSeriesName || '' }})</view>
<view>
<view class="customer-list">
<template v-for="(i, index) in listData">
<view :key="index" @click="choose(i)" :class="['item flex', { active: checkActive(i) }]">
<view class="sprite-icon icon-tag-checked"></view>
<view class="info flex text-hide">
<template v-if="i.customerName || (i.customer && i.customer.customerName)">
{{ i.customerName || (i.customer && i.customer.customerName) }}
</template>
<template v-if="i.carSeriesName || i.carType">
<view class="car-model text-hide">({{ i.carType ? i.carType : i.carChildsBrandName + '-' +
i.carSeriesName
|| '' }})</view>
</template>
</view>
<template v-if="i.customerPhone || i.customer.customerPhone">
<view class="phone">|{{ i.customerPhone || (i.customer && i.customer.customerPhone) }}</view>
</template>
</view>
<template v-if="i.customerPhone || i.customer.customerPhone">
<view class="phone">|{{ i.customerPhone || (i.customer && i.customer.customerPhone) }}</view>
</template>
</view>
</template>
</template>
</view>
<view v-if="nothing" class="no-data">没有更多了</view>
</view>
</template>
......@@ -29,14 +30,14 @@ export default {
mixins: [popupmixin],
name: 'Customer',
inject: ['userInfo'],
data () {
data() {
return {
}
},
mounted () {
mounted() {
},
methods: {
async getList (searchValue, search) {
async getList(searchValue, search) {
const { userInfo, params } = this,
{ cacheData } = params
this.currentId = ''
......@@ -48,37 +49,36 @@ export default {
const { shopMerchantId } = userInfo
const isOrderSearch = !params.defeat && userInfo.sceneType == 1
const useWorkPackageGoods = params.defeat || isOrderSearch
let apiTargetName = useWorkPackageGoods ? 'getWorkPackageGoodsList' : 'getQuotationCustomerList'
let apiParams = useWorkPackageGoods
? {
let apiTargetName = useWorkPackageGoods ? 'getWorkPackageGoodsList' : 'getQuotationCustomerList',
useWorkPackageGoodsParams = {
merchantId: shopMerchantId,
pageSize: 20,
pageNum: 1,
statusList: [1],
sceneType: 1,
keyword: searchValue || ''
keyword: searchValue || '',
lowPriceFlag: 1 //过滤低价单
}
let apiParams = useWorkPackageGoods
? useWorkPackageGoodsParams
: {
merchantId: shopMerchantId,
pageSize: 999999,
currentPage: 1,
search: searchValue
}
const { list } = await uni.$api.popupApi[apiTargetName](apiParams)
const { list, total } = await uni.$api.popupApi[apiTargetName](apiParams)
let customerList = list
if (useWorkPackageGoods) {
const listArray = list.map(item => {
if (item.customer && item.customer.carSeriesName) {
item.carType = `${item.customer.carBrand || ''}-${item.customer.carChildsBrandName || ''}-${item.customer.carSeriesName || ''}`
}
return item
})
customerList = listArray
customerList = this.formatList(list)
params.requestParams = useWorkPackageGoodsParams
params.apiTargetName = apiTargetName
params.total = total || 0
}
console.log(customerList, 'customerList')
this.updateParams(params, customerList || [])
},
initData (list) {
initData(list) {
const { params: { idKey, defeat }, data, userInfo } = this
const isOrderSearch = !defeat && userInfo.sceneType == 1
let key = defeat || isOrderSearch ? 'id' : 'customerPhone'
......@@ -91,23 +91,51 @@ export default {
this.list = list
this.$emit('onComplete')
},
handleSearch (searchValue) {
handleSearch(searchValue) {
this.nothing = false
this.list = []
this.getList(searchValue, true)
},
choose (i) {
choose(i) {
let { params, userInfo } = this
const isOrderSearch = !params.defeat && userInfo.sceneType == 1
let key = params.defeat || isOrderSearch ? 'id' : 'customerPhone'
this.currentId = i[key]
this.$emit('choose', i)
},
checkActive (i) {
formatList(list) {
return list.map(item => {
if (item.customer && item.customer.carSeriesName) {
item.carType = `${item.customer.carBrand || ''}-${item.customer.carChildsBrandName || ''}-${item.customer.carSeriesName || ''}`
}
return item
})
},
checkActive(i) {
let { currentId, data, params, userInfo } = this
const isOrderSearch = !params.defeat && userInfo.sceneType == 1
let key = params.defeat || isOrderSearch ? 'id' : 'customerPhone'
return currentId ? (i[key] == currentId) : (i[key]) == data[params.idKey]
}
},
async loadMore() {
this.nothing = false
let { params } = this,
{ requestParams, total, apiTargetName, cacheData } = params,
{ pageNum, pageSize } = requestParams
if (Math.ceil(total / pageSize) > pageNum) {
requestParams.pageNum += 1
uni.showLoading({
title: '加载中'
})
const res = await uni.$api.popupApi[apiTargetName](requestParams)
uni.hideLoading()
params.apiTargetName = apiTargetName
params.total = res.total || total
params.requestParams = requestParams
let list = this.formatList(res.list || [])
this.updateParams(params, [...cacheData, ...list])
} else this.nothing = true
},
}
}
</script>
......@@ -135,10 +163,12 @@ export default {
top: 0;
right: 0;
}
.info{
.info {
max-width: 70%;
}
.phone{
.phone {
flex-shrink: 0;
}
}
......@@ -152,5 +182,14 @@ export default {
display: block;
}
}
}
.no-data {
color: #999;
text-align: center;
padding: toRpx(50) 0;
font-size: toRpx(24);
}
</style>
......@@ -5,7 +5,7 @@ export default {
userInfo: { default: () => ({}) },
baseConfigData: { default: () => ({}) }
},
data () {
data() {
return {
list: [],
searchStatus: false,
......@@ -13,6 +13,7 @@ export default {
chooseList: [],
currentId: '',
currentIds: [],
nothing: false
}
},
props: {
......@@ -31,19 +32,19 @@ export default {
}
},
computed: {
listData () {
listData() {
return this.searchStatus ? this.searchList : this.list
},
noData () {
noData() {
return !this.listData.length
},
sceneType(){
sceneType() {
return uni.$storage.get('userInfo').sceneType
}
},
watch: {
noData: {
handler (val) {
handler(val) {
let { params } = this
params.noData = val
this.updateParams(params)
......@@ -52,14 +53,14 @@ export default {
}
},
methods: {
updateParams (params, data) {
updateParams(params, data) {
if (data) {
this.initData && this.initData(data)
params.cacheData = data
}
this.$emit('update:params', params)
},
componentLoading (params) {
componentLoading(params) {
params.loadComplete = false
this.$emit('update:params', this.params)
},
......@@ -67,5 +68,4 @@ export default {
return checkMarketingIcon(item, this.showMarketingIcon)
}
}
}
\ No newline at end of file
}
......@@ -16,7 +16,7 @@
</view>
</template>
<view v-if="componentObject[popupType]" :class="['popup-body', { 'hide-footer': componentObject[popupType].hideFooter }, { 'hide-search': componentObject[popupType].hideSearch }, { 'hide-footer-search': componentObject[popupType].hideFooter && componentObject[popupType].hideSearch }]">
<scroll-view scroll-y :class="['popup-scroll-view', { show: componentObject[popupType].loadComplete }]">
<scroll-view scroll-y :class="['popup-scroll-view', { show: componentObject[popupType].loadComplete }]" @scrolltolower="loadMore">
<component :is="componentObject[popupType].name" :params.sync="componentObject[popupType]" :data="data" :dataKey="dataKey" :isDefeatOrder="isDefeatOrder" :defaultTime="datePickerDefaultTime" :positionTypeList="positionTypeList" :show-marketing-icon="showMarketingIcon" :boutique-order-types-only="boutiqueOrderTypesOnly" ref="componentRef" @choose="chooseContent = $event" @openSkuPopup="openSkuPopup" @onComplete="componentObject[popupType].loadComplete = true" @confirm="confirm"></component>
<template v-if="componentObject[popupType].noData">
<view class="nothing flex">暂无数据</view>
......@@ -295,6 +295,14 @@ export default {
else componentRef.reset()
this.chooseContent = null
},
loadMore () {
let componentRef = this.componentRef()
if (!componentRef) uni.showToast({
title: '请稍后再试',
icon: 'none'
})
else componentRef.loadMore()
}
}
}
</script>
......
......@@ -180,8 +180,8 @@
</view>
<view class="flex align-center footer-box justify-center">
<view class="edit btn" @click.stop="edit">修改</view>
<view class="confirm btn" @click.stop="confirm">确认</view>
<view class="edit btn" @click.stop="edit" v-if="lowPriceFlag != 1">修改</view>
<view :class="['confirm btn',{w100:lowPriceFlag == 1}]" @click.stop="confirm">确认</view>
</view>
</view>
<PublishPopup ref="tipsPopup" popupClass="tipsPopup" type="center" :showClose="true" :showTitle="false"
......@@ -249,6 +249,11 @@ export default {
PublishPopup,
OrderPopup
},
computed: {
lowPriceFlag() {
return this.orderInfo?.lowPriceFlag || 0
}
},
watch: {
transmissionOfData: {
handler(newVal) {
......@@ -1117,7 +1122,9 @@ export default {
color: #ffffff;
margin-left: toRpx(32);
}
.w100 {
width: 100%;
}
.edit {
background: #3b73ff1a;
color: #4673ff;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!