OemSearch.vue 7.9 KB

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