暂存code

This commit is contained in:
hejiangming
2025-05-07 09:54:33 +08:00
parent 78270eeda0
commit 007b002b81
403 changed files with 14507 additions and 6320 deletions
@@ -2,8 +2,9 @@
const common_vendor = require("../../common/vendor.js");
const api_cart = require("../../api/cart.js");
const choiceness = () => "../../components/choiceness/choiceness.js";
const CustomTabBar = () => "../../components/custom-tab-bar.js";
const _sfc_main = {
components: { choiceness },
components: { choiceness, CustomTabBar },
data() {
return {
shoppingTotal: 0,
@@ -24,26 +25,38 @@ const _sfc_main = {
listLoading: false
};
},
onLoad() {
onShow() {
this.getCartList();
},
onLoad() {
},
methods: {
/**
* 查询购物车列表
*/
async getCartList() {
this.listLoading = true;
let result = [];
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;
const data = resp.data || [];
if (data && data.length !== 0) {
result = this.transformedArray(data);
}
this.shoppingTotal = data.length;
}
this.shoppingList = result;
this.listLoading = false;
this.total = 0;
this.count = 0;
this.isDataNull = result.length === 0 ? true : false;
},
// 处理购物车的数据
transformedArray(originalArray) {
const newOriginalArray = [];
if (!originalArray || originalArray.length === 0) {
return newOriginalArray;
}
originalArray.map((curr) => {
const existingShop = newOriginalArray.find((shop) => shop.shopId === curr.shopId && shop.shopName === curr.shopName);
if (existingShop) {
@@ -65,8 +78,8 @@ const _sfc_main = {
// 规格Id
isCheck: false,
// 用作于全选
isAvail: curr.isAvail
// 是否有库存
goodsStatus: curr.goodsStatus
//商品状态:0-可下单,1-库存不够,2-商品已下架
});
} else {
newOriginalArray.push({
@@ -94,8 +107,8 @@ const _sfc_main = {
// 规格Id
isCheck: false,
// 用作于全选
isAvail: curr.isAvail
// 是否有库存,用作于全选
goodsStatus: curr.goodsStatus
//商品状态:0-可下单,1-库存不够,2-商品已下架
}]
});
}
@@ -109,7 +122,11 @@ const _sfc_main = {
* @param {Object} cItem 需要修改的数据节点
*/
async quantityFun(type, index, pIndex, id) {
const currentData = this.shoppingList[index].product[pIndex];
let currentQuantity = this.shoppingList[index].product[pIndex].buyNum;
let total = Number(this.total);
let count = Number(this.count);
const data = this.shoppingList[index].product[pIndex];
if (type === "minus") {
if (currentQuantity === 1) {
this.$refs.uToastRef.show({
@@ -119,18 +136,25 @@ const _sfc_main = {
return;
} else {
currentQuantity = currentQuantity - 1;
total = total - data.unitPrice;
count = count - 1;
}
} else if (type === "add") {
currentQuantity = currentQuantity + 1;
total = total + data.unitPrice;
count = count + 1;
}
const params = {
id,
goodsNum: currentQuantity
};
const result = await api_cart.updateGoodsNum(params);
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;
if (currentData.isCheck) {
this.total = total.toFixed(2);
this.count = count;
}
}
},
/**
@@ -149,7 +173,6 @@ const _sfc_main = {
url: "/pages/order_submit/order_submit?ids=" + deleteId.join(",")
});
this.isAll = false;
this.selectCheck(false);
},
/**
* 删除选中的
@@ -158,7 +181,7 @@ const _sfc_main = {
const then = this;
common_vendor.index.showModal({
title: "提示",
content: "您确定要删除选中的所有商品吗?",
content: "您确定要删除选中的(" + this.getCheckList().length + "件)商品吗?",
success: function(res) {
if (res.confirm) {
then.deleteShoppingFun();
@@ -182,8 +205,6 @@ const _sfc_main = {
const result = await api_cart.removeGoods(params);
if (result && result.bizcode === 100) {
this.isEdit = false;
this.isAll = false;
this.selectCheck(false);
this.$refs.uToastRef.show({
type: "success",
message: "删除成功"
@@ -212,15 +233,9 @@ const _sfc_main = {
return deleteId;
},
// 全部选中 or 全部取消选中
isAllChange(val) {
this.selectCheck(val);
},
/**
* 编辑是否选中
*/
selectCheck(isAll) {
isAllChange(isAll) {
const currentShoppingList = this.shoppingList;
currentShoppingList.map((item) => {
currentShoppingList.map((item, index) => {
if (isAll) {
item.isCheck = true;
} else {
@@ -235,51 +250,74 @@ const _sfc_main = {
}
});
this.shoppingList = currentShoppingList;
if (isAll) {
this.checkIsAll();
} else {
this.total = 0;
this.count = 0;
}
},
/**
* 商品详情
* @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;
setTimeout(() => {
this.checkIsAll();
}, 300);
},
// 单个店铺的单选按钮选中与取消选中
shoppingChange(val, index) {
let total = this.total;
let count = this.count;
shoppingChange(isAll, index) {
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;
}
});
if (isAll) {
data.product.forEach((o) => o.isCheck = true);
} else {
data.product.forEach((o) => o.isCheck = false);
}
this.shoppingList[index] = data;
this.total = total;
this.count = count;
setTimeout(() => {
this.checkIsAll();
}, 300);
},
/**
* 检查是否全选
*/
checkIsAll() {
let total = 0;
let count = 0;
const shoppingList = this.shoppingList;
if (shoppingList && shoppingList.length !== 0) {
let sumFlag = false;
shoppingList.map((item) => {
let flag = true;
item.product.map((oItem) => {
if (oItem.isCheck) {
total = total + oItem.buyNum * oItem.unitPrice;
count = count + oItem.buyNum;
} else {
flag = false;
}
});
if (flag) {
item.isCheck = true;
sumFlag = true;
} else {
item.isCheck = false;
}
});
this.shoppingList = shoppingList;
this.isAll = sumFlag;
if (!this.isEdit) {
this.total = total.toFixed(2);
}
this.count = count;
}
}
}
};
@@ -289,7 +327,8 @@ if (!Array) {
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_loading_page2 + _easycom_up_image2 + _easycom_up_checkbox2 + _easycom_choiceness2 + _easycom_up_toast2)();
const _component_CustomTabBar = common_vendor.resolveComponent("CustomTabBar");
(_easycom_up_loading_page2 + _easycom_up_image2 + _easycom_up_checkbox2 + _easycom_choiceness2 + _easycom_up_toast2 + _component_CustomTabBar)();
}
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";
@@ -302,13 +341,20 @@ if (!Math) {
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: common_vendor.p({
b: !$data.isEdit
}, !$data.isEdit ? {
c: common_vendor.o(($event) => $data.isEdit = true),
d: !$data.isDataNull
} : {
e: common_vendor.o(($event) => $data.isEdit = false),
f: $data.isDataNull
}, {
g: common_vendor.p({
loading: $data.listLoading
}),
d: !$data.isDataNull
h: !$data.isDataNull
}, !$data.isDataNull ? {
e: common_vendor.f($data.shoppingList, (item, index, i0) => {
i: common_vendor.f($data.shoppingList, (item, index, i0) => {
return {
a: "7cc1684a-2-" + i0 + "," + ("7cc1684a-1-" + i0),
b: common_vendor.p({
@@ -350,45 +396,48 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
activeColor: "#FF7C41",
size: "19",
iconSize: "18",
disabled: !pItem.isAvail,
disabled: !$data.isEdit && [1, 2].includes(pItem.goodsStatus),
checked: pItem.isCheck
}),
e: "7cc1684a-4-" + i0 + "-" + i1,
f: common_vendor.p({
e: common_vendor.o(($event) => $options.jumpInfo(pItem), pItem.id),
f: "7cc1684a-4-" + i0 + "-" + i1,
g: common_vendor.p({
src: pItem.mainGraph,
width: "100",
height: "100",
bgColor: "#f1f6ff00"
}),
g: common_vendor.t(pItem.name),
h: common_vendor.t(pItem.goodsSpece),
i: common_vendor.t(pItem.unitPrice),
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 ? {} : {}, {
o: common_vendor.o(($event) => $options.jumpInfo(pItem), pItem.id),
p: pItem.id
h: common_vendor.t(pItem.name),
i: common_vendor.o(($event) => $options.jumpInfo(pItem), pItem.id),
j: common_vendor.t(pItem.goodsSpece),
k: common_vendor.t(pItem.unitPrice),
l: common_vendor.t(pItem.unitPrice),
m: common_vendor.o(($event) => $options.quantityFun("minus", index, pIndex, pItem.id), pItem.id),
n: common_vendor.t(pItem.buyNum),
o: common_vendor.o(($event) => $options.quantityFun("add", index, pIndex, pItem.id), pItem.id),
p: [1].includes(pItem.goodsStatus)
}, [1].includes(pItem.goodsStatus) ? {} : {}, {
q: [2].includes(pItem.goodsStatus)
}, [2].includes(pItem.goodsStatus) ? {} : {}, {
r: pItem.id
});
}),
j: item.id
};
})
} : {
f: common_vendor.p({
j: common_vendor.p({
src: "/static/common/not_shopping.png",
width: "80",
height: "80",
bgColor: "#f1f6ff00"
})
}, {
g: !$data.isDataNull
k: !$data.isDataNull
}, !$data.isDataNull ? common_vendor.e({
h: common_vendor.o($options.isAllChange),
i: common_vendor.o(($event) => $data.isAll = $event),
j: common_vendor.p({
l: common_vendor.o($options.isAllChange),
m: common_vendor.o(($event) => $data.isAll = $event),
n: common_vendor.p({
name: "isAll",
usedAlone: true,
shape: "circle",
@@ -397,16 +446,27 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
iconSize: "18",
checked: $data.isAll
}),
k: common_vendor.t($data.total),
l: $data.isEdit
o: !$data.isEdit
}, !$data.isEdit ? {} : {}, {
p: !$data.isEdit
}, !$data.isEdit ? {} : {}, {
q: !$data.isEdit
}, !$data.isEdit ? {
r: common_vendor.t($data.total)
} : {}, {
s: $data.isEdit
}, $data.isEdit ? {
m: common_vendor.o((...args) => $options.deleteShopping && $options.deleteShopping(...args))
t: common_vendor.t($data.count),
v: common_vendor.o((...args) => $options.deleteShopping && $options.deleteShopping(...args))
} : {
n: common_vendor.t($data.count),
o: common_vendor.o((...args) => $options.settleShopping && $options.settleShopping(...args))
w: common_vendor.t($data.count),
x: common_vendor.o((...args) => $options.settleShopping && $options.settleShopping(...args))
}) : {}, {
p: common_vendor.sr("uToastRef", "7cc1684a-8"),
q: $data.isDataNull ? "calc(100vh - 134rpx)" : "calc(100vh - 256rpx)"
y: common_vendor.sr("uToastRef", "7cc1684a-8"),
z: $data.isDataNull ? "calc(100vh - 134rpx)" : "calc(100vh - 410rpx)",
A: common_vendor.p({
tabIndex: 2
})
});
}
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",
"custom-tab-bar": "../../components/custom-tab-bar",
"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",
@@ -1 +1 @@
<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>
<view class="data-v-7cc1684a"><view style="{{'height:' + z}}" class="shopping_cart_warp data-v-7cc1684a"><view class="shopping_cart_header data-v-7cc1684a"><view class="cart data-v-7cc1684a">购物车({{a}})</view><view wx:if="{{b}}" class="enit_but data-v-7cc1684a" bindtap="{{c}}" hidden="{{!d}}">编辑</view><view wx:else class="enit_but data-v-7cc1684a" bindtap="{{e}}" hidden="{{!f}}">取消</view></view><up-loading-page wx:if="{{g}}" class="data-v-7cc1684a" u-i="7cc1684a-0" bind:__l="__l" u-p="{{g}}"></up-loading-page><view class="shopping_cart_content data-v-7cc1684a"><block wx:if="{{h}}"><view wx:for="{{i}}" 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="r" 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"><up-image wx:if="{{pItem.g}}" class="data-v-7cc1684a" bindclick="{{pItem.e}}" u-i="{{pItem.f}}" bind:__l="__l" u-p="{{pItem.g}}"></up-image><view class="content_info data-v-7cc1684a"><view class="shopping_content_info_title data-v-7cc1684a" bindtap="{{pItem.i}}">{{pItem.h}}</view><view class="content_info_description data-v-7cc1684a">{{pItem.j}}</view><view class="shopping_info_amount data-v-7cc1684a"><view class="data-v-7cc1684a"><view class="data-v-7cc1684a" style="color:#FF7C41"><text class="data-v-7cc1684a" style="font-size:22rpx">¥</text><text class="data-v-7cc1684a" style="font-size:32rpx">{{pItem.k}}</text></view><view class="shopping_info_amount_original data-v-7cc1684a">¥{{pItem.l}}</view></view><view class="data-v-7cc1684a"><view class="shopping_info_quantity data-v-7cc1684a"><view class="quantity_but data-v-7cc1684a" bindtap="{{pItem.m}}">-</view><view class="quantity_value data-v-7cc1684a">{{pItem.n}}</view><view class="quantity_but data-v-7cc1684a" bindtap="{{pItem.o}}">+</view></view><view wx:if="{{pItem.p}}" class="insufficient_stock data-v-7cc1684a">库存不足</view><view wx:if="{{pItem.q}}" 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="{{j}}" class="data-v-7cc1684a" u-i="7cc1684a-5" bind:__l="__l" u-p="{{j}}"></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="{{k}}" 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="{{n}}" class="data-v-7cc1684a" u-s="{{['label']}}" bindchange="{{l}}" u-i="7cc1684a-7" bind:__l="__l" bindupdateChecked="{{m}}" u-p="{{n}}"><text class="data-v-7cc1684a" style="font-size:26rpx;color:#444444" slot="label">全选</text></up-checkbox><text wx:if="{{o}}" class="data-v-7cc1684a" style="margin-left:20rpx;font-size:24rpx;color:#444444">合计:</text><text wx:if="{{p}}" class="data-v-7cc1684a" style="font-size:24rpx">¥</text><text wx:if="{{q}}" class="data-v-7cc1684a" style="font-size:32rpx">{{r}}</text></view><view wx:if="{{s}}" class="delete_but_css data-v-7cc1684a" bindtap="{{v}}"> 删除({{t}}) </view><view wx:else class="add_but_css data-v-7cc1684a" bindtap="{{x}}"> 结算({{w}}) </view></view></view><up-toast class="r data-v-7cc1684a" u-r="uToastRef" u-i="7cc1684a-8" bind:__l="__l"></up-toast></view><custom-tab-bar wx:if="{{A}}" class="data-v-7cc1684a" u-i="7cc1684a-9" bind:__l="__l" u-p="{{A}}"/></view>
@@ -42,7 +42,7 @@
}
.shopping_cart_content.data-v-7cc1684a {
margin-top: 30rpx;
height: calc(100vh - 304rpx);
height: calc(100vh - 456rpx);
overflow-y: auto;
}
.shopping_cart_content .shopping_cart_content_item.data-v-7cc1684a {
@@ -93,7 +93,7 @@
}
.shopping_cart_but.data-v-7cc1684a {
position: fixed;
bottom: 0;
bottom: 140rpx;
left: 0;
width: calc(100% - 40rpx);
background: #FFFFFF;