search-instrument.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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 wxLogin from "@/common/config/wxLogin.js"
  42. import tuiLoadmore from "@/components/tui-components/loadmore/loadmore"
  43. import tuiNomore from "@/components/tui-components/nomore/nomore"
  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:'https://static.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.type =='share'){
  72. authorize.getSetting().then(wxResponse =>{// console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
  73. console.log(wxResponse)
  74. if(wxResponse == 1){
  75. wxLogin.wxLoginAuthorize()
  76. }else{
  77. console.log(new Date +'用户未授权微信信息')
  78. }
  79. })
  80. }
  81. if(option.keyword){
  82. this.listQuery.keyword = option.keyword
  83. this.GetSearchEquipmentList();
  84. }
  85. },
  86. methods: {
  87. searchsupplierList(){//搜索
  88. this.listQuery.pageNum=1
  89. this.GetSearchEquipmentList()
  90. },
  91. GetSearchEquipmentList(){//查询供应商列表
  92. this.ProductService.GetSearchEquipmentList(this.listQuery).then(response =>{
  93. let data = JSON.parse(response.data)
  94. let dataList = data.items
  95. console.log(data)
  96. this.total = data.total
  97. if(dataList && dataList.length > 0){
  98. this.isEmpty = false
  99. this.list = dataList
  100. this.pullFlag = false;
  101. setTimeout(()=>{this.pullFlag = true;},500)
  102. if(this.total>this.list.length){
  103. this.pullUpOn = false
  104. this.nomoreText = '上拉显示更多'
  105. }else{
  106. this.pullUpOn = true
  107. this.loadding = false
  108. this.nomoreText = '已至底部'
  109. }
  110. }else{
  111. this.isEmpty = true
  112. }
  113. }).catch(error =>{
  114. this.$util.msg(error.msg,2000)
  115. })
  116. },
  117. GetSearchEquipmentListBottomData(){//上滑加载
  118. this.listQuery.pageNum+=1
  119. this.ProductService.GetSearchEquipmentList(this.listQuery).then(response =>{
  120. let data = JSON.parse(response.data)
  121. console.log(data)
  122. this.total = data.total
  123. this.list = this.list.concat(data.items)
  124. if(this.total>this.list.length){
  125. this.pullUpOn = false
  126. this.nomoreText = '上拉显示更多'
  127. }else{
  128. this.pullUpOn = true
  129. this.loadding = false
  130. this.nomoreText = '已至底部'
  131. }
  132. }).catch(error =>{
  133. this.$util.msg(error.msg,2000)
  134. })
  135. },
  136. onShowClose () {//输入框失去焦点时触发
  137. if(this.listQuery.keyword != ''){
  138. this.isShowClose = true
  139. }else{
  140. this.isShowClose = false
  141. this.listQuery.pageNum=1
  142. this.GetSearchEquipmentList()
  143. }
  144. },
  145. delInputText(){//清除输入框内容
  146. this.listQuery.keyword = ''
  147. this.isShowClose = false
  148. this.listQuery.pageNum=1
  149. this.GetSearchEquipmentList()
  150. },
  151. navToDetailPage(id) {//跳转仪器详情页
  152. this.$api.navigateTo(`/pages/goods/instrument-details?id=${id}`)
  153. },
  154. isInterceptHtmlFn(text){
  155. let name = this.$reg.interceptHtmlFn(text)
  156. return name
  157. },
  158. },
  159. onReachBottom() {
  160. if(this.total>this.list.length){
  161. this.loadding = true
  162. this.pullUpOn = true
  163. this.GetSearchEquipmentListBottomData()
  164. }
  165. },
  166. onShareAppMessage(res){//分享转发
  167. if (res.from === 'button') {
  168. // 来自页面内转发按钮
  169. }
  170. return {
  171. title: `做项目找仪器,上采美`,
  172. path: `pages/search/search-instrument?type=share&keyWord=${this.listQuery.keyword}`
  173. }
  174. },
  175. onShow() {
  176. }
  177. }
  178. </script>
  179. <style lang='scss'>
  180. page {
  181. height: auto;
  182. }
  183. page,.container{
  184. /* padding-bottom: 120upx; */
  185. background: #F7F7F7;
  186. }
  187. .container{
  188. position: relative;
  189. }
  190. .supplier {
  191. width: 100%;
  192. height: auto;
  193. box-sizing: border-box;
  194. }
  195. .supplier-search{
  196. height: 84rpx;
  197. width: 100%;
  198. padding:10rpx 24rpx;
  199. background: #FFFFFF;
  200. display: flex;
  201. align-items: center;
  202. position: fixed;
  203. top: 0;
  204. left: 0;
  205. z-index: 999;
  206. box-sizing: border-box;
  207. .search-from{
  208. width: 582rpx;
  209. height: 64rpx;
  210. background: #F7F7F7;
  211. border-radius: 32rpx;
  212. float: left;
  213. position: relative;
  214. .input{
  215. width: 500rpx;
  216. height: 64rpx;
  217. float: left;
  218. line-height: 64rpx;
  219. color: $text-color;
  220. font-size: $font-size-24;
  221. }
  222. .icon-sousuo{
  223. width: 64rpx;
  224. height: 64rpx;
  225. line-height: 64rpx;
  226. text-align: center;
  227. display: block;
  228. font-size: $font-size-38;
  229. float: left;
  230. color: #999999;
  231. }
  232. .icon-shanchu1{
  233. font-size: $font-size-32;
  234. color: #999999;
  235. position: absolute;
  236. width: 64rpx;
  237. height: 64rpx;
  238. line-height: 64rpx;
  239. text-align: center;
  240. top: 0;
  241. right: 0;
  242. z-index: 10;
  243. }
  244. }
  245. .search-btn{
  246. width: 120rpx;
  247. line-height: 64rpx;
  248. text-align: center;
  249. font-size: $font-size-28;
  250. color: #666666;
  251. float: left;
  252. background: #FFFFFF;
  253. }
  254. }
  255. .equipment-main{
  256. box-sizing: border-box;
  257. padding: 0 24rpx;
  258. margin-top: 94rpx;
  259. }
  260. .list{
  261. width: 340rpx;
  262. height: 301rpx;
  263. float: left;
  264. margin-right: 20rpx;
  265. margin-top: 10rpx;
  266. margin-bottom: 10rpx;
  267. border-radius: 6rpx;
  268. background-color: #FFFFFF;
  269. &:nth-child(2n){
  270. margin-right: 0;
  271. }
  272. .pros-item-image{
  273. width: 340rpx;
  274. height: 227rpx;
  275. display: block;
  276. float: left;
  277. border-radius: 6rpx 6rpx 0 0;
  278. }
  279. .pros-name{
  280. width: 100%;
  281. height: 74rpx;
  282. background-color: #FFFFFF;
  283. line-height: 74rpx;
  284. box-sizing: border-box;
  285. padding: 0 20rpx;
  286. font-size: $font-size-24;
  287. color: #666666;
  288. white-space: normal;
  289. word-break: break-all;
  290. overflow: hidden;
  291. text-overflow: ellipsis;
  292. display: -webkit-box;
  293. -webkit-box-orient: vertical;
  294. -webkit-line-clamp: 1;
  295. text-align: center;
  296. }
  297. }
  298. </style>