OemSearch.vue 6.0 KB

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