index.vue 18 KB

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