SimpleOemSearch.vue 6.6 KB

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