feat: 电子药箱小程序 - 4Tab药品管理
- 电子药箱: 药品库存管理 + 手动录入 + 今日用药打卡 - 药品百科: 搜索 + 分类筛选 + 20种药品静态数据 - 惠教中心: 4条药品使用指南课程 - 我的: 家庭成员信息管理 - 自定义TabBar + navigation-bar组件 - SVG药品分类插图
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
@import "variables";
|
||||
|
||||
.search {
|
||||
padding-left: $primary-gap;
|
||||
width: 100%;
|
||||
height: 70rpx;
|
||||
border: 1px solid $primary-color;
|
||||
border-radius: $primary-border-radius;
|
||||
background-color: #fff;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
.search-input {
|
||||
flex: 1;
|
||||
height: 100%;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.confim {
|
||||
height: 60rpx;
|
||||
width: 100rpx;
|
||||
margin: 4rpx;
|
||||
color: #fff;
|
||||
line-height: 60rpx;
|
||||
text-align: center;
|
||||
background-color: $primary-color;
|
||||
border-radius: 20rpx;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
// @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'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,12 @@
|
||||
<view class="search">
|
||||
<input
|
||||
class="search-input"
|
||||
type="text"
|
||||
placeholder="{{placeholder}}"
|
||||
value="{{value}}"
|
||||
cursor-color="#FA6905"
|
||||
bindinput="onInput"
|
||||
bindconfirm="onSearch"
|
||||
/>
|
||||
<view class="confim" bind:tap="onSearch">搜索</view>
|
||||
</view>
|
||||
Reference in New Issue
Block a user