增加新模块

This commit is contained in:
何江明
2025-03-20 08:46:07 +08:00
parent 15014e22aa
commit 2ae62b59ed
1729 changed files with 94700 additions and 4232 deletions
@@ -0,0 +1,353 @@
"use strict";
const common_vendor = require("../../common/vendor.js");
const api_cart = require("../../api/cart.js");
const choiceness = () => "../../components/choiceness/choiceness.js";
const _sfc_main = {
components: { choiceness },
data() {
return {
shoppingTotal: 0,
// 总条数
setShoppingList: [],
isDataNull: false,
// 数据是否为空
shoppingList: [],
// 购物车列表
isEdit: false,
// 是否编辑
isAll: false
// 是否全选
};
},
mounted() {
this.getCartList();
},
methods: {
/**
* 查询购物车列表
*/
async getCartList() {
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;
}
},
// 处理购物车的数据
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({
id: curr.id,
goodsId: curr.goodsId,
// 商品ID
name: curr.name,
// 商品名称
mainGraph: curr.mainGraph,
// 主图
buyNum: curr.buyNum,
// 数量
unitPrice: curr.unitPrice,
// 商品单价
goodsSpece: curr.goodsSpece,
// 规格
specsId: curr.specsId,
// 规格Id
isCheck: false,
// 用作于全选
isAvail: curr.isAvail
// 是否有库存
});
} else {
newOriginalArray.push({
isCheck: false,
// 用作于全选
shopId: curr.shopId,
shopName: curr.shopName,
name: curr.name,
shopLogo: curr.shopLogo,
product: [{
id: curr.id,
goodsId: curr.goodsId,
// 商品ID
name: curr.name,
// 商品名称
mainGraph: curr.mainGraph,
// 主图
buyNum: curr.buyNum,
// 数量
unitPrice: curr.unitPrice,
// 商品单价
goodsSpece: curr.goodsSpece,
// 规格
specsId: curr.specsId,
// 规格Id
isCheck: false,
// 用作于全选
isAvail: curr.isAvail
// 是否有库存,用作于全选
}]
});
}
});
return newOriginalArray;
},
/**
* 数量进行增加删除
* @param {Object} type 区分是 + 还是 -
* @param {Object} pItem 父节点数据,用作与从新修改数据
* @param {Object} cItem 需要修改的数据节点
*/
async quantityFun(type, index, pIndex, id) {
let currentQuantity = this.shoppingList[index].product[pIndex].buyNum;
if (type === "minus") {
if (currentQuantity === 1) {
this.$refs.uToastRef.show({
type: "warring",
message: "宝贝数量不能在减少啦~"
});
return;
} else {
currentQuantity = currentQuantity - 1;
}
} else if (type === "add") {
currentQuantity = currentQuantity + 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:226", "result", result);
if (result && result.bizcode === 100) {
this.shoppingList[index].product[pIndex].buyNum = currentQuantity;
}
},
/**
* 结算订单
*/
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({
type: "warring",
message: "请先选择需要结算的商品"
});
return;
}
this.isAll = false;
this.selectCheck(false);
common_vendor.index.navigateTo({
url: "/pages/order_submit/order_submit?ids=" + deleteId.join(",")
});
},
/**
* 删除选中的
*/
deleteShopping() {
const then = this;
common_vendor.index.showModal({
title: "提示",
content: "您确定要删除选中的所有商品吗?",
success: function(res) {
if (res.confirm) {
then.deleteShoppingFun();
}
}
});
},
// 删除选中的
async deleteShoppingFun() {
const deleteId = this.getCheckList();
if (!deleteId || deleteId.length === 0) {
this.$refs.uToastRef.show({
type: "warring",
message: "请先选择需要删除的商品"
});
return;
}
const params = {
ids: deleteId.join(",")
};
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: "删除成功"
});
this.getCartList();
} else {
this.$refs.uToastRef.show({
type: "error",
message: "删除失败"
});
}
},
// 获取选中的数据
getCheckList() {
const shoppingList = this.shoppingList;
const deleteId = [];
shoppingList.map((item) => {
if (item.product && item.product.length !== 0) {
item.product.map((pItem) => {
if (pItem.isCheck) {
deleteId.push(pItem.id);
}
});
}
});
return deleteId;
},
// 全部选中 or 全部取消选中
isAllChange(val) {
this.selectCheck(val);
},
/**
* 编辑是否选中
*/
selectCheck(isAll) {
const currentShoppingList = this.shoppingList;
currentShoppingList.map((item) => {
if (isAll) {
item.isCheck = true;
} else {
item.isCheck = false;
}
if (item.product && item.product.length !== 0) {
if (isAll) {
item.product.forEach((o) => o.isCheck = true);
} else {
item.product.forEach((o) => o.isCheck = false);
}
}
});
this.shoppingList = currentShoppingList;
}
}
};
if (!Array) {
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)();
}
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)();
}
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
}, !$data.isDataNull ? {
d: common_vendor.f($data.shoppingList, (item, index, i0) => {
return {
a: "7cc1684a-1-" + i0 + "," + ("7cc1684a-0-" + i0),
b: common_vendor.p({
src: item.shopLogo ? item.shopLogo : "/static/shopping/store.png",
width: "22",
height: "22",
bgColor: "#f1f6ff00"
}),
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({
customStyle: {
marginBottom: "8px"
},
name: "isCheck",
usedAlone: true,
shape: "circle",
activeColor: "#FF7C41",
size: "19",
iconSize: "18",
checked: item.isCheck
}),
h: 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({
customStyle: {
marginBottom: "8px"
},
name: "isCheck",
usedAlone: true,
shape: "circle",
activeColor: "#FF7C41",
size: "19",
iconSize: "18",
disabled: !pItem.isAvail,
checked: pItem.isCheck
}),
d: "7cc1684a-3-" + i0 + "-" + i1,
e: 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),
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
}, !pItem.isAvail ? {} : {}, {
n: pItem.id
});
}),
i: item.id
};
})
} : {
e: common_vendor.p({
src: "/static/common/not_shopping.png",
width: "80",
height: "80",
bgColor: "#f1f6ff00"
})
}, {
f: !$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({
name: "isAll",
usedAlone: true,
shape: "circle",
activeColor: "#FF7C41",
size: "19",
iconSize: "18",
checked: $data.isAll
}),
j: $data.isEdit
}, $data.isEdit ? {
k: common_vendor.o((...args) => $options.deleteShopping && $options.deleteShopping(...args))
} : {
l: 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)"
});
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-7cc1684a"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/shopping_cart/shopping_cart.js.map
@@ -0,0 +1,9 @@
{
"navigationStyle": "custom",
"usingComponents": {
"choiceness": "../../components/choiceness/choiceness",
"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"
}
}
@@ -0,0 +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>
@@ -0,0 +1,118 @@
/**
* 这里是uni-app内置的常用样式变量
*
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
*
*/
/* uni.scss */
/**
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
*
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
*/
/* 颜色变量 */
/* 行为相关颜色 */
/* 文字基本颜色 */
/* 背景颜色 */
/* 边框颜色 */
/* 尺寸变量 */
/* 文字尺寸 */
/* 图片尺寸 */
/* Border Radius */
/* 水平间距 */
/* 垂直间距 */
.shopping_cart_warp.data-v-7cc1684a {
background-color: #F5F5F5;
padding: 104rpx 30rpx 30rpx;
overflow: hidden;
}
.shopping_cart_header.data-v-7cc1684a {
display: flex;
justify-content: space-between;
color: #222222;
}
.shopping_cart_header .cart.data-v-7cc1684a {
font-weight: bold;
font-size: 38rpx;
}
.shopping_cart_header .enit_but.data-v-7cc1684a {
font-weight: 500;
font-size: 28rpx;
}
.shopping_cart_content.data-v-7cc1684a {
margin-top: 30rpx;
height: calc(100vh - 304rpx);
overflow-y: auto;
}
.shopping_cart_content .shopping_cart_content_item.data-v-7cc1684a {
background-color: #FFFFFF;
border-radius: 30rpx;
padding: 30rpx;
margin-bottom: 20rpx;
}
.shopping_cart_content .shopping_cart_content_item .content_item_header.data-v-7cc1684a {
display: flex;
}
.shopping_cart_content .shopping_cart_content_item .order_product_title.data-v-7cc1684a {
margin-left: 10rpx;
}
.shopping_cart_content .shopping_cart_content_item .info_item.data-v-7cc1684a {
display: flex;
margin-top: 10rpx;
width: calc(100% - 40rpx);
}
.shopping_cart_content .shopping_cart_content_item .content_info.data-v-7cc1684a {
margin-left: 10rpx;
}
.shopping_cart_content .shopping_cart_content_item .shopping_content_info_title.data-v-7cc1684a {
font-weight: bold;
font-size: 28rpx;
color: #272727;
}
.shopping_cart_content .shopping_cart_content_item .shopping_info_amount.data-v-7cc1684a {
display: flex;
justify-content: space-between;
margin-top: 20rpx;
}
.shopping_cart_content .shopping_cart_content_item .shopping_info_amount_original.data-v-7cc1684a {
font-size: 24rpx;
color: #999999;
-webkit-text-decoration-line: line-through;
text-decoration-line: line-through;
}
.shopping_cart_content .shopping_cart_content_item .insufficient_stock.data-v-7cc1684a {
text-align: center;
color: #9E9E9E;
font-size: 22rpx;
margin-top: 4rpx;
}
.shopping_cart_content .content_item_info.data-v-7cc1684a {
display: flex;
}
.shopping_cart_but.data-v-7cc1684a {
position: fixed;
bottom: 0;
left: 0;
width: calc(100% - 40rpx);
background: #FFFFFF;
box-shadow: 0rpx -1rpx 0rpx 0rpx #EEEEEE;
height: 84rpx;
display: flex;
justify-content: space-between;
padding: 20rpx;
align-items: center;
}
.shopping_cart_but .shopping_cart_but_total.data-v-7cc1684a {
font-weight: bold;
color: #FF7C41;
display: flex;
align-items: center;
}
.shopping_cart_but .add_but_css.data-v-7cc1684a {
height: 38rpx;
width: 226rpx;
}
.shopping_cart_but .delete_but_css.data-v-7cc1684a {
width: 226rpx;
}