|
|
|
@ -17,19 +17,13 @@
|
|
|
|
|
购物数量 |
|
|
|
|
<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)"> |
|
|
|
@ -46,31 +40,19 @@
|
|
|
|
|
</view> |
|
|
|
|
<view class="text"> |
|
|
|
|
<view class="line1">{{ item.productInfo.storeName }}</view> |
|
|
|
|
<view |
|
|
|
|
class="infor line1" |
|
|
|
|
v-if="item.productInfo.attrInfo" |
|
|
|
|
>属性:{{ item.productInfo.attrInfo.sku }}</view> |
|
|
|
|
<view class="infor line1" v-if="item.productInfo.attrInfo">属性:{{ item.productInfo.attrInfo.sku }}</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" |
|
|
|
|
<view class="plus" v-if="validList[cartListValidIndex].attrInfo" |
|
|
|
|
:class="validList[cartListValidIndex].cartNum >= validList[cartListValidIndex].attrInfo.stock ? 'on' : ''" |
|
|
|
|
@click.prevent="plus(cartListValidIndex)" |
|
|
|
|
>+</view> |
|
|
|
|
<view |
|
|
|
|
class="plus" |
|
|
|
|
v-else |
|
|
|
|
@click.prevent="plus(cartListValidIndex)">+</view> |
|
|
|
|
<view class="plus" v-else |
|
|
|
|
:class="validList[cartListValidIndex].cartNum >= validList[cartListValidIndex].stock ? 'on' : ''" |
|
|
|
|
@click.prevent="plus(cartListValidIndex)" |
|
|
|
|
>+</view> |
|
|
|
|
@click.prevent="plus(cartListValidIndex)">+</view> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
@ -78,25 +60,15 @@
|
|
|
|
|
<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>清空 |
|
|
|
|
</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" /> |
|
|
|
@ -104,10 +76,8 @@
|
|
|
|
|
</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.sku }}</view> |
|
|
|
|
<view class="infor line1" v-if="item.productInfo.attrInfo">属性:{{ item.productInfo.attrInfo.sku }} |
|
|
|
|
</view> |
|
|
|
|
<view class="acea-row row-between-wrapper"> |
|
|
|
|
<view class="end">该商品已下架</view> |
|
|
|
|
</view> |
|
|
|
@ -160,34 +130,41 @@
|
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
<Authorization v-if="!$store.getters.token" /> |
|
|
|
|
<Authorization v-else /> |
|
|
|
|
</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 { |
|
|
|
|
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"; |
|
|
|
|
} 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 { |
|
|
|
|
export default { |
|
|
|
|
name: "ShoppingCart", |
|
|
|
|
components: { |
|
|
|
|
Recommend, |
|
|
|
|
Authorization |
|
|
|
|
}, |
|
|
|
|
props: {}, |
|
|
|
|
data: function() { |
|
|
|
|
data: function () { |
|
|
|
|
return { |
|
|
|
|
cartList: { |
|
|
|
|
invalid: [], |
|
|
|
@ -242,7 +219,7 @@ export default {
|
|
|
|
|
this.validList = list.valid; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
onShow: function() { |
|
|
|
|
onShow: function () { |
|
|
|
|
if (this.userInfo.uid) { |
|
|
|
|
this.carnum(); |
|
|
|
|
this.countMoney(); |
|
|
|
@ -259,7 +236,7 @@ export default {
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
getCartList: function() { |
|
|
|
|
getCartList: function () { |
|
|
|
|
let that = this; |
|
|
|
|
getCartList().then(res => { |
|
|
|
|
that.cartList = res.data; |
|
|
|
@ -278,12 +255,12 @@ export default {
|
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
//删除商品; |
|
|
|
|
delgoods: function() { |
|
|
|
|
delgoods: function () { |
|
|
|
|
let that = this, |
|
|
|
|
id = [], |
|
|
|
|
valid = [], |
|
|
|
|
list = that.cartList.valid; |
|
|
|
|
list.forEach(function(val) { |
|
|
|
|
list.forEach(function (val) { |
|
|
|
|
if (val.checked === true) { |
|
|
|
|
id.push(val.id); |
|
|
|
|
} |
|
|
|
@ -296,8 +273,8 @@ export default {
|
|
|
|
|
}); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
postCartDel(id).then(function() { |
|
|
|
|
list.forEach(function(val, i) { |
|
|
|
|
postCartDel(id).then(function () { |
|
|
|
|
list.forEach(function (val, i) { |
|
|
|
|
if (val.checked === false || val.checked === undefined) |
|
|
|
|
valid.push(list[i]); |
|
|
|
|
}); |
|
|
|
@ -309,35 +286,35 @@ export default {
|
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
// //获取数量 |
|
|
|
|
gainCount: function() { |
|
|
|
|
gainCount: function () { |
|
|
|
|
let that = this; |
|
|
|
|
getCartCount().then(res => { |
|
|
|
|
that.count = res.data.count; |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
//清除失效产品; |
|
|
|
|
delInvalidGoods: function() { |
|
|
|
|
delInvalidGoods: function () { |
|
|
|
|
let that = this, |
|
|
|
|
id = [], |
|
|
|
|
list = that.cartList.invalid; |
|
|
|
|
list.forEach(function(val) { |
|
|
|
|
list.forEach(function (val) { |
|
|
|
|
id.push(val.id); |
|
|
|
|
}); |
|
|
|
|
postCartDel(id).then(function() { |
|
|
|
|
postCartDel(id).then(function () { |
|
|
|
|
list.splice(0, list.length); |
|
|
|
|
that.gainCount(); |
|
|
|
|
that.getCartList(); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
//批量收藏; |
|
|
|
|
collectAll: function() { |
|
|
|
|
collectAll: function () { |
|
|
|
|
let that = this, |
|
|
|
|
data = { |
|
|
|
|
id: [], |
|
|
|
|
category: "" |
|
|
|
|
}, |
|
|
|
|
list = that.cartList.valid; |
|
|
|
|
list.forEach(function(val) { |
|
|
|
|
list.forEach(function (val) { |
|
|
|
|
if (val.checked === true) { |
|
|
|
|
data.id.push(val.product_id); |
|
|
|
|
data.category = val.type; |
|
|
|
@ -351,7 +328,7 @@ export default {
|
|
|
|
|
}); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
postCollectAll(data).then(function() { |
|
|
|
|
postCollectAll(data).then(function () { |
|
|
|
|
uni.showToast({ |
|
|
|
|
title: "收藏成功!", |
|
|
|
|
icon: "none", |
|
|
|
@ -360,11 +337,11 @@ export default {
|
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
//立即下单; |
|
|
|
|
placeOrder: function() { |
|
|
|
|
placeOrder: function () { |
|
|
|
|
let that = this, |
|
|
|
|
list = that.cartList.valid, |
|
|
|
|
id = []; |
|
|
|
|
list.forEach(function(val) { |
|
|
|
|
list.forEach(function (val) { |
|
|
|
|
if (val.checked === true) { |
|
|
|
|
id.push(val.id); |
|
|
|
|
} |
|
|
|
@ -384,16 +361,16 @@ export default {
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
manage: function() { |
|
|
|
|
manage: function () { |
|
|
|
|
let that = this; |
|
|
|
|
that.footerswitch = !that.footerswitch; |
|
|
|
|
}, |
|
|
|
|
goodsOpen: function() { |
|
|
|
|
goodsOpen: function () { |
|
|
|
|
let that = this; |
|
|
|
|
that.goodsHidden = !that.goodsHidden; |
|
|
|
|
}, |
|
|
|
|
//加 |
|
|
|
|
plus: function(index) { |
|
|
|
|
plus: function (index) { |
|
|
|
|
let that = this; |
|
|
|
|
let list = that.cartList.valid[index]; |
|
|
|
|
list.cartNum++; |
|
|
|
@ -411,7 +388,7 @@ export default {
|
|
|
|
|
that.syncCartNum(list); |
|
|
|
|
}, |
|
|
|
|
//减 |
|
|
|
|
reduce: function(index) { |
|
|
|
|
reduce: function (index) { |
|
|
|
|
let that = this; |
|
|
|
|
let list = that.cartList.valid[index]; |
|
|
|
|
if (list.cartNum <= 1) { |
|
|
|
@ -448,7 +425,7 @@ export default {
|
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
//单选 |
|
|
|
|
switchSelect: function(index) { |
|
|
|
|
switchSelect: function (index) { |
|
|
|
|
let that = this, |
|
|
|
|
cart = that.cartList.valid[index], |
|
|
|
|
i = this.checkedIds.indexOf(cart.id); |
|
|
|
@ -474,7 +451,7 @@ export default {
|
|
|
|
|
that.countMoney(); |
|
|
|
|
}, |
|
|
|
|
//全选 |
|
|
|
|
allChecked: function(e) { |
|
|
|
|
allChecked: function (e) { |
|
|
|
|
console.log(e); |
|
|
|
|
let that = this; |
|
|
|
|
let selectAllStatus = e.mp.detail.value[0] == "allSelect" ? true : false; |
|
|
|
@ -506,7 +483,7 @@ export default {
|
|
|
|
|
this.$forceUpdate(); |
|
|
|
|
}, |
|
|
|
|
//数量 |
|
|
|
|
carnum: function() { |
|
|
|
|
carnum: function () { |
|
|
|
|
let that = this; |
|
|
|
|
var carnum = 0; |
|
|
|
|
var array = that.cartList.valid; |
|
|
|
@ -518,7 +495,7 @@ export default {
|
|
|
|
|
that.$set(that, "cartCount", carnum); |
|
|
|
|
}, |
|
|
|
|
//总共价钱; |
|
|
|
|
countMoney: function() { |
|
|
|
|
countMoney: function () { |
|
|
|
|
let that = this; |
|
|
|
|
let carmoney = 0; |
|
|
|
|
let array = that.cartList.valid; |
|
|
|
@ -530,5 +507,5 @@ export default {
|
|
|
|
|
that.countmoney = carmoney; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
}; |
|
|
|
|
</script> |
|
|
|
|