完善签到
This commit is contained in:
@ -39,7 +39,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="column-end" @click.stop="count++">
|
||||
<view class="column-end" @click.stop="addCart(item)">
|
||||
<u-icon name="plus-circle-fill" color="#254062" size="48"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
@ -57,16 +57,28 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="buy mx40 px40 br60 row-between">
|
||||
<view class="row" @tap="showCart = true">
|
||||
<view class="row" @tap="showCartPopup">
|
||||
<view class="u-relative">
|
||||
<u-image :src="cloudPath + 'img/icon_cart.png'" width="80" height="80"></u-image>
|
||||
<view class="u-absolute top-0 right-0 text-fff number u-text-center xxs" v-if="buyNumber">
|
||||
{{ buyNumber }}
|
||||
<view class="u-absolute top-0 right-0 text-fff number u-text-center xxs" v-if="cartNum">
|
||||
{{ cartNum }}
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-m-l-32">
|
||||
<view class="row-center" v-if="totalPrice">
|
||||
<text class="text-fff">
|
||||
共计
|
||||
</text>
|
||||
<view class="primary u-m-t-10 u-m-l-20">
|
||||
<price-format :price="totalPrice" :subscriptSize="26" :firstSize="34" :secondSize="26"></price-format>
|
||||
</view>
|
||||
</view>
|
||||
<view class="text-fff" v-else>
|
||||
未选购商品
|
||||
</view>
|
||||
</view>
|
||||
<view class="text-fff u-m-l-32">未选购商品</view>
|
||||
</view>
|
||||
<view class="text-999">去结算</view>
|
||||
<view class="text-999" @tap="goSettle">去结算</view>
|
||||
</view>
|
||||
|
||||
<!-- 购物车 -->
|
||||
@ -75,31 +87,41 @@
|
||||
<view class="px20 text-999 mt20">
|
||||
温馨提示:请适量点餐
|
||||
</view>
|
||||
<view>
|
||||
<view v-if="cartLists.length > 0">
|
||||
<scroll-view style="height: 700rpx;" scroll-y="true" scroll-with-animation="true">
|
||||
<view class="row-start u-row-between u-p-t-20 u-padding-bottom-20 px20" v-for="(item, index) in 20" :key="index">
|
||||
<view class="row-start u-row-between u-p-t-20 u-padding-bottom-20 px20" v-for="(item, index) in cartLists" :key="index">
|
||||
<view class="row-start">
|
||||
<view>
|
||||
<u-image :src="cloudPath + 'img/banner.png'" width="136" height="136" border-radius="16"></u-image>
|
||||
<u-image :src="item.img" width="136" height="136" border-radius="16"></u-image>
|
||||
</view>
|
||||
<view class="ml20">
|
||||
<view class="u-line-2 u-p-t-10">葱烩海鲜卷边披萨</view>
|
||||
<view class="primary u-p-t-40">
|
||||
<price-format :price="12.9" :subscriptSize="22" :firstSize="34" :secondSize="26"></price-format>
|
||||
<view class="u-line-2 sm">{{ item.name }}</view>
|
||||
<view class="xxs text-999 u-m-t-8 attr u-p-6-8 u-p-b-8">
|
||||
<text>味浓芳香</text>
|
||||
<text class="u-m-l-8 u-m-r-8">|</text>
|
||||
<text>味浓芳香</text>
|
||||
<text class="u-m-l-8 u-m-r-8">|</text>
|
||||
<text>味浓芳香</text>
|
||||
</view>
|
||||
<view class="primary">
|
||||
<price-format :price="item.price" :subscriptSize="22" :firstSize="34" :secondSize="26"></price-format>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
<view class="u-text-right">
|
||||
<view class="u-text-right" @tap="deleteGoods(item.cart_id)">
|
||||
<u-icon class="u-p-t-10" name="trash" size="32"></u-icon>
|
||||
</view>
|
||||
<view class="u-p-t-30">
|
||||
<u-number-box min="1" v-model="numberVal" @change="changeNumber"></u-number-box>
|
||||
<u-number-box :disabled="item.cart_status != 0" :min="1" :max="item.item_stock" :value="item.goods_num" @blur="countChange($event, item.cart_id, item)" @minus="countChange($event, item.cart_id, item)" @plus="countChange($event, item.cart_id, item)"></u-number-box>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
<view class="u-text-center" style="height: 700rpx;line-height: 700rpx;" v-else>
|
||||
~ 暂无商品 ~
|
||||
</view>
|
||||
</view>
|
||||
</u-popup>
|
||||
<shop-spec v-model="showSpec" @close="showSpec = false"></shop-spec>
|
||||
@ -107,11 +129,21 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
mapActions,
|
||||
mapGetters
|
||||
} from 'vuex';
|
||||
import {
|
||||
loadingFun
|
||||
} from '@/utils/tools'
|
||||
import {
|
||||
getGoodsSearch,
|
||||
addCart,
|
||||
getPoster,
|
||||
getCartNum,
|
||||
getCartList,
|
||||
changeGoodsCount,
|
||||
deleteGoods
|
||||
} from '@/api/store';
|
||||
import {
|
||||
loadingType
|
||||
@ -136,10 +168,18 @@
|
||||
numberVal: 1,
|
||||
showCart: false,
|
||||
showSpec: false,
|
||||
count: 0
|
||||
goods_num: 0,
|
||||
cartLists: [],
|
||||
totalPrice: 0
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getCartNum()
|
||||
},
|
||||
methods: {
|
||||
...mapActions(['getCartNum']),
|
||||
|
||||
// 切换商品分类
|
||||
changeActive(index) {
|
||||
const {
|
||||
cateList
|
||||
@ -185,23 +225,108 @@
|
||||
this.goodsList = data.dataList
|
||||
this.status = data.status
|
||||
},
|
||||
|
||||
// 显示购物车弹出窗
|
||||
showCartPopup() {
|
||||
if (this.cartLists.length > 0) {
|
||||
this.showCart = true
|
||||
}
|
||||
// else {
|
||||
// this.$toast({
|
||||
// title: '请先添加商品'
|
||||
// });
|
||||
// }
|
||||
},
|
||||
|
||||
changeNumber() {
|
||||
// 添加到购物车(默认商品数量+1,可以让后端连表查询商品数量字段)
|
||||
async addCart(item) {
|
||||
const {
|
||||
code,
|
||||
data,
|
||||
msg
|
||||
} = await addCart({
|
||||
item_id: item.id,
|
||||
goods_num: 1
|
||||
});
|
||||
if (code == 1) {
|
||||
this.getCartListFun()
|
||||
}
|
||||
},
|
||||
|
||||
// 购物车商品里面的数量
|
||||
countChange({value}, cartId, item) {
|
||||
console.log("countChange", value, cartId, item);
|
||||
changeGoodsCount({
|
||||
cart_id: cartId,
|
||||
goods_num: value,
|
||||
}).then((res) => {
|
||||
if (res.code == 1) {
|
||||
this.getCartListFun()
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 获取购物车列表数据
|
||||
getCartListFun() {
|
||||
console.log("1>>>", 1);
|
||||
|
||||
getCartList().then((res) => {
|
||||
if (res.code == 1) {
|
||||
console.log("res>>>", res);
|
||||
|
||||
let {
|
||||
lists,
|
||||
total_amount
|
||||
} = res.data;
|
||||
// let cartType = 0;
|
||||
|
||||
// if (lists.length == 0) {
|
||||
// cartType = 2;
|
||||
// } else {
|
||||
// cartType = 1;
|
||||
// }
|
||||
|
||||
this.cartLists = lists;
|
||||
|
||||
// this.cartType = cartType;
|
||||
this.totalPrice = total_amount
|
||||
// this.isShow = true;
|
||||
this.getCartNum();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 购物车删除商品
|
||||
deleteGoods(cart_id) {
|
||||
deleteGoods({
|
||||
cart_id
|
||||
}).then((res) => {
|
||||
if (res.code == 1) {
|
||||
this.getCartListFun();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 去结算
|
||||
goSettle() {
|
||||
uni.navigateTo({
|
||||
url: `/pages/order_now/order_now?id=${id}`
|
||||
})
|
||||
},
|
||||
|
||||
// 跳转商品详情页
|
||||
toShop(id) {
|
||||
console.log(id)
|
||||
uni.navigateTo({
|
||||
url: `/pages/shop/shop?id=${id}`
|
||||
})
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['cartNum']),
|
||||
// 显示购物车数量
|
||||
buyNumber() {
|
||||
if (this.count > 0) {
|
||||
return this.count > 99 ? '99+' : this.count
|
||||
if (this.goods_num > 0) {
|
||||
return this.goods_num > 99 ? '99+' : this.goods_num
|
||||
}
|
||||
|
||||
return ''
|
||||
@ -242,7 +367,7 @@
|
||||
flex: none;
|
||||
height: 100%;
|
||||
background-color: #F7F8FA;
|
||||
|
||||
|
||||
.one-item {
|
||||
position: relative;
|
||||
text-align: center;
|
||||
|
||||
Reference in New Issue
Block a user