Commit 4166c5af by 李伟康

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

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