search-instrument.vue 7.3 KB

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