search-instrument.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <template>
  2. <view class="container supplier clearfix">
  3. <view class="supplier-search clearfix">
  4. <view class="search-from name">
  5. <text class="iconfont icon-sousuo"></text>
  6. <input class="input"
  7. type="text"
  8. confirm-type="search"
  9. v-model="listQuery.keyword"
  10. :focus="isFocus"
  11. @input="onShowClose"
  12. @confirm="GetSearchEquipmentList()"
  13. placeholder="请输入仪器名称"
  14. maxlength="16"/>
  15. <text class="iconfont icon-shanchu1" v-if="isShowClose" @click="delInputText()"></text>
  16. </view>
  17. <view class="search-btn">
  18. <button class="search-btn" type="default" @click.stop="searchsupplierList">搜索</button>
  19. </view>
  20. </view>
  21. <view class="equipment-main">
  22. <view v-if="isEmpty" class="empty-container">
  23. <image class="empty-container-image" :src="productNoneImage" mode="aspectFit"></image>
  24. <view class="txt">暂无项目仪器数据^_^</view>
  25. </view>
  26. <view v-else class="supplier-list">
  27. <view class="list clearfix" v-for="(item, index) in list" :key="index" @click.stop="navToDetailPage(item.e_id)">
  28. <image class="pros-item-image" :src="item.e_image" mode="scaleToFill"></image>
  29. <view class="pros-name">{{ isInterceptHtmlFn(item.e_name) }}</view>
  30. </view>
  31. <!--加载loadding-->
  32. <tui-loadmore :visible="loadding" :index="3" type="black"></tui-loadmore>
  33. <tui-nomore :visible="!pullUpOn" bgcolor="#F7F7F7" :text='nomoreText'></tui-nomore>
  34. <!--加载loadding-->
  35. </view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import authorize from '@/common/config/authorize.js'
  41. import tuiLoadmore from "@/components/tui-components/loadmore/loadmore"
  42. import tuiNomore from "@/components/tui-components/nomore/nomore"
  43. import { getFindAllsupplierList } from "@/api/seller.js"
  44. export default {
  45. components:{
  46. tuiLoadmore,
  47. tuiNomore
  48. },
  49. data() {
  50. return {
  51. iconClass:'icon-aixin',
  52. iconColor:'#ff9100',
  53. isShowClose:false,
  54. isEmpty:false,
  55. isFocus:true,
  56. productNoneImage:'http://static-b.caimei365.com/app/img/icon/icon-pnone.png',
  57. nomoreText: '上拉显示更多',
  58. loadding: false,
  59. pullUpOn: true,
  60. pullFlag: true,
  61. list:[],
  62. listQuery:{
  63. keyword: '',
  64. pageSize: 10,
  65. pageNum: 1
  66. },
  67. total:0
  68. }
  69. },
  70. onLoad(option){
  71. if(option.keyword){
  72. this.listQuery.keyword = option.keyword
  73. this.GetSearchEquipmentList();
  74. }
  75. },
  76. methods: {
  77. searchsupplierList(){//搜索
  78. this.listQuery.pageNum=1
  79. this.GetSearchEquipmentList()
  80. },
  81. GetSearchEquipmentList(){//查询供应商列表
  82. this.ProductService.GetSearchEquipmentList(this.listQuery).then(response =>{
  83. let data = JSON.parse(response.data)
  84. let dataList = data.items
  85. console.log(data)
  86. this.total = data.total
  87. if(dataList && dataList.length > 0){
  88. this.isEmpty = false
  89. this.list = dataList
  90. this.pullFlag = false;
  91. setTimeout(()=>{this.pullFlag = true;},500)
  92. if(this.total>this.list.length){
  93. this.pullUpOn = false
  94. this.nomoreText = '上拉显示更多'
  95. }else{
  96. this.pullUpOn = true
  97. this.loadding = false
  98. this.nomoreText = '已至底部'
  99. }
  100. }else{
  101. this.isEmpty = true
  102. }
  103. }).catch(error =>{
  104. this.$util.msg(error.msg,2000)
  105. })
  106. },
  107. GetSearchEquipmentListBottomData(){//上滑加载
  108. this.listQuery.pageNum+=1
  109. this.ProductService.GetSearchEquipmentList(this.listQuery).then(response =>{
  110. let data = JSON.parse(response.data)
  111. console.log(data)
  112. this.total = data.total
  113. this.list = this.list.concat(data.items)
  114. if(this.total>this.list.length){
  115. this.pullUpOn = false
  116. this.nomoreText = '上拉显示更多'
  117. }else{
  118. this.pullUpOn = true
  119. this.loadding = false
  120. this.nomoreText = '已至底部'
  121. }
  122. }).catch(error =>{
  123. this.$util.msg(error.msg,2000)
  124. })
  125. },
  126. onShowClose () {//输入框失去焦点时触发
  127. if(this.listQuery.keyword != ''){
  128. this.isShowClose = true
  129. }else{
  130. this.isShowClose = false
  131. this.listQuery.pageNum=1
  132. this.GetSearchEquipmentList()
  133. }
  134. },
  135. delInputText(){//清除输入框内容
  136. this.listQuery.keyword = ''
  137. this.isShowClose = false
  138. this.listQuery.pageNum=1
  139. this.GetSearchEquipmentList()
  140. },
  141. navToDetailPage(id) {//跳转仪器详情页
  142. this.$api.navigateTo(`/pages/goods/instrument-details?id=${id}`)
  143. },
  144. isInterceptHtmlFn(text){
  145. let name = this.$reg.interceptHtmlFn(text)
  146. return name
  147. },
  148. },
  149. onReachBottom() {
  150. if(this.total>this.list.length){
  151. this.loadding = true
  152. this.pullUpOn = true
  153. this.GetSearchEquipmentListBottomData()
  154. }
  155. },
  156. onShow() {
  157. }
  158. }
  159. </script>
  160. <style lang='scss'>
  161. page {
  162. height: auto;
  163. }
  164. page,.container{
  165. /* padding-bottom: 120upx; */
  166. background: #F7F7F7;
  167. }
  168. .container{
  169. position: relative;
  170. }
  171. .supplier {
  172. width: 100%;
  173. height: auto;
  174. box-sizing: border-box;
  175. }
  176. .supplier-search{
  177. height: 84rpx;
  178. width: 100%;
  179. padding:10rpx 24rpx;
  180. background: #FFFFFF;
  181. display: flex;
  182. align-items: center;
  183. position: fixed;
  184. top: 0;
  185. left: 0;
  186. z-index: 999;
  187. box-sizing: border-box;
  188. .search-from{
  189. width: 582rpx;
  190. height: 64rpx;
  191. background: #F7F7F7;
  192. border-radius: 32rpx;
  193. float: left;
  194. position: relative;
  195. .input{
  196. width: 500rpx;
  197. height: 64rpx;
  198. float: left;
  199. line-height: 64rpx;
  200. color: $text-color;
  201. font-size: $font-size-24;
  202. }
  203. .icon-sousuo{
  204. width: 64rpx;
  205. height: 64rpx;
  206. line-height: 64rpx;
  207. text-align: center;
  208. display: block;
  209. font-size: $font-size-38;
  210. float: left;
  211. color: #999999;
  212. }
  213. .icon-shanchu1{
  214. font-size: $font-size-32;
  215. color: #999999;
  216. position: absolute;
  217. width: 64rpx;
  218. height: 64rpx;
  219. line-height: 64rpx;
  220. text-align: center;
  221. top: 0;
  222. right: 0;
  223. z-index: 10;
  224. }
  225. }
  226. .search-btn{
  227. width: 120rpx;
  228. line-height: 64rpx;
  229. text-align: center;
  230. font-size: $font-size-28;
  231. color: #666666;
  232. float: left;
  233. background: #FFFFFF;
  234. }
  235. }
  236. .equipment-main{
  237. box-sizing: border-box;
  238. padding: 0 24rpx;
  239. margin-top: 94rpx;
  240. }
  241. .list{
  242. width: 340rpx;
  243. height: 301rpx;
  244. float: left;
  245. margin-right: 20rpx;
  246. margin-top: 10rpx;
  247. margin-bottom: 10rpx;
  248. border-radius: 6rpx;
  249. background-color: #FFFFFF;
  250. &:nth-child(2n){
  251. margin-right: 0;
  252. }
  253. .pros-item-image{
  254. width: 340rpx;
  255. height: 227rpx;
  256. display: block;
  257. float: left;
  258. border-radius: 6rpx 6rpx 0 0;
  259. }
  260. .pros-name{
  261. width: 100%;
  262. height: 74rpx;
  263. background-color: #FFFFFF;
  264. line-height: 74rpx;
  265. box-sizing: border-box;
  266. padding: 0 20rpx;
  267. font-size: $font-size-24;
  268. color: #666666;
  269. white-space: normal;
  270. word-break: break-all;
  271. overflow: hidden;
  272. text-overflow: ellipsis;
  273. display: -webkit-box;
  274. -webkit-box-orient: vertical;
  275. -webkit-line-clamp: 1;
  276. text-align: center;
  277. }
  278. }
  279. </style>