search.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <view class="content">
  3. <view class="Search-box">
  4. <view class="Search-box-size">
  5. <image class="box-img" src="https://zhxc2030.com/img/img01.png"></image>
  6. <input class="box-word" placeholder="默认关键字" v-model="keyword" @input="searchlist">
  7. </view>
  8. </view>
  9. <view class="select-box">
  10. <!-- <u-select v-model="show" :list="array"></u-select> -->
  11. <u-select v-model="show" mode="single-column" :list="array" value-name='name' label-name='name' @confirm="confirm"></u-select>
  12. </view>
  13. <!-- 空白页 -->
  14. <!-- <picker @change="PickerInstitution" :range="array" class="box-right" @input="searchlist">
  15. <text>{{ keyword }}</text>
  16. </picker> -->
  17. <!-- <empty v-if="list.length === 0"></empty> -->
  18. <!-- <uni-load-more :status="loadingType"></uni-load-more> -->
  19. </view>
  20. </template>
  21. <script>
  22. import {
  23. mechanism
  24. } from '@/api/ask.js'
  25. import empty from '@/components/empty';
  26. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  27. export default {
  28. components: {
  29. empty,
  30. uniLoadMore
  31. },
  32. data() {
  33. return {
  34. show: false,
  35. institution:'',
  36. list: [{
  37. value: '1',
  38. label: '江'
  39. },
  40. {
  41. value: '2',
  42. label: '湖'
  43. }
  44. ],
  45. keyword: '',
  46. page: 1, // 页数
  47. limit: 10, //每页条数
  48. loadingType: 'more',
  49. // list: [],
  50. array: [],
  51. }
  52. },
  53. onLoad() {
  54. // this.getlist();
  55. },
  56. methods: {
  57. // 选择机构
  58. PickerInstitution: function(e) {
  59. console.log(3333)
  60. // this.keyword = this.array[e.target.value];
  61. // this.index = e.target.value + 1;
  62. },
  63. searchlist(e) {
  64. let obj = this;
  65. obj.keyword = e.detail.value
  66. console.log('e.detail.value', e.detail.value)
  67. // console.log('obj.keyword',obj.keyword)
  68. mechanism({
  69. page: obj.page,
  70. limit: obj.limit,
  71. keyword: obj.keyword
  72. }).then(data => {
  73. console.log('请求成功',data)
  74. this.array = data.data.map(item => item)
  75. this.show = true
  76. })
  77. },
  78. showSelect(){
  79. console.log('点击打开')
  80. this.show = true
  81. console.log(this.array)
  82. },
  83. confirm(e){
  84. console.log('点击确认')
  85. // console.log(3)
  86. this.keyword = e[0].value
  87. this.institution = e[0].value
  88. console.log('当前机构值',this.institution)
  89. //
  90. uni.removeStorage({
  91. key: 'institution',
  92. success: function (res) {
  93. console.log('success');
  94. }
  95. });
  96. let institution = e[0].value
  97. uni.setStorageSync('institution', institution)
  98. // uni.showModal({
  99. // title:'institution的值',
  100. // content:JSON.stringify(institution)
  101. // })
  102. uni.switchTab({
  103. url:'/pages/category/category'
  104. })
  105. // console.log(uni.setStorageSync)
  106. }
  107. }
  108. }
  109. </script>
  110. <style lang="scss">
  111. .content {
  112. line-height: 1;
  113. //搜索框
  114. .Search-box {
  115. z-index: 999;
  116. height: 80rpx;
  117. position: fixed;
  118. top: 0;
  119. left: 0;
  120. width: 100%;
  121. // background: #FFFFFF;
  122. padding-top: 10rpx;
  123. padding-right: 24rpx;
  124. padding-left: 24rpx;
  125. .Search-box-sort {
  126. float: left;
  127. margin-left: 32rpx;
  128. margin-right: 19rpx;
  129. .sort-text {
  130. width: 57rpx;
  131. height: 29rpx;
  132. font-size: 30rpx;
  133. font-weight: 500;
  134. color: rgba(51, 51, 51, 1);
  135. line-height: 58rpx;
  136. margin-right: 19rpx;
  137. }
  138. .sort-img {
  139. width: 21rpx;
  140. height: 11rpx;
  141. margin-bottom: 4rpx;
  142. }
  143. }
  144. .Search-box-size {
  145. // width:70%;
  146. height: 58rpx;
  147. border-radius: 32rpx;
  148. background-color: #f1f1f1;
  149. padding-left: 36rpx;
  150. display: flex;
  151. align-items: center;
  152. .box-img {
  153. height: 32rpx;
  154. width: 32rpx;
  155. margin-right: 16rpx;
  156. }
  157. // .box-right{
  158. // height: 58rpx;
  159. // // width: 100%;
  160. // background-color: pink;
  161. // }
  162. .box-word {
  163. width: 100%;
  164. font-size: 26rpx;
  165. font-weight: 500;
  166. color: rgba(205, 203, 203, 1);
  167. line-height: 55rpx;
  168. }
  169. }
  170. }
  171. // 选择框
  172. .select-box{
  173. margin-top: 100rpx;
  174. }
  175. }
  176. </style>