修改购物车Bug

msb_beta
ch 3 years ago
parent 1e8d4645c2
commit e3991f0867

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-03-17 17:42:32
* @LastEditors: ch
* @LastEditTime: 2022-04-21 11:38:48
* @LastEditTime: 2022-04-21 16:02:45
* @Description: 项目接口请求统一处理器返回一个需要token和不需要token的请求封装方法
*/

@ -2,13 +2,13 @@
* @Author: ch
* @Date: 2022-03-20 16:45:27
* @LastEditors: ch
* @LastEditTime: 2022-04-19 18:08:43
* @LastEditTime: 2022-04-21 16:48:27
* @Description: file content
-->
<template>
<view>
<UiGoodsGroup :listData="listData"></UiGoodsGroup>
<u-loadmore :status="loadingStatus" nomoreText="我也是有底线的啦~"/>
<u-loadmore :status="loadingStatus" color="#ccc" nomoreText="我也是有底线的啦~" />
</view>
</template>
<script>

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-03-20 13:11:55
* @LastEditors: ch
* @LastEditTime: 2022-04-07 15:34:03
* @LastEditTime: 2022-04-21 16:00:40
* @Description: file content
-->
<template>
@ -46,10 +46,11 @@ export default {
<style lang="scss" scoped>
.empty {
box-sizing: border-box;
width: 100%;
padding: 50rpx;
text-align: center;
background: $color-grey0;
margin: 20rpx 30rpx;
border-radius: 16rpx;
&--tips {
font-size: 26rpx;

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-04-07 17:22:44
* @LastEditors: ch
* @LastEditTime: 2022-04-09 15:02:28
* @LastEditTime: 2022-04-21 16:38:03
* @Description: file content
-->
@ -14,10 +14,11 @@
<image class="goods-item--img" :src="item.mainPicture" mode="widthFix"></image>
<view class="goods-item--title"><text>{{item.name}}</text></view>
<view class="goods-item--pirce-box">
<view>
<UiMoney :money="item.startingPrice" prefix class="goods-item--pirce"/>
<!-- <view>
<text class="goods-item--pirce">{{item.startingPrice}}</text>
<!-- <text class="goods-item--original-pirce">50</text> -->
</view>
<text class="goods-item--original-pirce">50</text>
</view> -->
<!-- <view>
<image class="goods-item--icon" src='@/static/index/bz.png'></image>
</view> -->
@ -34,10 +35,11 @@
<image class="goods-item--img" :src="item.mainPicture" mode="widthFix"></image>
<view class="goods-item--title"><text>{{item.name}}</text></view>
<view class="goods-item--pirce-box">
<view>
<UiMoney :money="item.startingPrice" prefix class="goods-item--pirce"/>
<!-- <view>
<text class="goods-item--pirce">{{item.startingPrice}}</text>
<!-- <text class="goods-item--original-pirce">50</text> -->
</view>
<text class="goods-item--original-pirce">50</text>
</view> -->
<!-- <view>
<image class="goods-item--icon" src='@/static/index/bz.png'></image>
</view> -->
@ -51,7 +53,9 @@
</view>
</template>
<script>
import UiMoney from './UiMoney.vue';
export default {
components: { UiMoney },
data(){
return {
// goodsLeftData : [],
@ -130,18 +134,15 @@ export default {
}
&--title{
font-size: $font-size-base;
padding: 20rpx 20rpx;
padding: 20rpx 20rpx 24rpx;
line-height: 36rpx;
font-weight: bold;
}
&--pirce-box{
padding:0 20rpx;
display: flex;
justify-content: space-between;
}
&--pirce{
font-size: $font-size-lg;
color: $color-yellow4;
}
&--original-pirce{
color: $color-grey3;
font-size: 20rpx;
@ -176,4 +177,18 @@ export default {
}
}
}
/deep/ {
.goods-item--pirce{
text{
font-size: $font-size-lg;
line-height: 32rpx;
color: $color-yellow4;
font-weight: bold;
}
.ui-money--prefix{
font-size: $font-size-sm;
}
}
}
</style>

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-03-31 14:49:33
* @LastEditors: ch
* @LastEditTime: 2022-04-14 10:01:14
* @LastEditTime: 2022-04-21 16:27:29
* @Description: file content
-->
<template>
@ -12,7 +12,7 @@
<view class="ui-goods-item--right">
<view class="ui-goods-item--con">
<text class="ui-goods-item--title">{{data.productName}}</text>
<text class="ui-goods-item--pirce">{{data.realAmount}}</text>
<UiMoney :money="data.realAmount"></UiMoney>
</view>
<view class="ui-goods-item--desc">
<text>{{data.skuDescribe}}</text>
@ -25,7 +25,9 @@
</view>
</template>
<script>
import UiMoney from './UiMoney.vue'
export default {
components: { UiMoney },
props : {
data : {
type : Object,

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-04-21 09:54:15
* @LastEditors: ch
* @LastEditTime: 2022-04-21 10:59:21
* @LastEditTime: 2022-04-21 15:41:48
* @Description: file content
-->
<template>
@ -50,7 +50,7 @@ export default {
return priceStr;
},
moneyArr (){
let moneyArr = this.money.toString().split('.');
let moneyArr = (this.money || '0').toString().split('.');
// 0 00
if(this.flaot){
if(!moneyArr[1]){
@ -66,4 +66,12 @@ export default {
}
</script>
<style lang="scss" scoped>
.ui-money{
// display: flex;
align-items: center;
text{
// display: block;
line-height: initial;
}
}
</style>

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-03-25 10:11:37
* @LastEditors: ch
* @LastEditTime: 2022-04-09 15:02:30
* @LastEditTime: 2022-04-21 15:27:05
* @Description: file content
-->
<template>
@ -37,7 +37,7 @@ export default {
display: flex;
justify-content: space-between;
align-items: center;
background: $color-grey0;
background: $color-grey1;
position: sticky;
top: var(--window-top);
z-index: 999;
@ -49,7 +49,8 @@ export default {
&--title{
flex: 1;
text-align: center;
font-size: $font-size-lg;
font-size: 36rpx;
font-weight: bold;
}
&--operation{
position: absolute;

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-03-22 13:54:15
* @LastEditors: ch
* @LastEditTime: 2022-04-20 15:32:04
* @LastEditTime: 2022-04-21 14:18:12
* @Description: file content
-->
<template>
@ -72,16 +72,6 @@ export default {
}
this.addresList = result;
this.$store.commit('SET_ADDRESS', result);
//
if(this.query.source=== 'submitOrder' && this.query.status === 'created'){
if(result.length){
uni.$emit('changeAddress',result.find(i => i.isDefault) || result[0], this.query.source);
}else{
uni.$emit('changeAddress',{}, this.query.source);
}
}
},
/**
* 选择地址

@ -3,12 +3,14 @@
<!-- 页面顶部 -->
<UiPageHeader :back="type == 'inner'" :class="`head__${type}`">
<template slot="custom">
<view :class="`head--title`">
<view class="head--title">
<text>购物车</text>
<text v-if="list.length">({{list.length}})</text>
</view>
<view v-if="mode == 'normal'" class="head--edit" @click="handleToggleMode"></view>
<view v-else class="head--finish" @click="handleToggleMode"></view>
<template v-if="list.length">
<view v-if="mode == 'normal'" class="head--edit" @click="handleToggleMode"></view>
<view v-else class="head--finish" @click="handleToggleMode"></view>
</template>
</template>
</UiPageHeader>
@ -21,26 +23,19 @@
</BsEmpty>
<!-- 购物车商品列表 -->
<view v-else class="cart-list">
<view class="cart-item" v-for="(item, index) in list" :key="index"
@click="$Router.push(`/goodsDetail?id=${item.id}`)">
<template v-else >
<UiWhiteBox class="cart-item" v-for="(item, index) in list" :key="index" >
<label class="cart-item--radio" @click.stop="handleCheckItem(item.id)">
<radio class="radio" color="#FF875B"
:checked="checkedIds.length ? checkedIds.includes(item.id) : false" />
</label>
<image class="cart-item--image" :src="item.product.mainPicture" mode="scaleToFill"></image>
<view class="cart-item--content">
<view class="cart-item--title"><text>{{ item.product.name }}</text></view>
<view class="cart-item--props">
<view class="cart-item--props-item" >
<text>{{ item.productSku.name }}</text>
</view>
</view>
<image class="cart-item--image" :src="item.product.mainPicture" mode="scaleToFill"
@click="$Router.push(`/goodsDetail?id=${item.productId}`)"></image>
<view class="cart-item--content" @click="$Router.push(`/goodsDetail?id=${item.productId}`)">
<view class="cart-item--title">{{ item.product.name }}</view>
<view class="cart-item--props">{{ item.productSku.name }}</view>
<view class="cart-item--footer">
<view class="cart-item--price">
<text class="unit"></text>
<text class="value">{{ item.productSku.sellPrice }}</text>
</view>
<UiMoney class="cart-item--price" :money="item.productSku.sellPrice" prefix></UiMoney>
<view class="cart-item--stepper">
<u-number-box :min="1" button-size="40rpx" bgColor="#F5F6FA"
:value="item.number" :max="item.maxBuyNum" @change="onChangeStepper($event, item)" >
@ -50,8 +45,8 @@
</view>
</view>
</view>
</view>
</view>
</UiWhiteBox>
</template>
<template v-if="!isLoading">
<view class="title">为您推荐</view>
@ -61,30 +56,17 @@
<!-- 底部操作栏 -->
<view v-if="list.length" :class="`footer footer__${type}`">
<label class="all-radio" @click="handleCheckAll">
<radio class="radio" color="#FF875B"
<radio class="radio" color="#FF875B"
:checked="checkedIds.length > 0 && checkedIds.length === list.length" />
<text>全选</text>
</label>
<view class="total-info">
<text>合计</text>
<view class="goods-price">
<text class="unit"></text>
<text class="value">{{ totalPrice }}</text>
</view>
<UiMoney class="goods-price" :money="totalPrice" prefix/>
</view>
<view class="cart-action">
<view class="btn-wrapper">
<!-- dev:下面的disabled条件使用checkedIds.join方式判断 -->
<!-- dev:通常情况下vue项目使用checkedIds.length更合理, 但是length属性在微信小程序中不起作用 -->
<view v-if="mode == 'normal'" class="btn-item btn-main" :class="{ disabled: checkedIds.length === 0 }"
@click="handleOrder()">
<text>去结算 {{ checkedIds.length > 0 ? `(${checkedIds.length})` : '' }}</text>
</view>
<view v-if="mode == 'edit'" class="btn-item btn-main" :class="{ disabled: !checkedIds.length }"
@click="handleDelete()">
<text>删除</text>
</view>
</view>
<UiButton v-if="mode == 'edit'" :disable="!checkedIds.length" @click="handleDelete"></UiButton>
<UiButton v-else type="gradual" :disable="!checkedIds.length" @click="handleOrder">({{list.length}})</UiButton>
</view>
</view>
</view>
@ -96,6 +78,9 @@ import BsEmpty from '@/components/BsEmpty.vue';
import BsChoiceGoods from '@/components/BsChoiceGoods.vue';
import UiPageHeader from '@/components/UiPageHeader.vue';
import {ApiGetCartList, ApiPutCartNum, ApiDeleteCartGoods} from '@/common/api/cart';
import UiMoney from '../../../components/UiMoney.vue';
import UiButton from '../../../components/UiButton.vue';
import UiWhiteBox from '../../../components/UiWhiteBox.vue';
const CartIdsIndex = 'CartIds';
@ -103,7 +88,10 @@ export default {
components: {
BsEmpty,
BsChoiceGoods,
UiPageHeader
UiPageHeader,
UiMoney,
UiButton,
UiWhiteBox
},
props : {
type : {
@ -280,32 +268,30 @@ export default {
const ids = this.checkedIds;
if (!ids.length) {
return false
}
uni.showModal({
title: '友情提示',
content: '您确定要删除该商品吗?',
showCancel: true,
success:async ()=> {
}
this.$msb.confirm({
content : '您确定要删除该商品吗?',
confirm : async ()=>{
const {error} = await ApiDeleteCartGoods({idList : ids.join(',')});
if(error){
uni.$u.toast(error.message);
return false;
}
this.list = this.list.filter(item => !ids.includes(item.id));
// this.checkedIds = [];
this.checkedIds = [];
this.onClearInvalidId();
}
})
}
})
}
}
}
</script>
<style>
<style lang="scss">
page {
background: #f5f5f5;
background: $color-grey1;
padding-bottom: 240rpx;
}
</style>
@ -321,6 +307,9 @@ export default {
position: sticky;
top: var(--window-top);
z-index: 999;
&--title text{
font-size: 36rpx;
}
&--totla{
font-size: 36rpx;
color: $color-grey6;
@ -342,17 +331,13 @@ export default {
}
//
.cart-list {
background: $color-grey0;
}
//
.cart-item {
width: 690rpx;
display: flex;
align-items: center;
padding: 30rpx 0;
margin: 0 auto 24rpx auto;
border-bottom: 1px solid $color-grey2;
padding: 50rpx 40rpx 40rpx 24rpx;
margin: 20rpx auto;
&--radio {
width: 56rpx;
height: 80rpx;
@ -390,7 +375,7 @@ export default {
&--props {
margin-top: 14rpx;
height: 40rpx;
color: #ababab;
color: $color-grey4;
font-size: $font-size-sm;
overflow: hidden;
@ -405,18 +390,6 @@ export default {
align-items: center;
margin-top: 20rpx;
}
&--price {
vertical-align: bottom;
color: $color-yellow4;
.unit {
font-size: 20rpx;
}
.value {
font-size: 22rpx;
font-weight: bold;
}
}
&--stepper-icon{
font-size: 38rpx;
color: $color-grey3;
@ -507,53 +480,28 @@ export default {
padding-right: 30rpx;
font-size: $font-size-sm;
color: $color-grey5;
.goods-price {
vertical-align: bottom;
color: $color-yellow3;
.unit {
font-size: $font-size-sm;
}
.value {
font-size: $font-size-lg;
}
}
}
.cart-action {
width: 200rpx;
.btn-wrapper {
height: 100%;
display: flex;
align-items: center;
}
.btn-item {
flex: 1;
font-size: $font-size-base;
height: 72rpx;
line-height: 72rpx;
text-align: center;
border-radius: 50rpx;
}
/deep/{
.cart-item--price{
text{
color: $color-grey0;
font-size: $font-size-base;
color: $color-yellow4;
}
}
//
.btn-main {
background: $color-yellow3;//linear-gradient(to right, #f9211c, #ff6335);
//
&.disabled {
background: rgba($color: $color-yellow3, $alpha: .7);
}
}
}
.ui-money--prefix{
font-size: $font-size-sm;
}
}
.goods-price{
text{
font-size: 40rpx;
color: $color-yellow4;
}
.ui-money--prefix{
font-size: $font-size-lg;
}
}
}
</style>

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-04-08 18:36:14
* @LastEditors: ch
* @LastEditTime: 2022-04-09 10:38:37
* @LastEditTime: 2022-04-21 15:46:55
* @Description: file content
-->
<template>
@ -25,7 +25,7 @@ export default {
<style lang="scss" >
page {
background: #f5f5f5;
background: $color-grey1;
padding-bottom: 240rpx;
}
</style>

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-03-24 11:30:55
* @LastEditors: ch
* @LastEditTime: 2022-04-19 10:51:46
* @LastEditTime: 2022-04-21 14:42:04
* @Description: file content
-->
<template>
@ -200,7 +200,9 @@ export default {
uni.$u.toast(error.message);
return false;
}
this.$Router.push('/cart');
uni.$u.toast('加入购物车成功~');
this.close();
// this.$Router.push('/cart');
},
/**
* 立即购买
@ -225,7 +227,7 @@ export default {
}
},
close(){
this.$emit('update:visible', false)
this.$emit('update:visible', false);
}
}
};

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-03-23 17:27:21
* @LastEditors: ch
* @LastEditTime: 2022-04-19 10:48:00
* @LastEditTime: 2022-04-21 14:49:48
* @Description: file content
-->
<template>
@ -112,7 +112,7 @@ export default {
const {query} = this.$Route;
const {error, result} = await ApiGetGoodsSkus({productId : query.id});
if(error) {
uni.$u.totast(error.message);
uni.$u.toast(error.message);
return false;
}
this.skuInfoData = result;

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-03-23 10:29:07
* @LastEditors: ch
* @LastEditTime: 2022-04-21 11:04:56
* @LastEditTime: 2022-04-21 16:23:22
* @Description: file content
-->
<template>
@ -140,6 +140,7 @@ export default {
text{
color: $color-yellow4;
font-size: $font-size-lg;
font-weight: bold;
}
.ui-money--prefix{
font-size: $font-size-sm;

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-03-23 10:07:48
* @LastEditors: ch
* @LastEditTime: 2022-04-21 11:13:03
* @LastEditTime: 2022-04-21 16:45:14
* @Description: file content
-->
<template>
@ -23,12 +23,10 @@
</view>
<view class="seckill--group">
<view v-for="item in data.activityProductListVO" :key="item.activityProductId">
<image class="seckill--item-img" :src="item.productMainPicture"></image>
<view class="seckill--item-pirce-box">
<!-- <text class="seckill--item-pirce-title">秒杀价</text> -->
<UiMoney class="seckill--item-pirce" :money="item.activityPrice" prefix></UiMoney>
<!-- <text class="seckill--item-pirce">{{item.activityPrice}}</text> -->
<view class="seckill--item-img-box">
<image class="seckill--item-img" :src="item.productMainPicture"></image>
</view>
<UiMoney class="seckill--item-pirce" :money="item.activityPrice" prefix></UiMoney>
<text class="seckill--item-original-pirce">{{item.originalPrice}}</text>
</view>
</view>
@ -121,6 +119,7 @@ export default {
}
&--left{
display: flex;
align-items: center;
}
&--time{
display: flex;
@ -134,46 +133,25 @@ export default {
}
&--time-name{
height: 100%;
padding: 0 22rpx 0 15rpx;
background: #FF512B;
padding: 0 32rpx 0 15rpx;
background: url('@/static/index/time_bg.png') right top no-repeat #FF512B;
background-size: 32rpx;
font-size: 22rpx;
color: #fff;
position: relative;
&::after{
display: block;
content: '';
width: 16rpx;
height: 36rpx;
background: #FF512B;
transform: rotate(40deg);
position: absolute;
right: -10rpx;
top: -12rpx;
}
}
&--time-time{
margin-right: 15rpx;
margin-right: 5rpx;
padding-right: 10rpx;
font-size: 22rpx;
color: #FF512B;
position: relative;
&::before{
display: block;
content: '';
width: 14rpx;
height: 36rpx;
background: #FFEDE9;
transform: rotate(40deg);
position: absolute;
left: -52rpx;
top: 8rpx;
z-index: 0;
}
}
&--time-icon{
width: 22rpx;
height: 22rpx;
padding-left: 20rpx;
margin-right: 8rpx;
}
&--more{
@ -197,28 +175,20 @@ export default {
margin-top: 30rpx;
}
&--item{
&-img{
&-img-box{
width: 200rpx;
height: 200rpx;
border-radius: 8rpx;
background: #F8F8F8;
}
&-pirce-box{
width: 180rpx;
height: 44rpx;
line-height: 44rpx;
background: linear-gradient(90deg, #FFE7DE 0%, #FFFFFF 100%);
border-radius: 20rpx;
text-align: center;
margin: 20rpx 0 10rpx 0;
}
&-pirce-title{
font-size: 22rpx;
color: $color-grey5;
&-img{
width: 100%;
height: 100%;
}
&-pirce{
color: #FF512B;
font-size: 32rpx;
text-align: center;
margin-top: 24rpx;
}
&-original-pirce{
display: block;
@ -226,6 +196,7 @@ export default {
color: #999;
text-decoration: line-through;
text-align: center;
margin-top: 6rpx;
}
}
@ -238,6 +209,7 @@ export default {
text{
color: $color-yellow4;
font-size: $font-size-lg;
font-weight: bold;
}
.ui-money--prefix{
font-size: $font-size-base;

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2019-08-22 19:41:20
* @LastEditors: ch
* @LastEditTime: 2022-04-20 19:02:05
* @LastEditTime: 2022-04-21 17:00:00
* @Description: file content
-->
<template>
@ -175,15 +175,11 @@ page{
display: block;
content: "";
width: 34rpx;
height: 38rpx;
background: url("@/static/index/search.png") no-repeat;
height: 42rpx;
background: url("@/static/index/search.png") 0 6rpx no-repeat;
background-size: 100%;
}
}
&--icon{
width: 34rpx;
height: 36rpx;
}
}

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-04-15 17:46:10
* @LastEditors: ch
* @LastEditTime: 2022-04-19 17:36:45
* @LastEditTime: 2022-04-21 14:49:57
* @Description: file content
-->
<template>
@ -82,7 +82,7 @@ export default {
orderId : this.$Route.query.id
});
if(error){
uni.$u.totast(error.message);
uni.$u.toast(error.message);
return false;
}
//

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-03-31 14:26:09
* @LastEditors: ch
* @LastEditTime: 2022-04-18 16:16:44
* @LastEditTime: 2022-04-21 14:49:52
* @Description: file content
-->
<template>
@ -59,7 +59,7 @@ export default {
async getOrderInfo(){
const {error, result} = await ApiGetOrderDetail(this.$Route.query.id);
if(error){
uni.$u.totast(error.message);
uni.$u.toast(error.message);
return false;
}
this.orderInfo = {...result};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 826 B

After

Width:  |  Height:  |  Size: 696 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 826 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 B

Loading…
Cancel
Save