|
@@ -5,7 +5,7 @@
|
|
|
<view class="u-nav-slot" slot="left">
|
|
|
<view class="">
|
|
|
<text class="shopcart">{{ i18n.Shopping }}</text>
|
|
|
- <text class="sum">(12)</text>
|
|
|
+ <text class="sum">({{ goodsNum }})</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="u-nav-slot" slot="right">
|
|
@@ -25,6 +25,21 @@
|
|
|
<view class="item">
|
|
|
<view class="shopname u-flex">
|
|
|
<image
|
|
|
+ src="/static/mine/354.png"
|
|
|
+ class="circle"
|
|
|
+ mode="scaleToFill"
|
|
|
+ @click="shopSelectAll(item.goods)"
|
|
|
+ v-if="shop(item.goods)"
|
|
|
+ />
|
|
|
+ <image
|
|
|
+ src="/static/mine/353.png"
|
|
|
+ class="circle"
|
|
|
+ mode="scaleToFill"
|
|
|
+ @click="shopSelectAll(item.goods)"
|
|
|
+ v-else
|
|
|
+ />
|
|
|
+
|
|
|
+ <image
|
|
|
:src="item.image"
|
|
|
style="width: 28rpx; height: 28rpx"
|
|
|
mode=""
|
|
@@ -48,7 +63,8 @@
|
|
|
<u-checkbox
|
|
|
shape="circle"
|
|
|
:customStyle="{ marginBottom: '8px' }"
|
|
|
- :name="shopitem"
|
|
|
+ :name="chid.cart.merchant_goods_id"
|
|
|
+ activeColor="#F83224"
|
|
|
>
|
|
|
</u-checkbox>
|
|
|
<view
|
|
@@ -94,11 +110,14 @@
|
|
|
>{{ chid.sku_item[0].weight }}kg</text
|
|
|
>
|
|
|
</view>
|
|
|
- <view class="">
|
|
|
+ <view class="aaaaaa">
|
|
|
<!-- <view class="delect" v-if='dele'>{{i18n.delete}}</view> -->
|
|
|
- <view class="" v-if="num && success">
|
|
|
+ <view class="" v-if="num == chid.cart.id && success">
|
|
|
<!-- <u-number-box v-model="value" @change="valChange"></u-number-box> -->
|
|
|
- <u-number-box v-model="value">
|
|
|
+ <u-number-box
|
|
|
+ v-model="chid.cart.goods_num"
|
|
|
+ @change="addOrReduce"
|
|
|
+ >
|
|
|
<view slot="minus" class="minus">
|
|
|
<u-icon
|
|
|
name="minus"
|
|
@@ -114,7 +133,7 @@
|
|
|
font-size: 20rpx;
|
|
|
"
|
|
|
class="input"
|
|
|
- >{{ value }}</text
|
|
|
+ >{{ chid.cart.goods_num }}</text
|
|
|
>
|
|
|
<view slot="plus" class="plus">
|
|
|
<u-icon
|
|
@@ -127,10 +146,10 @@
|
|
|
</view>
|
|
|
<view
|
|
|
class="num"
|
|
|
- v-if="num == false && success"
|
|
|
- @click="num = true"
|
|
|
+ v-if="num != chid.cart.id && success"
|
|
|
+ @click="num = chid.cart.id"
|
|
|
>
|
|
|
- x1
|
|
|
+ x{{ chid.cart.goods_num }}
|
|
|
</view>
|
|
|
</view>
|
|
|
<view v-if="success == false" class="icon">
|
|
@@ -145,7 +164,13 @@
|
|
|
</view>
|
|
|
</u-checkbox-group>
|
|
|
<view class="" style="height: 260rpx"></view>
|
|
|
- <kj-tabbar ref="tabbar1" :value1="3"></kj-tabbar>
|
|
|
+ <kj-tabbar
|
|
|
+ ref="tabbar1"
|
|
|
+ :value1="3"
|
|
|
+ @allSelect="allSelect"
|
|
|
+ :goodsWeight="goodsWeight"
|
|
|
+ :goodsPrice="goodsPrice"
|
|
|
+ ></kj-tabbar>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
@@ -161,18 +186,21 @@ export default {
|
|
|
all: [], //全选数组
|
|
|
goodsList: [],
|
|
|
selectall: -1,
|
|
|
+ goodsNum: 0,
|
|
|
num: false,
|
|
|
+ goodsWeight: 0, //商品重量
|
|
|
+ goodsPrice: 0, //商品价格
|
|
|
options2: [
|
|
|
{
|
|
|
- text: "收藏",
|
|
|
+ text: "移入关注",
|
|
|
style: {
|
|
|
- backgroundColor: "#3c9cff",
|
|
|
+ backgroundColor: "#FFB115",
|
|
|
},
|
|
|
},
|
|
|
{
|
|
|
text: "删除",
|
|
|
style: {
|
|
|
- backgroundColor: "#f56c6c",
|
|
|
+ backgroundColor: "#F83224",
|
|
|
},
|
|
|
},
|
|
|
],
|
|
@@ -186,18 +214,73 @@ export default {
|
|
|
},
|
|
|
onLoad() {
|
|
|
const systemInfo = wx.getSystemInfoSync();
|
|
|
- console.log(systemInfo);
|
|
|
const tab =
|
|
|
systemInfo.screenHeight -
|
|
|
systemInfo.safeArea.bottom +
|
|
|
systemInfo.statusBarHeight;
|
|
|
this.tabarheight = tab;
|
|
|
- console.log(this.tabarheight);
|
|
|
},
|
|
|
methods: {
|
|
|
+ shop(value) {
|
|
|
+ let num = 0;
|
|
|
+ value.map((item) => {
|
|
|
+ if (this.checkboxValue1.indexOf(item.cart.merchant_goods_id) >= 0) {
|
|
|
+ num++;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return num;
|
|
|
+ },
|
|
|
+
|
|
|
+ addOrReduce(n) {
|
|
|
+ uni.$u.http
|
|
|
+ .post(`/api/cart/num/${this.num}`, { goods_num: n.value, type: "" })
|
|
|
+ .then((res) => {
|
|
|
+ console.log(res);
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ //店铺商品全选
|
|
|
+ shopSelectAll(value) {
|
|
|
+ //先判断存放选中的数组有没有选中的数据
|
|
|
+ if (this.checkboxValue1.length == 0) {
|
|
|
+ //没有数据则直接将选中店铺中的商品存入数组
|
|
|
+ value.map((item) => {
|
|
|
+ this.checkboxValue1.push(item.cart.merchant_goods_id);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ if (this.shop(value) > 0 && this.shop(value) == value.length) {
|
|
|
+ value.map((item) => {
|
|
|
+ //先判断选中的商品数组中该店铺商品是否已被选中,已被选中则取消选中,未被选中则推入选中状态
|
|
|
+ if (this.checkboxValue1.indexOf(item.cart.merchant_goods_id) >= 0) {
|
|
|
+ this.checkboxValue1.splice(
|
|
|
+ this.checkboxValue1.indexOf(item.cart.merchant_goods_id),
|
|
|
+ 1
|
|
|
+ );
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else if (
|
|
|
+ (this.shop(value) > 0 && this.shop(value) != value.length) ||
|
|
|
+ this.shop(value) == 0
|
|
|
+ ) {
|
|
|
+ value.map((item) => {
|
|
|
+ //先判断选中的商品数组中该店铺商品是否已被选中,已被选中则取消选中,未被选中则推入选中状态
|
|
|
+ if (
|
|
|
+ this.checkboxValue1.indexOf(item.cart.merchant_goods_id) == -1
|
|
|
+ ) {
|
|
|
+ this.checkboxValue1.push(item.cart.merchant_goods_id);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (this.checkboxValue1.length == this.goodsNum) {
|
|
|
+ this.$refs.tabbar1.cancelAll();
|
|
|
+ } else {
|
|
|
+ this.$refs.tabbar1.cancelAll("取消");
|
|
|
+ }
|
|
|
+ this.shop(value);
|
|
|
+ },
|
|
|
admin() {
|
|
|
this.success = !this.success;
|
|
|
- console.log(this.success);
|
|
|
},
|
|
|
valChange(e) {
|
|
|
console.log("当前值为: " + e.value);
|
|
@@ -206,17 +289,61 @@ export default {
|
|
|
checkAll(e) {
|
|
|
console.log("all", e);
|
|
|
},
|
|
|
- aaa() {
|
|
|
- console.log(this.$refs.tabbar1.getLabelHeight());
|
|
|
- },
|
|
|
checkboxChange(n) {
|
|
|
- console.log("change", n);
|
|
|
+ this.goodsWeight = 0;
|
|
|
+ this.goodsPrice = 0;
|
|
|
+ this.checkboxValue1 = n;
|
|
|
+ this.goodsList.map((item) => {
|
|
|
+ item.goods.map((items) => {
|
|
|
+ if (n.indexOf(items.id) > -1) {
|
|
|
+ this.goodsWeight += items.sku_item[0].weight;
|
|
|
+ this.goodsPrice += Number(items.sku_item[0].price);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ //判断是否全部选中
|
|
|
+ if (this.checkboxValue1.length == this.goodsNum && this.goodsNum != 0) {
|
|
|
+ this.$refs.tabbar1.cancelAll();
|
|
|
+ } else if (this.checkboxValue1.length < this.goodsNum) {
|
|
|
+ this.$refs.tabbar1.cancelAll("取消");
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //购物车全选
|
|
|
+ allSelect() {
|
|
|
+ const all = this.$refs.tabbar1.cancelAll("全选");
|
|
|
+ if (this.checkboxValue1.length == this.goodsNum && all.length == 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ console.log(this.checkboxValue1.length, this.goodsNum);
|
|
|
+ console.log(this.checkboxValue1, this.goodsNum);
|
|
|
+ //判断是否已经全选,如已全选,则取消全选
|
|
|
+ if (this.checkboxValue1.length == this.goodsNum) {
|
|
|
+ this.checkboxValue1 = [];
|
|
|
+ this.goodsPrice = 0;
|
|
|
+ this.goodsWeight = 0;
|
|
|
+ } else {
|
|
|
+ this.goodsList.map((item) => {
|
|
|
+ item.goods.map((items) => {
|
|
|
+ //判断是否有商品已被选中
|
|
|
+ if (
|
|
|
+ this.checkboxValue1.indexOf(items.cart.merchant_goods_id) == -1
|
|
|
+ ) {
|
|
|
+ this.checkboxValue1.push(items.cart.merchant_goods_id);
|
|
|
+ this.goodsWeight += items.sku_item[0].weight;
|
|
|
+ this.goodsPrice += Number(items.sku_item[0].price);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
},
|
|
|
//获取购物车数据
|
|
|
getShopCarList() {
|
|
|
uni.$u.http.get(`/api/cart`).then((res) => {
|
|
|
- console.log(res);
|
|
|
this.goodsList = res.data;
|
|
|
+ //循环店铺,获取购物车商品数量
|
|
|
+ this.goodsList.map((item) => {
|
|
|
+ this.goodsNum += item.goods.length;
|
|
|
+ });
|
|
|
});
|
|
|
},
|
|
|
},
|
|
@@ -418,6 +545,7 @@ export default {
|
|
|
line-height: 28rpx;
|
|
|
text-align: left;
|
|
|
font-style: normal;
|
|
|
+ margin-right: 6rpx;
|
|
|
}
|
|
|
|
|
|
.goods {
|
|
@@ -458,6 +586,11 @@ export default {
|
|
|
line-height: 36rpx;
|
|
|
text-align: left;
|
|
|
font-style: normal;
|
|
|
+ .circle {
|
|
|
+ width: 32rpx;
|
|
|
+ height: 32rpx;
|
|
|
+ margin-right: 10rpx;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|