Commit 7ce5ceeb by 李伟康

feat(OrderPopup): 新增礼券列表功能

- 在 popupApi.js 中添加获取门店礼券列表和客户礼券列表的方法
- 新增 CouponList 组件用于显示礼券列表
- 在 OrderPopup 中集成 CouponList 组件
- 优化 OrderPopup 组件,支持礼券列表的缓存和搜索功能
1 parent b853cc6e
......@@ -32,4 +32,25 @@ module.exports = {
...data
})
},
/***
* 获取门店礼券列表
*/
getMerchantCouponList (data) {
return http.post({
method: 'dj.api.smartCarLife.merchant.coupon.list',
projectName: 'boutique',
...data
})
},
/**
* 获取客户礼券列表
*/
getCustomerCouponList (data) {
return http.post({
method: 'dj.api.customer.coupon.list',
projectName: 'boutique',
...data
})
},
}
\ No newline at end of file
<template>
<view class="car-model-box">
<scroll-view
class="scroll-view"
scroll-y
:scroll-into-view="letter"
>
<template v-for="(i, index) in (searchStatus ? searchList : list)">
<view
class="item-box"
:key="index"
>
<view class="letter-title flex">{{i.title}}</view>
<view class="brand-list">
<template v-for="(c,cindex) in i.list">
<view
:key="cindex"
:class="[
'item flex',
{active: currentId ? c.id == currentId : c.id == data[params.idKey]},
{disabled: c.disabled}
]"
@click="choose(c)"
>{{c.couponName}}{{c.merchantCouponCode}}</view>
</template>
</view>
</view>
</template>
</scroll-view>
<view class="letter-list">
<template v-for="(i, index) in list">
<view
class="letter-item"
:key="index"
@click="letter = i.letter"
>
{{i.letter}}
</view>
</template>
</view>
</view>
</template>
<script type='text/ecmascript-6'>
export default {
name: 'CarModelList',
inject: ['userInfo'],
data () {
return {
list: [],
currentId: '',
searchList: [],
searchStatus: false,
}
},
props: {
params: Object,
data: Object,
},
mounted () {
},
methods: {
async getList (searchValue) {
const { userInfo, params } = this,
{ cacheData } = params
this.currentId = ''
if (cacheData && cacheData.length) {
this.initCouponList(cacheData)
if (searchValue) this.handleSearch(searchValue)
return
}
const { shopMerchantId, merchantId } = userInfo,
data = await uni.$api.popupApi.getMerchantCouponList({
merchantId: shopMerchantId,
yqMerchantId: merchantId,
orderByType: 9
})
if (data && data.length) {
this.initCouponList(data)
params.cacheData = data
this.$emit('update:params', params)
}
},
initCouponList (data) {
let couponTypeList = Array.from(new Set([...data.map((e) => e.couponInfo.couponType)])),
couponList = couponTypeList.map((e, index) => {
let list = [];
let title = "";
data.map((i) => {
i.merchantCouponCode = i.merchantCouponCode.split("-")[0];
if (i.couponInfo.couponType == e) {
list.push(i);
title = i.couponInfo.couponTypeName;
}
});
return {
title,
list,
};
})
console.log(couponList)
this.list = couponList
},
handleSearch (searchValue) {
if (!searchValue) {
this.searchStatus = false
this.letter = 'A'
} else {
searchValue = searchValue.toUpperCase()
let { list } = this,
carBrand = JSON.parse(JSON.stringify(list))
let arr = [];
carBrand.map(c => {
c.list.map(i => {
let childs_list = [],
i_name = i.name.toUpperCase()
i.childs_list.map((k) => {
let k_name = k.name.toUpperCase()
if (k_name.indexOf(searchValue) != -1) {
childs_list.push(k);
}
});
if (i_name.indexOf(searchValue) != -1 || childs_list.length > 0) {
i.childs_list = childs_list.length > 0 ? childs_list : i.childs_list;
arr.push(i);
}
})
})
let letterList = Array.from(new Set([...arr.map((e) => e.letter)]));
let searchList = letterList.map((l) => {
let _list = [];
arr.map((i) => {
if (l === i.letter) {
_list.push(i);
}
})
return {
letter: l,
list: _list,
}
})
this.searchList = searchList
this.searchStatus = true
}
},
choose (that, item) {
if (that.isTitle) return
let chooseItem = {
carBrandId: item.id,
carBrand: item.name,
carChildsBrandId: that.carChildsBrandId,
carChildsBrandName: that.carChildsBrandName,
carSeriesId: that.id,
carSeriesName: that.name,
}
this.currentId = that.id
this.$emit('choose', chooseItem)
}
}
}
</script>
<style scoped lang='scss'>
.car-model-box {
position: relative;
height: 100%;
width: 100%;
.scroll-view {
height: 100%;
}
.letter-list {
position: absolute;
top: 50%;
transform: translateY(-50%);
right: 0;
color: #888888;
font-size: 28rpx;
line-height: 40rpx;
padding: 0 18rpx;
text-align: center;
}
.item-box {
margin-bottom: 32rpx;
.letter-title {
color: #888888;
font-size: 28rpx;
height: 40rpx;
background: #f5f7fa;
padding-left: 48rpx;
margin-bottom: 16rpx;
}
}
.brand-list {
// display: grid;
// grid-template-columns: repeat(4, 1fr);
gap: 32rpx;
display: flex;
// gap: 32rpx 0;
flex-wrap: wrap;
margin: 0 48rpx;
.item {
width: calc((100% - 96rpx) / 4);
justify-content: center;
min-height: 72rpx;
border-radius: 8rpx;
border: 2rpx solid #dce0e6;
box-sizing: border-box;
position: relative;
color: #333333;
font-size: 32rpx;
padding: 14rpx 16rpx;
word-break:break-all;
text-align: center;
.sprite-icon {
display: none;
position: absolute;
top: 0;
right: 0;
}
}
.active {
border-color: #2c66f7;
background: #ecf1ff;
color: #2c66f7;
.sprite-icon {
display: block;
}
}
}
}
</style>
\ No newline at end of file
......@@ -38,13 +38,20 @@ const componentConfig = {
placeholder: '查找',
idKey: 'carSeriesId'
},
5: {
name: 'CouponList',
title: '选择礼券',
placeholder: '查找',
idKey: 'customerCouponCode'
}
}
import EmployeeList from './components/EmployeeList.vue'
import DiversionMerchant from './components/DiversionMerchant.vue'
import CarModelList from './components/CarModelList.vue'
import CouponList from './components/CouponList.vue'
export default {
data(){
data () {
return {
componentConfig
}
......@@ -52,6 +59,7 @@ export default {
components: {
EmployeeList,
DiversionMerchant,
CarModelList
CarModelList,
CouponList
},
}
\ No newline at end of file
......@@ -112,30 +112,26 @@ export default {
position: 'bottom',
searchValue: '',
chooseContent: null,
componentObject: null,
}
},
watch: {
popupType: {
handler (val) {
this.searchValue = ''
this.componentObject = this.componentConfig[this.popupType]
},
deep: true,
immediate: true
},
externalData: {
handler (val) {
if (val) this.componentObject.cacheData = val
if (val && this.componentObject) this.componentObject.cacheData = val
},
deep: true,
}
},
computed: {
componentObject () {
return {
...this.componentConfig[this.popupType],
cacheData: []
}
},
title () {
return this.componentConfig[this.popupType].title
},
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!