| | |
| | | <template> |
| | | <view class="cart"> |
| | | <u-swipe-action> |
| | | <u-swipe-action-item :options="options" v-for="(item, index) in list" :name="index" :key="index" @click="deleRow"> |
| | | <view class="cart-item"> |
| | | <view class="cart-item-check" @click="select(item)"> |
| | | <u-swipe-action-item :options="options" v-for="(item, index) in list" :name="index" :key="item.id" @click="deleRow" ref="item"> |
| | | <view class="cart-item" @click="jumpDetails(item.goodsId, item.status)"> |
| | | <view class="cart-item-check" @click.stop="select(index)"> |
| | | <image src="/static/icon/ic_agree@2x.png" mode="widthFix" v-if="!item.active"></image> |
| | | <image src="/static/icon/cart_ic_sel@2x.png" mode="widthFix" v-else></image> |
| | | </view> |
| | |
| | | <text>{{item.price[0]}}</text> |
| | | <text>.{{item.price[1]}}</text> |
| | | </view> |
| | | <u-number-box v-model="item.num" @change="changeNum(index)"></u-number-box> |
| | | <u-number-box v-model="item.num" @change.stop="changeNum(index)"></u-number-box> |
| | | </view> |
| | | </view> |
| | | </view> |
| | |
| | | <text>{{totalPrice[0]}}</text> |
| | | <text>.{{totalPrice[1]}}</text> |
| | | </view> |
| | | <view class="edit-right-btn">结算</view> |
| | | <view class="edit-right-btn" @click="jiesuan">结算</view> |
| | | </view> |
| | | </view> |
| | | <view style="width: 100%; height: env(safe-area-inset-bottom);"></view> |
| | |
| | | }, |
| | | onLoad() { |
| | | this.getList() |
| | | uni.$on('shuaxin', () => { |
| | | this.getList() |
| | | }) |
| | | }, |
| | | methods: { |
| | | jumpDetails(id, status) { |
| | | if (status === 1) return uni.showToast({ |
| | | title: '商品已下架', |
| | | icon: 'none' |
| | | }) |
| | | uni.navigateTo({ |
| | | url: '/pages/details/details?id=' + id |
| | | }) |
| | | }, |
| | | jiesuan() { |
| | | let arr = this.list.filter(item => item.active) |
| | | if (arr.length === 0) return uni.showToast({ |
| | | title: '至少选择一项商品', |
| | | icon: 'none' |
| | | }) |
| | | for (let i = 0; i < arr.length; i++) { |
| | | if (arr[i].status === 1) { |
| | | return uni.showToast({ |
| | | title: '请先删除已下架的商品', |
| | | icon: 'none' |
| | | }) |
| | | } |
| | | } |
| | | let shop = arr.map(item => { |
| | | return { |
| | | goodsNum: item.num, |
| | | goodsSkuId: item.goodsSkuId |
| | | } |
| | | }) |
| | | uni.setStorageSync('shop', shop) |
| | | uni.navigateTo({ |
| | | url: '/pages/confirm-order/confirm-order' |
| | | }) |
| | | }, |
| | | // 全选 |
| | | quanxuan() { |
| | | this.list.forEach((item) => { |
| | |
| | | }) |
| | | }, |
| | | // 单选 |
| | | select(item) { |
| | | item.active = !item.active |
| | | select(index) { |
| | | this.list[index].active = !this.list[index].active |
| | | }, |
| | | // 更新商品数量 |
| | | changeNum(index) { |
| | |
| | | .then(res => { |
| | | if (res.code === 200) { |
| | | this.list.splice(e.name, 1) |
| | | that.$refs.item.forEach(item => item.closeHandler(true)) |
| | | } |
| | | }) |
| | | }, |