|
|
|
@ -3,16 +3,13 @@
|
|
|
|
|
<view v-if="$store.getters.token||userInfo.uid"> |
|
|
|
|
<view class="labelNav acea-row row-around row-middle"> |
|
|
|
|
<view class="item"> |
|
|
|
|
<text class="iconfont icon-xuanzhong"></text> |
|
|
|
|
100%正品保证 |
|
|
|
|
<text class="iconfont icon-xuanzhong"></text>100%正品保证 |
|
|
|
|
</view> |
|
|
|
|
<view class="item"> |
|
|
|
|
<text class="iconfont icon-xuanzhong"></text> |
|
|
|
|
所有商品精挑细选 |
|
|
|
|
<text class="iconfont icon-xuanzhong"></text>所有商品精挑细选 |
|
|
|
|
</view> |
|
|
|
|
<view class="item"> |
|
|
|
|
<text class="iconfont icon-xuanzhong"></text> |
|
|
|
|
售后无忧 |
|
|
|
|
<text class="iconfont icon-xuanzhong"></text>售后无忧 |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
<view class="nav acea-row row-between-wrapper"> |
|
|
|
@ -20,15 +17,25 @@
|
|
|
|
|
购物数量 |
|
|
|
|
<text class="num font-color-red">{{ count }}</text> |
|
|
|
|
</view> |
|
|
|
|
<view v-if="cartList.valid.length > 0" class="administrate acea-row row-center-wrapper" @click="manage">{{ footerswitch ? '取消' : '管理' }}</view> |
|
|
|
|
<view |
|
|
|
|
v-if="cartList.valid.length > 0" |
|
|
|
|
class="administrate acea-row row-center-wrapper" |
|
|
|
|
@click="manage" |
|
|
|
|
>{{ footerswitch ? '取消' : '管理' }}</view> |
|
|
|
|
</view> |
|
|
|
|
<view v-if="validList.length > 0 || cartList.invalid.length > 0"> |
|
|
|
|
<view class="list"> |
|
|
|
|
<view class="item acea-row row-between-wrapper" v-for="(item, cartListValidIndex) in validList" :key="cartListValidIndex"> |
|
|
|
|
<view |
|
|
|
|
class="item acea-row row-between-wrapper" |
|
|
|
|
v-for="(item, cartListValidIndex) in validList" |
|
|
|
|
:key="cartListValidIndex" |
|
|
|
|
> |
|
|
|
|
<view class="select-btn"> |
|
|
|
|
<view class="checkbox-wrapper"> |
|
|
|
|
<checkbox-group @change="switchSelect(cartListValidIndex)"> |
|
|
|
|
<label class="well-check"><checkbox value :checked="item.checked"></checkbox></label> |
|
|
|
|
<label class="well-check"> |
|
|
|
|
<checkbox value :checked="item.checked"></checkbox> |
|
|
|
|
</label> |
|
|
|
|
</checkbox-group> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
@ -39,28 +46,31 @@
|
|
|
|
|
</view> |
|
|
|
|
<view class="text"> |
|
|
|
|
<view class="line1">{{ item.productInfo.storeName }}</view> |
|
|
|
|
<view class="infor line1" v-if="item.productInfo.attrInfo">属性:{{ item.productInfo.attrInfo.suk }}</view> |
|
|
|
|
<view |
|
|
|
|
class="infor line1" |
|
|
|
|
v-if="item.productInfo.attrInfo" |
|
|
|
|
>属性:{{ item.productInfo.attrInfo.suk }}</view> |
|
|
|
|
<view class="money">¥{{ item.truePrice }}</view> |
|
|
|
|
</view> |
|
|
|
|
<view class="carnum acea-row row-center-wrapper"> |
|
|
|
|
<view class="reduce" :class="validList[cartListValidIndex].cartNum <= 1 ? 'on' : ''" @click.prevent="reduce(cartListValidIndex)">-</view> |
|
|
|
|
<view |
|
|
|
|
class="reduce" |
|
|
|
|
:class="validList[cartListValidIndex].cartNum <= 1 ? 'on' : ''" |
|
|
|
|
@click.prevent="reduce(cartListValidIndex)" |
|
|
|
|
>-</view> |
|
|
|
|
<view class="num">{{ item.cartNum }}</view> |
|
|
|
|
<view |
|
|
|
|
class="plus" |
|
|
|
|
v-if="validList[cartListValidIndex].attrInfo" |
|
|
|
|
:class="validList[cartListValidIndex].cartNum >= validList[cartListValidIndex].attrInfo.stock ? 'on' : ''" |
|
|
|
|
@click.prevent="plus(cartListValidIndex)" |
|
|
|
|
> |
|
|
|
|
+ |
|
|
|
|
</view> |
|
|
|
|
>+</view> |
|
|
|
|
<view |
|
|
|
|
class="plus" |
|
|
|
|
v-else |
|
|
|
|
:class="validList[cartListValidIndex].cartNum >= validList[cartListValidIndex].stock ? 'on' : ''" |
|
|
|
|
@click.prevent="plus(cartListValidIndex)" |
|
|
|
|
> |
|
|
|
|
+ |
|
|
|
|
</view> |
|
|
|
|
>+</view> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
@ -68,17 +78,25 @@
|
|
|
|
|
<view class="invalidGoods" v-if="cartList.invalid.length > 0"> |
|
|
|
|
<view class="goodsNav acea-row row-between-wrapper"> |
|
|
|
|
<view @click="goodsOpen"> |
|
|
|
|
<text class="iconfont" :class="goodsHidden === true ? 'icon-xiangyou' : 'icon-xiangxia'"></text> |
|
|
|
|
失效商品 |
|
|
|
|
<text |
|
|
|
|
class="iconfont" |
|
|
|
|
:class="goodsHidden === true ? 'icon-xiangyou' : 'icon-xiangxia'" |
|
|
|
|
></text>失效商品 |
|
|
|
|
</view> |
|
|
|
|
<view class="del" @click="delInvalidGoods"> |
|
|
|
|
<text class="iconfont icon-shanchu1"></text> |
|
|
|
|
清空 |
|
|
|
|
<text class="iconfont icon-shanchu1"></text>清空 |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
<view class="goodsList" :hidden="goodsHidden"> |
|
|
|
|
<view v-for="(item, cartListinvalidIndex) in cartList.invalid" :key="cartListinvalidIndex"> |
|
|
|
|
<view @click="goGoodsCon(item)" class="item acea-row row-between-wrapper" v-if="item.productInfo"> |
|
|
|
|
<view |
|
|
|
|
v-for="(item, cartListinvalidIndex) in cartList.invalid" |
|
|
|
|
:key="cartListinvalidIndex" |
|
|
|
|
> |
|
|
|
|
<view |
|
|
|
|
@click="goGoodsCon(item)" |
|
|
|
|
class="item acea-row row-between-wrapper" |
|
|
|
|
v-if="item.productInfo" |
|
|
|
|
> |
|
|
|
|
<view class="invalid acea-row row-center-wrapper">失效</view> |
|
|
|
|
<view class="pictrue"> |
|
|
|
|
<image :src="item.productInfo.attrInfo.image" v-if="item.productInfo.attrInfo" /> |
|
|
|
@ -86,8 +104,13 @@
|
|
|
|
|
</view> |
|
|
|
|
<view class="text acea-row row-column-between"> |
|
|
|
|
<view class="line1">{{ item.productInfo.storeName }}</view> |
|
|
|
|
<view class="infor line1" v-if="item.productInfo.attrInfo">属性:{{ item.productInfo.attrInfo.suk }}</view> |
|
|
|
|
<view class="acea-row row-between-wrapper"><view class="end">该商品已下架</view></view> |
|
|
|
|
<view |
|
|
|
|
class="infor line1" |
|
|
|
|
v-if="item.productInfo.attrInfo" |
|
|
|
|
>属性:{{ item.productInfo.attrInfo.suk }}</view> |
|
|
|
|
<view class="acea-row row-between-wrapper"> |
|
|
|
|
<view class="end">该商品已下架</view> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
@ -96,7 +119,9 @@
|
|
|
|
|
</view> |
|
|
|
|
<!--购物车暂无商品--> |
|
|
|
|
<view class="noCart" v-if="cartList.valid.length === 0 && cartList.invalid.length === 0"> |
|
|
|
|
<view class="pictrue"><image src="@/static/images/noCart.png" /></view> |
|
|
|
|
<view class="pictrue"> |
|
|
|
|
<image src="@/static/images/noCart.png" /> |
|
|
|
|
</view> |
|
|
|
|
<Recommend></Recommend> |
|
|
|
|
</view> |
|
|
|
|
<view style="height:210rpx"></view> |
|
|
|
@ -139,19 +164,24 @@
|
|
|
|
|
</view> |
|
|
|
|
</template> |
|
|
|
|
<script> |
|
|
|
|
import Recommend from '@/components/Recommend'; |
|
|
|
|
import Authorization from '@/pages/authorization/index'; |
|
|
|
|
import { mapGetters } from 'vuex'; |
|
|
|
|
import Recommend from "@/components/Recommend"; |
|
|
|
|
import Authorization from "@/pages/authorization/index"; |
|
|
|
|
import { mapGetters } from "vuex"; |
|
|
|
|
|
|
|
|
|
import { getCartList, postCartDel, changeCartNum, getCartCount } from '@/api/store'; |
|
|
|
|
import { postCollectAll } from '@/api/user'; |
|
|
|
|
import { mul, add } from '@/utils/bc'; |
|
|
|
|
import cookie from '@/utils/store/cookie'; |
|
|
|
|
import { |
|
|
|
|
getCartList, |
|
|
|
|
postCartDel, |
|
|
|
|
changeCartNum, |
|
|
|
|
getCartCount |
|
|
|
|
} from "@/api/store"; |
|
|
|
|
import { postCollectAll } from "@/api/user"; |
|
|
|
|
import { mul, add } from "@/utils/bc"; |
|
|
|
|
import cookie from "@/utils/store/cookie"; |
|
|
|
|
|
|
|
|
|
const CHECKED_IDS = 'cart_checked'; |
|
|
|
|
const CHECKED_IDS = "cart_checked"; |
|
|
|
|
|
|
|
|
|
export default { |
|
|
|
|
name: 'ShoppingCart', |
|
|
|
|
name: "ShoppingCart", |
|
|
|
|
components: { |
|
|
|
|
Recommend, |
|
|
|
|
Authorization |
|
|
|
@ -174,7 +204,7 @@ export default {
|
|
|
|
|
loaded: false |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
computed: mapGetters(['userInfo', 'token']), |
|
|
|
|
computed: mapGetters(["userInfo", "token"]), |
|
|
|
|
|
|
|
|
|
// watch: { |
|
|
|
|
// $yroute(n) { |
|
|
|
@ -223,7 +253,7 @@ export default {
|
|
|
|
|
methods: { |
|
|
|
|
goGoodsCon(item) { |
|
|
|
|
this.$yrouter.push({ |
|
|
|
|
path: '/pages/shop/GoodsCon/index', |
|
|
|
|
path: "/pages/shop/GoodsCon/index", |
|
|
|
|
query: { |
|
|
|
|
id: item.productId |
|
|
|
|
} |
|
|
|
@ -260,17 +290,18 @@ export default {
|
|
|
|
|
}); |
|
|
|
|
if (id.length === 0) { |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: '请选择产品', |
|
|
|
|
icon: 'none', |
|
|
|
|
title: "请选择产品", |
|
|
|
|
icon: "none", |
|
|
|
|
duration: 2000 |
|
|
|
|
}); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
postCartDel(id).then(function() { |
|
|
|
|
list.forEach(function(val, i) { |
|
|
|
|
if (val.checked === false || val.checked === undefined) valid.push(list[i]); |
|
|
|
|
if (val.checked === false || val.checked === undefined) |
|
|
|
|
valid.push(list[i]); |
|
|
|
|
}); |
|
|
|
|
that.$set(that.cartList, 'valid', valid); |
|
|
|
|
that.$set(that.cartList, "valid", valid); |
|
|
|
|
that.carnum(); |
|
|
|
|
that.countMoney(); |
|
|
|
|
that.gainCount(); |
|
|
|
@ -303,7 +334,7 @@ export default {
|
|
|
|
|
let that = this, |
|
|
|
|
data = { |
|
|
|
|
id: [], |
|
|
|
|
category: '' |
|
|
|
|
category: "" |
|
|
|
|
}, |
|
|
|
|
list = that.cartList.valid; |
|
|
|
|
list.forEach(function(val) { |
|
|
|
@ -314,16 +345,16 @@ export default {
|
|
|
|
|
}); |
|
|
|
|
if (data.id.length === 0) { |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: '请选择产品', |
|
|
|
|
icon: 'none', |
|
|
|
|
title: "请选择产品", |
|
|
|
|
icon: "none", |
|
|
|
|
duration: 2000 |
|
|
|
|
}); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
postCollectAll(data).then(function() { |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: '收藏成功!', |
|
|
|
|
icon: 'none', |
|
|
|
|
title: "收藏成功!", |
|
|
|
|
icon: "none", |
|
|
|
|
duration: 2000 |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
@ -340,16 +371,16 @@ export default {
|
|
|
|
|
}); |
|
|
|
|
if (id.length === 0) { |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: '请选择产品', |
|
|
|
|
icon: 'none', |
|
|
|
|
title: "请选择产品", |
|
|
|
|
icon: "none", |
|
|
|
|
duration: 2000 |
|
|
|
|
}); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
this.$yrouter.push({ |
|
|
|
|
path: '/pages/order/OrderSubmission/index', |
|
|
|
|
path: "/pages/order/OrderSubmission/index", |
|
|
|
|
query: { |
|
|
|
|
id: id.join(',') |
|
|
|
|
id: id.join(",") |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
@ -368,11 +399,11 @@ export default {
|
|
|
|
|
list.cartNum++; |
|
|
|
|
if (list.attrInfo) { |
|
|
|
|
if (list.cartNum >= list.attrInfo.stock) { |
|
|
|
|
that.$set(list, 'cart_num', list.attrInfo.stock); |
|
|
|
|
that.$set(list, "cart_num", list.attrInfo.stock); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if (list.cartNum >= list.stock) { |
|
|
|
|
that.$set(list, 'cart_num', list.stock); |
|
|
|
|
that.$set(list, "cart_num", list.stock); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
that.carnum(); |
|
|
|
@ -385,15 +416,15 @@ export default {
|
|
|
|
|
let list = that.cartList.valid[index]; |
|
|
|
|
if (list.cartNum <= 1) { |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: '已经是底线啦!', |
|
|
|
|
icon: 'none', |
|
|
|
|
title: "已经是底线啦!", |
|
|
|
|
icon: "none", |
|
|
|
|
duration: 2000 |
|
|
|
|
}); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
list.cartNum--; |
|
|
|
|
if (list.cartNum < 1) { |
|
|
|
|
that.$set(list, 'cart_num', 1); |
|
|
|
|
that.$set(list, "cart_num", 1); |
|
|
|
|
} |
|
|
|
|
that.carnum(); |
|
|
|
|
that.countMoney(); |
|
|
|
@ -404,11 +435,13 @@ export default {
|
|
|
|
|
changeCartNum(cart.id, Math.max(cart.cartNum, 1) || 1) |
|
|
|
|
.then(res => { |
|
|
|
|
this.getCartList(); |
|
|
|
|
this.gainCount(); |
|
|
|
|
}) |
|
|
|
|
.catch(error => { |
|
|
|
|
this.gainCount(); |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: error.response.data.msg, |
|
|
|
|
icon: 'none', |
|
|
|
|
icon: "none", |
|
|
|
|
duration: 2000 |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
@ -433,18 +466,19 @@ export default {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
that.isAllSelect = selectnum.length === len; |
|
|
|
|
that.$set(that, 'cartList', that.cartList); |
|
|
|
|
that.$set(that, 'isAllSelect', that.isAllSelect); |
|
|
|
|
that.$set(that, "cartList", that.cartList); |
|
|
|
|
that.$set(that, "isAllSelect", that.isAllSelect); |
|
|
|
|
cookie.set(CHECKED_IDS, that.checkedIds); |
|
|
|
|
that.carnum(); |
|
|
|
|
that.gainCount(); |
|
|
|
|
that.countMoney(); |
|
|
|
|
}, |
|
|
|
|
//全选 |
|
|
|
|
allChecked: function(e) { |
|
|
|
|
console.log(e) |
|
|
|
|
console.log(e); |
|
|
|
|
let that = this; |
|
|
|
|
let selectAllStatus = e.mp.detail.value[0]=='allSelect' ? true : false; |
|
|
|
|
console.log(selectAllStatus) |
|
|
|
|
let selectAllStatus = e.mp.detail.value[0] == "allSelect" ? true : false; |
|
|
|
|
console.log(selectAllStatus); |
|
|
|
|
// let selectAllStatus = that.isAllSelect; |
|
|
|
|
let checkedIds = []; |
|
|
|
|
// for (let i = 0; i < array.length; i++) { |
|
|
|
@ -462,9 +496,9 @@ export default {
|
|
|
|
|
}; |
|
|
|
|
that.cartList = []; |
|
|
|
|
that.cartList = cartList; |
|
|
|
|
console.log(this.cartList) |
|
|
|
|
this.$set(this, 'cartList', this.cartList); |
|
|
|
|
this.$set(this, 'isAllSelect', selectAllStatus); |
|
|
|
|
console.log(this.cartList); |
|
|
|
|
this.$set(this, "cartList", this.cartList); |
|
|
|
|
this.$set(this, "isAllSelect", selectAllStatus); |
|
|
|
|
this.checkedIds = checkedIds; |
|
|
|
|
cookie.set(CHECKED_IDS, checkedIds); |
|
|
|
|
that.carnum(); |
|
|
|
@ -481,7 +515,7 @@ export default {
|
|
|
|
|
carnum += parseInt(array[i].cartNum); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
that.$set(that, 'cartCount', carnum); |
|
|
|
|
that.$set(that, "cartCount", carnum); |
|
|
|
|
}, |
|
|
|
|
//总共价钱; |
|
|
|
|
countMoney: function() { |
|
|
|
|