select_picker.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <view class="content">
  3. <view class="liy-select-fixed">
  4. <view class="liy-search-warp">
  5. <view class="liy-search-input">
  6. <view class="lsi-warp">
  7. <image :src="loadImgSrc('search.png')" mode="widthFix" class="lsi-icon"></image>
  8. <input class="lsi-input" v-model="keyword" placeholder="请输入搜索内容" @input="getParamsList" />
  9. </view>
  10. </view>
  11. <scroll-view scroll-y="true" class="scroll-Y" @scrolltolower="lower">
  12. <view class="liy-search-list" v-if="outPutList.length > 0">
  13. <view class="liy-search-li" v-for="(item,index) in outPutList" :key="index"
  14. @click="mapSelectMenu(item,index)">
  15. <view class="liy-search-left">
  16. <view class="liy-search-title" v-if="titleKey">{{item[titleKey]}}
  17. </view>
  18. <view class="liy-search-title" v-else>未选择标题
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. <view v-else class="liy-void">
  24. <image class="liy-void-img" :src="loadImgSrc('void.png')" mode="widthFix"></image>
  25. <view class="liy-void-text">未查询到内容</view>
  26. </view>
  27. </scroll-view>
  28. </view>
  29. </view>
  30. <view class="liy-overlay" @click="closeOverlay"></view>
  31. </view>
  32. </template>
  33. <script>
  34. export default {
  35. name: 'select_picker',
  36. props: {
  37. list: {
  38. type: Array,
  39. default: []
  40. },
  41. titleKey: {
  42. type: [String, null],
  43. default: null
  44. },
  45. subtitleKey: {
  46. type: [String, null],
  47. default: null
  48. },
  49. },
  50. components: {
  51. //unieasyinput
  52. },
  53. data() {
  54. return {
  55. mapSelectIndex: null,
  56. keyword: "",
  57. outPutList: [],
  58. openClass: false
  59. }
  60. },
  61. watch: {
  62. list(newList, oldList) {
  63. this.getParamsList();
  64. },
  65. },
  66. created() {
  67. this.getParamsList();
  68. },
  69. methods: {
  70. mapSelectMenu(item, index) {
  71. this.mapSelectIndex = index;
  72. this.$emit("change", item, index)
  73. // this.$parent.open=false;
  74. },
  75. getParamsList() {
  76. var selectList = this.list;
  77. this.mapSelectIndex = null;
  78. if (!this.keyword) {
  79. this.outPutList = selectList;
  80. return false;
  81. }
  82. var arr = [];
  83. for (var i = 0; i < selectList.length; i++) {
  84. let item = selectList[i];
  85. if (item[this.titleKey].indexOf(this.keyword) > -1) {
  86. arr.push(item);
  87. } else {
  88. }
  89. }
  90. this.outPutList = arr;
  91. },
  92. lower() {
  93. },
  94. closeOverlay() {
  95. this.$emit("close");
  96. },
  97. confirm() {
  98. }
  99. }
  100. }
  101. </script>
  102. <style scoped lang="scss">
  103. .liy-overlay {
  104. transition-duration: 300ms;
  105. transition-timing-function: ease-out;
  106. position: fixed;
  107. inset: 0px;
  108. z-index: 100;
  109. background-color: rgba(0, 0, 0, 0.5);
  110. }
  111. .liy-select-fixed {
  112. position: fixed;
  113. bottom: 0;
  114. left: 0;
  115. width: 100%;
  116. z-index: 150;
  117. transition: transform .5s ease-in-out;
  118. transform: translateY(calc(100% + 40rpx));
  119. animation: showHandler 0.3s forwards;
  120. .liy-search-warp {
  121. background: #fff;
  122. border-radius: 10rpx 10rpx 0 0;
  123. .liy-search-input {
  124. padding: 30rpx 40rpx;
  125. font-size: 28rpx;
  126. .lsi-warp {
  127. display: flex;
  128. align-items: center;
  129. border: 2rpx solid #e3e3e3;
  130. padding: 16rpx 20rpx;
  131. border-radius: 50rpx;
  132. .lsi-icon {
  133. width: 30rpx;
  134. height: 30rpx;
  135. }
  136. .lsi-input {
  137. width: 90%;
  138. padding-left: 16rpx;
  139. font-size: 28rpx;
  140. }
  141. }
  142. }
  143. .liy-search-list {
  144. .liy-search-li {
  145. padding: 20rpx 30rpx;
  146. display: flex;
  147. align-items: center;
  148. border-bottom: 1rpx solid #f7f7f7;
  149. min-height: 50rpx;
  150. .liy-search-left {
  151. width: 90%;
  152. .liy-search-title {
  153. font-size: 28rpx;
  154. line-height: 36rpx;
  155. color: #333;
  156. }
  157. .liy-search-desc {
  158. padding-top: 10rpx;
  159. font-size: 24rpx;
  160. line-height: 36rpx;
  161. color: #999;
  162. }
  163. }
  164. .liy-search-icon {
  165. .lsi-icon {
  166. width: 40rpx;
  167. height: 40rpx;
  168. }
  169. }
  170. }
  171. }
  172. }
  173. }
  174. .scroll-Y {
  175. height: 500rpx;
  176. }
  177. .liy-loading {
  178. color: #333;
  179. font-size: 26rpx;
  180. display: flex;
  181. align-items: center;
  182. justify-content: center;
  183. padding: 20rpx 0;
  184. .liy-loading-img {
  185. width: 32rpx;
  186. height: 32rpx;
  187. // animation: turn 3s linear infinite;
  188. }
  189. .liy-loading-text {
  190. padding-left: 12rpx;
  191. padding-right: 32rpx;
  192. }
  193. }
  194. @keyframes turn {
  195. 0% {
  196. transform: rotate(0deg);
  197. }
  198. 25% {
  199. transform: rotate(90deg);
  200. }
  201. 50% {
  202. transform: rotate(180deg);
  203. }
  204. 75% {
  205. transform: rotate(270deg);
  206. }
  207. 100% {
  208. transform: rotate(360deg);
  209. }
  210. }
  211. @keyframes showHandler {
  212. 0% {
  213. transform: translateY(calc(100% + 40rpx));
  214. }
  215. 100% {
  216. transform: translateY(0);
  217. }
  218. }
  219. @keyframes hideHandler {
  220. 0% {
  221. transform: translateY(0);
  222. }
  223. 100% {
  224. transform: translateY(calc(100% + 40rpx));
  225. }
  226. }
  227. .liy-void {
  228. text-align: center;
  229. padding-top: 60rpx;
  230. .liy-void-img {
  231. width: 40%;
  232. }
  233. .liy-void-text {
  234. padding-top: 30rpx;
  235. font-size: 26rpx;
  236. color: #909090;
  237. }
  238. }
  239. </style>