Commit 85fcb5e1 by 李伟康

refactor(OrderPopup): 优化 SkuPopup 组件

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