index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. <template>
  2. <view class="content">
  3. <!-- <view class="top">
  4. <view class="status_bar" :style="{height: iStatusBarHeight + 'px'}"></view>
  5. <view style="height: 43px;"></view>
  6. <view class="searchBox">
  7. <view class="searchInputBox" @click="goSearch">
  8. <image src="../../static/img/icon_search.png" mode="" class="simg"></image>
  9. <input type="text" placeholder="请输入车辆品牌、车系或VIN码" placeholder-class="ip" class="ssinput">
  10. </view>
  11. <view class="st" @click="stBtn">
  12. <image src="../../static/img/icon_shitu.png" mode="" class="stimg"></image>
  13. <view class="shitu">识图</view>
  14. </view>
  15. </view>
  16. </view> -->
  17. <!-- 历史查询 -->
  18. <!-- <view class="historybox ">
  19. <view class="history">
  20. <view class="historyTop" @click="gohistory">
  21. <view class="historyTitle">历史查询</view>
  22. <image src="../../static/img/icon_arrow.png" mode="" class="jiantouimg"></image>
  23. </view>
  24. <view class="historyLine" v-for="(item,index) in historyList" v-if="index<3" @click="gocarDetail(item)">
  25. <view class="historyLogoBox">
  26. <image :src="item.logo" mode="" class="historylinecarImg"></image>
  27. </view>
  28. <view class="historylinecar">{{item.title}}</view>
  29. </view>
  30. </view>
  31. </view> -->
  32. <!-- <view :style="{height: aaa}" class="aaaaa"></view> -->
  33. <!-- <view @click="wy">asdfasdfasdfas</view> -->
  34. <!-- <carModel ref="carModelView" :iStatusBarHeight="iStatusBarHeight" :svHeight="aaa"></carModel> -->
  35. <!-- 选择车型 -->
  36. <!-- <view class="ckcarBox" v-if="ckCarShow" >
  37. <view class="ckcar" @click.stop="">
  38. <view class="ckcarTop flex">
  39. <view class="ckcarTitle">请选择车型</view>
  40. <image src="../../static/img/icon_quxiao.png" mode="" class="ckcarClose" @click="ckcarClose"></image>
  41. </view>
  42. <view class="ckcarlineBox" v-for="(item,index) in moreVinList" @click="gobyItem(item)">
  43. <view class="ckcarline flex">
  44. <view class="ckcarLeft">{{item.title}}</view>
  45. <image src="../../static/img/icon_arrow.png" mode="" class="ckcarJtimg"></image>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. -->
  51. <view class="viewBox" v-if="tabIndex==1">
  52. <view class="status_bar" :style="{height: iStatusBarHeight + 'px'}"></view>
  53. <view style="height: 43px;"></view>
  54. <view class="topNavBox">
  55. <view class="status_bar" :style="{height: iStatusBarHeight + 'px'}"></view>
  56. <view class="indexnav">精准用油</view>
  57. </view>
  58. <!-- 轮播-->
  59. <view class="swpBox">
  60. <swiper class="swiperTk" circular :autoplay="true" :interval="interval"
  61. :duration="duration" :indicator-dots="true" indicator-color="#CCCCCC" :indicator-active-color="'#'+themeColor">
  62. <swiper-item >
  63. <view class="swiper-itemTk" >
  64. <image class="tkHdImg" src="http://dmsphoto.66km.com.cn/thFiles/084CAE69-DFFC-48FC-9F82-04E94696AE56.png" mode="widthFix"></image>
  65. </view>
  66. </swiper-item>
  67. <swiper-item >
  68. <view class="swiper-itemTk" >
  69. <image class="tkHdImg" src="http://dmsphoto.66km.com.cn/thFiles/37B94D9D-5D8A-4754-9BBF-5715C1B5F665.jpg" mode="widthFix"></image>
  70. </view>
  71. </swiper-item>
  72. </swiper>
  73. </view>
  74. <view class="contBox">
  75. <view class="vincar">
  76. <view class="vincarTab">
  77. <view class="vincarTabLine anVin">按VIN</view>
  78. <view class="vincarTabLine" @click="goCarModel">按车型</view>
  79. </view>
  80. <view class="inputsBox">
  81. <view class="searchInputBox" @click="goSearch">
  82. <image src="../../static/img/icon_search.png" mode="" class="simg"></image>
  83. <input type="text" placeholder="输入17位VIN查询" placeholder-class="ip" class="ssinput">
  84. </view>
  85. <view class="inputsBtn">查询</view>
  86. </view>
  87. <view class="historyBox">
  88. <view class="historyLeft">
  89. <view class="historyLeftTxt">历史查询:</view>
  90. <view class="historyLeftNum" @click="gocarDetail" v-if="historyvin">{{historyvin}} </view>
  91. <view class="historyLeftNum" v-else>暂无</view>
  92. </view>
  93. <view class="historyMore" @click="gohistory">更多
  94. <image src="../../static/img/lanjt.png" mode="" class="lanjt"></image>
  95. </view>
  96. </view>
  97. </view>
  98. <view class="productBox">
  99. <view class="productTitle">产品列表</view>
  100. <view class="productLinBox">
  101. <view class="productLine" @click="goCarModelType(1)">
  102. <image class="productImg" src="/static/img/jiyou.png" mode=""></image>
  103. <view class="productTxt" >机油</view>
  104. </view>
  105. <view class="productLine" @click="goCarModelType(2)">
  106. <image class="productImg" src="/static/img/bsxy.png" mode=""></image>
  107. <view class="productTxt" >变速箱油</view>
  108. </view>
  109. <view class="productLine">
  110. <image class="productImg" src="/static/img/bsxglq.png" mode=""></image>
  111. <view class="productTxt" >变速箱滤清器</view>
  112. </view>
  113. <view class="productLine">
  114. <image class="productImg" src="/static/img/yusha.png" mode=""></image>
  115. <view class="productTxt" >雨刮</view>
  116. </view>
  117. </view>
  118. </view>
  119. </view>
  120. </view>
  121. <user v-if="tabIndex==2" :iStatusBarHeight="iStatusBarHeight"></user>
  122. <view class="bTabBox">
  123. <view class="btabLine" @click="tabFn(1)">
  124. <image class="btabLineImg" v-if="tabIndex==1" src="/static/img/index1.png" mode=""></image>
  125. <image class="btabLineImg" v-if="tabIndex==2" src="/static/img/index2.png" mode=""></image>
  126. <view class="btabLineTxt">首页</view>
  127. </view>
  128. <view class="btabLine">
  129. <image @click="stBtn" class="btabLineImg2" src="/static/img/vin.png" mode=""></image>
  130. </view>
  131. <view class="btabLine" @click="tabFn(2)">
  132. <image class="btabLineImg" v-if="tabIndex==2" src="/static/img/user1.png" mode=""></image>
  133. <image class="btabLineImg" v-if="tabIndex==1" src="/static/img/user2.png" mode=""></image>
  134. <view class="btabLineTxt">我的</view>
  135. </view>
  136. </view>
  137. </view>
  138. </template>
  139. <script>
  140. import carModel from './carModel.vue'
  141. import user from './user.vue'
  142. export default {
  143. components: {
  144. carModel, //注册子组件
  145. user
  146. },
  147. //props:['iStatusBarHeight',],
  148. data() {
  149. return {
  150. fileURl: '',
  151. ckCarShow:false,
  152. vinNum:'',
  153. moreVinList:[],
  154. historyList:[],
  155. iStatusBarHeight:'',
  156. openId:'',
  157. aaa:'',
  158. duration:500,
  159. interval:3000,
  160. historyvin:'',
  161. tabIndex:1,
  162. byItem:'',
  163. }
  164. },
  165. onLoad() {
  166. this.iStatusBarHeight = uni.getSystemInfoSync().statusBarHeight;
  167. //console.log(this.iStatusBarHeight)
  168. var that=this;
  169. this.uniLogin()
  170. /* setTimeout(function(){
  171. that.$refs.carModelView.getdata();
  172. },500) */
  173. var bb= this.iStatusBarHeight + 44 + 'px';
  174. var cc= '520rpx'
  175. this.aaa= `calc(100vh - ${bb} - ${cc})`
  176. },
  177. onShow() {
  178. if(this.openId){
  179. this.queryHistory()
  180. }
  181. },
  182. methods: {
  183. tabFn(num){
  184. this.tabIndex=num
  185. },
  186. goCarModel(){
  187. uni.navigateTo({
  188. url:'carModel2'
  189. })
  190. },
  191. goCarModelType(type){
  192. uni.navigateTo({
  193. url:'carModel2?type='+type
  194. })
  195. },
  196. wy(){
  197. uni.chooseImage({
  198. count: 6, //默认9
  199. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  200. sourceType: ['album'], //从相册选择
  201. success: function (res) {
  202. console.log(JSON.stringify(res.tempFilePaths));
  203. }
  204. });
  205. },
  206. uniLogin(){
  207. var that=this;
  208. uni.login({
  209. provider: 'weixin',
  210. success: function (loginRes) {
  211. console.log(loginRes);
  212. that.getWxOpenID(loginRes)
  213. }
  214. });
  215. },
  216. getWxOpenID(e){
  217. var that=this;
  218. this.$http2('sys/getWxOpenID', {
  219. code:e.code,
  220. },'GET').then(res => {
  221. this.openId=res.data.openId;
  222. uni.setStorage({
  223. key: 'wxdata',
  224. data: res.data,
  225. success: function () {
  226. that.queryHistory()
  227. }
  228. });
  229. })
  230. },
  231. queryHistory(){
  232. this.$http2('queryHistory', {
  233. },'POST').then(res => {
  234. this.historyList=res.data
  235. this.historyList.forEach(item=>{
  236. if(item.vin){
  237. if(!this.historyvin){
  238. this.historyvin=item.vin
  239. this.byItem=item
  240. }
  241. }
  242. })
  243. var bb= this.iStatusBarHeight + 44 + 'px';
  244. var cc='520rpx'
  245. if(this.historyList.length==0){
  246. cc= '240rpx'
  247. }else
  248. if(this.historyList.length==1){
  249. cc= '352rpx'
  250. }else
  251. if(this.historyList.length==2){
  252. cc= '418rpx'
  253. }
  254. this.aaa= `calc(100vh - ${bb} - ${cc})`
  255. })
  256. },
  257. gocarDetail(){
  258. var e=this.byItem
  259. uni.navigateTo({
  260. url:'/pages/index/byItem?nLevelID='+e.nLevelID+'&logo='+e.logo+'&value='+e.title+'&id='+e.groupID+'&isVin='+e.ifVin+'&vin='+e.vin
  261. })
  262. },
  263. gobyItem(e){
  264. var nLevelID=e.nLevelIDs.split(',')[0]
  265. uni.navigateTo({
  266. url:'/pages/index/byItem?nLevelID='+nLevelID+'&logo='+e.carModelInfo.logo+'&value='+e.title+'&id='+e.ids+'&isVin=1&vin='+this.vinNum
  267. })
  268. },
  269. gohistory(){
  270. uni.navigateTo({
  271. url:'/pages/index/history'
  272. })
  273. },
  274. goSearch(){
  275. uni.navigateTo({
  276. url:'/pages/index/search'
  277. })
  278. },
  279. stBtn(){
  280. var that = this;
  281. console.log("识图识图识图识图")
  282. uni.authorize({
  283. scope: 'scope.camera',
  284. success() {
  285. console.log("chengg");
  286. uni.chooseImage({
  287. sourceType: ['album','camera'],
  288. count:1,
  289. success: (chooseImageRes) => {
  290. //console.log(chooseImageRes)
  291. const tempFilePaths = chooseImageRes.tempFilePaths;
  292. this.fileURl=tempFilePaths[0]
  293. uni.showLoading({ title: '加载中'});
  294. uni.uploadFile({
  295. url: that.$baseURL+'scanner?action=/vinByOpenApi/scanner', //仅为示例,非真实的接口地址
  296. filePath: tempFilePaths[0],
  297. name: 'photo',
  298. /* formData: {
  299. 'user': 'test'
  300. }, */
  301. success: (uploadFileRes) => {
  302. var data=JSON.parse(uploadFileRes.data);
  303. uni.hideLoading();
  304. if(data.code == 0){
  305. console.log(data.data)
  306. that.vinNum=data.data;
  307. that.queryCarModelGroupByVinAggregation()
  308. }else{
  309. uni.showToast({
  310. title: data.msg,
  311. duration: 3000,
  312. icon:'none',
  313. });
  314. }
  315. //console.log(JSON.parse(uploadFileRes.data).data );
  316. },fail(err) {
  317. uni.hideLoading();
  318. console.log(err)
  319. uni.showToast({
  320. title: '拉取失败',
  321. icon:'none',
  322. duration: 3000,
  323. });
  324. },
  325. complete(obj){
  326. uni.hideLoading();
  327. if(obj.statusCode!=200){
  328. uni.showToast({
  329. title: 'vin扫描失败,请重试',
  330. icon:'none',
  331. duration: 3000,
  332. });
  333. console.log("vin扫描失败,请重试")
  334. }
  335. }
  336. });
  337. },fail(err){
  338. console.log("上传失败")
  339. console.log(err)
  340. }
  341. });
  342. },fail(err) {
  343. uni.showToast({
  344. title: '授权失败',
  345. icon:'none',
  346. duration: 3000,
  347. });
  348. console.log("授权失败")
  349. uni.showModal({
  350. title: '是否重新授权识图功能',
  351. success(res) {
  352. if (res.confirm) {
  353. uni.openSetting({
  354. success() {
  355. console.log('开启权限成功');
  356. },
  357. fail() {
  358. console.log('开启权限失败');
  359. }
  360. });
  361. } else if (res.cancel) {
  362. console.log('拒绝开启开启权限');
  363. }
  364. }
  365. });
  366. }
  367. })
  368. },
  369. queryCarModelGroupByVinAggregation(){
  370. this.$http('matchingByOpen/queryCarModelGroupByVinAggregation', {
  371. vin: this.vinNum,type:2
  372. }, 'POST').then(res => {
  373. if(res.code!=1){
  374. this.moreVinList=res.data;
  375. if(this.moreVinList.length>1){
  376. this.ckCarShow=true;
  377. }else{
  378. this.gobyItem(this.moreVinList[0])
  379. }
  380. }
  381. else {
  382. uni.showToast({
  383. title: res.msg,
  384. duration: 3000,
  385. icon:'none',
  386. });
  387. }
  388. })
  389. },
  390. ckcarClose(){
  391. this.ckCarShow=false;
  392. }
  393. },
  394. onShareAppMessage(){
  395. }
  396. }
  397. </script>
  398. <style scoped>
  399. .contBox{
  400. padding: 0 24rpx;
  401. }
  402. .productBox{
  403. height: 520rpx;
  404. background: #FFFFFF;
  405. border-radius: 16rpx;
  406. padding: 30rpx;
  407. margin-top: 20rpx;
  408. }
  409. .productTitle{
  410. font-weight: 500;
  411. font-size: 28rpx;
  412. color: #1A1A1A;
  413. line-height: 40rpx;
  414. }
  415. .productLinBox{
  416. display: flex;justify-content: space-between;
  417. }
  418. .productImg{
  419. width: 90rpx;height: 90rpx;
  420. }
  421. .productLine{
  422. text-align: center;
  423. padding-top: 24rpx;
  424. }
  425. .productTxt{
  426. text-align: center;
  427. font-size: 26rpx;
  428. color: #1A1A1A;
  429. }
  430. .vincar{
  431. background: #FFFFFF;
  432. border-radius: 16rpx;
  433. padding: 24rpx 30rpx;
  434. }
  435. .vincarTab{
  436. display: flex;
  437. }
  438. .vincarTabLine{
  439. font-size: 26rpx;
  440. color: #333333;
  441. line-height: 37rpx;
  442. }
  443. .anVin{
  444. font-weight: 500;
  445. font-size: 28rpx;
  446. color: #FF4F00;
  447. margin-right: 50rpx;
  448. border-bottom: 4rpx solid #FF4F00;
  449. }
  450. .inputsBox{
  451. border-radius: 10rpx;
  452. border: 2rpx solid #FF4F00;
  453. padding: 8rpx;
  454. display: flex;justify-content: space-between;
  455. margin-top: 27rpx;
  456. }
  457. .inputsBtn{
  458. width: 108rpx;
  459. height: 58rpx;
  460. background: #FF4F00;
  461. border-radius: 6rpx;
  462. text-align: center;
  463. line-height: 58rpx;
  464. font-size: 26rpx;
  465. color: #FFFFFF;
  466. }
  467. .lanjt{
  468. width: 8rpx;height: 15rpx;
  469. margin-top: 20rpx;margin-left: 6rpx;
  470. }
  471. .historyLeft{
  472. display: flex;
  473. font-size: 24rpx;
  474. color: #999999;
  475. }
  476. .historyLeftNum{
  477. height: 50rpx;
  478. background: #FAFAFA;
  479. padding: 0 10rpx;line-height: 50rpx;
  480. }
  481. .historyLeftTxt{
  482. line-height: 50rpx;
  483. }
  484. .historyMore{
  485. line-height: 50rpx;color: #3E86F0;font-size: 24rpx;display: flex;
  486. }
  487. .historyBox{
  488. display: flex;justify-content: space-between;padding-top: 24rpx;
  489. }
  490. .swpBox{
  491. height: 400rpx;
  492. }
  493. .swiperTk{
  494. height: 400rpx;
  495. }
  496. .swiper-itemTk{
  497. padding-top: 20rpx;text-align: center;
  498. overflow: hidden;height: 360rpx;
  499. }
  500. .tkHdImg{
  501. width: 702rpx;height: 360rpx;
  502. }
  503. .aaaaa{
  504. width: 500rpx;
  505. background-color: #1A1A1A;
  506. }
  507. .ckcarJtimg{
  508. width: 26rpx;height: 26rpx;margin-top: 4rpx;
  509. }
  510. .ckcarlineBox{
  511. padding:24rpx ;
  512. border-bottom: 1px solid #EEEEEE;
  513. }
  514. .ckcarLeft{
  515. font-weight: 400;line-height: 36rpx;
  516. color: #1A1A1A;font-size: 26rpx;
  517. }
  518. .ckcarBox{
  519. width: 100vw;height: 100vh;
  520. background:rgba(0, 0, 0, 0.4) ;
  521. position: fixed;top: 0;left: 0;
  522. }
  523. .ckcar{
  524. width: 750rpx;
  525. height: 772rpx;
  526. background: #FFFFFF;
  527. border-radius: 24rpx 24rpx 0rpx 0rpx;
  528. position: absolute;
  529. left: 0;
  530. bottom: 0;
  531. }
  532. .ckcarClose{
  533. width: 30rpx;height: 30rpx;
  534. }
  535. .ckcarTitle{
  536. font-weight: 500;font-size: 28rpx;
  537. color: #1A1A1A;
  538. line-height: 40rpx;
  539. }
  540. .ckcarTop{
  541. padding: 40rpx 26rpx 20rpx 24rpx;
  542. }
  543. .content{
  544. min-height: 100vh;background: #F4F5F7;
  545. }
  546. .top{
  547. width: 100%;height: 385rpx;
  548. background: url('http://dmsphoto.66km.com.cn/thFiles/DE1573A0-1C08-4243-8313-C0BA094406D0.png') no-repeat;
  549. background-size: 100% 100%;
  550. }
  551. .topNavBox{
  552. background: #FFFFFF;
  553. width: 750rpx;
  554. position: fixed;
  555. top: 0;
  556. left: 0;
  557. z-index: 111;
  558. color: #333333;
  559. }
  560. .searchInputBox{
  561. width: 550rpx;display: flex;
  562. height: 58rpx;
  563. background: #FFFFFF;
  564. border-radius: 16rpx;
  565. }
  566. .simg{
  567. width: 34rpx;height: 34rpx;margin-top: 13rpx;margin-left:30rpx;
  568. }
  569. .stimg{
  570. width: 44rpx;height: 44rpx;
  571. }
  572. .searchBox{
  573. display: flex;padding: 20rpx 24rpx;
  574. justify-content: space-between;
  575. padding-right: 0rpx;
  576. }
  577. .st{
  578. text-align: center;padding-left: 20rpx;padding-right: 24rpx;
  579. }
  580. .ssinput{
  581. font-size: 28rpx;font-weight: 400;padding-left: 24rpx;line-height: 58rpx;height: 58rpx;
  582. width: 450rpx;
  583. }
  584. .ip{
  585. color: #999999;
  586. }
  587. .shitu{
  588. font-weight: 400;
  589. color: #FFFFFF;font-size: 22rpx;
  590. }
  591. .historybox{
  592. padding: 0 18rpx; margin-top: -88rpx;
  593. }
  594. .history{
  595. background: #FFFFFF;
  596. border-radius: 16rpx;
  597. padding: 20rpx;padding-bottom: 0;
  598. }
  599. .jiantouimg{
  600. width: 26rpx;height: 26rpx;margin-top: 7rpx;
  601. }
  602. .historyTop{
  603. display: flex;justify-content: space-between;
  604. padding-bottom: 30rpx;
  605. }
  606. .historyTitle{
  607. font-weight: 500;font-size: 28rpx;
  608. color: #1A1A1A;line-height: 40rpx;
  609. }
  610. .historylinecarImg{
  611. width: 54rpx;
  612. height: 54rpx;
  613. }
  614. .historylinecar{
  615. font-weight: 400;font-size: 26rpx;
  616. color: #1A1A1A;
  617. line-height: 46rpx;width: 576rpx;
  618. }
  619. .historyLine{
  620. display: flex;justify-content: space-between;
  621. padding: 15rpx 0;border-top: 1rpx solid #EEEEEE;
  622. }
  623. .indexnav{
  624. height: 44px;
  625. line-height: 44px;
  626. text-align: center;
  627. font-size: 36rpx;
  628. /* color: #FFFFFF; */
  629. }
  630. .historyLogoBox{
  631. display: flex;align-items: center;
  632. }
  633. .bTabBox{
  634. width: 100vw;
  635. position: fixed;
  636. left: 0;
  637. bottom: 0;
  638. background: #FFFFFF;
  639. box-shadow: 0rpx -2rpx 16rpx 0rpx rgba(153,153,153,0.2);
  640. padding-bottom: constant(safe-area-inset-bottom);
  641. padding-bottom: env(safe-area-inset-bottom);
  642. display: flex;
  643. justify-content: space-around;
  644. }
  645. .btabLineImg{
  646. width: 42rpx;height: 42rpx;
  647. }
  648. .btabLineTxt{
  649. font-weight: 400;
  650. font-size: 22rpx;
  651. color: #1A1A1A;
  652. }
  653. .btabLine{
  654. padding-top: 21rpx;
  655. }
  656. .btabLineImg2{
  657. width: 140rpx;height: 140rpx;
  658. margin-top: -70rpx;
  659. }
  660. </style>