select_picker.vue 5.5 KB

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