2020-08-13 08:12:57 +00:00
|
|
|
|
<template>
|
|
|
|
|
<view>
|
|
|
|
|
<view class='shoppingCart copy-data'>
|
2021-06-11 09:41:16 +00:00
|
|
|
|
<view class='labelNav acea-row row-around'>
|
2020-08-13 08:12:57 +00:00
|
|
|
|
<view class='item'><text class='iconfont icon-xuanzhong'></text>100%正品保证</view>
|
|
|
|
|
<view class='item'><text class='iconfont icon-xuanzhong'></text>所有商品精挑细选</view>
|
|
|
|
|
<view class='item'><text class='iconfont icon-xuanzhong'></text>售后无忧</view>
|
|
|
|
|
</view>
|
2021-06-11 09:41:16 +00:00
|
|
|
|
<view class="borRadius14 cartBox">
|
|
|
|
|
<view
|
|
|
|
|
v-if="(cartList.valid.length === 0 && cartList.invalid.length === 0) || (cartList.valid.length > 0)"
|
|
|
|
|
class='nav acea-row row-between-wrapper'>
|
|
|
|
|
<view>购物数量 <text class='num font-color'>{{cartCount}}</text></view>
|
|
|
|
|
<view v-if="cartList.valid.length > 0 || cartList.invalid.length > 0"
|
|
|
|
|
class='administrate acea-row row-center-wrapper' @click='manage'>{{ footerswitch ? '管理' : '取消'}}
|
2020-08-13 08:12:57 +00:00
|
|
|
|
</view>
|
2021-06-11 09:41:16 +00:00
|
|
|
|
</view>
|
|
|
|
|
<view v-if="cartList.valid.length > 0 || cartList.invalid.length > 0" class="pad30">
|
2023-08-29 15:28:17 +00:00
|
|
|
|
<!-- 有效的购物车 -->
|
|
|
|
|
<view class='list'>
|
2021-06-11 09:41:16 +00:00
|
|
|
|
<checkbox-group @change="checkboxChange">
|
|
|
|
|
<block v-for="(item,index) in cartList.valid" :key="index">
|
|
|
|
|
<view class='item acea-row row-between-wrapper'>
|
|
|
|
|
<!-- #ifndef MP -->
|
2023-08-29 15:28:17 +00:00
|
|
|
|
<checkbox :value="(item.id).toString()" :checked="item.selected"
|
|
|
|
|
:disabled="!item.canChecked && footerswitch" style="margin-right: 10rpx;" />
|
2021-06-11 09:41:16 +00:00
|
|
|
|
<!-- #endif -->
|
|
|
|
|
<!-- #ifdef MP -->
|
2023-08-29 15:28:17 +00:00
|
|
|
|
<checkbox :value="item.id" :checked="item.selected"
|
|
|
|
|
:disabled="!item.canChecked && footerswitch" />
|
2021-06-11 09:41:16 +00:00
|
|
|
|
<!-- #endif -->
|
2023-08-29 15:28:17 +00:00
|
|
|
|
<navigator :url='"/pages/goods_details/index?id=" + item.spu.id' hover-class='none'
|
|
|
|
|
class='picTxt acea-row row-between-wrapper'>
|
2021-06-11 09:41:16 +00:00
|
|
|
|
<view class='pictrue'>
|
2023-08-29 15:28:17 +00:00
|
|
|
|
<image v-if="item.sku" :src='item.sku.picUrl' />
|
|
|
|
|
<image v-else :src='item.spu.picUrl' />
|
2021-06-11 09:41:16 +00:00
|
|
|
|
</view>
|
|
|
|
|
<view class='text'>
|
2023-08-29 15:28:17 +00:00
|
|
|
|
<view class='line1' :class="item.canChecked?'':'reColor'">
|
|
|
|
|
{{ item.spu.name }}
|
2021-06-11 09:41:16 +00:00
|
|
|
|
</view>
|
2023-08-29 15:28:17 +00:00
|
|
|
|
<view class='infor line1' v-if="item.sku.properties">属性:
|
|
|
|
|
<text v-for="property in item.sku.properties" style="padding-left: 2px">{{property.valueName}}</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view class='money' v-if="item.canChecked">¥{{ fen2yuan(item.sku.price) }}</view>
|
|
|
|
|
<!-- TODO 芋艿:重选 -->
|
|
|
|
|
<view class="reElection acea-row row-between-wrapper" v-else>
|
2021-06-11 09:41:16 +00:00
|
|
|
|
<view class="title">请重新选择商品规格</view>
|
2023-08-29 15:28:17 +00:00
|
|
|
|
<view class="reBnt cart-color acea-row row-center-wrapper" @click.stop="reElection(item)">重选</view>
|
2021-06-11 09:41:16 +00:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2023-08-29 15:28:17 +00:00
|
|
|
|
<view class='carnum acea-row row-center-wrapper' v-if="item.canChecked">
|
|
|
|
|
<view class="reduce" :class="item.numSub ? 'on' : ''" @click.stop='subCart(index)'>-</view>
|
|
|
|
|
<view class='num'>{{ item.count }}</view>
|
|
|
|
|
<view class="plus" :class="item.numAdd ? 'on' : ''" @click.stop='addCart(index)'>+</view>
|
2021-06-11 09:41:16 +00:00
|
|
|
|
</view>
|
|
|
|
|
</navigator>
|
2020-08-13 08:12:57 +00:00
|
|
|
|
</view>
|
2021-06-11 09:41:16 +00:00
|
|
|
|
</block>
|
|
|
|
|
</checkbox-group>
|
|
|
|
|
</view>
|
2023-08-29 15:28:17 +00:00
|
|
|
|
<!-- 无效的购物车 -->
|
|
|
|
|
<view v-if="cartList.invalid.length > 0" class='invalidGoods borRadius14'
|
|
|
|
|
:style="cartList.valid.length === 0 && cartList.invalid.length > 0
|
|
|
|
|
? 'position: relative;z-index: 111;top: -120rpx;'
|
|
|
|
|
:'position: static;'">
|
2021-06-11 09:41:16 +00:00
|
|
|
|
<view class='goodsNav acea-row row-between-wrapper'>
|
|
|
|
|
<view v-if="cartList.invalid.length > 1 || cartList.valid.length > 0" @click='goodsOpen'>
|
2023-08-29 15:28:17 +00:00
|
|
|
|
<text class='iconfont' :class='goodsHidden ? "icon-xiangxia":"icon-xiangshang"' /> 失效商品
|
2021-06-11 09:41:16 +00:00
|
|
|
|
</view>
|
2023-08-29 15:28:17 +00:00
|
|
|
|
<view v-else>失效商品</view>
|
|
|
|
|
<view class='del' @click='unsetCart'>
|
|
|
|
|
<text class='iconfont icon-shanchu1' />清空
|
|
|
|
|
</view>
|
2021-06-11 09:41:16 +00:00
|
|
|
|
</view>
|
|
|
|
|
<view class='goodsList' :hidden='goodsHidden'>
|
|
|
|
|
<block v-for="(item,index) in cartList.invalid" :key='index'>
|
|
|
|
|
<view class='item acea-row row-between-wrapper'>
|
|
|
|
|
<view class='invalid'>失效</view>
|
|
|
|
|
<view class='picTxt acea-row row-between-wrapper'>
|
|
|
|
|
<view class='pictrue'>
|
2023-08-29 15:28:17 +00:00
|
|
|
|
<image v-if="item.sku" :src='item.sku.picUrl' />
|
|
|
|
|
<image v-else :src='item.spu.picUrl' />
|
2021-06-11 09:41:16 +00:00
|
|
|
|
</view>
|
|
|
|
|
<view class='text acea-row row-column-between'>
|
2023-08-29 15:28:17 +00:00
|
|
|
|
<view class='line1 name'>{{ item.spu.name }}</view>
|
|
|
|
|
<view class='infor line1' v-if="item.sku.properties">属性:
|
|
|
|
|
<text v-for="property in item.sku.properties" style="padding-left: 2px">{{property.valueName}}</text>
|
|
|
|
|
</view>
|
2021-06-11 09:41:16 +00:00
|
|
|
|
<view class='acea-row row-between-wrapper'>
|
|
|
|
|
<view class='end'>该商品已失效</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2020-08-13 08:12:57 +00:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2021-06-11 09:41:16 +00:00
|
|
|
|
</block>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2020-08-13 08:12:57 +00:00
|
|
|
|
</view>
|
2023-08-29 15:28:17 +00:00
|
|
|
|
<!-- TODO -->
|
2023-06-04 16:03:30 +00:00
|
|
|
|
<view class='noCart' v-if="cartList.valid.length === 0 && cartList.invalid.length === 0 && canShow">
|
2021-06-11 09:41:16 +00:00
|
|
|
|
<view class='pictrue'>
|
|
|
|
|
<image src='../../static/images/noCart.png'></image>
|
|
|
|
|
</view>
|
|
|
|
|
<recommend :hostProduct='hostProduct'></recommend>
|
2020-08-13 08:12:57 +00:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2021-06-11 09:41:16 +00:00
|
|
|
|
</view>
|
2023-08-29 15:28:17 +00:00
|
|
|
|
<!-- TODO -->
|
|
|
|
|
<view class='footer acea-row row-between-wrapper' v-if="cartList.valid.length > 0">
|
2021-06-11 09:41:16 +00:00
|
|
|
|
<view>
|
|
|
|
|
<checkbox-group @change="checkboxAllChange">
|
|
|
|
|
<checkbox value="all" :checked="!!isAllSelect" />
|
|
|
|
|
<text class='checkAll'>全选({{selectValue.length}})</text>
|
|
|
|
|
</checkbox-group>
|
2020-08-13 08:12:57 +00:00
|
|
|
|
</view>
|
2023-08-29 15:58:33 +00:00
|
|
|
|
<view class='money acea-row row-middle' v-if="footerswitch">
|
|
|
|
|
<text class='font-color'>¥{{ fen2yuan(selectCountPrice) }}</text>
|
2021-06-11 09:41:16 +00:00
|
|
|
|
<form @submit="subOrder" report-submit='true'>
|
|
|
|
|
<button class='placeOrder bg-color' formType="submit">立即下单</button>
|
|
|
|
|
</form>
|
|
|
|
|
</view>
|
|
|
|
|
<view class='button acea-row row-middle' v-else>
|
|
|
|
|
<form @submit="subCollect" report-submit='true'>
|
|
|
|
|
<button class='bnt cart-color' formType="submit">收藏</button>
|
|
|
|
|
</form>
|
|
|
|
|
<form @submit="subDel" report-submit='true'>
|
|
|
|
|
<button class='bnt' formType="submit">删除</button>
|
|
|
|
|
</form>
|
2020-08-13 08:12:57 +00:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2023-08-29 15:28:17 +00:00
|
|
|
|
<!-- SKU 不可用的商品,重新选择 SKU TODO -->
|
|
|
|
|
<productWindow :attr="attr" :isShow='1' :iSplus='1' :iScart='1' @myevent="onMyEvent" @ChangeAttr="ChangeAttr"
|
2021-06-11 09:41:16 +00:00
|
|
|
|
@ChangeCartNum="ChangeCartNum" @attrVal="attrVal" @iptCartNum="iptCartNum" @goCat="reGoCat"
|
|
|
|
|
id='product-window'></productWindow>
|
2023-08-29 15:28:17 +00:00
|
|
|
|
<view class="uni-p-b-96" />
|
|
|
|
|
<view class="uni-p-b-98" />
|
2020-08-13 08:12:57 +00:00
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2021-03-19 10:26:43 +00:00
|
|
|
|
let sysHeight = 0
|
2023-08-29 15:58:33 +00:00
|
|
|
|
import { cartDel, getResetCart } from '@/api/order.js';
|
2023-08-29 15:28:17 +00:00
|
|
|
|
import { getProductHot, collectAll, getProductDetail } from '@/api/store.js';
|
|
|
|
|
import { toLogin } from '@/libs/login.js';
|
|
|
|
|
import { mapGetters } from "vuex";
|
2020-08-13 08:12:57 +00:00
|
|
|
|
import recommend from '@/components/recommend';
|
|
|
|
|
import productWindow from '@/components/productWindow';
|
2023-08-29 15:28:17 +00:00
|
|
|
|
import * as TradeCartApi from '@/api/trade/cart.js';
|
|
|
|
|
import * as Util from '@/utils/util.js';
|
|
|
|
|
export default {
|
2020-08-13 08:12:57 +00:00
|
|
|
|
components: {
|
|
|
|
|
recommend,
|
|
|
|
|
productWindow,
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
2021-06-11 09:41:16 +00:00
|
|
|
|
goodsHidden: false,
|
2020-08-13 08:12:57 +00:00
|
|
|
|
footerswitch: true,
|
|
|
|
|
hostProduct: [],
|
2023-08-29 15:28:17 +00:00
|
|
|
|
hotPage: 1,
|
|
|
|
|
hotLimit: 10,
|
|
|
|
|
hotScroll: false,
|
|
|
|
|
|
2023-08-29 15:58:33 +00:00
|
|
|
|
cartList: { // 购物车列表
|
|
|
|
|
valid: [], // 有效
|
|
|
|
|
invalid: [] // 无效
|
2020-08-13 08:12:57 +00:00
|
|
|
|
},
|
2023-08-29 15:28:17 +00:00
|
|
|
|
isAllSelect: false, // 是否全选
|
|
|
|
|
selectValue: [], // 选中的数据
|
2023-08-29 15:58:33 +00:00
|
|
|
|
selectCountPrice: 0.00, // 选中的金额
|
|
|
|
|
cartCount: 0, // 选中的商品数量
|
2023-08-29 15:28:17 +00:00
|
|
|
|
|
2020-08-13 08:12:57 +00:00
|
|
|
|
loading: false,
|
|
|
|
|
loadTitle: '加载更多', //提示语
|
|
|
|
|
attr: {
|
|
|
|
|
cartAttr: false,
|
|
|
|
|
productAttr: [],
|
|
|
|
|
productSelect: {}
|
|
|
|
|
},
|
|
|
|
|
productValue: [], //系统属性
|
2021-06-11 09:41:16 +00:00
|
|
|
|
productInfo: {},
|
2020-08-13 08:12:57 +00:00
|
|
|
|
attrValue: '', //已选属性
|
|
|
|
|
attrTxt: '请选择', //属性页面提示
|
|
|
|
|
cartId: 0,
|
2021-03-19 10:26:43 +00:00
|
|
|
|
product_id: 0,
|
2021-06-11 09:41:16 +00:00
|
|
|
|
sysHeight: sysHeight,
|
|
|
|
|
canShow: false
|
2020-08-13 08:12:57 +00:00
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
computed: mapGetters(['isLogin']),
|
|
|
|
|
onLoad: function(options) {
|
2023-08-29 15:28:17 +00:00
|
|
|
|
if (!this.isLogin) {
|
2020-08-13 08:12:57 +00:00
|
|
|
|
toLogin();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onShow: function() {
|
2021-06-11 09:41:16 +00:00
|
|
|
|
this.canShow = false
|
2023-06-04 16:03:30 +00:00
|
|
|
|
if (this.isLogin === true) {
|
2023-08-29 15:28:17 +00:00
|
|
|
|
// 加载热门商品
|
2020-08-13 08:12:57 +00:00
|
|
|
|
this.hotPage = 1;
|
2023-08-29 15:28:17 +00:00
|
|
|
|
this.hotLimit = 10;
|
|
|
|
|
this.hostProduct = [];
|
|
|
|
|
this.hotScroll = false;
|
|
|
|
|
this.loadend = false;
|
|
|
|
|
|
|
|
|
|
// 加载购物车列表
|
|
|
|
|
this.footerswitch = true;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
this.hotScroll = false;
|
|
|
|
|
this.cartList = {
|
2023-06-04 16:03:30 +00:00
|
|
|
|
valid: [],
|
|
|
|
|
invalid: []
|
|
|
|
|
};
|
2023-08-29 15:58:33 +00:00
|
|
|
|
this.isAllSelect = false; // 全选
|
|
|
|
|
this.selectValue = []; // 选中的数据
|
|
|
|
|
this.selectCountPrice = 0.00;
|
|
|
|
|
this.cartCount = 0;
|
2023-08-29 15:28:17 +00:00
|
|
|
|
this.getCartList();
|
2023-06-04 16:03:30 +00:00
|
|
|
|
}
|
2020-08-13 08:12:57 +00:00
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
// 修改购物车
|
|
|
|
|
reGoCat: function() {
|
|
|
|
|
let that = this,
|
|
|
|
|
productSelect = that.productValue[this.attrValue];
|
|
|
|
|
//如果有属性,没有选择,提示用户选择
|
|
|
|
|
if (
|
|
|
|
|
that.attr.productAttr.length &&
|
|
|
|
|
productSelect === undefined
|
|
|
|
|
)
|
|
|
|
|
return that.$util.Tips({
|
|
|
|
|
title: "产品库存不足,请选择其它"
|
|
|
|
|
});
|
2021-06-11 09:41:16 +00:00
|
|
|
|
|
2020-08-13 08:12:57 +00:00
|
|
|
|
let q = {
|
|
|
|
|
id: that.cartId,
|
|
|
|
|
productId: that.product_id,
|
|
|
|
|
num: that.attr.productSelect.cart_num,
|
|
|
|
|
unique: that.attr.productSelect !== undefined ?
|
2021-06-11 09:41:16 +00:00
|
|
|
|
that.attr.productSelect.unique : that.productInfo.id
|
2020-08-13 08:12:57 +00:00
|
|
|
|
};
|
|
|
|
|
getResetCart(q)
|
|
|
|
|
.then(function(res) {
|
|
|
|
|
that.attr.cartAttr = false;
|
|
|
|
|
that.$util.Tips({
|
|
|
|
|
title: "添加购物车成功",
|
|
|
|
|
success: () => {
|
|
|
|
|
that.loadend = false;
|
|
|
|
|
that.cartList.valid = [];
|
|
|
|
|
that.getCartList();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
.catch(res => {
|
|
|
|
|
return that.$util.Tips({
|
2020-11-05 08:21:06 +00:00
|
|
|
|
title: res
|
2020-08-13 08:12:57 +00:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
onMyEvent: function() {
|
|
|
|
|
this.$set(this.attr, 'cartAttr', false);
|
|
|
|
|
},
|
|
|
|
|
reElection: function(item) {
|
|
|
|
|
this.getGoodsDetails(item)
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 获取产品详情
|
2023-06-04 16:03:30 +00:00
|
|
|
|
*
|
2020-08-13 08:12:57 +00:00
|
|
|
|
*/
|
|
|
|
|
getGoodsDetails: function(item) {
|
|
|
|
|
uni.showLoading({
|
|
|
|
|
title: '加载中',
|
|
|
|
|
mask: true
|
|
|
|
|
});
|
|
|
|
|
let that = this;
|
|
|
|
|
that.cartId = item.id;
|
|
|
|
|
that.product_id = item.productId;
|
|
|
|
|
getProductDetail(item.productId).then(res => {
|
|
|
|
|
uni.hideLoading();
|
|
|
|
|
that.attr.cartAttr = true;
|
2021-06-11 09:41:16 +00:00
|
|
|
|
let productInfo = res.data.productInfo;
|
|
|
|
|
that.$set(that, 'productInfo', productInfo);
|
2020-08-13 08:12:57 +00:00
|
|
|
|
that.$set(that.attr, 'productAttr', res.data.productAttr);
|
|
|
|
|
that.$set(that, 'productValue', res.data.productValue);
|
|
|
|
|
that.DefaultSelect();
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
uni.hideLoading();
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 属性变动赋值
|
2023-06-04 16:03:30 +00:00
|
|
|
|
*
|
2020-08-13 08:12:57 +00:00
|
|
|
|
*/
|
|
|
|
|
ChangeAttr: function(res) {
|
|
|
|
|
let productSelect = this.productValue[res];
|
|
|
|
|
if (productSelect && productSelect.stock > 0) {
|
|
|
|
|
this.$set(this.attr.productSelect, "image", productSelect.image);
|
|
|
|
|
this.$set(this.attr.productSelect, "price", productSelect.price);
|
|
|
|
|
this.$set(this.attr.productSelect, "stock", productSelect.stock);
|
|
|
|
|
this.$set(this.attr.productSelect, "unique", productSelect.id);
|
|
|
|
|
this.$set(this.attr.productSelect, "cart_num", 1);
|
|
|
|
|
this.$set(this, "attrValue", res);
|
|
|
|
|
this.$set(this, "attrTxt", "已选择");
|
|
|
|
|
} else {
|
2021-06-11 09:41:16 +00:00
|
|
|
|
this.$set(this.attr.productSelect, "image", this.productInfo.image);
|
|
|
|
|
this.$set(this.attr.productSelect, "price", this.productInfo.price);
|
2020-08-13 08:12:57 +00:00
|
|
|
|
this.$set(this.attr.productSelect, "stock", 0);
|
2021-06-11 09:41:16 +00:00
|
|
|
|
this.$set(this.attr.productSelect, "unique", this.productInfo.id);
|
2020-08-13 08:12:57 +00:00
|
|
|
|
this.$set(this.attr.productSelect, "cart_num", 0);
|
|
|
|
|
this.$set(this, "attrValue", "");
|
|
|
|
|
this.$set(this, "attrTxt", "请选择");
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 默认选中属性
|
2023-06-04 16:03:30 +00:00
|
|
|
|
*
|
2020-08-13 08:12:57 +00:00
|
|
|
|
*/
|
|
|
|
|
DefaultSelect: function() {
|
|
|
|
|
let productAttr = this.attr.productAttr;
|
|
|
|
|
let value = [];
|
|
|
|
|
for (let key in this.productValue) {
|
|
|
|
|
if (this.productValue[key].stock > 0) {
|
|
|
|
|
value = this.attr.productAttr.length ? key.split(",") : [];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (let i = 0; i < productAttr.length; i++) {
|
|
|
|
|
this.$set(productAttr[i], "index", value[i]);
|
|
|
|
|
}
|
|
|
|
|
//sort();排序函数:数字-英文-汉字;
|
|
|
|
|
let productSelect = this.productValue[value.sort().join(",")];
|
|
|
|
|
if (productSelect && productAttr.length) {
|
|
|
|
|
this.$set(
|
|
|
|
|
this.attr.productSelect,
|
|
|
|
|
"storeName",
|
2021-06-11 09:41:16 +00:00
|
|
|
|
this.productInfo.storeName
|
2020-08-13 08:12:57 +00:00
|
|
|
|
);
|
|
|
|
|
this.$set(this.attr.productSelect, "image", productSelect.image);
|
|
|
|
|
this.$set(this.attr.productSelect, "price", productSelect.price);
|
|
|
|
|
this.$set(this.attr.productSelect, "stock", productSelect.stock);
|
|
|
|
|
this.$set(this.attr.productSelect, "unique", productSelect.id);
|
|
|
|
|
this.$set(this.attr.productSelect, "cart_num", 1);
|
|
|
|
|
this.$set(this, "attrValue", value.sort().join(","));
|
|
|
|
|
this.$set(this, "attrTxt", "已选择");
|
|
|
|
|
} else if (!productSelect && productAttr.length) {
|
|
|
|
|
this.$set(
|
|
|
|
|
this.attr.productSelect,
|
|
|
|
|
"storeName",
|
2021-06-11 09:41:16 +00:00
|
|
|
|
this.productInfo.storeName
|
2020-08-13 08:12:57 +00:00
|
|
|
|
);
|
2021-06-11 09:41:16 +00:00
|
|
|
|
this.$set(this.attr.productSelect, "image", this.productInfo.image);
|
|
|
|
|
this.$set(this.attr.productSelect, "price", this.productInfo.price);
|
2020-08-13 08:12:57 +00:00
|
|
|
|
this.$set(this.attr.productSelect, "stock", 0);
|
2021-06-11 09:41:16 +00:00
|
|
|
|
this.$set(this.attr.productSelect, "unique", this.productInfo.id);
|
2020-08-13 08:12:57 +00:00
|
|
|
|
this.$set(this.attr.productSelect, "cart_num", 0);
|
|
|
|
|
this.$set(this, "attrValue", "");
|
|
|
|
|
this.$set(this, "attrTxt", "请选择");
|
|
|
|
|
} else if (!productSelect && !productAttr.length) {
|
|
|
|
|
this.$set(
|
|
|
|
|
this.attr.productSelect,
|
|
|
|
|
"storeName",
|
2021-06-11 09:41:16 +00:00
|
|
|
|
this.productInfo.storeName
|
2020-08-13 08:12:57 +00:00
|
|
|
|
);
|
2021-06-11 09:41:16 +00:00
|
|
|
|
this.$set(this.attr.productSelect, "image", this.productInfo.image);
|
|
|
|
|
this.$set(this.attr.productSelect, "price", this.productInfo.price);
|
|
|
|
|
this.$set(this.attr.productSelect, "stock", this.productInfo.stock);
|
2020-08-13 08:12:57 +00:00
|
|
|
|
this.$set(
|
|
|
|
|
this.attr.productSelect,
|
|
|
|
|
"unique",
|
2021-06-11 09:41:16 +00:00
|
|
|
|
this.productInfo.id || ""
|
2020-08-13 08:12:57 +00:00
|
|
|
|
);
|
|
|
|
|
this.$set(this.attr.productSelect, "cart_num", 1);
|
|
|
|
|
this.$set(this, "attrValue", "");
|
|
|
|
|
this.$set(this, "attrTxt", "请选择");
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
attrVal(val) {
|
2021-06-11 09:41:16 +00:00
|
|
|
|
this.$set(this.attr.productAttr[val.indexw], 'index', this.attr.productAttr[val.indexw].attrValues[val
|
|
|
|
|
.indexn]);
|
2020-08-13 08:12:57 +00:00
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 购物车数量加和数量减
|
2023-06-04 16:03:30 +00:00
|
|
|
|
*
|
2020-08-13 08:12:57 +00:00
|
|
|
|
*/
|
|
|
|
|
ChangeCartNum: function(changeValue) {
|
|
|
|
|
//changeValue:是否 加|减
|
|
|
|
|
//获取当前变动属性
|
|
|
|
|
let productSelect = this.productValue[this.attrValue];
|
|
|
|
|
//如果没有属性,赋值给商品默认库存
|
|
|
|
|
if (productSelect === undefined && !this.attr.productAttr.length)
|
|
|
|
|
productSelect = this.attr.productSelect;
|
|
|
|
|
//无属性值即库存为0;不存在加减;
|
|
|
|
|
if (productSelect === undefined) return;
|
|
|
|
|
let stock = productSelect.stock || 0;
|
|
|
|
|
let num = this.attr.productSelect;
|
|
|
|
|
if (changeValue) {
|
|
|
|
|
num.cart_num++;
|
|
|
|
|
if (num.cart_num > stock) {
|
|
|
|
|
this.$set(this.attr.productSelect, "cart_num", stock ? stock : 1);
|
|
|
|
|
this.$set(this, "cart_num", stock ? stock : 1);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
num.cart_num--;
|
|
|
|
|
if (num.cart_num < 1) {
|
|
|
|
|
this.$set(this.attr.productSelect, "cart_num", 1);
|
|
|
|
|
this.$set(this, "cart_num", 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 购物车手动填写
|
2023-06-04 16:03:30 +00:00
|
|
|
|
*
|
2020-08-13 08:12:57 +00:00
|
|
|
|
*/
|
|
|
|
|
iptCartNum: function(e) {
|
|
|
|
|
this.$set(this.attr.productSelect, 'cart_num', e);
|
|
|
|
|
},
|
|
|
|
|
subDel: function(event) {
|
|
|
|
|
let that = this,
|
|
|
|
|
selectValue = that.selectValue;
|
|
|
|
|
if (selectValue.length > 0)
|
|
|
|
|
cartDel(selectValue).then(res => {
|
|
|
|
|
that.loadend = false;
|
|
|
|
|
that.cartList.valid = [];
|
|
|
|
|
that.getCartList();
|
|
|
|
|
});
|
|
|
|
|
else
|
|
|
|
|
return that.$util.Tips({
|
|
|
|
|
title: '请选择产品'
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
getSelectValueProductId: function() {
|
|
|
|
|
let that = this;
|
|
|
|
|
let validList = that.cartList.valid;
|
|
|
|
|
let selectValue = that.selectValue;
|
|
|
|
|
let productId = [];
|
|
|
|
|
if (selectValue.length > 0) {
|
|
|
|
|
for (let index in validList) {
|
|
|
|
|
if (that.inArray(validList[index].id, selectValue)) {
|
|
|
|
|
productId.push(validList[index].productId);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-08-29 15:58:33 +00:00
|
|
|
|
}
|
2020-08-13 08:12:57 +00:00
|
|
|
|
return productId;
|
|
|
|
|
},
|
|
|
|
|
subCollect: function(event) {
|
|
|
|
|
let that = this,
|
|
|
|
|
selectValue = that.selectValue;
|
|
|
|
|
if (selectValue.length > 0) {
|
|
|
|
|
let selectValueProductId = that.getSelectValueProductId();
|
|
|
|
|
collectAll(that.getSelectValueProductId()).then(res => {
|
|
|
|
|
return that.$util.Tips({
|
2021-01-19 02:16:45 +00:00
|
|
|
|
title: '收藏成功',
|
2020-08-13 08:12:57 +00:00
|
|
|
|
icon: 'success'
|
|
|
|
|
});
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
return that.$util.Tips({
|
|
|
|
|
title: err
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
return that.$util.Tips({
|
|
|
|
|
title: '请选择产品'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-06-11 09:41:16 +00:00
|
|
|
|
// 立即下单
|
2020-08-13 08:12:57 +00:00
|
|
|
|
subOrder: function(event) {
|
2021-06-11 09:41:16 +00:00
|
|
|
|
|
2020-08-13 08:12:57 +00:00
|
|
|
|
let that = this,
|
|
|
|
|
selectValue = that.selectValue;
|
|
|
|
|
if (selectValue.length > 0) {
|
2021-06-11 09:41:16 +00:00
|
|
|
|
that.getPreOrder();
|
2020-08-13 08:12:57 +00:00
|
|
|
|
} else {
|
|
|
|
|
return that.$util.Tips({
|
|
|
|
|
title: '请选择产品'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-06-11 09:41:16 +00:00
|
|
|
|
/**
|
|
|
|
|
* 预下单
|
|
|
|
|
*/
|
|
|
|
|
getPreOrder: function() {
|
|
|
|
|
let shoppingCartId = this.selectValue.map(item => {
|
|
|
|
|
return {
|
|
|
|
|
"shoppingCartId": Number(item)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
this.$Order.getPreOrder("shoppingCart", shoppingCartId);
|
|
|
|
|
},
|
2020-08-13 08:12:57 +00:00
|
|
|
|
checkboxAllChange: function(event) {
|
|
|
|
|
let value = event.detail.value;
|
|
|
|
|
if (value.length > 0) {
|
|
|
|
|
this.setAllSelectValue(1)
|
|
|
|
|
} else {
|
|
|
|
|
this.setAllSelectValue(0)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
setAllSelectValue: function(status) {
|
|
|
|
|
let that = this;
|
|
|
|
|
let selectValue = [];
|
|
|
|
|
let valid = that.cartList.valid;
|
|
|
|
|
if (valid.length > 0) {
|
2021-02-06 09:25:18 +00:00
|
|
|
|
let newValid = valid.map(item => {
|
|
|
|
|
if (status) {
|
|
|
|
|
if (that.footerswitch) {
|
2023-08-29 15:28:17 +00:00
|
|
|
|
if (item.canChecked) {
|
|
|
|
|
item.selected = true;
|
2021-02-06 09:25:18 +00:00
|
|
|
|
selectValue.push(item.id);
|
2021-06-11 09:41:16 +00:00
|
|
|
|
} else {
|
2023-08-29 15:28:17 +00:00
|
|
|
|
item.selected = false;
|
2021-02-06 09:25:18 +00:00
|
|
|
|
}
|
2021-06-11 09:41:16 +00:00
|
|
|
|
} else {
|
2023-08-29 15:28:17 +00:00
|
|
|
|
item.selected = true;
|
2021-02-06 09:25:18 +00:00
|
|
|
|
selectValue.push(item.id);
|
2020-08-13 08:12:57 +00:00
|
|
|
|
}
|
2021-02-06 09:25:18 +00:00
|
|
|
|
that.isAllSelect = true;
|
2021-06-11 09:41:16 +00:00
|
|
|
|
} else {
|
2023-08-29 15:28:17 +00:00
|
|
|
|
item.selected = false;
|
2021-02-06 09:25:18 +00:00
|
|
|
|
that.isAllSelect = false;
|
|
|
|
|
}
|
|
|
|
|
return item;
|
|
|
|
|
});
|
|
|
|
|
that.$set(that.cartList, 'valid', newValid);
|
2020-08-13 08:12:57 +00:00
|
|
|
|
that.selectValue = selectValue;
|
|
|
|
|
that.switchSelect();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
checkboxChange: function(event) {
|
|
|
|
|
let that = this;
|
|
|
|
|
let value = event.detail.value;
|
|
|
|
|
let valid = that.cartList.valid;
|
2021-02-06 09:25:18 +00:00
|
|
|
|
let arr1 = [];
|
|
|
|
|
let arr2 = [];
|
|
|
|
|
let arr3 = [];
|
|
|
|
|
let newValid = valid.map(item => {
|
|
|
|
|
if (that.inArray(item.id, value)) {
|
|
|
|
|
if (that.footerswitch) {
|
2023-08-29 15:28:17 +00:00
|
|
|
|
if (item.canChecked) {
|
|
|
|
|
item.selected = true;
|
2021-02-06 09:25:18 +00:00
|
|
|
|
arr1.push(item);
|
2021-06-11 09:41:16 +00:00
|
|
|
|
} else {
|
2023-08-29 15:28:17 +00:00
|
|
|
|
item.selected = false;
|
2021-02-06 09:25:18 +00:00
|
|
|
|
}
|
2021-06-11 09:41:16 +00:00
|
|
|
|
} else {
|
2023-08-29 15:28:17 +00:00
|
|
|
|
item.selected = true;
|
2021-02-06 09:25:18 +00:00
|
|
|
|
arr1.push(item);
|
2020-08-13 08:12:57 +00:00
|
|
|
|
}
|
2021-06-11 09:41:16 +00:00
|
|
|
|
} else {
|
2023-08-29 15:28:17 +00:00
|
|
|
|
item.selected = false;
|
2021-02-06 09:25:18 +00:00
|
|
|
|
arr2.push(item);
|
|
|
|
|
}
|
|
|
|
|
return item;
|
|
|
|
|
});
|
|
|
|
|
if (that.footerswitch) {
|
2023-08-29 15:28:17 +00:00
|
|
|
|
arr3 = arr2.filter(item => !item.canChecked);
|
2020-08-13 08:12:57 +00:00
|
|
|
|
}
|
2021-02-06 09:25:18 +00:00
|
|
|
|
that.$set(that.cartList, 'valid', newValid);
|
|
|
|
|
that.isAllSelect = newValid.length === arr1.length + arr3.length;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
that.selectValue = value;
|
|
|
|
|
that.switchSelect();
|
|
|
|
|
},
|
2023-08-29 15:58:33 +00:00
|
|
|
|
/**
|
|
|
|
|
* 合计金额、数量
|
|
|
|
|
*/
|
2020-08-13 08:12:57 +00:00
|
|
|
|
switchSelect: function() {
|
2023-08-29 15:58:33 +00:00
|
|
|
|
const validList = this.cartList.valid;
|
|
|
|
|
const selectValue = this.selectValue;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
if (selectValue.length < 1) {
|
2023-08-29 15:58:33 +00:00
|
|
|
|
this.selectCountPrice = 0.00;
|
|
|
|
|
return;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
}
|
2023-08-29 15:58:33 +00:00
|
|
|
|
// 合计金额
|
|
|
|
|
let selectCountPrice = 0.00;
|
|
|
|
|
let cartCount = 0
|
|
|
|
|
for (let index in validList) {
|
|
|
|
|
if (this.inArray(validList[index].id, selectValue)) {
|
|
|
|
|
selectCountPrice = this.$util.$h.Add(selectCountPrice, this.$util.$h.Mul(validList[index].count, validList[index].sku.price))
|
|
|
|
|
cartCount += validList[index].count
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.selectCountPrice = selectCountPrice;
|
|
|
|
|
this.cartCount = cartCount;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 购物车手动填写
|
|
|
|
|
*/
|
|
|
|
|
iptCartNum: function(index) {
|
|
|
|
|
let item = this.cartList.valid[index];
|
|
|
|
|
if (item.cartNum) {
|
|
|
|
|
this.setCartNum(item.id, item.cartNum);
|
|
|
|
|
}
|
|
|
|
|
this.switchSelect();
|
|
|
|
|
},
|
|
|
|
|
blurInput: function(index) {
|
|
|
|
|
let item = this.cartList.valid[index];
|
|
|
|
|
if (!item.cartNum) {
|
|
|
|
|
item.cartNum = 1;
|
|
|
|
|
this.$set(this.cartList, 'valid', this.cartList.valid)
|
|
|
|
|
}
|
|
|
|
|
},
|
2023-08-29 15:58:33 +00:00
|
|
|
|
/**
|
|
|
|
|
* 减少购买数量
|
|
|
|
|
*/
|
2020-08-13 08:12:57 +00:00
|
|
|
|
subCart: function(index) {
|
2023-08-29 15:58:33 +00:00
|
|
|
|
let item = this.cartList.valid[index];
|
|
|
|
|
if (item.count < 1) {
|
|
|
|
|
this.$util.Tips({
|
|
|
|
|
title: '商品数量不能减少!'
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 本地先修改状态
|
|
|
|
|
item.count = Number(item.count) - 1;
|
|
|
|
|
if (item.count <= 1) {
|
|
|
|
|
item.count = 1;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
item.numSub = true;
|
|
|
|
|
} else {
|
|
|
|
|
item.numSub = false;
|
|
|
|
|
item.numAdd = false;
|
|
|
|
|
}
|
2023-08-29 15:58:33 +00:00
|
|
|
|
// 提交修改
|
|
|
|
|
this.setCartNum(item.id, item.count);
|
2020-08-13 08:12:57 +00:00
|
|
|
|
},
|
2023-08-29 15:58:33 +00:00
|
|
|
|
/**
|
|
|
|
|
* 增加购买数量
|
|
|
|
|
*/
|
2020-08-13 08:12:57 +00:00
|
|
|
|
addCart: function(index) {
|
2023-08-29 15:58:33 +00:00
|
|
|
|
// 本地先修改状态
|
|
|
|
|
let item = this.cartList.valid[index];
|
|
|
|
|
item.count = Number(item.count) + 1
|
|
|
|
|
if (item.count >= item.sku.stock) {
|
|
|
|
|
item.count = item.sku.stock;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
item.numAdd = true;
|
|
|
|
|
item.numSub = false;
|
|
|
|
|
} else {
|
|
|
|
|
item.numAdd = false;
|
|
|
|
|
item.numSub = false;
|
|
|
|
|
}
|
2023-08-29 15:58:33 +00:00
|
|
|
|
// 提交修改
|
|
|
|
|
this.setCartNum(item.id, item.count);
|
2020-08-13 08:12:57 +00:00
|
|
|
|
},
|
2023-08-29 15:58:33 +00:00
|
|
|
|
/**
|
|
|
|
|
* 修改购物项为指定数量
|
|
|
|
|
*/
|
|
|
|
|
setCartNum(cartId, cartNum) {
|
|
|
|
|
TradeCartApi.updateCart({
|
|
|
|
|
id: cartId,
|
|
|
|
|
count: cartNum
|
|
|
|
|
}).then(res => {
|
|
|
|
|
// 加载最新状态
|
|
|
|
|
this.getCartList()
|
2020-08-13 08:12:57 +00:00
|
|
|
|
});
|
|
|
|
|
},
|
2023-08-29 15:28:17 +00:00
|
|
|
|
getCartData() {
|
2021-06-11 09:41:16 +00:00
|
|
|
|
return new Promise((resolve, reject) => {
|
2023-08-29 15:28:17 +00:00
|
|
|
|
TradeCartApi.getCartList().then((res) => {
|
2021-06-11 09:41:16 +00:00
|
|
|
|
resolve(res.data);
|
|
|
|
|
}).catch(function(err) {
|
|
|
|
|
this.loading = false;
|
|
|
|
|
this.canShow = true;
|
|
|
|
|
this.$util.Tips({
|
|
|
|
|
title: err
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
async getCartList() {
|
|
|
|
|
uni.showLoading({
|
|
|
|
|
title: '加载中',
|
|
|
|
|
mask: true
|
|
|
|
|
});
|
2023-08-29 15:28:17 +00:00
|
|
|
|
// 加载购物车
|
|
|
|
|
const cartList = await this.getCartData();
|
|
|
|
|
const validList = cartList.validList;
|
|
|
|
|
const invalidList = cartList.invalidList;
|
2021-06-11 09:41:16 +00:00
|
|
|
|
|
2023-08-29 15:28:17 +00:00
|
|
|
|
// 有效的购物车
|
|
|
|
|
const selectValue = [];
|
|
|
|
|
if (validList.length > 0) {
|
|
|
|
|
for (let index in validList) {
|
|
|
|
|
// 设置是否可减少(到底,不可减少)
|
|
|
|
|
validList[index].numSub = validList[index].cartNum === 1;
|
|
|
|
|
// 设置是否可添加(到顶,不可添加)
|
|
|
|
|
const sku = validList[index].sku;
|
2023-08-29 15:58:33 +00:00
|
|
|
|
validList[index].numAdd = sku && validList[index].count < sku.stock;
|
2023-08-29 15:28:17 +00:00
|
|
|
|
// 设置为选中,并添加到 selectValue 数组中
|
|
|
|
|
// why?库存不足时,可以引导选择该 SPU 对应的其它 SKU。而 invalidList 是 SPU 不存在或者库存彻底不足
|
|
|
|
|
if (sku && sku.stock > 0) {
|
|
|
|
|
validList[index].canChecked = true; // 是否可选中:是
|
|
|
|
|
selectValue.push(validList[index].id);
|
|
|
|
|
} else {
|
|
|
|
|
validList[index].canChecked = false; // 是否可选中:否
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.$set(this.cartList, 'valid', validList);
|
|
|
|
|
this.selectValue = selectValue;
|
|
|
|
|
let newArr = validList.filter(item => item.canChecked);
|
|
|
|
|
this.isAllSelect = newArr.length === selectValue.length && newArr.length;
|
|
|
|
|
this.switchSelect();
|
|
|
|
|
|
|
|
|
|
// 无效的购物车
|
|
|
|
|
this.$set(this.cartList, 'invalid', invalidList);
|
2020-08-13 08:12:57 +00:00
|
|
|
|
|
2023-08-29 15:28:17 +00:00
|
|
|
|
// 标记加载结束
|
|
|
|
|
this.loading = false;
|
|
|
|
|
this.canShow = true;
|
|
|
|
|
uni.hideLoading();
|
2020-08-13 08:12:57 +00:00
|
|
|
|
},
|
|
|
|
|
getHostProduct: function() {
|
|
|
|
|
let that = this;
|
|
|
|
|
if (that.hotScroll) return
|
|
|
|
|
getProductHot(
|
|
|
|
|
that.hotPage,
|
|
|
|
|
that.hotLimit,
|
|
|
|
|
).then(res => {
|
|
|
|
|
that.hotPage++
|
|
|
|
|
that.hotScroll = res.data.list.length < that.hotLimit
|
|
|
|
|
that.hostProduct = that.hostProduct.concat(res.data.list)
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
goodsOpen: function() {
|
|
|
|
|
let that = this;
|
|
|
|
|
that.goodsHidden = !that.goodsHidden;
|
|
|
|
|
},
|
|
|
|
|
manage: function() {
|
|
|
|
|
let that = this;
|
|
|
|
|
that.footerswitch = !that.footerswitch;
|
2021-02-06 09:25:18 +00:00
|
|
|
|
let arr1 = [];
|
|
|
|
|
let arr2 = [];
|
|
|
|
|
let newValid = that.cartList.valid.map(item => {
|
|
|
|
|
if (that.footerswitch) {
|
2023-08-29 15:28:17 +00:00
|
|
|
|
if (item.canChecked) {
|
|
|
|
|
if (item.selected) {
|
2021-02-06 09:25:18 +00:00
|
|
|
|
arr1.push(item.id);
|
|
|
|
|
}
|
2021-06-11 09:41:16 +00:00
|
|
|
|
} else {
|
2023-08-29 15:28:17 +00:00
|
|
|
|
item.selected = false;
|
2021-02-06 09:25:18 +00:00
|
|
|
|
arr2.push(item);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2023-08-29 15:28:17 +00:00
|
|
|
|
if (item.selected) {
|
2021-02-06 09:25:18 +00:00
|
|
|
|
arr1.push(item.id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return item;
|
|
|
|
|
});
|
|
|
|
|
that.cartList.valid = newValid;
|
|
|
|
|
if (that.footerswitch) {
|
|
|
|
|
that.isAllSelect = newValid.length === arr1.length + arr2.length;
|
2021-06-11 09:41:16 +00:00
|
|
|
|
} else {
|
2021-02-06 09:25:18 +00:00
|
|
|
|
that.isAllSelect = newValid.length === arr1.length;
|
|
|
|
|
}
|
|
|
|
|
that.selectValue = arr1;
|
|
|
|
|
that.switchSelect();
|
2020-08-13 08:12:57 +00:00
|
|
|
|
},
|
|
|
|
|
unsetCart: function() {
|
|
|
|
|
let that = this,
|
|
|
|
|
ids = [];
|
|
|
|
|
for (let i = 0, len = that.cartList.invalid.length; i < len; i++) {
|
|
|
|
|
ids.push(that.cartList.invalid[i].id);
|
|
|
|
|
}
|
|
|
|
|
cartDel(ids).then(res => {
|
|
|
|
|
that.$util.Tips({
|
|
|
|
|
title: '清除成功'
|
|
|
|
|
});
|
|
|
|
|
that.$set(that.cartList, 'invalid', []);
|
2021-06-11 09:41:16 +00:00
|
|
|
|
that.getHostProduct();
|
2020-08-13 08:12:57 +00:00
|
|
|
|
}).catch(res => {
|
|
|
|
|
|
|
|
|
|
});
|
2023-08-29 15:28:17 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
fen2yuan(price) {
|
|
|
|
|
return Util.fen2yuan(price)
|
2023-08-29 15:58:33 +00:00
|
|
|
|
},
|
|
|
|
|
inArray: function(search, array) {
|
|
|
|
|
for (let i in array) {
|
|
|
|
|
if (array[i] === search) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
},
|
2020-08-13 08:12:57 +00:00
|
|
|
|
},
|
|
|
|
|
onReachBottom() {
|
2023-08-29 15:28:17 +00:00
|
|
|
|
// TODO 芋艿:临时禁用
|
|
|
|
|
if (true) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-08-13 08:12:57 +00:00
|
|
|
|
let that = this;
|
2021-03-19 10:26:43 +00:00
|
|
|
|
if (that.cartList.valid.length == 0 && that.cartList.invalid.length == 0 && this.hotPage != 1) {
|
|
|
|
|
that.getHostProduct();
|
2020-08-13 08:12:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
2021-06-11 09:41:16 +00:00
|
|
|
|
.invalidClas {
|
|
|
|
|
position: relative;
|
|
|
|
|
z-index: 111;
|
|
|
|
|
top: -120rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.invalidClasNO {
|
|
|
|
|
position: static;
|
|
|
|
|
margin-top: 15px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.cartBox {
|
|
|
|
|
// background-color: #fff;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart {
|
|
|
|
|
/* #ifdef H5 */
|
|
|
|
|
// padding-bottom: 0;
|
2023-06-04 16:03:30 +00:00
|
|
|
|
// padding-bottom: constant(safe-area-inset-bottom);
|
2021-06-11 09:41:16 +00:00
|
|
|
|
// padding-bottom: env(safe-area-inset-bottom);
|
|
|
|
|
/* #endif */
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-13 08:12:57 +00:00
|
|
|
|
.shoppingCart .labelNav {
|
2021-06-11 09:41:16 +00:00
|
|
|
|
height: 178rpx;
|
|
|
|
|
padding: 30rpx 30rpx 0 30rpx;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
font-size: 22rpx;
|
2021-06-11 09:41:16 +00:00
|
|
|
|
color: #fff;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
position: fixed;
|
|
|
|
|
left: 0;
|
|
|
|
|
width: 100%;
|
|
|
|
|
box-sizing: border-box;
|
2021-06-11 09:41:16 +00:00
|
|
|
|
background-color: $theme-color;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
z-index: 5;
|
|
|
|
|
top: 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .labelNav .item .iconfont {
|
|
|
|
|
font-size: 25rpx;
|
|
|
|
|
margin-right: 10rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .nav {
|
2021-06-11 09:41:16 +00:00
|
|
|
|
width: 92%;
|
|
|
|
|
height: 90rpx;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
background-color: #fff;
|
2021-06-11 09:41:16 +00:00
|
|
|
|
padding: 0 24rpx;
|
|
|
|
|
-webkit-box-sizing: border-box;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
color: #282828;
|
|
|
|
|
position: fixed;
|
2021-06-11 09:41:16 +00:00
|
|
|
|
left: 30rpx;
|
|
|
|
|
z-index: 6;
|
|
|
|
|
top: 94rpx;
|
|
|
|
|
border-top-left-radius: 14rpx;
|
|
|
|
|
border-top-right-radius: 14rpx;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .nav .num {
|
|
|
|
|
margin-left: 12rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .nav .administrate {
|
2021-06-11 09:41:16 +00:00
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
color: #333333;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .noCart {
|
|
|
|
|
margin-top: 171rpx;
|
|
|
|
|
background-color: #fff;
|
|
|
|
|
padding-top: 0.1rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .noCart .pictrue {
|
|
|
|
|
width: 414rpx;
|
|
|
|
|
height: 336rpx;
|
|
|
|
|
margin: 78rpx auto 56rpx auto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .noCart .pictrue image {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .list {
|
2021-06-11 09:41:16 +00:00
|
|
|
|
width: 100%;
|
|
|
|
|
margin-top: 178rpx;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
border-bottom-left-radius: 14rpx;
|
|
|
|
|
border-bottom-right-radius: 14rpx;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .list .item {
|
2021-06-11 09:41:16 +00:00
|
|
|
|
padding: 24rpx;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
background-color: #fff;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .list .item .picTxt {
|
2021-06-11 09:41:16 +00:00
|
|
|
|
width: 582rpx;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
position: relative;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .list .item .picTxt .pictrue {
|
|
|
|
|
width: 160rpx;
|
|
|
|
|
height: 160rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .list .item .picTxt .pictrue image {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
border-radius: 6rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .list .item .picTxt .text {
|
2021-06-11 09:41:16 +00:00
|
|
|
|
width: 396rpx;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
color: #282828;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .list .item .picTxt .text .reColor {
|
|
|
|
|
color: #999;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .list .item .picTxt .text .reElection {
|
|
|
|
|
margin-top: 20rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .list .item .picTxt .text .reElection .title {
|
|
|
|
|
font-size: 24rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .list .item .picTxt .text .reElection .reBnt {
|
|
|
|
|
width: 120rpx;
|
|
|
|
|
height: 46rpx;
|
|
|
|
|
border-radius: 23rpx;
|
|
|
|
|
font-size: 26rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .list .item .picTxt .text .infor {
|
|
|
|
|
font-size: 24rpx;
|
2021-06-11 09:41:16 +00:00
|
|
|
|
color: #999999;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
margin-top: 16rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .list .item .picTxt .text .money {
|
|
|
|
|
font-size: 32rpx;
|
2021-06-11 09:41:16 +00:00
|
|
|
|
color: #E93323;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
margin-top: 28rpx;
|
2021-06-11 09:41:16 +00:00
|
|
|
|
font-weight: 600;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .list .item .picTxt .carnum {
|
|
|
|
|
height: 47rpx;
|
|
|
|
|
position: absolute;
|
|
|
|
|
bottom: 7rpx;
|
|
|
|
|
right: 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .list .item .picTxt .carnum view {
|
|
|
|
|
border: 1rpx solid #a4a4a4;
|
|
|
|
|
width: 66rpx;
|
|
|
|
|
text-align: center;
|
|
|
|
|
height: 100%;
|
2021-06-11 09:41:16 +00:00
|
|
|
|
line-height: 44rpx;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
color: #a4a4a4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .list .item .picTxt .carnum .reduce {
|
|
|
|
|
border-right: 0;
|
|
|
|
|
border-radius: 3rpx 0 0 3rpx;
|
2021-06-11 09:41:16 +00:00
|
|
|
|
border-radius: 22rpx 0rpx 0rpx 22rpx;
|
|
|
|
|
font-size: 34rpx;
|
|
|
|
|
line-height: 40rpx;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .list .item .picTxt .carnum .reduce.on {
|
|
|
|
|
border-color: #e3e3e3;
|
|
|
|
|
color: #dedede;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .list .item .picTxt .carnum .plus {
|
|
|
|
|
border-left: 0;
|
|
|
|
|
border-radius: 0 3rpx 3rpx 0;
|
2021-06-11 09:41:16 +00:00
|
|
|
|
border-radius: 0rpx 22rpx 22rpx 0rpx;
|
|
|
|
|
font-size: 34rpx;
|
|
|
|
|
line-height: 40rpx;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .list .item .picTxt .carnum .num {
|
|
|
|
|
color: #282828;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .invalidGoods {
|
|
|
|
|
background-color: #fff;
|
2021-06-11 09:41:16 +00:00
|
|
|
|
margin-top: 30rpx;
|
|
|
|
|
/* #ifdef MP */
|
|
|
|
|
margin-top: 140rpx;
|
|
|
|
|
/* #endif */
|
|
|
|
|
|
2020-08-13 08:12:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .invalidGoods .goodsNav {
|
|
|
|
|
width: 100%;
|
2021-06-11 09:41:16 +00:00
|
|
|
|
height: 90rpx;
|
|
|
|
|
padding: 0 24rpx;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
font-size: 28rpx;
|
2021-06-11 09:41:16 +00:00
|
|
|
|
color: #333333;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .invalidGoods .goodsNav .iconfont {
|
|
|
|
|
color: #424242;
|
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
margin-right: 17rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .invalidGoods .goodsNav .del {
|
|
|
|
|
font-size: 26rpx;
|
2021-06-11 09:41:16 +00:00
|
|
|
|
color: #333;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .invalidGoods .goodsNav .del .icon-shanchu1 {
|
2021-06-11 09:41:16 +00:00
|
|
|
|
color: #333;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
font-size: 33rpx;
|
|
|
|
|
vertical-align: -2rpx;
|
|
|
|
|
margin-right: 8rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .invalidGoods .goodsList .item {
|
2021-06-11 09:41:16 +00:00
|
|
|
|
padding: 24rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .invalidGoods .goodsList .picTxt {
|
|
|
|
|
width: 576rpx;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .invalidGoods .goodsList .item .invalid {
|
|
|
|
|
font-size: 22rpx;
|
2021-06-11 09:41:16 +00:00
|
|
|
|
color: #CCCCCC;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
height: 36rpx;
|
|
|
|
|
border-radius: 3rpx;
|
|
|
|
|
text-align: center;
|
|
|
|
|
line-height: 36rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .invalidGoods .goodsList .item .pictrue {
|
2021-06-11 09:41:16 +00:00
|
|
|
|
width: 160rpx;
|
|
|
|
|
height: 160rpx;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .invalidGoods .goodsList .item .pictrue image {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
border-radius: 6rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .invalidGoods .goodsList .item .text {
|
2021-06-11 09:41:16 +00:00
|
|
|
|
width: 396rpx;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
color: #999;
|
|
|
|
|
height: 140rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .invalidGoods .goodsList .item .text .name {
|
|
|
|
|
width: 100%;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .invalidGoods .goodsList .item .text .infor {
|
|
|
|
|
font-size: 24rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shoppingCart .invalidGoods .goodsList .item .text .end {
|
|
|
|
|
font-size: 26rpx;
|
|
|
|
|
color: #bbb;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-11 09:41:16 +00:00
|
|
|
|
.footer {
|
2020-08-13 08:12:57 +00:00
|
|
|
|
z-index: 9;
|
|
|
|
|
width: 100%;
|
2021-06-11 09:41:16 +00:00
|
|
|
|
height: 100rpx;
|
|
|
|
|
background-color: #fff;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
position: fixed;
|
2021-06-11 09:41:16 +00:00
|
|
|
|
padding: 0 24rpx;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
border-top: 1rpx solid #eee;
|
2021-06-11 09:41:16 +00:00
|
|
|
|
// border-bottom: 1px solid #EEEEEE;
|
|
|
|
|
/* #ifdef H5 */
|
|
|
|
|
bottom: 98rpx;
|
|
|
|
|
/* #endif */
|
|
|
|
|
/* #ifdef MP */
|
2020-08-13 08:12:57 +00:00
|
|
|
|
bottom: 0;
|
2021-06-11 09:41:16 +00:00
|
|
|
|
/* #endif */
|
|
|
|
|
/* #ifndef MP */
|
|
|
|
|
// bottom: 98rpx;
|
|
|
|
|
// bottom: calc(98rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
|
|
|
|
|
// bottom: calc(98rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
|
|
|
|
|
/* #endif */
|
2020-08-13 08:12:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-06-11 09:41:16 +00:00
|
|
|
|
.footer .checkAll {
|
2020-08-13 08:12:57 +00:00
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
color: #282828;
|
2021-06-11 09:41:16 +00:00
|
|
|
|
margin-left: 14rpx;
|
2020-08-13 08:12:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-06-11 09:41:16 +00:00
|
|
|
|
.footer .money {
|
2020-08-13 08:12:57 +00:00
|
|
|
|
font-size: 30rpx;
|
2021-06-11 09:41:16 +00:00
|
|
|
|
|
|
|
|
|
.font-color {
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
}
|
2020-08-13 08:12:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-06-11 09:41:16 +00:00
|
|
|
|
.footer .placeOrder {
|
2020-08-13 08:12:57 +00:00
|
|
|
|
color: #fff;
|
|
|
|
|
font-size: 30rpx;
|
|
|
|
|
width: 226rpx;
|
|
|
|
|
height: 70rpx;
|
|
|
|
|
border-radius: 50rpx;
|
|
|
|
|
text-align: center;
|
|
|
|
|
line-height: 70rpx;
|
|
|
|
|
margin-left: 22rpx;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-11 09:41:16 +00:00
|
|
|
|
.footer .button .bnt {
|
2020-08-13 08:12:57 +00:00
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
color: #999;
|
|
|
|
|
border-radius: 50rpx;
|
|
|
|
|
border: 1px solid #999;
|
|
|
|
|
width: 160rpx;
|
|
|
|
|
height: 60rpx;
|
|
|
|
|
text-align: center;
|
|
|
|
|
line-height: 60rpx;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-11 09:41:16 +00:00
|
|
|
|
.footer .button form~form {
|
2020-08-13 08:12:57 +00:00
|
|
|
|
margin-left: 17rpx;
|
|
|
|
|
}
|
2021-06-11 09:41:16 +00:00
|
|
|
|
|
|
|
|
|
.uni-p-b-96 {
|
|
|
|
|
height: 96rpx;
|
|
|
|
|
}
|
|
|
|
|
</style>
|