- 电子药箱: 药品库存管理 + 手动录入 + 今日用药打卡 - 药品百科: 搜索 + 分类筛选 + 20种药品静态数据 - 惠教中心: 4条药品使用指南课程 - 我的: 家庭成员信息管理 - 自定义TabBar + navigation-bar组件 - SVG药品分类插图
51 lines
1.2 KiB
TypeScript
51 lines
1.2 KiB
TypeScript
// @ts-nocheck
|
|
Component({
|
|
properties: {
|
|
placeholder: {
|
|
type: String,
|
|
value: "请输入内容"
|
|
},
|
|
value: {
|
|
type: String,
|
|
value: ''
|
|
},
|
|
redirect: { //页面跳转的路径
|
|
type: String,
|
|
value: ''
|
|
}
|
|
},
|
|
methods: {
|
|
onInput(e: any) {
|
|
this.setData({ value: e.detail.value })
|
|
//抛出一个事件,让父组件拿到输入值
|
|
this.triggerEvent('change', e.detail.value)
|
|
},
|
|
onSearch() {
|
|
const keyword = this.data.value.trim()
|
|
if (keyword === '' || keyword == undefined) {
|
|
wx.showToast({
|
|
title: '请输入商品名称!',
|
|
icon: 'none'
|
|
})
|
|
return
|
|
}
|
|
// 如果父组件绑定有search,则调父组件的方法
|
|
if (this.dataset.hasOwnProperty('search')) {
|
|
this.triggerEvent('search', keyword)
|
|
return
|
|
}
|
|
|
|
//否则执行默认跳转逻辑
|
|
if (this.data.redirect) {
|
|
wx.navigateTo({
|
|
url: `${this.data.redirect}?keyword=${keyword}`
|
|
})
|
|
} else {
|
|
wx.showToast({
|
|
title: '未配置跳转页面',
|
|
icon: 'none'
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}) |