【代码评审】购物车提交的校验、bgStyle 样式

pull/131/MERGE
YunaiV 2024-12-11 13:08:55 +08:00
parent 39869cd92d
commit 164589f634
3 changed files with 52 additions and 18 deletions

View File

@ -1,6 +1,10 @@
<template> <template>
<s-layout :bgStyle="{ backgroundColor: '#fff' }" tabbar="/pages/index/cart" title="购物车"> <s-layout :bgStyle="{ backgroundColor: '#fff' }" tabbar="/pages/index/cart" title="购物车">
<s-empty v-if="state.list.length === 0" icon="/static/cart-empty.png" text="购物车空空如也,快去逛逛吧~" /> <s-empty
v-if="state.list.length === 0"
icon="/static/cart-empty.png"
text="购物车空空如也,快去逛逛吧~"
/>
<!-- 头部 --> <!-- 头部 -->
<view v-if="state.list.length" class="cart-box ss-flex ss-flex-col ss-row-between"> <view v-if="state.list.length" class="cart-box ss-flex ss-flex-col ss-row-between">
@ -24,16 +28,35 @@
<view v-for="item in state.list" :key="item.id" class="goods-box ss-r-10 ss-m-b-14"> <view v-for="item in state.list" :key="item.id" class="goods-box ss-r-10 ss-m-b-14">
<view class="ss-flex ss-col-center"> <view class="ss-flex ss-col-center">
<label class="check-box ss-flex ss-col-center ss-p-l-10" @tap="onSelectSingle(item.id)"> <label class="check-box ss-flex ss-col-center ss-p-l-10" @tap="onSelectSingle(item.id)">
<radio :checked="state.selectedIds.includes(item.id)" color="var(--ui-BG-Main)" <radio
style="transform: scale(0.8)" @tap.stop="onSelectSingle(item.id)" /> :checked="state.selectedIds.includes(item.id)"
color="var(--ui-BG-Main)"
style="transform: scale(0.8)"
@tap.stop="onSelectSingle(item.id)"
/>
</label> </label>
<s-goods-item :img="item.spu.picUrl || item.goods.image" :price="item.sku.price" <s-goods-item
:skuText="item.sku.properties.length>1? item.sku.properties.reduce((items2,items)=>items2.valueName+' '+items.valueName):item.sku.properties[0].valueName" :img="item.spu.picUrl || item.goods.image"
:title="item.spu.name" :price="item.sku.price"
:titleWidth="400" priceColor="#FF3000"> :skuText="
item.sku.properties.length > 1
? item.sku.properties.reduce(
(items2, items) => items2.valueName + ' ' + items.valueName,
)
: item.sku.properties[0].valueName
"
:title="item.spu.name"
:titleWidth="400"
priceColor="#FF3000"
>
<template v-if="!state.editMode" v-slot:tool> <template v-if="!state.editMode" v-slot:tool>
<su-number-box v-model="item.count" :max="item.sku.stock" :min="0" :step="1" <su-number-box
@change="onNumberChange($event, item)" /> v-model="item.count"
:max="item.sku.stock"
:min="0"
:step="1"
@change="onNumberChange($event, item)"
/>
</template> </template>
</s-goods-item> </s-goods-item>
</view> </view>
@ -44,8 +67,12 @@
<view class="cart-footer ss-flex ss-col-center ss-row-between ss-p-x-30 border-bottom"> <view class="cart-footer ss-flex ss-col-center ss-row-between ss-p-x-30 border-bottom">
<view class="footer-left ss-flex ss-col-center"> <view class="footer-left ss-flex ss-col-center">
<label class="check-box ss-flex ss-col-center ss-p-r-30" @tap="onSelectAll"> <label class="check-box ss-flex ss-col-center ss-p-r-30" @tap="onSelectAll">
<radio :checked="state.isAllSelected" color="var(--ui-BG-Main)" <radio
style="transform: scale(0.8)" @tap.stop="onSelectAll" /> :checked="state.isAllSelected"
color="var(--ui-BG-Main)"
style="transform: scale(0.8)"
@tap.stop="onSelectAll"
/>
<view class="ss-m-l-8"> 全选</view> <view class="ss-m-l-8"> 全选</view>
</label> </label>
<text>合计</text> <text>合计</text>
@ -54,12 +81,18 @@
</view> </view>
</view> </view>
<view class="footer-right"> <view class="footer-right">
<button v-if="state.editMode" class="ss-reset-button ui-BG-Main-Gradient pay-btn ui-Shadow-Main" <button
@tap="onDelete"> v-if="state.editMode"
class="ss-reset-button ui-BG-Main-Gradient pay-btn ui-Shadow-Main"
@tap="onDelete"
>
删除 删除
</button> </button>
<button v-else class="ss-reset-button ui-BG-Main-Gradient pay-btn ui-Shadow-Main" <button
@tap="onConfirm"> v-else
class="ss-reset-button ui-BG-Main-Gradient pay-btn ui-Shadow-Main"
@tap="onConfirm"
>
去结算 去结算
{{ state.selectedIds?.length ? `(${state.selectedIds.length})` : '' }} {{ state.selectedIds?.length ? `(${state.selectedIds.length})` : '' }}
</button> </button>
@ -133,8 +166,9 @@
reject('获取商品信息失败!!!'); reject('获取商品信息失败!!!');
return; return;
} }
let onlyExpress = false; // let onlyExpress = false; //
let onlyPickup = false; // let onlyPickup = false; //
// TODO @puhui999A B A B
const deliveryTypes = data.map((item) => item.deliveryTypes); const deliveryTypes = data.map((item) => item.deliveryTypes);
for (const deliveryType of deliveryTypes) { for (const deliveryType of deliveryTypes) {
// //

View File

@ -153,6 +153,7 @@
}); });
// 1 // 1
// TODO puhui999 color~
const bgMain = computed(() => { const bgMain = computed(() => {
if (navbarMode.value === 'inner') { if (navbarMode.value === 'inner') {
return { return {

View File

@ -194,7 +194,6 @@ const bindBrokerageUser = async (val = undefined) => {
if (!!data || msg.includes('不能绑定自己')) { if (!!data || msg.includes('不能绑定自己')) {
uni.removeStorageSync('shareId'); uni.removeStorageSync('shareId');
} }
} catch (e) { } catch (e) {
console.error(e); console.error(e);
} }