增加新功能
This commit is contained in:
+102
-41
@@ -15,11 +15,16 @@ const _sfc_main = {
|
||||
// 购物车列表
|
||||
isEdit: false,
|
||||
// 是否编辑
|
||||
isAll: false
|
||||
isAll: false,
|
||||
// 是否全选
|
||||
total: 0,
|
||||
// 总合计的金额
|
||||
count: 0,
|
||||
// 总条数
|
||||
listLoading: false
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
onLoad() {
|
||||
this.getCartList();
|
||||
},
|
||||
methods: {
|
||||
@@ -27,18 +32,19 @@ const _sfc_main = {
|
||||
* 查询购物车列表
|
||||
*/
|
||||
async getCartList() {
|
||||
this.listLoading = true;
|
||||
const resp = await api_cart.getCartList();
|
||||
if (resp && resp.bizcode === 100) {
|
||||
const data = this.transformedArray(resp.data);
|
||||
this.shoppingTotal = resp.data.length;
|
||||
this.shoppingList = data;
|
||||
}
|
||||
this.listLoading = false;
|
||||
},
|
||||
// 处理购物车的数据
|
||||
transformedArray(originalArray) {
|
||||
const newOriginalArray = [];
|
||||
originalArray.map((curr) => {
|
||||
common_vendor.index.__f__("log", "at pages/shopping_cart/shopping_cart.vue:156", "currcurrcurrcurr", curr);
|
||||
const existingShop = newOriginalArray.find((shop) => shop.shopId === curr.shopId && shop.shopName === curr.shopName);
|
||||
if (existingShop) {
|
||||
existingShop.product.push({
|
||||
@@ -122,7 +128,7 @@ const _sfc_main = {
|
||||
goodsNum: currentQuantity
|
||||
};
|
||||
const result = await api_cart.updateGoodsNum(params);
|
||||
common_vendor.index.__f__("log", "at pages/shopping_cart/shopping_cart.vue:226", "result", result);
|
||||
common_vendor.index.__f__("log", "at pages/shopping_cart/shopping_cart.vue:232", "result", result);
|
||||
if (result && result.bizcode === 100) {
|
||||
this.shoppingList[index].product[pIndex].buyNum = currentQuantity;
|
||||
}
|
||||
@@ -131,7 +137,6 @@ const _sfc_main = {
|
||||
* 结算订单
|
||||
*/
|
||||
settleShopping() {
|
||||
common_vendor.index.__f__("log", "at pages/shopping_cart/shopping_cart.vue:235", "结算订单....");
|
||||
const deleteId = this.getCheckList();
|
||||
if (!deleteId || deleteId.length === 0) {
|
||||
this.$refs.uToastRef.show({
|
||||
@@ -140,11 +145,11 @@ const _sfc_main = {
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.isAll = false;
|
||||
this.selectCheck(false);
|
||||
common_vendor.index.navigateTo({
|
||||
url: "/pages/order_submit/order_submit?ids=" + deleteId.join(",")
|
||||
});
|
||||
this.isAll = false;
|
||||
this.selectCheck(false);
|
||||
},
|
||||
/**
|
||||
* 删除选中的
|
||||
@@ -230,43 +235,95 @@ const _sfc_main = {
|
||||
}
|
||||
});
|
||||
this.shoppingList = currentShoppingList;
|
||||
},
|
||||
/**
|
||||
* 商品详情
|
||||
* @param {Object} item
|
||||
*/
|
||||
jumpInfo(item) {
|
||||
common_vendor.index.__f__("log", "at pages/shopping_cart/shopping_cart.vue:348", "item", item);
|
||||
common_vendor.index.navigateTo({
|
||||
url: "/pages/productInfo/productInfo?id=" + item.goodsId
|
||||
});
|
||||
},
|
||||
// 单个产品的单选按钮选中与取消选中
|
||||
productChange(val, index, pIndex) {
|
||||
let total = this.total;
|
||||
let count = this.count;
|
||||
const data = this.shoppingList[index].product[pIndex];
|
||||
if (val) {
|
||||
total = total + data.buyNum * data.unitPrice;
|
||||
count = count + data.buyNum;
|
||||
} else {
|
||||
total = total - data.buyNum * data.unitPrice;
|
||||
count = count - data.buyNum;
|
||||
}
|
||||
this.total = total;
|
||||
this.count = count;
|
||||
},
|
||||
// 单个店铺的单选按钮选中与取消选中
|
||||
shoppingChange(val, index) {
|
||||
let total = this.total;
|
||||
let count = this.count;
|
||||
const data = this.shoppingList[index];
|
||||
data.product.map((item) => {
|
||||
if (val) {
|
||||
item.isCheck = true;
|
||||
total = total + item.buyNum * item.unitPrice;
|
||||
count = count + item.buyNum;
|
||||
} else {
|
||||
item.isCheck = false;
|
||||
total = total - item.buyNum * item.unitPrice;
|
||||
count = count - item.buyNum;
|
||||
}
|
||||
});
|
||||
this.shoppingList[index] = data;
|
||||
this.total = total;
|
||||
this.count = count;
|
||||
}
|
||||
}
|
||||
};
|
||||
if (!Array) {
|
||||
const _easycom_up_loading_page2 = common_vendor.resolveComponent("up-loading-page");
|
||||
const _easycom_up_image2 = common_vendor.resolveComponent("up-image");
|
||||
const _easycom_up_checkbox2 = common_vendor.resolveComponent("up-checkbox");
|
||||
const _easycom_choiceness2 = common_vendor.resolveComponent("choiceness");
|
||||
const _easycom_up_toast2 = common_vendor.resolveComponent("up-toast");
|
||||
(_easycom_up_image2 + _easycom_up_checkbox2 + _easycom_choiceness2 + _easycom_up_toast2)();
|
||||
(_easycom_up_loading_page2 + _easycom_up_image2 + _easycom_up_checkbox2 + _easycom_choiceness2 + _easycom_up_toast2)();
|
||||
}
|
||||
const _easycom_up_loading_page = () => "../../uni_modules/uview-plus/components/u-loading-page/u-loading-page.js";
|
||||
const _easycom_up_image = () => "../../uni_modules/uview-plus/components/u-image/u-image.js";
|
||||
const _easycom_up_checkbox = () => "../../uni_modules/uview-plus/components/u-checkbox/u-checkbox.js";
|
||||
const _easycom_choiceness = () => "../../components/choiceness/choiceness.js";
|
||||
const _easycom_up_toast = () => "../../uni_modules/uview-plus/components/u-toast/u-toast.js";
|
||||
if (!Math) {
|
||||
(_easycom_up_image + _easycom_up_checkbox + _easycom_choiceness + _easycom_up_toast)();
|
||||
(_easycom_up_loading_page + _easycom_up_image + _easycom_up_checkbox + _easycom_choiceness + _easycom_up_toast)();
|
||||
}
|
||||
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
return common_vendor.e({
|
||||
a: common_vendor.t($data.shoppingTotal),
|
||||
b: common_vendor.o(($event) => $data.isEdit = true),
|
||||
c: !$data.isDataNull
|
||||
c: common_vendor.p({
|
||||
loading: $data.listLoading
|
||||
}),
|
||||
d: !$data.isDataNull
|
||||
}, !$data.isDataNull ? {
|
||||
d: common_vendor.f($data.shoppingList, (item, index, i0) => {
|
||||
e: common_vendor.f($data.shoppingList, (item, index, i0) => {
|
||||
return {
|
||||
a: "7cc1684a-1-" + i0 + "," + ("7cc1684a-0-" + i0),
|
||||
a: "7cc1684a-2-" + i0 + "," + ("7cc1684a-1-" + i0),
|
||||
b: common_vendor.p({
|
||||
src: item.shopLogo ? item.shopLogo : "/static/shopping/store.png",
|
||||
width: "22",
|
||||
height: "22",
|
||||
bgColor: "#f1f6ff00"
|
||||
bgColor: "#f1f6ff00",
|
||||
shape: "circle"
|
||||
}),
|
||||
c: common_vendor.t(item.shopName),
|
||||
d: common_vendor.t(item.id),
|
||||
e: "7cc1684a-0-" + i0,
|
||||
f: common_vendor.o(($event) => item.isCheck = $event, item.id),
|
||||
g: common_vendor.p({
|
||||
e: common_vendor.o((event) => $options.shoppingChange(event, index), item.id),
|
||||
f: "7cc1684a-1-" + i0,
|
||||
g: common_vendor.o(($event) => item.isCheck = $event, item.id),
|
||||
h: common_vendor.p({
|
||||
customStyle: {
|
||||
marginBottom: "8px"
|
||||
},
|
||||
@@ -278,11 +335,12 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
iconSize: "18",
|
||||
checked: item.isCheck
|
||||
}),
|
||||
h: common_vendor.f(item.product, (pItem, pIndex, i1) => {
|
||||
i: common_vendor.f(item.product, (pItem, pIndex, i1) => {
|
||||
return common_vendor.e({
|
||||
a: "7cc1684a-2-" + i0 + "-" + i1,
|
||||
b: common_vendor.o(($event) => pItem.isCheck = $event, pItem.id),
|
||||
c: common_vendor.p({
|
||||
a: common_vendor.o((event) => $options.productChange(event, index, pIndex), pItem.id),
|
||||
b: "7cc1684a-3-" + i0 + "-" + i1,
|
||||
c: common_vendor.o(($event) => pItem.isCheck = $event, pItem.id),
|
||||
d: common_vendor.p({
|
||||
customStyle: {
|
||||
marginBottom: "8px"
|
||||
},
|
||||
@@ -295,41 +353,42 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
disabled: !pItem.isAvail,
|
||||
checked: pItem.isCheck
|
||||
}),
|
||||
d: "7cc1684a-3-" + i0 + "-" + i1,
|
||||
e: common_vendor.p({
|
||||
e: "7cc1684a-4-" + i0 + "-" + i1,
|
||||
f: common_vendor.p({
|
||||
src: pItem.mainGraph,
|
||||
width: "100",
|
||||
height: "100",
|
||||
bgColor: "#f1f6ff00"
|
||||
}),
|
||||
f: common_vendor.t(pItem.name),
|
||||
g: common_vendor.t(pItem.goodsSpece),
|
||||
h: common_vendor.t(pItem.unitPrice),
|
||||
g: common_vendor.t(pItem.name),
|
||||
h: common_vendor.t(pItem.goodsSpece),
|
||||
i: common_vendor.t(pItem.unitPrice),
|
||||
j: common_vendor.o(($event) => $options.quantityFun("minus", index, pIndex, pItem.id), pItem.id),
|
||||
k: common_vendor.t(pItem.buyNum),
|
||||
l: common_vendor.o(($event) => $options.quantityFun("add", index, pIndex, pItem.id), pItem.id),
|
||||
m: !pItem.isAvail
|
||||
j: common_vendor.t(pItem.unitPrice),
|
||||
k: common_vendor.o(($event) => $options.quantityFun("minus", index, pIndex, pItem.id), pItem.id),
|
||||
l: common_vendor.t(pItem.buyNum),
|
||||
m: common_vendor.o(($event) => $options.quantityFun("add", index, pIndex, pItem.id), pItem.id),
|
||||
n: !pItem.isAvail
|
||||
}, !pItem.isAvail ? {} : {}, {
|
||||
n: pItem.id
|
||||
o: common_vendor.o(($event) => $options.jumpInfo(pItem), pItem.id),
|
||||
p: pItem.id
|
||||
});
|
||||
}),
|
||||
i: item.id
|
||||
j: item.id
|
||||
};
|
||||
})
|
||||
} : {
|
||||
e: common_vendor.p({
|
||||
f: common_vendor.p({
|
||||
src: "/static/common/not_shopping.png",
|
||||
width: "80",
|
||||
height: "80",
|
||||
bgColor: "#f1f6ff00"
|
||||
})
|
||||
}, {
|
||||
f: !$data.isDataNull
|
||||
g: !$data.isDataNull
|
||||
}, !$data.isDataNull ? common_vendor.e({
|
||||
g: common_vendor.o($options.isAllChange),
|
||||
h: common_vendor.o(($event) => $data.isAll = $event),
|
||||
i: common_vendor.p({
|
||||
h: common_vendor.o($options.isAllChange),
|
||||
i: common_vendor.o(($event) => $data.isAll = $event),
|
||||
j: common_vendor.p({
|
||||
name: "isAll",
|
||||
usedAlone: true,
|
||||
shape: "circle",
|
||||
@@ -338,14 +397,16 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
iconSize: "18",
|
||||
checked: $data.isAll
|
||||
}),
|
||||
j: $data.isEdit
|
||||
k: common_vendor.t($data.total),
|
||||
l: $data.isEdit
|
||||
}, $data.isEdit ? {
|
||||
k: common_vendor.o((...args) => $options.deleteShopping && $options.deleteShopping(...args))
|
||||
m: common_vendor.o((...args) => $options.deleteShopping && $options.deleteShopping(...args))
|
||||
} : {
|
||||
l: common_vendor.o((...args) => $options.settleShopping && $options.settleShopping(...args))
|
||||
n: common_vendor.t($data.count),
|
||||
o: common_vendor.o((...args) => $options.settleShopping && $options.settleShopping(...args))
|
||||
}) : {}, {
|
||||
m: common_vendor.sr("uToastRef", "7cc1684a-7"),
|
||||
n: $data.isDataNull ? "calc(100vh - 134rpx)" : "calc(100vh - 256rpx)"
|
||||
p: common_vendor.sr("uToastRef", "7cc1684a-8"),
|
||||
q: $data.isDataNull ? "calc(100vh - 134rpx)" : "calc(100vh - 256rpx)"
|
||||
});
|
||||
}
|
||||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-7cc1684a"]]);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"navigationStyle": "custom",
|
||||
"usingComponents": {
|
||||
"choiceness": "../../components/choiceness/choiceness",
|
||||
"up-loading-page": "../../uni_modules/uview-plus/components/u-loading-page/u-loading-page",
|
||||
"up-image": "../../uni_modules/uview-plus/components/u-image/u-image",
|
||||
"up-checkbox": "../../uni_modules/uview-plus/components/u-checkbox/u-checkbox",
|
||||
"up-toast": "../../uni_modules/uview-plus/components/u-toast/u-toast"
|
||||
|
||||
@@ -1 +1 @@
|
||||
<view style="{{'height:' + n}}" class="shopping_cart_warp data-v-7cc1684a"><view class="shopping_cart_header data-v-7cc1684a"><view class="cart data-v-7cc1684a">购物车({{a}})</view><view class="enit_but data-v-7cc1684a" bindtap="{{b}}">编辑</view></view><view class="shopping_cart_content data-v-7cc1684a"><block wx:if="{{c}}"><view wx:for="{{d}}" wx:for-item="item" wx:key="i" class="shopping_cart_content_item data-v-7cc1684a"><up-checkbox wx:if="{{item.g}}" class="data-v-7cc1684a" u-s="{{['label']}}" u-i="{{item.e}}" bind:__l="__l" bindupdateChecked="{{item.f}}" u-p="{{item.g}}"><view class="content_item_header data-v-7cc1684a" slot="label"><up-image wx:if="{{item.b}}" class="data-v-7cc1684a" u-i="{{item.a}}" bind:__l="__l" u-p="{{item.b}}"></up-image><view class="order_product_title data-v-7cc1684a">{{item.c}}{{item.d}}</view></view></up-checkbox><view class="data-v-7cc1684a"><view wx:for="{{item.h}}" wx:for-item="pItem" wx:key="n" class="content_item_info data-v-7cc1684a"><up-checkbox wx:if="{{pItem.c}}" class="data-v-7cc1684a" u-i="{{pItem.a}}" bind:__l="__l" bindupdateChecked="{{pItem.b}}" u-p="{{pItem.c}}"></up-checkbox><view class="info_item data-v-7cc1684a"><up-image wx:if="{{pItem.e}}" class="data-v-7cc1684a" u-i="{{pItem.d}}" bind:__l="__l" u-p="{{pItem.e}}"></up-image><view class="content_info data-v-7cc1684a"><view class="shopping_content_info_title data-v-7cc1684a">{{pItem.f}}</view><view class="content_info_description data-v-7cc1684a">{{pItem.g}}</view><view class="shopping_info_amount data-v-7cc1684a"><view class="data-v-7cc1684a"><view class="data-v-7cc1684a" style="color:#FF7C41FF"><text class="data-v-7cc1684a" style="font-size:22rpx">¥</text><text class="data-v-7cc1684a" style="font-size:32rpx">{{pItem.h}}</text></view><view class="shopping_info_amount_original data-v-7cc1684a">¥{{pItem.i}}</view></view><view class="data-v-7cc1684a"><view class="shopping_info_quantity data-v-7cc1684a"><view class="quantity_but data-v-7cc1684a" bindtap="{{pItem.j}}">-</view><view class="quantity_value data-v-7cc1684a">{{pItem.k}}</view><view class="quantity_but data-v-7cc1684a" bindtap="{{pItem.l}}">+</view></view><view wx:if="{{pItem.m}}" class="insufficient_stock data-v-7cc1684a">库存不足</view></view></view></view></view></view></view></view></block><view wx:else class="not_order_warp data-v-7cc1684a"><up-image wx:if="{{e}}" class="data-v-7cc1684a" u-i="7cc1684a-4" bind:__l="__l" u-p="{{e}}"></up-image><view class="not_order_msg_warp data-v-7cc1684a">购物车是空的</view></view><choiceness class="data-v-7cc1684a" u-i="7cc1684a-5" bind:__l="__l"/></view><view wx:if="{{f}}" class="data-v-7cc1684a"><view class="shopping_cart_but data-v-7cc1684a"><view class="shopping_cart_but_total data-v-7cc1684a"><up-checkbox wx:if="{{i}}" class="data-v-7cc1684a" u-s="{{['label']}}" bindchange="{{g}}" u-i="7cc1684a-6" bind:__l="__l" bindupdateChecked="{{h}}" u-p="{{i}}"><text class="data-v-7cc1684a" style="font-size:26rpx;color:#444444" slot="label">全选</text></up-checkbox><text class="data-v-7cc1684a" style="margin-left:20rpx;font-size:24rpx;color:#444444">合计:</text><text class="data-v-7cc1684a" style="font-size:24rpx">¥</text><text class="data-v-7cc1684a" style="font-size:32rpx">2000.00</text></view><view wx:if="{{j}}" class="delete_but_css data-v-7cc1684a" bindtap="{{k}}"> 删除 </view><view wx:else class="add_but_css data-v-7cc1684a" bindtap="{{l}}"> 结算(2) </view></view></view><up-toast class="r data-v-7cc1684a" u-r="uToastRef" u-i="7cc1684a-7" bind:__l="__l"></up-toast></view>
|
||||
<view style="{{'height:' + q}}" class="shopping_cart_warp data-v-7cc1684a"><view class="shopping_cart_header data-v-7cc1684a"><view class="cart data-v-7cc1684a">购物车({{a}})</view><view class="enit_but data-v-7cc1684a" bindtap="{{b}}">编辑</view></view><up-loading-page wx:if="{{c}}" class="data-v-7cc1684a" u-i="7cc1684a-0" bind:__l="__l" u-p="{{c}}"></up-loading-page><view class="shopping_cart_content data-v-7cc1684a"><block wx:if="{{d}}"><view wx:for="{{e}}" wx:for-item="item" wx:key="j" class="shopping_cart_content_item data-v-7cc1684a"><up-checkbox wx:if="{{item.h}}" class="data-v-7cc1684a" u-s="{{['label']}}" bindchange="{{item.e}}" u-i="{{item.f}}" bind:__l="__l" bindupdateChecked="{{item.g}}" u-p="{{item.h}}"><view class="content_item_header data-v-7cc1684a" slot="label"><up-image wx:if="{{item.b}}" class="data-v-7cc1684a" u-i="{{item.a}}" bind:__l="__l" u-p="{{item.b}}"></up-image><view class="order_product_title data-v-7cc1684a">{{item.c}}{{item.d}}</view></view></up-checkbox><view class="data-v-7cc1684a"><view wx:for="{{item.i}}" wx:for-item="pItem" wx:key="p" class="content_item_info data-v-7cc1684a"><up-checkbox wx:if="{{pItem.d}}" class="data-v-7cc1684a" bindchange="{{pItem.a}}" u-i="{{pItem.b}}" bind:__l="__l" bindupdateChecked="{{pItem.c}}" u-p="{{pItem.d}}"></up-checkbox><view class="info_item data-v-7cc1684a" bindtap="{{pItem.o}}"><up-image wx:if="{{pItem.f}}" class="data-v-7cc1684a" u-i="{{pItem.e}}" bind:__l="__l" u-p="{{pItem.f}}"></up-image><view class="content_info data-v-7cc1684a"><view class="shopping_content_info_title data-v-7cc1684a">{{pItem.g}}</view><view class="content_info_description data-v-7cc1684a">{{pItem.h}}</view><view class="shopping_info_amount data-v-7cc1684a"><view class="data-v-7cc1684a"><view class="data-v-7cc1684a" style="color:#FF7C41FF"><text class="data-v-7cc1684a" style="font-size:22rpx">¥</text><text class="data-v-7cc1684a" style="font-size:32rpx">{{pItem.i}}</text></view><view class="shopping_info_amount_original data-v-7cc1684a">¥{{pItem.j}}</view></view><view class="data-v-7cc1684a"><view class="shopping_info_quantity data-v-7cc1684a"><view class="quantity_but data-v-7cc1684a" bindtap="{{pItem.k}}">-</view><view class="quantity_value data-v-7cc1684a">{{pItem.l}}</view><view class="quantity_but data-v-7cc1684a" bindtap="{{pItem.m}}">+</view></view><view wx:if="{{pItem.n}}" class="insufficient_stock data-v-7cc1684a">库存不足</view></view></view></view></view></view></view></view></block><view wx:else class="not_order_warp data-v-7cc1684a"><up-image wx:if="{{f}}" class="data-v-7cc1684a" u-i="7cc1684a-5" bind:__l="__l" u-p="{{f}}"></up-image><view class="not_order_msg_warp data-v-7cc1684a">购物车是空的</view></view><choiceness class="data-v-7cc1684a" u-i="7cc1684a-6" bind:__l="__l"/></view><view wx:if="{{g}}" class="data-v-7cc1684a"><view class="shopping_cart_but data-v-7cc1684a"><view class="shopping_cart_but_total data-v-7cc1684a"><up-checkbox wx:if="{{j}}" class="data-v-7cc1684a" u-s="{{['label']}}" bindchange="{{h}}" u-i="7cc1684a-7" bind:__l="__l" bindupdateChecked="{{i}}" u-p="{{j}}"><text class="data-v-7cc1684a" style="font-size:26rpx;color:#444444" slot="label">全选</text></up-checkbox><text class="data-v-7cc1684a" style="margin-left:20rpx;font-size:24rpx;color:#444444">合计:</text><text class="data-v-7cc1684a" style="font-size:24rpx">¥</text><text class="data-v-7cc1684a" style="font-size:32rpx">{{k}}</text></view><view wx:if="{{l}}" class="delete_but_css data-v-7cc1684a" bindtap="{{m}}"> 删除 </view><view wx:else class="add_but_css data-v-7cc1684a" bindtap="{{o}}"> 结算({{n}}) </view></view></view><up-toast class="r data-v-7cc1684a" u-r="uToastRef" u-i="7cc1684a-8" bind:__l="__l"></up-toast></view>
|
||||
@@ -64,6 +64,7 @@
|
||||
}
|
||||
.shopping_cart_content .shopping_cart_content_item .content_info.data-v-7cc1684a {
|
||||
margin-left: 10rpx;
|
||||
width: calc(100% - 100rpx);
|
||||
}
|
||||
.shopping_cart_content .shopping_cart_content_item .shopping_content_info_title.data-v-7cc1684a {
|
||||
font-weight: bold;
|
||||
|
||||
Reference in New Issue
Block a user