常志远 2 년 전
부모
커밋
f58f1842fe
6개의 변경된 파일412개의 추가작업 그리고 0개의 파일을 삭제
  1. 6 0
      assets/img/md-arrow_drop_down.svg
  2. BIN
      assets/img/md-arrow_drop_down@1x.png
  3. 274 0
      components/nx-search.vue
  4. 9 0
      pages.json
  5. 1 0
      pages/index/index.vue
  6. 122 0
      pages/search/search.vue

+ 6 - 0
assets/img/md-arrow_drop_down.svg

@@ -0,0 +1,6 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24" width="20" height="20" style="border-color: rgba(0,0,0,0);border-width: bpx;border-style: undefined" filter="none">
+    
+    <g>
+    <path d="M7 10l5 5 5-5z" fill="rgba(153,153,153,1)"></path>
+    </g>
+  </svg>

BIN
assets/img/md-arrow_drop_down@1x.png


+ 274 - 0
components/nx-search.vue

@@ -0,0 +1,274 @@
+<template>
+    <view class="serach">
+		
+        <view class="content" :style="{ 'border-radius': radius + 'px' }">
+            <view class="content-box">
+                <!-- 下拉选择框 -->
+                <view class="seach-select" v-if="selectList.length>0">
+                    <!-- 选中值 -->
+                    <view class="select-value" @click="selectClick">
+                        {{selectList[selectIndex].name}}
+                        <text class="cuIcon-triangledownfill" style="">
+						</text>
+						
+							 <u-icon style="margin-left: 16rpx;" name="arrow-down-fill" size="16" color="#999999"></u-icon>
+						
+						
+                    </view>
+                    <!-- 选择列表 -->
+                    <view class="select-item-list" :style="{'display':(showSelectList)?'block':'none'}">
+                        <text class="cuIcon-triangleupfill"
+                            style="position: absolute;top: -18px;left: 60rpx;font-size: 30rpx;color: #FFFFFF;"></text>
+                        <view :class="['select-item',(index>0)?'item-border':'']" v-for="(data,index) in selectList"
+                            :key="index" @click="selectItem(index)">{{data.name}}</view>
+                    </view>
+					
+                </view>
+
+				
+                <input :placeholder="placeholder" @input="inputChange" confirm-type="search" @confirm="triggerConfirm"
+                    class="input" :focus="isFocus" v-model="inputVal" @focus="focus" @blur="blur" />
+                <text v-if="isDelShow" class="cuIcon-roundclose" @tap.stop="clear"></text>
+            </view>
+				<u-line color="#D6DADE" direction="col" length="28" margin="20rpx 0"/>
+            <view v-if="
+					(showSeachBth && button === 'inside') ||
+						(isDelShow && button === 'inside')
+				" class="serachBtn" style="color: #2795fd;" @tap="search">
+                搜索
+            </view>
+        </view>
+        <view v-if="button === 'outside'" class="button" :class="{ active: showSeachBth }" @tap="search">
+            <view class="button-item">{{ !showSeachBth ? searchName : '搜索' }}</view>
+        </view>
+        <view v-show="showSelectList" @click="selectClick" class="page-mask"></view>
+    </view>
+</template>
+
+<script>
+    export default {
+		
+        props: {
+            selectList: {
+                type: Array,
+                default: [
+
+
+                ]
+            },
+            placeholder: {
+                value: String,
+                default: ''
+            },
+            value: {
+                type: String,
+                default: ''
+            },
+            button: {
+                value: String,
+                default: 'outside'
+            },
+            showSeachIcon: {
+                value: Boolean,
+                default: true
+            },
+            showSeachBth: {
+                value: Boolean,
+                default: true
+            },
+            radius: {
+                value: String,
+                default: 60
+            }
+        },
+        data() {
+            return {
+                showSelectList: false,
+                selectIndex: 0,
+                isFocus: true,
+                inputVal: '',
+                searchName: '取消',
+                isDelShow: false
+            };
+        },
+        methods: {
+            selectItem(index) {
+                this.selectIndex = index
+                this.showSelectList = !this.showSelectList;
+            },
+            selectClick() {
+                this.showSelectList = !this.showSelectList;
+            },
+            triggerConfirm() {
+				
+				let searchQuery = {
+				    keyword: this.inputVal
+				}
+				if (this.selectList.length > 0) {
+				    searchQuery.selectIndex = this.selectIndex;
+				}
+				this.$emit('confirm', searchQuery);
+            },
+            inputChange(event) {
+                const keyword = event.detail.value;
+                this.$emit('input', keyword);
+                if (this.inputVal) {
+                    this.isDelShow = true;
+                }
+            },
+            focus() {
+                if (this.inputVal) {
+                    this.isDelShow = true;
+                }
+            },
+            blur() {
+                this.isFocus = false;
+                uni.hideKeyboard();
+            },
+            clear() {
+                uni.hideKeyboard();
+                this.isFocus = false;
+                this.inputVal = '';
+                this.$emit('input', '');
+            },
+            getFocus() {
+                this.isFocus = true;
+            },
+            search() {
+                let searchQuery = {
+                    keyword: this.inputVal
+                }
+                if (this.selectList.length > 0) {
+                    searchQuery.selectIndex = this.selectIndex;
+                }
+                this.$emit('search', searchQuery);
+            }
+        },
+        watch: {
+            inputVal(newVal) {
+                if (newVal) {
+                    this.searchName = '搜索';
+                } else {
+                    this.searchName = '取消';
+                    this.isDelShow = false;
+                }
+            },
+            value(val) {
+                this.inputVal = val.trim();
+            }
+        }
+    };
+</script>
+
+<style lang="scss" scoped>
+	img{
+		   width: 24px;
+		   height: 24px;
+		   vertical-align: middle;
+	}
+    .serach {
+        display: flex;
+        width: 100%;
+        box-sizing: border-box;
+        font-size: $uni-font-size-base;
+
+        .content {
+            display: flex;
+            align-items: center;
+            width: 100%;
+            height: 72rpx;
+            background-color: rgba(243, 246, 249, 1);
+            transition: all 0.2s linear;
+            border-radius: 30px;
+
+            .content-box {
+                width: 100%;
+                display: flex;
+                align-items: center;
+				.cuIcon-search{
+					width: 24px;
+					height: 24px;
+					img{
+						   width: 24px;
+						   height: 24px;
+						   
+						   vertical-align: middle;
+					}
+				}
+  
+                .seach-select {
+                    min-width: 160rpx;
+                    margin-left: 10px;
+                    position: relative;
+                    
+                    color: #101010;
+					
+                    .select-item-list {
+                        background-color: #FFFFFF;
+                        position: absolute;
+                        top: 75rpx;
+                        width: 150rpx;
+                        left: -20rpx;
+                        border-radius: 10rpx;
+                        z-index: 10;
+                        box-shadow: 0px 0px 5px #C9C9C9;
+
+                        .select-item {
+                            text-align: center;
+                            padding: 10rpx 0;
+                        }
+
+                        .item-border {
+                            border-top: 1rpx solid #EEEEEE;
+                        }
+                    }
+                }
+
+                .input {
+                    width: 100%;
+                    max-width: 100%;
+                    line-height: 60upx;
+                    height: 60upx;
+                    transition: all 0.2s linear;
+
+                }
+            }
+
+            .serachBtn {
+                height: 100%;
+                flex-shrink: 0;
+                padding: 0 30upx;
+                line-height: 72rpx;
+                transition: all 0.3s;
+                border-top-right-radius: 60px;
+                border-bottom-right-radius: 60px;
+            }
+        }
+
+        .button {
+            display: flex;
+            align-items: center;
+            justify-content: center;
+            position: relative;
+            flex-shrink: 0;
+            width: 0;
+            transition: all 0.2s linear;
+            white-space: nowrap;
+            overflow: hidden;
+
+            &.active {
+                padding-left: 15upx;
+                width: 100upx;
+            }
+        }
+
+        .page-mask {
+            position: fixed;
+            top: 0;
+            bottom: 0;
+            right: 0;
+            left: 0;
+            z-index: 5;
+        }
+    }
+</style>

+ 9 - 0
pages.json

@@ -73,6 +73,15 @@
             }
             
         }
+        ,{
+            "path" : "pages/search/search",
+            "style" :                                                                                    
+            {
+                "navigationBarTitleText": "",
+                "enablePullDownRefresh": false
+            }
+            
+        }
     ],
 	"globalStyle": {
 		"navigationStyle": "custom", // 隐藏系统导航栏

+ 1 - 0
pages/index/index.vue

@@ -133,6 +133,7 @@
 
 <script>
 	import tabbar from "../../components/Tabbar.vue"
+	
 	export default {
 		components: {
 			tabbar

+ 122 - 0
pages/search/search.vue

@@ -0,0 +1,122 @@
+<template>
+	<view>
+		<u-navbar back-text="搜索" back-icon-size="28" back-icon-color="#ffffff"
+			:background="{backgroundColor: '#2795FD',}" :back-text-style="{color: '#ffffff'}"></u-navbar>
+
+		<!-- 搜索框 -->
+		<view class="search">
+			<view class="search-box">
+				<view class="option">
+		  <nxsearch :selectList="selectList" button="inside"  @search="doSearch" @confirm="doSearc" v-model="searchQuery.keyword" placeholder="输入关键字找工作" />
+         
+
+				</view>
+			</view>
+		</view>
+		<!-- 搜索历史 -->
+		<view class="search-history">
+			<view class="top">
+				<view class="title">
+					搜索历史
+				</view>
+				<view class="clear">
+					清空历史
+				</view>
+			</view>
+			<view class="history">
+				<view class="tag">
+					打杂
+				</view>
+				<view class="tag">
+					地推
+				</view>
+			</view>
+			
+		</view>
+	</view>
+</template>
+
+<script>
+	import nxsearch from "../../components/nx-search.vue"
+
+	export default {
+		components: {
+			nxsearch
+		},
+
+		data() {
+			return {
+				keyword: '',
+				searchQuery: {
+					keyword: '',
+					selectIndex: 0
+				},
+				selectList: [{
+						id: 1,
+						name: '找工作'
+					},
+					{
+						id: 2,
+						name: '找公司'
+					},
+				],
+
+
+			}
+		},
+		methods: {
+             // 执行搜索
+            doSearch(searchQuery) {
+                console.log('searchQuery', searchQuery);
+            },
+
+		}
+	}
+</script>
+
+<style lang="scss" scoped>
+	// 搜索框
+	.search {
+		padding: 16rpx 32rpx;
+
+		.search-box {
+			border-radius: 50px;
+			// background-color: rgba(243, 246, 249, 1);
+			height: 72rpx;
+			line-height: 72rpx;
+		}
+	}
+	// 搜索历史
+	.search-history{
+		padding: 0 32rpx;
+		margin-top: 40rpx;
+      .top{
+		  display: flex;
+		  justify-content: space-between;
+		  align-items: center;
+		  .title{
+			  color: #101010;
+		  }
+		  .clear{
+			  color: rgba(169, 169, 169, 1);
+			  font-size: 24rpx;
+		  }
+	  }
+	  .history{
+		  display: flex;
+		  margin-top: 16rpx;
+		  .tag{
+			  width: 144rpx;
+			  height: 56rpx;
+			  line-height: 56rpx;
+			  border-radius: 4px;
+			  background-color: rgba(241, 244, 247, 1);
+			  color: rgba(88, 88, 88, 1);
+			  font-size: 12px;
+			  text-align: center;
+			  font-family: Arial;
+			  margin-right: 16rpx;
+		  }
+	  }
+	}
+</style>