Commit d97f9c25 by 李伟康

feat(OrderPopup): 新增套餐列表组件并优化商品列表

- 添加新的 PackageList 组件用于显示套餐列表
- 修改 GoodsList 组件,支持按套餐类型筛选商品
- 更新 OrderPopup 配置,增加套餐列表相关设置
- 调整 OrderPopup 布局,支持右侧弹出方式
- 修复 boutique 页面数据加载问题
1 parent ea4b3257
......@@ -76,7 +76,6 @@ export default {
arr.push(c)
}
})
console.log(arr)
this.searchList = arr
this.searchStatus = true
}
......
<template>
<view class="goods-list">
<!-- <template v-if="list.length"> -->
<template v-for="(item, index) in (searchStatus ? searchList : list)">
<view
:key="index"
@click="choose(item)"
:class="['item',{active: checkActive(item)}]"
>
<view class="title flex">
<view class="icon">
<uni-icons
type="circle"
:size="16"
color="#8C8C8C"
class="uni-icons"
></uni-icons>
<view class="sprite-icon icon-notice-success"></view>
</view>
{{item.packageGoods.packageAlias||item.packageGoods.packageName}}
<text class="price">¥{{item.packageGoods.upgradePrice}}</text>
</view>
<view class="package-list">
<template v-for="(i,ind) in item.packageGoods.goodsList">
<view
class="package-item flex"
:key="ind"
>
<view class="name">{{i.goodsAlias||i.upgradeGoodsAlias||i.upgradeGoodsName}}</view>
<view class="price">¥{{i.sellPrice}}</view>
</view>
</template>
</view>
</view>
</template>
<!-- </template> -->
</view>
</template>
<script type='text/ecmascript-6'>
import NP from 'number-precision'
export default {
name: 'GoodsList',
inject: ['userInfo', 'baseConfigData'],
data () {
return {
list: [],
currentIds: [],
chooseList: [],
searchStatus: false,
searchList: [],
}
},
props: {
params: Object,
data: [Object, Array],
cacheData: Array
},
mounted () {
},
methods: {
async getList (searchValue) {
const { userInfo, params } = this,
{ cacheData } = params
this.currentIds = []
this.chooseList = []
if (cacheData && cacheData.length) {
this.list = this.initGoodsList(cacheData)
if (searchValue) this.handleSearch(searchValue)
return
}
const { shopMerchantId, sceneType } = userInfo,
response = await uni.$api.popupApi.getGoodsList({
merchantId: shopMerchantId,
sceneType
})
if (response && response.length) {
this.list = this.initGoodsList(response)
params.cacheData = response
this.$emit('update:params', params)
}
},
handleSearch (searchValue) {
if (!searchValue) this.searchStatus = false
else {
let { list } = this,
goodsList = JSON.parse(JSON.stringify(list)),
arr = []
goodsList.map(c => {
let name = ''
if (c.goodsFlag == 3 && c.packageGoods) name = c.packageGoods.packageName || c.packageGoods.packageAlias
if (name.indexOf(searchValue) != -1) {
arr.push(c)
}
})
this.searchList = arr
this.searchStatus = true
}
},
initGoodsList (goodsData) {
let { data } = this,
arr = []
goodsData.map(val => {
if (val.goodsFlag == 3) {
val.packageGoods.upgradePrice = NP.round(val.packageGoods.goodsList.reduce((prev, cur) => {
prev = NP.plus(prev + cur.sellPrice);
return prev;
}, 0), 2)
arr.push(val)
}
})
if (data.length) data.map(e => {
this.currentIds.push(e.packageGoods.packageCode)
this.chooseList.push(e)
})
return arr
},
choose (i) {
let { packageCode } = i.packageGoods,
{ currentIds } = this,
index = currentIds.indexOf(packageCode)
if (index == -1) {
this.currentIds.push(packageCode)
this.chooseList.push(i)
}
else {
this.currentIds.splice(index, 1)
this.chooseList.splice(index, 1)
}
this.$emit('choose', this.chooseList)
},
replaceItemText (item, key) {
let reg = getRegExp(';~;', 'g'),
value = item[key]
return value ? value.replace(reg, ' ') : ''
},
checkActive (i) {
let { currentIds } = this,
active = false
if (currentIds.length) active = currentIds.includes(i.packageGoods.packageCode)
return active
}
}
}
</script>
<style scoped lang='scss'>
.goods-list {
display: flex;
flex-direction: column;
gap: 32rpx 0;
margin: 0 48rpx;
.item {
justify-content: center;
border-radius: 24rpx;
border: 2rpx solid #dce0e6;
box-sizing: border-box;
position: relative;
color: #333333;
font-size: 32rpx;
box-sizing: border-box;
padding: 0 32rpx 24rpx;
.price {
margin-left: auto;
}
.title {
line-height: 44rpx;
padding: 24rpx 0 20rpx;
.icon {
margin-right: 16rpx;
}
.sprite-icon {
display: none;
}
}
.package-list {
border-radius: 16rpx;
background-color: #f5f7fa;
padding-left: 32rpx;
overflow: hidden;
.package-item {
color: #333333;
font-size: 28rpx;
line-height: 40rpx;
padding: 24rpx 0;
border-bottom: 2rpx solid #f0f0ef;
padding-right: 32rpx;
.price {
margin-left: auto;
}
&:last-of-type {
border: none;
}
}
}
}
.active {
border-color: #2c66f7;
background: #ecf1ff;
color: #2c66f7;
.icon {
.uni-icons {
display: none;
}
.sprite-icon {
display: block;
}
}
.package-list {
background: #fff;
}
}
}
</style>
\ No newline at end of file
......@@ -79,15 +79,21 @@ const componentConfig = {
title: '选择商品(可多选)',
placeholder: '请输入名称',
idKey: 'goodsId',
goodsType: [5, 6, 7] // 后档
goodsType: [4] // 后档
},
10: {
name: 'GoodsList',
title: '选择商品(可多选)',
placeholder: '请输入名称',
idKey: 'goodsId',
goodsType: 'skylight' // 天窗
goodsType:[5, 6, 7] // 天窗
},
11:{
name: 'PackageList',
title: '选择套餐',
placeholder:'查找',
idKey: 'packageCode'
}
}
import EmployeeList from './components/EmployeeList.vue'
......@@ -95,6 +101,7 @@ import DiversionMerchant from './components/DiversionMerchant.vue'
import CarModelList from './components/CarModelList.vue'
import CouponList from './components/CouponList.vue'
import GoodsList from './components/GoodsList.vue'
import PackageList from './components/PackageList.vue'
export default {
data () {
return {
......@@ -106,6 +113,7 @@ export default {
DiversionMerchant,
CarModelList,
CouponList,
GoodsList
GoodsList,
PackageList
},
}
\ No newline at end of file
......@@ -5,7 +5,7 @@
:is-mask-click="maskClick"
:animation="animation"
>
<view :class="['popup-box']">
<view :class="['popup-box',{'right-box':position=='right'}]">
<view class="popup-title flex">
{{title}}
<view
......@@ -110,6 +110,7 @@ export default {
popupType: {
handler (val) {
this.componentObject = this.componentConfig[this.popupType]
if (val == 11 || val == 12) this.position = 'right'
},
deep: true,
immediate: true
......@@ -273,4 +274,12 @@ export default {
}
}
}
.right-box {
width: 46vw;
height: 100vh;
border-radius: 32rpx 0 0 32rpx;
.popup-footer {
margin: 0 48rpx;
}
}
</style>
\ No newline at end of file
......@@ -224,7 +224,7 @@ export default {
async getSoure () {
let baseConfigData = await uni.$api.systemApi.getBoutiqueMockData(true),
{moduleList, toolList, defaultCarId } = baseConfigData
this.$store.state.boutique.baseConfigData = configData
this.$store.state.boutique.baseConfigData = baseConfigData
this.moduleList = moduleList
this.toolList = toolList
this.defaultCarId = defaultCarId
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!