Commit 85fcb5e1 by 李伟康

refactor(OrderPopup): 优化 SkuPopup 组件

- 添加数据存在性检查,提高组件的健壮性
- 调整模板结构,确保仅在数据存在时渲染商品列表
- 优化确认按钮点击逻辑,增加数据存在性验证
1 parent 99d6018b
......@@ -17,38 +17,40 @@
</view>
</view>
<view class="popup-tips">温馨提示:请仔细确认当前售价,避免录错单</view>
<view class="popup-body">
<scroll-view
scroll-y
class="popup-scroll-view"
>
<view class="goods-list">
<template v-for="(i, index) in data.multipleSpecificationsGoods.skuGoodsList">
<view
:key="index"
@click="choose(i)"
:class="['item flex',{active: i.goodsId == currentId }]"
>
<view class="sprite-icon icon-tag-checked"></view>
<view class="text">
<view class="name"> {{data.multipleSpecificationsGoods.baseGoodsName}}</view>
<view
class="alias"
v-if="i.goodsAlias"
>
商品别名:{{i.goodsAlias}}
<template v-if="data">
<view class="popup-body">
<scroll-view
scroll-y
class="popup-scroll-view"
>
<view class="goods-list">
<template v-for="(i, index) in data.multipleSpecificationsGoods.skuGoodsList">
<view
:key="index"
@click="choose(i)"
:class="['item flex',{active: i.goodsId == currentId }]"
>
<view class="sprite-icon icon-tag-checked"></view>
<view class="text">
<view class="name"> {{data.multipleSpecificationsGoods.baseGoodsName}}</view>
<view
class="alias"
v-if="i.goodsAlias"
>
商品别名:{{i.goodsAlias}}
</view>
<view
class="position"
v-if="i.specificationStr "
>{{i.specificationStr}}</view>
</view>
<view
class="position"
v-if="i.specificationStr "
>{{i.specificationStr}}</view>
<view class="price">¥<text class="price-num">{{i.sellPrice}}</text>x1</view>
</view>
<view class="price">¥<text class="price-num">{{i.sellPrice}}</text>x1</view>
</view>
</template>
</view>
</scroll-view>
</view>
</template>
</view>
</scroll-view>
</view>
</template>
</popup>
</template>
......@@ -64,7 +66,7 @@ export default {
data () {
return {
data: {},
data: null,
currentId: ''
}
},
......@@ -94,11 +96,11 @@ export default {
this.currentId = i.goodsId
},
confirm () {
let { currentId, data } = this,
{ baseGoodsName, id, specificationGoodsMap, specificationList, skuGoodsList } = data.multipleSpecificationsGoods
if (!currentId) return uni.showToast({
let { currentId, data } = this
if (!currentId || !data) return uni.showToast({
title: '请勾选商品',
})
let { baseGoodsName, id, specificationGoodsMap, specificationList, skuGoodsList } = data.multipleSpecificationsGoods
let goods = skuGoodsList.find(e => e.goodsId == currentId)
this.$emit('onConfirm', {
count: 1,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!