OemSearch.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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. background-color: #1777FF;
  146. padding: 24rpx;
  147. color: #FFFFFF;
  148. font-size: 28rpx;
  149. }
  150. .tab {
  151. background: #FFFFFF;
  152. display: flex;
  153. justify-content: space-around;
  154. line-height: 87rpx;
  155. /* position: fixed; */
  156. width: calc(100vw - 100rpx);
  157. padding-left: 50rpx;
  158. padding-right: 50rpx;
  159. height: 87rpx;
  160. /* z-index: 11; */
  161. }
  162. .tabLine {
  163. font-size: 32rpx;
  164. color: #999999;
  165. text-align: center;
  166. }
  167. .tabActive {
  168. color: #3F90F7;
  169. font-weight: bold;
  170. border-bottom: 4rpx solid #3F90F7;
  171. }
  172. .searchBoxBg {
  173. width: 100%;
  174. background-color: #FFFFFF;
  175. border-top: 1rpx solid #EEEEEE;
  176. border-bottom: 1rpx solid #EEEEEE;
  177. }
  178. .searchBox {
  179. height: 72rpx;
  180. margin: 24rpx;
  181. background-color: #F4F5F7;
  182. border-radius: 36rpx;
  183. display: flex;
  184. position: relative;
  185. }
  186. .searchImg {
  187. margin-top: 20rpx;
  188. margin-left: 20rpx;
  189. width: 32rpx;
  190. height: 32rpx;
  191. }
  192. .searchInput {
  193. height: 72rpx;
  194. font-size: 28rpx;
  195. padding-left: 16rpx;
  196. width: 78%;
  197. }
  198. .searchClose {
  199. position: absolute;
  200. width: 36rpx;
  201. height: 36rpx;
  202. right: 36rpx;
  203. top: 20rpx;
  204. }
  205. .history {
  206. padding: 24rpx;
  207. }
  208. .historyTop {
  209. display: flex;
  210. justify-content: space-between;
  211. }
  212. .historyDelImg {
  213. width: 34rpx;
  214. height: 34rpx;
  215. }
  216. .historyTopTxt {
  217. font-size: 28rpx;
  218. font-weight: 400;
  219. color: #666666;
  220. line-height: 34rpx;
  221. }
  222. .historyLIneBox {
  223. display: inline-flex;
  224. flex-wrap: wrap;
  225. }
  226. .historyLIne {
  227. color: #333333;
  228. font-size: 24rpx;
  229. height: 64rpx;
  230. background: #F4F5F7;
  231. border-radius: 32rpx;
  232. line-height: 64rpx;
  233. padding: 0 24rpx;
  234. margin-top: 20rpx;
  235. margin-right: 24rpx;
  236. }
  237. .commentBox {
  238. padding: 20rpx 24rpx;
  239. border-bottom: 1rpx solid #EEEEEE;
  240. }
  241. .name {
  242. color: #333333;
  243. font-size: 26rpx;
  244. font-weight: bold;
  245. padding-top: 16rpx;
  246. padding-bottom: 10rpx;
  247. }
  248. .comment {
  249. color: #999999;
  250. font-size: 24rpx;
  251. padding-bottom: 14rpx;
  252. }
  253. .code {
  254. color: #3F90F7;
  255. font-size: 24rpx;
  256. }
  257. </style>