Initial commit - full huishou project

This commit is contained in:
jiapengyu
2026-07-27 14:07:26 +08:00
commit 60790ad1b3
39127 changed files with 5989265 additions and 0 deletions
+177
View File
@@ -0,0 +1,177 @@
"use strict";
const common_vendor = require("../../common/vendor.js");
const stores_price = require("../../stores/price.js");
const stores_bluetooth = require("../../stores/bluetooth.js");
const stores_order = require("../../stores/order.js");
const stores_region = require("../../stores/region.js");
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
__name: "weigh",
setup(__props) {
const priceStore = stores_price.usePriceStore();
const bluetoothStore = stores_bluetooth.useBluetoothStore();
const orderStore = stores_order.useOrderStore();
const regionStore = stores_region.useRegionStore();
const category = common_vendor.ref("");
const currentWeight = common_vendor.ref(0);
const count = common_vendor.ref(0);
const countInput = common_vendor.ref("");
const inputMode = common_vendor.ref("bluetooth");
const manualWeight = common_vendor.ref("");
const currentPrice = common_vendor.computed(() => {
return priceStore.getPriceByCategory(category.value);
});
const estimatedAmount = common_vendor.computed(() => {
if (!currentPrice.value) return 0;
const value = currentPrice.value.unit === "kg" ? inputMode.value === "bluetooth" ? currentWeight.value : parseFloat(manualWeight.value) || 0 : count.value;
return Number((value * currentPrice.value.price).toFixed(2));
});
common_vendor.onLoad(async (options) => {
if (options == null ? void 0 : options.category) {
category.value = options.category;
}
await priceStore.loadPrices();
bluetoothStore.init();
});
const goToBluetooth = () => {
common_vendor.index.navigateTo({ url: "/pages/bluetooth/bluetooth" });
};
const resetWeight = () => {
bluetoothStore.resetWeight();
currentWeight.value = 0;
};
const decreaseCount = () => {
if (count.value > 0) {
count.value--;
countInput.value = count.value.toString();
}
};
const increaseCount = () => {
count.value++;
countInput.value = count.value.toString();
};
const onCountInput = () => {
const value = parseInt(countInput.value) || 0;
count.value = Math.max(0, value);
};
const quickCountInput = (num) => {
count.value += num;
countInput.value = count.value.toString();
};
const switchMode = (mode) => {
inputMode.value = mode;
if (mode === "manual") {
manualWeight.value = currentWeight.value > 0 ? currentWeight.value.toString() : "";
}
};
const onManualWeightInput = () => {
const value = parseFloat(manualWeight.value);
if (!isNaN(value) && value >= 0) {
currentWeight.value = value;
}
};
const quickInput = (weight) => {
const current = parseFloat(manualWeight.value) || 0;
manualWeight.value = (current + weight).toFixed(2);
onManualWeightInput();
};
const confirmRecycle = async () => {
if (!currentPrice.value) {
common_vendor.index.showToast({ title: "请选择回收种类", icon: "none" });
return;
}
const value = currentPrice.value.unit === "kg" ? inputMode.value === "bluetooth" ? currentWeight.value : parseFloat(manualWeight.value) || 0 : count.value;
if (value <= 0) {
common_vendor.index.showToast({ title: currentPrice.value.unit === "kg" ? "请输入重量" : "请输入数量", icon: "none" });
return;
}
const orderItem = {
category: currentPrice.value.category,
name: currentPrice.value.name,
weight: currentPrice.value.unit === "kg" ? value : void 0,
count: currentPrice.value.unit === "piece" ? count.value : void 0,
unit: currentPrice.value.unit,
price: currentPrice.value.price,
amount: estimatedAmount.value
};
common_vendor.index.showModal({
title: "确认回收",
content: `确定回收${currentPrice.value.name} ${value}${currentPrice.value.unit === "kg" ? "kg" : "个"},金额¥${estimatedAmount.value.toFixed(2)}`,
success: async (res) => {
if (res.confirm) {
common_vendor.index.showLoading({ title: "保存中..." });
const region = regionStore.getRegion();
const order = await orderStore.createOrder([orderItem], region);
common_vendor.index.hideLoading();
if (order) {
common_vendor.index.showToast({ title: "回收成功", icon: "success" });
setTimeout(() => {
common_vendor.index.navigateBack();
}, 1500);
} else {
common_vendor.index.showToast({ title: "保存失败", icon: "none" });
}
}
}
});
};
common_vendor.onMounted(() => {
const updateWeight = () => {
currentWeight.value = bluetoothStore.currentWeight;
};
bluetoothStore.$subscribe(() => {
updateWeight();
});
updateWeight();
});
common_vendor.onShow(() => {
priceStore.loadPrices();
});
return (_ctx, _cache) => {
var _a, _b, _c, _d, _e;
return common_vendor.e({
a: common_vendor.t(common_vendor.unref(bluetoothStore).isConnected ? "🔵" : "⚪"),
b: common_vendor.t(common_vendor.unref(bluetoothStore).isConnected ? "已连接" : "未连接"),
c: common_vendor.unref(bluetoothStore).isConnected ? 1 : "",
d: common_vendor.t(((_a = currentPrice.value) == null ? void 0 : _a.name) || "-"),
e: common_vendor.t(((_b = currentPrice.value) == null ? void 0 : _b.price) || 0),
f: common_vendor.t(((_c = currentPrice.value) == null ? void 0 : _c.unit) === "kg" ? "kg" : "个"),
g: ((_d = currentPrice.value) == null ? void 0 : _d.unit) === "kg"
}, ((_e = currentPrice.value) == null ? void 0 : _e.unit) === "kg" ? common_vendor.e({
h: inputMode.value === "bluetooth" ? 1 : "",
i: common_vendor.o(($event) => switchMode("bluetooth")),
j: inputMode.value === "manual" ? 1 : "",
k: common_vendor.o(($event) => switchMode("manual")),
l: inputMode.value === "bluetooth"
}, inputMode.value === "bluetooth" ? {
m: common_vendor.t(currentWeight.value.toFixed(2))
} : {
n: common_vendor.o([($event) => manualWeight.value = $event.detail.value, onManualWeightInput]),
o: manualWeight.value
}, {
p: inputMode.value === "bluetooth"
}, inputMode.value === "bluetooth" ? {
q: common_vendor.o(goToBluetooth),
r: common_vendor.o(resetWeight)
} : {
s: common_vendor.o(($event) => quickInput(0.5)),
t: common_vendor.o(($event) => quickInput(1)),
v: common_vendor.o(($event) => quickInput(2)),
w: common_vendor.o(($event) => quickInput(5))
}) : {
x: common_vendor.o([($event) => countInput.value = $event.detail.value, onCountInput]),
y: countInput.value,
z: common_vendor.o(decreaseCount),
A: common_vendor.o(increaseCount),
B: common_vendor.o(($event) => quickCountInput(1)),
C: common_vendor.o(($event) => quickCountInput(5)),
D: common_vendor.o(($event) => quickCountInput(10)),
E: common_vendor.o(($event) => quickCountInput(50))
}, {
F: common_vendor.t(estimatedAmount.value.toFixed(2)),
G: common_vendor.o(confirmRecycle)
});
};
}
});
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-6f825acf"]]);
wx.createPage(MiniProgramPage);
+6
View File
@@ -0,0 +1,6 @@
{
"navigationBarTitleText": "称重回收",
"navigationBarBackgroundColor": "#3366ff",
"navigationBarTextStyle": "white",
"usingComponents": {}
}
+1
View File
@@ -0,0 +1 @@
<view class="container data-v-6f825acf"><view class="status-bar data-v-6f825acf"><view class="{{['bluetooth-status', 'data-v-6f825acf', c && 'connected']}}"><text class="status-icon data-v-6f825acf">{{a}}</text><text class="data-v-6f825acf">{{b}}</text></view></view><view class="info-card data-v-6f825acf"><view class="info-item data-v-6f825acf"><text class="info-label data-v-6f825acf">回收种类</text><text class="info-value data-v-6f825acf">{{d}}</text></view><view class="info-item data-v-6f825acf"><text class="info-label data-v-6f825acf">单价</text><text class="info-value price-text data-v-6f825acf">¥{{e}}/{{f}}</text></view></view><view wx:if="{{g}}" class="display-card data-v-6f825acf"><view class="display-icon data-v-6f825acf">📏</view><view class="display-title data-v-6f825acf">重量输入</view><view class="mode-switch data-v-6f825acf"><view class="{{['mode-btn', 'data-v-6f825acf', h && 'active']}}" bindtap="{{i}}"><text class="data-v-6f825acf">蓝牙称重</text></view><view class="{{['mode-btn', 'data-v-6f825acf', j && 'active']}}" bindtap="{{k}}"><text class="data-v-6f825acf">手动输入</text></view></view><view wx:if="{{l}}" class="display-value-wrap data-v-6f825acf"><text class="display-value data-v-6f825acf">{{m}}</text><text class="display-unit data-v-6f825acf">kg</text></view><view wx:else class="manual-input data-v-6f825acf"><input class="data-v-6f825acf" type="digit" placeholder="请输入重量" bindinput="{{n}}" value="{{o}}"/><text class="input-unit data-v-6f825acf">kg</text></view><view wx:if="{{p}}" class="control-row data-v-6f825acf"><view class="control-btn data-v-6f825acf" bindtap="{{q}}"><text class="control-icon data-v-6f825acf">📱</text><text class="data-v-6f825acf">蓝牙连接</text></view><view class="control-btn data-v-6f825acf" bindtap="{{r}}"><text class="control-icon data-v-6f825acf">⚖️</text><text class="data-v-6f825acf">归零</text></view></view><view wx:else class="quick-input data-v-6f825acf"><view class="quick-btn data-v-6f825acf" bindtap="{{s}}">+0.5kg</view><view class="quick-btn data-v-6f825acf" bindtap="{{t}}">+1kg</view><view class="quick-btn data-v-6f825acf" bindtap="{{v}}">+2kg</view><view class="quick-btn data-v-6f825acf" bindtap="{{w}}">+5kg</view></view></view><view wx:else class="display-card data-v-6f825acf"><view class="display-icon data-v-6f825acf">🥫</view><view class="display-title data-v-6f825acf">个数统计</view><view class="manual-input data-v-6f825acf"><input class="data-v-6f825acf" type="number" placeholder="请输入数量" bindinput="{{x}}" value="{{y}}"/><text class="input-unit data-v-6f825acf">个</text></view><view class="count-controls data-v-6f825acf"><view class="count-btn minus data-v-6f825acf" bindtap="{{z}}"><text class="data-v-6f825acf">-</text></view><view class="count-btn plus data-v-6f825acf" bindtap="{{A}}"><text class="data-v-6f825acf">+</text></view></view><view class="quick-input data-v-6f825acf"><view class="quick-btn data-v-6f825acf" bindtap="{{B}}">+1</view><view class="quick-btn data-v-6f825acf" bindtap="{{C}}">+5</view><view class="quick-btn data-v-6f825acf" bindtap="{{D}}">+10</view><view class="quick-btn data-v-6f825acf" bindtap="{{E}}">+50</view></view></view><view class="amount-card data-v-6f825acf"><view class="amount-title data-v-6f825acf">💰 预估金额</view><view class="amount-value-wrap data-v-6f825acf"><text class="amount-currency data-v-6f825acf">¥</text><text class="amount-num data-v-6f825acf">{{F}}</text></view></view><view class="confirm-btn data-v-6f825acf" bindtap="{{G}}"><text class="data-v-6f825acf">确认回收</text></view></view>
+336
View File
@@ -0,0 +1,336 @@
.container.data-v-6f825acf {
min-height: 100vh;
background: #f5f5f5;
padding: 24rpx;
}
.status-bar.data-v-6f825acf {
display: flex;
justify-content: flex-end;
align-items: center;
margin-bottom: 24rpx;
}
.bluetooth-status.data-v-6f825acf {
display: flex;
align-items: center;
font-size: 26rpx;
color: #999;
}
.bluetooth-status.connected.data-v-6f825acf {
color: #3366ff;
}
.status-icon.data-v-6f825acf {
margin-right: 8rpx;
}
.info-card.data-v-6f825acf {
background: #fff;
border-radius: 16rpx;
padding: 24rpx;
margin-bottom: 24rpx;
display: flex;
justify-content: space-between;
}
.info-item.data-v-6f825acf {
display: flex;
flex-direction: column;
align-items: center;
}
.info-label.data-v-6f825acf {
font-size: 24rpx;
color: #999;
margin-bottom: 8rpx;
}
.info-value.data-v-6f825acf {
font-size: 32rpx;
font-weight: 600;
color: #333;
}
.info-value.price-text.data-v-6f825acf {
color: #3366ff;
}
.display-card.data-v-6f825acf {
background: #fff;
border-radius: 16rpx;
padding: 48rpx 24rpx;
margin-bottom: 24rpx;
display: flex;
flex-direction: column;
align-items: center;
}
.display-icon.data-v-6f825acf {
font-size: 64rpx;
margin-bottom: 16rpx;
}
.display-title.data-v-6f825acf {
font-size: 28rpx;
color: #999;
margin-bottom: 24rpx;
}
.display-value-wrap.data-v-6f825acf {
display: flex;
align-items: baseline;
margin-bottom: 32rpx;
}
.display-value.data-v-6f825acf {
font-size: 96rpx;
font-weight: 700;
color: #333;
}
.display-unit.data-v-6f825acf {
font-size: 32rpx;
color: #999;
margin-left: 8rpx;
}
.mode-switch.data-v-6f825acf {
display: flex;
background: #f5f5f5;
border-radius: 12rpx;
padding: 8rpx;
margin-bottom: 32rpx;
width: 100%;
}
.mode-btn.data-v-6f825acf {
flex: 1;
text-align: center;
padding: 16rpx;
font-size: 28rpx;
color: #666;
border-radius: 8rpx;
transition: all 0.3s;
}
.mode-btn.active.data-v-6f825acf {
background: #3366ff;
color: #fff;
font-weight: 600;
}
.manual-input.data-v-6f825acf {
display: flex;
align-items: center;
gap: 16rpx;
margin-bottom: 32rpx;
width: 100%;
padding: 0 24rpx;
}
.manual-input input.data-v-6f825acf {
flex: 1;
height: 80rpx;
border: 2rpx solid #e5e7eb;
border-radius: 12rpx;
padding: 0 24rpx;
font-size: 48rpx;
font-weight: 600;
color: #333;
text-align: center;
}
.input-unit.data-v-6f825acf {
font-size: 32rpx;
color: #999;
font-weight: 600;
}
.quick-input.data-v-6f825acf {
display: flex;
flex-wrap: wrap;
gap: 16rpx;
justify-content: center;
}
.quick-btn.data-v-6f825acf {
padding: 16rpx 32rpx;
background: #f0fdf4;
border: 2rpx solid #3366ff;
border-radius: 24rpx;
font-size: 26rpx;
color: #3366ff;
font-weight: 600;
transition: all 0.2s;
}
.quick-btn.data-v-6f825acf:active {
background: #3366ff;
color: #fff;
}
.control-row.data-v-6f825acf {
display: flex;
gap: 32rpx;
}
.control-btn.data-v-6f825acf {
display: flex;
flex-direction: column;
align-items: center;
padding: 20rpx 48rpx;
background: #f5f5f5;
border-radius: 12rpx;
font-size: 24rpx;
color: #666;
}
.control-icon.data-v-6f825acf {
font-size: 36rpx;
margin-bottom: 8rpx;
}
.count-controls.data-v-6f825acf {
display: flex;
gap: 48rpx;
margin-bottom: 32rpx;
}
.count-btn.data-v-6f825acf {
width: 80rpx;
height: 80rpx;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 48rpx;
font-weight: 300;
}
.count-btn.minus.data-v-6f825acf {
background: #f87171;
color: #fff;
}
.count-btn.plus.data-v-6f825acf {
background: #3366ff;
color: #fff;
}
.amount-card.data-v-6f825acf {
background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
border-radius: 16rpx;
padding: 32rpx;
margin-bottom: 32rpx;
display: flex;
flex-direction: column;
align-items: center;
}
.amount-title.data-v-6f825acf {
font-size: 28rpx;
color: #92400e;
margin-bottom: 12rpx;
}
.amount-value-wrap.data-v-6f825acf {
display: flex;
align-items: baseline;
}
.amount-currency.data-v-6f825acf {
font-size: 36rpx;
font-weight: 600;
color: #f59e0b;
}
.amount-num.data-v-6f825acf {
font-size: 72rpx;
font-weight: 700;
color: #f59e0b;
margin-left: 8rpx;
}
.region-card.data-v-6f825acf {
background: #fff;
border-radius: 16rpx;
padding: 24rpx;
margin-bottom: 32rpx;
}
.region-title.data-v-6f825acf {
font-size: 28rpx;
font-weight: 600;
color: #333;
margin-bottom: 20rpx;
}
.region-row.data-v-6f825acf {
margin-bottom: 16rpx;
}
.region-item.data-v-6f825acf {
display: flex;
align-items: center;
justify-content: space-between;
}
.region-label.data-v-6f825acf {
font-size: 26rpx;
color: #999;
width: 120rpx;
}
.region-select.data-v-6f825acf {
flex: 1;
display: flex;
align-items: center;
justify-content: space-between;
padding: 20rpx 24rpx;
background: #f8fafc;
border-radius: 12rpx;
font-size: 28rpx;
color: #333;
}
.region-select.disabled.data-v-6f825acf {
color: #ccc;
background: #f0f0f0;
}
.arrow.data-v-6f825acf {
font-size: 20rpx;
color: #999;
margin-left: 16rpx;
}
.custom-region.data-v-6f825acf {
margin-top: 20rpx;
padding-top: 20rpx;
border-top: 1rpx solid #f0f0f0;
}
.region-input.data-v-6f825acf {
flex: 1;
padding: 20rpx 24rpx;
background: #f8fafc;
border-radius: 12rpx;
font-size: 28rpx;
margin-left: 16rpx;
}
.picker-overlay.data-v-6f825acf {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
z-index: 1000;
display: flex;
align-items: flex-end;
}
.picker-content.data-v-6f825acf {
width: 100%;
background: #fff;
border-radius: 24rpx 24rpx 0 0;
max-height: 70vh;
}
.picker-header.data-v-6f825acf {
display: flex;
align-items: center;
justify-content: space-between;
padding: 28rpx 32rpx;
border-bottom: 1rpx solid #f0f0f0;
}
.picker-title.data-v-6f825acf {
font-size: 32rpx;
font-weight: 600;
color: #333;
}
.picker-close.data-v-6f825acf {
font-size: 32rpx;
color: #999;
padding: 8rpx;
}
.picker-list.data-v-6f825acf {
max-height: 60vh;
}
.picker-item.data-v-6f825acf {
padding: 28rpx 32rpx;
font-size: 30rpx;
color: #333;
border-bottom: 1rpx solid #f8fafc;
}
.picker-item.active.data-v-6f825acf {
color: #3366ff;
font-weight: 600;
}
.confirm-btn.data-v-6f825acf {
background: linear-gradient(135deg, #3366ff 0%, #254edb 100%);
border-radius: 48rpx;
padding: 32rpx;
text-align: center;
font-size: 34rpx;
font-weight: 600;
color: #fff;
box-shadow: 0 8rpx 24rpx rgba(16, 185, 129, 0.3);
}
.confirm-btn.data-v-6f825acf:active {
opacity: 0.85;
}