OemSearch.vue 5.3 KB

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