select_picker.vue 5.8 KB

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