search - 副本.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. <template>
  2. <view class="search-box" @touchmove="(e) => {return false}">
  3. <view class="search-val">
  4. <view class="search-frame">
  5. <text v-if="searchType === 1" class="search-icon iconfont_nvue">&#xe653;</text>
  6. <text v-else class="back-icon search-icon iconfont_nvue"
  7. @click.stop="$emit('clearSearch')">&#xe65f;</text>
  8. <!-- <image class="search-icon" src="/static/map/icon_01.png" mode="scaleToFill"></image> -->
  9. <input confirm-type="search" ref="searchInputRef" class="search-input" :auto-blur="true" type="text" placeholder="请输入关键字"
  10. v-model="keyWord_" @focus="onSearchFocus()" @blur="onSearchBlur()"
  11. @confirm="getMapList"
  12. />
  13. </view>
  14. <!-- 选择类型 -->
  15. <view class="classify-box" v-if="searchType === 2">
  16. <block v-for="(item , index) in hotClassify">
  17. <view class="classify-item" :key="`hot_${index}`" @click.stop="selectHotClassify(item)">
  18. <image class="classify-icon" :src="item.icon" mode="aspectFit">
  19. </image>
  20. <text class="classify-text">{{item.name}}</text>
  21. </view>
  22. </block>
  23. <view class="classify-item">
  24. <image class="classify-icon" :src="deIocn" mode="aspectFit">
  25. </image>
  26. <text class="classify-text">更多</text>
  27. </view>
  28. </view>
  29. <!-- 筛选条件 -->
  30. <view class="condition-box" v-if="[3,4,5].includes(searchType)">
  31. <view class="condition-label">
  32. <view class="label-item" @click.stop="selectLabel(searchType , 4)">
  33. <text
  34. class="label-item-text nvue-one-row">{{ activeDistance ? activeDistance.label : '位置距离' }}</text>
  35. <image :class="['label-item-icon' , searchType === 4 ? 'active-condition-label' : '' ]"
  36. src="/static/map/icon_02.png" mode="aspectFit"></image>
  37. </view>
  38. <view class="label-item" @click.stop="selectLabel(searchType , 5)">
  39. <text
  40. class="label-item-text nvue-one-row">{{ activeClassify ? activeClassify.name : '全部分类' }}</text>
  41. <image :class="['label-item-icon' , searchType === 5 ? 'active-condition-label' : '' ]"
  42. src="/static/map/icon_02.png" mode="scaleToFill"></image>
  43. </view>
  44. </view>
  45. <view class="condition-val" v-if="searchType === 3">
  46. <scroll-view class="scroll-condition" scroll-x="true" :show-scrollbar="false">
  47. <view class="scroll-condition-content">
  48. <block v-for="(item , index) in classifyList">
  49. <view class="auto-width-item" :key="`classify_${index}`">
  50. <view class="auto-width-item-v" @click.stop="selectHotClassify(item)">
  51. <text
  52. :class="['condition-item-v' , activeClassify && activeClassify.id=== item.id ? 'active-condition-val' : '' ]">
  53. {{ item.name }}
  54. </text>
  55. </view>
  56. </view>
  57. </block>
  58. </view>
  59. </scroll-view>
  60. </view>
  61. <view class="condition-list-box initial-style show-style" v-if="[4,5].includes(searchType)">
  62. <!-- 选择范围 -->
  63. <view class="distance-list" v-if="searchType === 4">
  64. <scroll-view :style="{'height': 260 +'px' }" class="scroll-condition" scroll-y="true"
  65. :show-scrollbar="false">
  66. <block v-for="(item , index) in distance">
  67. <text :key="`Distance_${index}`"
  68. :class="['condition-list-item' , 'nvue-one-row' , activeDistance && activeDistance.value === item.value ? 'active-condition' : '']"
  69. @click.stop="onSelectClassify(3,item , index)">
  70. {{item.label}}
  71. </text>
  72. </block>
  73. </scroll-view>
  74. </view>
  75. <view class="condition-list" v-if="searchType === 5">
  76. <view class="condition-list-left">
  77. <scroll-view :style="{'height': 260 +'px' }" class="scroll-condition" scroll-y="true"
  78. :show-scrollbar="false">
  79. <block v-for="(item , index) in classifyTree">
  80. <text :key="`classifyTree_${index}`"
  81. :class="['condition-list-item' , 'nvue-one-row' , oneClassifyIndex === index? 'active-condition' : '']"
  82. @click.stop="onSelectClassify(1,item , index)">
  83. {{item.name}}
  84. </text>
  85. </block>
  86. </scroll-view>
  87. </view>
  88. <view class="condition-list-right">
  89. <scroll-view :style="{'height': 260 +'px' }" class="scroll-condition" scroll-y="true"
  90. :show-scrollbar="false">
  91. <block v-for="(item , index) in classifyTree[oneClassifyIndex].children || []">
  92. <text :key="`classifyTree_two_${index}`"
  93. :class="['condition-list-item' , 'nvue-one-row' , activeClassify && activeClassify.id === item.id ? 'active-condition' : '']"
  94. @click.stop="onSelectClassify(2,item , index)">
  95. {{item.name}}
  96. </text>
  97. </block>
  98. </scroll-view>
  99. </view>
  100. </view>
  101. </view>
  102. </view>
  103. </view>
  104. </view>
  105. </template>
  106. <script>
  107. import { string } from "clipboard"
  108. import Mixin from "./Mixin.js"
  109. export default {
  110. mixins: [Mixin],
  111. props: {
  112. keyWord:{
  113. type:String,
  114. default:''
  115. }
  116. },
  117. watch:{
  118. keyWord:{
  119. handler:function(newK){
  120. this.keyWord_ = newK || ''
  121. },immediate:true
  122. }
  123. },
  124. // classifyList
  125. data() {
  126. return {
  127. keyWord_:'',
  128. oldValue: '',
  129. awaitTime: 0,
  130. awaitInterval: null,
  131. deIocn: 'http://t13.baidu.com/it/u=3259673001,1762014915&fm=224&app=112&f=JPEG?w=500&h=500',
  132. distance: [{
  133. label: '1公里',
  134. value: 1000
  135. }, {
  136. label: '2公里',
  137. value: 2000
  138. }, {
  139. label: '3公里',
  140. value: 3000
  141. }, {
  142. label: '5公里',
  143. value: 5000
  144. }, {
  145. label: '10公里',
  146. value: 10000
  147. }, {
  148. label: '20公里',
  149. value: 20000
  150. }],
  151. }
  152. },
  153. mounted() {
  154. // setTimeout(()=> {
  155. // console.log('aaaaa = ' , 1)
  156. // this.blur()
  157. // },3000)
  158. },
  159. methods: {
  160. blur() {
  161. console.log('-------------------999-----------------')
  162. try {
  163. this.$refs.searchInputRef.blur()
  164. } catch (e) {
  165. //TODO handle the exception
  166. console.log('------------------------------------', e)
  167. }
  168. },
  169. onSearchFocus() {
  170. this.$emit('onSearchFocus')
  171. },
  172. selectHotClassify(item) {
  173. console.log('000')
  174. this.$emit('selectHotClassify', item)
  175. },
  176. onSelectClassify(level, val, index) {
  177. this.$emit('onSelectClassify', {
  178. level: level,
  179. val: val,
  180. index: index
  181. })
  182. },
  183. selectLabel(avt, num) {
  184. const n = avt === num ? 3 : num;
  185. this.$emit('selectLabel', n)
  186. },
  187. getMapList(kw) {
  188. if (kw.detail.value === this.oldValue) return false;
  189. this.oldValue = kw.detail.value
  190. this.$emit('onSearch', kw.detail.value);
  191. // try {
  192. // clearInterval(this.awaitInterval)
  193. // } catch (e) {
  194. // //TODO handle the exception
  195. // }
  196. // if (kw.detail.value === this.oldValue) return false;
  197. // this.awaitTime = 0;
  198. // this.awaitInterval = setInterval(() => {
  199. // this.awaitTime = this.awaitTime + 100;
  200. // if (this.awaitTime >= 500) {
  201. // if (kw.detail.value) {
  202. // this.$emit('onSearch', kw.detail.value);
  203. // }
  204. // this.oldValue = kw.detail.value
  205. // clearInterval(this.awaitInterval)
  206. // }
  207. // }, 100)
  208. }
  209. }
  210. }
  211. </script>
  212. <style lang="scss" scoped>
  213. @import url("./style.scss");
  214. .iconfont_nvue {
  215. font-family: iconfont_nvue;
  216. }
  217. .search-box {
  218. position: absolute;
  219. z-index: 21111111111;
  220. top: 70rpx;
  221. left: 20rpx;
  222. right: 20rpx;
  223. // margin-top: 20rpx;
  224. background: #fff;
  225. border-radius: 20rpx;
  226. .search-val {
  227. position: relative;
  228. z-index: 999;
  229. border-radius: 20rpx;
  230. background: rgba(184, 184, 184, 0.30);
  231. .search-frame {
  232. background-color: #fff;
  233. height: 89rpx;
  234. flex-direction: row;
  235. align-items: center;
  236. padding: 20rpx;
  237. border-radius: 20rpx;
  238. box-shadow: 0px 10px 16px 0px rgba(153, 153, 153, 0.15);
  239. .back-icon {
  240. transform: rotate(-180deg) !important;
  241. }
  242. .search-icon {
  243. font-size: 40rpx;
  244. color: #666666;
  245. width: 40rpx;
  246. height: 40rpx;
  247. transform: rotate(0deg);
  248. }
  249. .search-input {
  250. flex: 1;
  251. font-size: 28rpx;
  252. margin-left: 10rpx;
  253. }
  254. }
  255. .classify-box {
  256. height: 179rpx;
  257. flex-direction: row;
  258. align-items: center;
  259. justify-content: space-between;
  260. padding: 30rpx 30rpx;
  261. .classify-item {
  262. height: 100rpx;
  263. flex-direction: column;
  264. align-items: center;
  265. justify-content: space-between;
  266. .classify-icon {
  267. width: 64rpx;
  268. height: 64rpx;
  269. }
  270. .classify-text {
  271. font-size: 24rpx;
  272. font-family: PingFang SC, PingFang SC-Bold;
  273. font-weight: 700;
  274. color: #373737;
  275. }
  276. }
  277. }
  278. .condition-box {
  279. .condition-label {
  280. flex-direction: row;
  281. align-items: center;
  282. height: 92rpx;
  283. border-bottom: 1rpx solid $zw-border-color;
  284. padding: 0 30rpx;
  285. .label-item {
  286. // width: 200rpx;
  287. flex-direction: row;
  288. align-items: center;
  289. &+.label-item {
  290. margin-left: 20rpx;
  291. }
  292. .label-item-text {
  293. width: 130rpx;
  294. font-size: 28rpx;
  295. line-height: 36rpx;
  296. font-family: PingFang SC, PingFang SC-Regular;
  297. font-weight: 400;
  298. text-align: center;
  299. color: #1a1a1a;
  300. padding-right: 4px;
  301. }
  302. .label-item-icon {
  303. width: 28rpx;
  304. height: 28rpx;
  305. transform: rotate(0deg);
  306. transition: transform 1s;
  307. }
  308. .active-condition-label {
  309. transform: rotate(-180deg);
  310. }
  311. }
  312. }
  313. .condition-val {
  314. height: 121rpx;
  315. flex-direction: row;
  316. align-items: center;
  317. .scroll-condition {
  318. // width: 710rpx;
  319. padding: 0 30rpx;
  320. flex-direction: row;
  321. .scroll-condition-content {
  322. flex-direction: row;
  323. }
  324. }
  325. .auto-width-item-v {
  326. padding-right: 30rpx;
  327. .condition-item-v {
  328. height: 70rpx;
  329. background-color: #f2f2f2;
  330. line-height: 70rpx;
  331. padding: 0 30rpx;
  332. font-size: 28rpx;
  333. font-family: PingFang SC, PingFang SC-Regular;
  334. font-weight: 400;
  335. text-align: center;
  336. color: #666666;
  337. border-radius: 10rpx;
  338. border-width: 1rpx;
  339. border-style: solid;
  340. border-color: #f2f2f2;
  341. }
  342. .active-condition-val {
  343. border-color: #4fc9d5;
  344. background-color: #EDFDFD;
  345. color: #3FB9D4;
  346. }
  347. }
  348. }
  349. .condition-list-box {
  350. .distance-list {
  351. .active-condition {
  352. background-color: #fff;
  353. color: #3DB8D2;
  354. }
  355. }
  356. .condition-list {
  357. // padding: 0 30rpx;
  358. flex-direction: row;
  359. justify-content: space-between;
  360. align-items: stretch;
  361. .condition-list-left {
  362. width: 200rpx;
  363. .active-condition {
  364. background-color: #fff;
  365. }
  366. }
  367. .condition-list-right {
  368. // width: 430rpx;
  369. flex: 1;
  370. background-color: #fff;
  371. .active-condition {
  372. color: #3DB8D2;
  373. }
  374. }
  375. }
  376. .condition-list-item {
  377. height: 80rpx;
  378. line-height: 80rpx;
  379. font-size: 28rpx;
  380. font-family: PingFang SC, PingFang SC-Regular;
  381. font-weight: 400;
  382. color: #666666;
  383. padding: 0 20rpx;
  384. }
  385. }
  386. }
  387. }
  388. }
  389. </style>