添加了新的 search-popup 组件,包含完整的搜索和筛选功能, 支持扫码、输入搜索、自定义插槽等特性。同时优化了 popup-plugin 组件的代码结构,移除了调试日志并改进了模板格式。
80 lines
1.4 KiB
TypeScript
80 lines
1.4 KiB
TypeScript
Component({
|
|
options: { multipleSlots: true },
|
|
/**
|
|
* 组件的属性列表
|
|
*/
|
|
properties: {
|
|
useFooterSlot: {
|
|
type: Boolean,
|
|
},
|
|
dataKey: {
|
|
type: String,
|
|
},
|
|
placeholder: {
|
|
type: String,
|
|
},
|
|
value: null,
|
|
hideMore: {
|
|
type: Boolean,
|
|
},
|
|
hideInput: {
|
|
type: Boolean,
|
|
},
|
|
customStyle: {
|
|
type: String,
|
|
value: "",
|
|
},
|
|
useInputSlot: {
|
|
type: Boolean,
|
|
},
|
|
},
|
|
|
|
/**
|
|
* 组件的初始数据
|
|
*/
|
|
data: {
|
|
show: false,
|
|
},
|
|
|
|
/**
|
|
* 组件的方法列表
|
|
*/
|
|
methods: {
|
|
showSearch() {
|
|
this.setData({ show: true });
|
|
this.triggerEvent("showChange", true);
|
|
},
|
|
close() {
|
|
this.setData({ show: false });
|
|
this.triggerEvent("showChange", false);
|
|
},
|
|
ok() {
|
|
this.setData({ show: false });
|
|
this.triggerEvent("showChange", false);
|
|
this.triggerEvent("ok");
|
|
},
|
|
change(e: any) {
|
|
this.triggerEvent("change", e.detail);
|
|
},
|
|
scanCode() {
|
|
const _this = this;
|
|
wx.scanCode({
|
|
onlyFromCamera: true,
|
|
scanType: ["qrCode"],
|
|
success: (res) => {
|
|
const qrcode = res.result || "";
|
|
_this.triggerEvent("change", { value: qrcode });
|
|
_this.triggerEvent("ok");
|
|
},
|
|
});
|
|
},
|
|
search() {
|
|
this.triggerEvent("ok");
|
|
},
|
|
clear() {
|
|
this.triggerEvent("change", { value: "" });
|
|
this.triggerEvent("ok");
|
|
},
|
|
},
|
|
});
|