search-instrument.vue 7.5 KB

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