OemSearch.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <template>
  2. <view class="box">
  3. <view class="brand">当前品牌:{{brand}}</view>
  4. <!-- <view class="tab">
  5. <view class="tabLine" :class="{tabActive:tabIndex==0}" @click="tabClick(0)">品牌下搜索</view>
  6. <view class="tabLine" :class="{tabActive:tabIndex==1}" @click="tabClick(1)">车型下搜索</view>
  7. </view> -->
  8. <!-- 搜索 -->
  9. <view class="searchBox">
  10. <image src="../../static/img/icon_search.png" class="searchImg"></image>
  11. <input type="text" class="searchInput" placeholder='配件名称/原厂OEM' v-model="inputValue"
  12. @confirm="search" />
  13. <image src="../../static/img/icon_close.png" class="searchClose" v-if="inputValue!=''"
  14. @click="clear"></image>
  15. </view>
  16. <view class="history" v-if="inputValue.length==0">
  17. <view class="historyTop">
  18. <view class="historyTopTxt">历史搜索</view>
  19. <!-- <image src="../../static/img/icon_delete.png" mode="" class="historyDelImg"></image> -->
  20. </view>
  21. <view v-for="(item,index) in 1" class="historyLIneBox">
  22. <view class="historyLIne" @click="goSearch('16400RZDH01')">16400RZDH01</view>
  23. </view>
  24. </view>
  25. <view @click="goCarModelList(item.partnum)" class="commentBox" v-for="(item,index) in itemList" :key="index">
  26. <view class="name">{{item.caption}}</view>
  27. <view class="comment">{{item.description}}</view>
  28. <view class="code">{{item.extened}}</view>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. export default {
  34. components: {
  35. },
  36. data() {
  37. return {
  38. inputValue: '',
  39. tabIndex: 0,
  40. historyList: [],
  41. itemData: {},
  42. itemList: [],
  43. brandList: [],
  44. brand: '',
  45. epc_id: '',
  46. vin:'',
  47. token:'',
  48. param:'',
  49. access_time:'',
  50. page: 1,
  51. total_page: 1
  52. }
  53. },
  54. onLoad(opt) {
  55. console.log('opt+',opt);
  56. this.brand = opt.brand;
  57. this.epc_id = opt.epc_id;
  58. this.vin = opt.vin;
  59. this.token = opt.token;
  60. this.param = opt.param;
  61. this.access_time = opt.access_time;
  62. },
  63. methods: {
  64. search(){
  65. if (!this.inputValue) return;
  66. //console.log(this.inputValue);
  67. this.$emit('search',this.inputValue);
  68. },
  69. clear(){
  70. this.inputValue = ''
  71. this.$emit('search','');
  72. },
  73. goCarModelList(partnum) {
  74. uni.navigateTo({
  75. url: 'CarModelList?epc_id=' + this.epc_id + '&partnum=' + partnum
  76. })
  77. },
  78. tabClick(num) {
  79. this.tabIndex = num;
  80. },
  81. search(val) {
  82. // console.log(val);
  83. this.inputValue = val
  84. this.page = 1;
  85. this.getItemData();
  86. },
  87. goSearch(str){
  88. this.inputValue = str
  89. this.page = 1;
  90. this.getItemData();
  91. },
  92. // 配件查询
  93. getItemData() {
  94. uni.showLoading({
  95. title: '加载中'
  96. });
  97. this.$http('advancedEpc/findParts', {
  98. epc_id: this.epc_id,
  99. keyword: this.inputValue,
  100. vin:this.vin,
  101. token: this.token,
  102. param: this.param,
  103. access_time:this.access_time,
  104. page: this.page,
  105. }, 'GET').then(res => {
  106. uni.hideLoading();
  107. this.itemData = res.data.result;
  108. var list = res.data.result.list;
  109. this.total_page = res.data.result.total_page;
  110. if (this.page == 1) {
  111. this.itemList = list;
  112. }
  113. else if (list.length != 0) {
  114. this.itemList = this.itemList.concat(list)
  115. }
  116. if (this.itemList.length == 0) {
  117. uni.showToast({
  118. title: '暂无符合要求的配件',
  119. icon: 'none',
  120. duration: 2000
  121. });
  122. }
  123. });
  124. },
  125. },
  126. // 下拉刷新 上拉加载更多
  127. onPullDownRefresh() {
  128. // this.page = 1
  129. // this.getItemData()
  130. setTimeout(function() {
  131. uni.stopPullDownRefresh();
  132. }, 1000);
  133. },
  134. onReachBottom() {
  135. if (this.page <= this.total_page) {
  136. this.page++;
  137. this.getItemData()
  138. }
  139. }
  140. }
  141. </script>
  142. <style>
  143. .box {
  144. min-height: 100vh;
  145. background: #FFFFFF;
  146. padding-bottom: constant(safe-area-inset-bottom);
  147. padding-bottom: env(safe-area-inset-bottom);
  148. }
  149. .brand {
  150. background: linear-gradient(110deg, #48B9F9 0%, #3F90F7 100%);
  151. padding: 24rpx;
  152. color: #FFFFFF;
  153. font-size: 28rpx;
  154. }
  155. .tab {
  156. background: #FFFFFF;
  157. display: flex;
  158. justify-content: space-around;
  159. line-height: 87rpx;
  160. /* position: fixed; */
  161. width: calc(100vw - 100rpx);
  162. padding-left: 50rpx;
  163. padding-right: 50rpx;
  164. height: 87rpx;
  165. /* z-index: 11; */
  166. }
  167. .tabLine {
  168. font-size: 32rpx;
  169. color: #999999;
  170. text-align: center;
  171. }
  172. .tabActive {
  173. color: #3F90F7;
  174. font-weight: bold;
  175. border-bottom: 4rpx solid #3F90F7;
  176. }
  177. .searchBoxBg {
  178. width: 100%;
  179. background-color: #FFFFFF;
  180. border-top: 1rpx solid #EEEEEE;
  181. border-bottom: 1rpx solid #EEEEEE;
  182. }
  183. .searchBox {
  184. height: 72rpx;
  185. margin: 24rpx;
  186. background-color: #F4F5F7;
  187. border-radius: 36rpx;
  188. display: flex;
  189. position: relative;
  190. }
  191. .searchImg {
  192. margin-top: 20rpx;
  193. margin-left: 20rpx;
  194. width: 32rpx;
  195. height: 32rpx;
  196. }
  197. .searchInput {
  198. height: 72rpx;
  199. font-size: 28rpx;
  200. padding-left: 16rpx;
  201. width: 78%;
  202. }
  203. .searchClose {
  204. position: absolute;
  205. width: 36rpx;
  206. height: 36rpx;
  207. right: 36rpx;
  208. top: 20rpx;
  209. }
  210. .history {
  211. padding: 24rpx;
  212. }
  213. .historyTop {
  214. display: flex;
  215. justify-content: space-between;
  216. }
  217. .historyDelImg {
  218. width: 34rpx;
  219. height: 34rpx;
  220. }
  221. .historyTopTxt {
  222. font-size: 28rpx;
  223. font-weight: 400;
  224. color: #666666;
  225. line-height: 34rpx;
  226. }
  227. .historyLIneBox {
  228. display: inline-flex;
  229. flex-wrap: wrap;
  230. }
  231. .historyLIne {
  232. color: #333333;
  233. font-size: 24rpx;
  234. height: 64rpx;
  235. background: #F4F5F7;
  236. border-radius: 32rpx;
  237. line-height: 64rpx;
  238. padding: 0 24rpx;
  239. margin-top: 20rpx;
  240. margin-right: 24rpx;
  241. }
  242. .commentBox {
  243. padding: 20rpx 24rpx;
  244. border-bottom: 1rpx solid #EEEEEE;
  245. }
  246. .name {
  247. color: #333333;
  248. font-size: 26rpx;
  249. font-weight: bold;
  250. padding-top: 16rpx;
  251. padding-bottom: 10rpx;
  252. }
  253. .comment {
  254. color: #999999;
  255. font-size: 24rpx;
  256. padding-bottom: 14rpx;
  257. }
  258. .code {
  259. color: #3F90F7;
  260. font-size: 24rpx;
  261. }
  262. </style>