selectParking.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <view>
  3. <view class="top">
  4. <view class="search">
  5. <view class="searchBox">
  6. <u-search shape="square" placeholder="搜索停车场" v-model="testName" :show-action="false" :animation="true"></u-search>
  7. <u-button type="primary" size="mini" @click="testBtn">搜素</u-button>
  8. </view>
  9. </view>
  10. </view>
  11. <view class="body2">
  12. <view class="item"
  13. v-for="(item,i) in list" :key="i" @click="returnName(item.name,item.id)" >
  14. <view class="v1" v-html="item.html"></view>
  15. </view>
  16. <view class="item" @click="returnName(queryName,'')" v-if="queryName!=''&&testName==queryName&&(list.length==0)">
  17. <view class="v1">未查询到“<span class="qName">{{queryName}}</span>”相关结果</view>
  18. <view class="v2">点击创建“<span class="qName">{{queryName}}</span>”停车场</view>
  19. </view>
  20. </view>
  21. <u-divider color="#B6BDC3" :isnone="list.length==0" >已经到底了</u-divider>
  22. </view>
  23. </template>
  24. <script>
  25. import * as API from '@/apis/pagejs/pagesMylock.js'
  26. export default {
  27. data() {
  28. return {
  29. list: [],
  30. testName:"",
  31. queryName:"",
  32. };
  33. },
  34. onLoad() {
  35. this.getList()
  36. },
  37. methods:{
  38. getList() {
  39. uni.showLoading({
  40. title: "加载中",
  41. mask: true,
  42. })
  43. API.findParking({
  44. name:this.testName
  45. }).then((res) => {
  46. this.queryName=this.testName
  47. var list=res.data.parkingInfoList
  48. if(list==null){
  49. list=[]
  50. }
  51. this.list =list
  52. if(this.testName){
  53. for (var i = 0; i < this.list.length; i++) {
  54. var item=this.list[i]
  55. var targetChar=this.testName
  56. item.html=item.name.replace(new RegExp(`(${targetChar})`, 'g'), '<span style="color:#FF5100 ">$1</span>');
  57. console.log(item.html)
  58. }
  59. }
  60. uni.hideLoading();
  61. }).catch(error => {
  62. uni.hideLoading();
  63. uni.showToast({
  64. title: error,
  65. icon: "none"
  66. })
  67. })
  68. },
  69. returnName(item,id){
  70. const eventChannel = this.getOpenerEventChannel();
  71. eventChannel.emit('acceptDataFromOpenerPage', { data: item,dataid: id})
  72. uni.navigateBack()
  73. },
  74. testBtn(){
  75. this.list=[]
  76. //this.listForm.pageIndex=1
  77. this.getList()
  78. },
  79. getInfo(){
  80. }
  81. }
  82. }
  83. </script>
  84. <style>
  85. page {
  86. background-color: rgba(242, 244, 246, 1);
  87. }
  88. </style>
  89. <style lang="scss" scoped>
  90. ::v-deep .u-content{
  91. width: 380% !important;
  92. }
  93. .search {
  94. padding: 16rpx 32rpx;
  95. background: #fff;
  96. .searchBox {
  97. display: flex;
  98. align-items: center;
  99. background: #F2F2F2;
  100. padding: 1px 16rpx;
  101. border-radius: 8px;
  102. justify-content: space-between;
  103. }
  104. }
  105. .body2{
  106. .item:not(:last-child) {
  107. border-bottom:1px solid rgba(232,232,232,1);
  108. }
  109. .item{
  110. padding: 24rpx 32rpx;
  111. background: #fff;
  112. .qName{
  113. color:#FF5100
  114. }
  115. .v1{
  116. color: rgba(16,16,16,1);
  117. font-size: 32rpx;
  118. }
  119. .v2{
  120. color: rgba(119,119,119,1);
  121. font-size: 24rpx;
  122. }
  123. }
  124. }
  125. </style>