This commit is contained in:
2025-09-16 22:11:19 +08:00
parent 562ec4abf9
commit 46c5682960
65 changed files with 1997 additions and 56 deletions

View File

@@ -0,0 +1,48 @@
"use strict";
const common_vendor = require("../../common/vendor.js");
const common_http = require("../../common/http.js");
const _sfc_main = {
data() {
return { kw: "", products: [] };
},
onLoad() {
this.search();
},
methods: {
async search() {
try {
const res = await common_http.get("/api/products", { kw: this.kw, page: 1, size: 50 });
this.products = Array.isArray(res == null ? void 0 : res.list) ? res.list : Array.isArray(res) ? res : [];
} catch (e) {
common_vendor.index.showToast({ title: "加载失败", icon: "none" });
}
},
select(p) {
const opener = getCurrentPages()[getCurrentPages().length - 2];
if (opener && opener.$vm && opener.$vm.items) {
opener.$vm.items.push({ productId: p.id, productName: p.name, quantity: 1, unitPrice: Number(p.price || 0) });
}
common_vendor.index.navigateBack();
}
}
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return {
a: common_vendor.o((...args) => $options.search && $options.search(...args)),
b: $data.kw,
c: common_vendor.o(($event) => $data.kw = $event.detail.value),
d: common_vendor.o((...args) => $options.search && $options.search(...args)),
e: common_vendor.f($data.products, (p, k0, i0) => {
return {
a: common_vendor.t(p.name),
b: common_vendor.t(p.code),
c: common_vendor.t(p.stock || 0),
d: p.id,
e: common_vendor.o(($event) => $options.select(p), p.id)
};
})
};
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/product/select.js.map

View File

@@ -0,0 +1,4 @@
{
"navigationBarTitleText": "选择商品",
"usingComponents": {}
}

View File

@@ -0,0 +1 @@
<view class="page"><view class="search"><input placeholder="搜索商品名称/编码" bindconfirm="{{a}}" value="{{b}}" bindinput="{{c}}"/><button size="mini" bindtap="{{d}}">搜索</button></view><scroll-view scroll-y class="list"><view wx:for="{{e}}" wx:for-item="p" wx:key="d" class="item" bindtap="{{p.e}}"><view class="name">{{p.a}}</view><view class="meta">{{p.b}} · 库存:{{p.c}}</view></view></scroll-view></view>

View File

@@ -0,0 +1,15 @@
.page { display:flex; flex-direction: column; height: 100vh;
}
.search { display:flex; gap: 12rpx; padding: 16rpx; background:#fff;
}
.search input { flex:1; background:#f6f6f6; border-radius: 12rpx; padding: 12rpx;
}
.list { flex:1;
}
.item { padding: 20rpx 24rpx; background:#fff; border-bottom: 1rpx solid #f1f1f1;
}
.name { color:#333; margin-bottom: 6rpx;
}
.meta { color:#888; font-size: 24rpx;
}