index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  1. <template>
  2. <view class="content">
  3. <view class="top">
  4. <view class="topNavBox">
  5. <view class="status_bar" :style="{height: iStatusBarHeight + 'px'}"></view>
  6. <view class="indexnav">雷曼精准用油</view>
  7. </view>
  8. <view class="status_bar" :style="{height: iStatusBarHeight + 'px'}"></view>
  9. <view style="height: 43px;"></view>
  10. <view class="searchBox">
  11. <view class="searchInputBox" @click="goSearch">
  12. <image src="../../static/img/icon_search.png" mode="" class="simg"></image>
  13. <input type="text" placeholder="请输入车辆品牌、车系或VIN码" placeholder-class="ip" class="ssinput">
  14. </view>
  15. <!-- <view class="st" @click="stBtn">
  16. <image src="../../static/img/icon_shitu.png" mode="" class="stimg"></image>
  17. <view class="shitu">识图</view>
  18. </view> -->
  19. </view>
  20. <view class="topFlex">
  21. <view class="topFline" @click="stBtn">
  22. <image src="../../static/img/pai.png" mode="" class="topFlineImg"></image>
  23. <view class="topFlineTxt">拍照识别</view>
  24. </view>
  25. <view class="topFline" @click="ckcAr">
  26. <image src="../../static/img/car@2x.png" mode="" class="topFlineImg"></image>
  27. <view class="topFlineTxt">选择车型</view>
  28. </view>
  29. <view class="topFline" @click="goSearch">
  30. <image src="../../static/img/vin@2x.png" mode="" class="topFlineImg"></image>
  31. <view class="topFlineTxt">输入VIN码</view>
  32. </view>
  33. </view>
  34. </view>
  35. <!-- -->
  36. <!-- 历史查询 -->
  37. <view class="historybox ">
  38. <view class="history">
  39. <view class="historyTop" @click="gohistory">
  40. <view class="historyTitle">历史查询</view>
  41. <image src="../../static/img/icon_arrow.png" mode="" class="jiantouimg"></image>
  42. </view>
  43. <view class="historyLine" v-for="(item,index) in historyList" v-if="index<3" @click="gocarDetail(item)">
  44. <view class="historyLogoBox">
  45. <image :src="item.logo" mode="" class="historylinecarImg"></image>
  46. </view>
  47. <view>
  48. <view class="historylinecar">{{item.title}}</view>
  49. <view class="historyLineVin" v-if="item.ifVin">
  50. <!-- <view class="vinms">VIN</view> -->
  51. <view class="vinNum">{{item.vin}}</view>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. <!-- <view :style="{height: aaa}" class="aaaaa"></view> -->
  58. <!-- <view @click="wy">asdfasdfasdfas</view> -->
  59. <carModel ref="carModelView" :iStatusBarHeight="iStatusBarHeight" :svHeight="aaa"></carModel>
  60. <!-- 选择车型 -->
  61. <view class="ckcarBox" v-if="ckCarShow" >
  62. <view class="ckcar" @click.stop="">
  63. <view class="ckcarTop flex">
  64. <view class="ckcarTitle">请选择车型</view>
  65. <image src="../../static/img/icon_quxiao.png" mode="" class="ckcarClose" @click="ckcarClose"></image>
  66. </view>
  67. <view class="ckcarlineBox" v-for="(item,index) in moreVinList" @click="gobyItem(item)">
  68. <view class="ckcarline flex">
  69. <view class="ckcarLeft">{{item.title}}</view>
  70. <image src="../../static/img/icon_arrow.png" mode="" class="ckcarJtimg"></image>
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. </template>
  77. <script>
  78. import carModel from './carModel.vue'
  79. export default {
  80. components: {
  81. carModel, //注册子组件
  82. },
  83. data() {
  84. return {
  85. fileURl: '',
  86. ckCarShow:false,
  87. vinNum:'',
  88. moreVinList:[],
  89. historyList:[],
  90. iStatusBarHeight:'',
  91. openId:'',
  92. aaa:'',
  93. }
  94. },
  95. onLoad() {
  96. this.iStatusBarHeight = uni.getSystemInfoSync().statusBarHeight;
  97. var that=this;
  98. this.uniLogin()
  99. setTimeout(function(){
  100. that.$refs.carModelView.getdata();
  101. },500)
  102. var bb= this.iStatusBarHeight + 44 + 'px';
  103. var cc= '520rpx'
  104. this.aaa= `calc(100vh - ${bb} - ${cc})`
  105. },
  106. onShow() {
  107. if(this.openId){
  108. this.queryHistory()
  109. }
  110. },
  111. methods: {
  112. ckcAr(){
  113. var e={'首字母':'热'}
  114. this.$refs.carModelView.bindToView(e);
  115. uni.showToast({
  116. title: '请在下面选择车辆',
  117. duration: 3000,
  118. icon:'none',
  119. });
  120. },
  121. wy(){
  122. uni.chooseImage({
  123. count: 6, //默认9
  124. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  125. sourceType: ['album'], //从相册选择
  126. success: function (res) {
  127. console.log(JSON.stringify(res.tempFilePaths));
  128. }
  129. });
  130. },
  131. uniLogin(){
  132. var that=this;
  133. uni.login({
  134. provider: 'weixin',
  135. success: function (loginRes) {
  136. console.log(loginRes);
  137. that.getWxOpenID(loginRes)
  138. }
  139. });
  140. },
  141. getWxOpenID(e){
  142. var that=this;
  143. this.$http2('sys/getWxOpenID', {
  144. code:e.code,
  145. },'GET').then(res => {
  146. this.openId=res.data.openId;
  147. uni.setStorage({
  148. key: 'wxdata',
  149. data: res.data,
  150. success: function () {
  151. that.queryHistory()
  152. }
  153. });
  154. })
  155. },
  156. queryHistory(){
  157. this.$http2('queryHistory', {
  158. },'POST').then(res => {
  159. this.historyList=res.data
  160. var bb= this.iStatusBarHeight + 44 + 'px';
  161. var cc='520rpx'
  162. if(this.historyList.length==0){
  163. cc= '240rpx'
  164. }else
  165. if(this.historyList.length==1){
  166. cc= '352rpx'
  167. }else
  168. if(this.historyList.length==2){
  169. cc= '418rpx'
  170. }
  171. this.aaa= `calc(100vh - ${bb} - ${cc})`
  172. })
  173. },
  174. gocarDetail(e){
  175. uni.navigateTo({
  176. url:'/pages/index/byItem?nLevelID='+e.nLevelID+'&logo='+e.logo+'&value='+e.title+'&id='+e.groupID+'&isVin='+e.ifVin+'&vin='+e.vin
  177. })
  178. },
  179. gobyItem(e){
  180. var nLevelID=e.nLevelIDs.split(',')[0]
  181. uni.navigateTo({
  182. url:'/pages/index/byItem?nLevelID='+nLevelID+'&logo='+e.carModelInfo.logo+'&value='+e.title+'&id='+e.ids+'&isVin=1&vin='+this.vinNum
  183. })
  184. },
  185. gohistory(){
  186. uni.navigateTo({
  187. url:'/pages/index/history'
  188. })
  189. },
  190. goSearch(){
  191. uni.navigateTo({
  192. url:'/pages/index/search'
  193. })
  194. },
  195. stBtn(){
  196. var that = this;
  197. console.log("识图识图识图识图")
  198. uni.authorize({
  199. scope: 'scope.camera',
  200. success() {
  201. console.log("chengg");
  202. uni.chooseImage({
  203. sourceType: ['album','camera'],
  204. count:1,
  205. success: (chooseImageRes) => {
  206. //console.log(chooseImageRes)
  207. const tempFilePaths = chooseImageRes.tempFilePaths;
  208. this.fileURl=tempFilePaths[0]
  209. uni.showLoading({ title: '加载中'});
  210. uni.uploadFile({
  211. url: that.$baseURL+'scanner?action=/vinByOpenApi/scanner', //仅为示例,非真实的接口地址
  212. filePath: tempFilePaths[0],
  213. name: 'photo',
  214. /* formData: {
  215. 'user': 'test'
  216. }, */
  217. success: (uploadFileRes) => {
  218. var data=JSON.parse(uploadFileRes.data);
  219. uni.hideLoading();
  220. if(data.code == 0){
  221. console.log(data.data)
  222. that.vinNum=data.data;
  223. that.queryCarModelGroupByVinAggregation()
  224. }else{
  225. uni.showToast({
  226. title: data.msg,
  227. duration: 3000,
  228. icon:'none',
  229. });
  230. }
  231. //console.log(JSON.parse(uploadFileRes.data).data );
  232. },fail(err) {
  233. uni.hideLoading();
  234. console.log(err)
  235. uni.showToast({
  236. title: '拉取失败',
  237. icon:'none',
  238. duration: 3000,
  239. });
  240. },
  241. complete(obj){
  242. uni.hideLoading();
  243. if(obj.statusCode!=200){
  244. uni.showToast({
  245. title: 'vin扫描失败,请重试',
  246. icon:'none',
  247. duration: 3000,
  248. });
  249. console.log("vin扫描失败,请重试")
  250. }
  251. }
  252. });
  253. },fail(err){
  254. console.log("上传失败")
  255. console.log(err)
  256. }
  257. });
  258. },fail(err) {
  259. uni.showToast({
  260. title: '授权失败',
  261. icon:'none',
  262. duration: 3000,
  263. });
  264. console.log("授权失败")
  265. uni.showModal({
  266. title: '是否重新授权识图功能',
  267. success(res) {
  268. if (res.confirm) {
  269. uni.openSetting({
  270. success() {
  271. console.log('开启权限成功');
  272. },
  273. fail() {
  274. console.log('开启权限失败');
  275. }
  276. });
  277. } else if (res.cancel) {
  278. console.log('拒绝开启开启权限');
  279. }
  280. }
  281. });
  282. }
  283. })
  284. },
  285. queryCarModelGroupByVinAggregation(){
  286. this.$http('matchingByOpen/queryCarModelGroupByVinAggregation', {
  287. vin: this.vinNum,type:2
  288. }, 'POST').then(res => {
  289. if(res.code!=1){
  290. this.moreVinList=res.data;
  291. if(this.moreVinList.length>1){
  292. this.ckCarShow=true;
  293. }else{
  294. this.gobyItem(this.moreVinList[0])
  295. }
  296. }
  297. else {
  298. uni.showToast({
  299. title: res.msg,
  300. duration: 3000,
  301. icon:'none',
  302. });
  303. }
  304. })
  305. },
  306. ckcarClose(){
  307. this.ckCarShow=false;
  308. }
  309. },
  310. onShareAppMessage(){
  311. }
  312. }
  313. </script>
  314. <style scoped>
  315. .aaaaa{
  316. width: 500rpx;
  317. background-color: #1A1A1A;
  318. }
  319. .ckcarJtimg{
  320. width: 26rpx;height: 26rpx;margin-top: 4rpx;
  321. }
  322. .ckcarlineBox{
  323. padding:24rpx ;
  324. border-bottom: 1px solid #EEEEEE;
  325. }
  326. .ckcarLeft{
  327. font-weight: 400;line-height: 36rpx;
  328. color: #1A1A1A;font-size: 26rpx;
  329. }
  330. .ckcarBox{
  331. width: 100vw;height: 100vh;
  332. background:rgba(0, 0, 0, 0.4) ;
  333. position: fixed;top: 0;left: 0;
  334. }
  335. .ckcar{
  336. width: 750rpx;
  337. height: 772rpx;
  338. background: #FFFFFF;
  339. border-radius: 24rpx 24rpx 0rpx 0rpx;
  340. position: absolute;
  341. left: 0;
  342. bottom: 0;
  343. }
  344. .ckcarClose{
  345. width: 30rpx;height: 30rpx;
  346. }
  347. .ckcarTitle{
  348. font-weight: 500;font-size: 28rpx;
  349. color: #1A1A1A;
  350. line-height: 40rpx;
  351. }
  352. .ckcarTop{
  353. padding: 40rpx 26rpx 20rpx 24rpx;
  354. }
  355. .content{
  356. min-height: 100vh;background: #F4F5F7;
  357. }
  358. .top{
  359. width: 100%;height: 496rpx;
  360. background: url('http://dmsphoto.66km.com.cn/thFiles/5F251610-E452-47FE-8EE5-3C3AC74E081F.png') no-repeat;
  361. background-size: 100% 100%;
  362. }
  363. .topNavBox{
  364. background: #D53533;
  365. width: 750rpx;
  366. position: fixed;
  367. top: 0;
  368. left: 0;
  369. z-index: 111;
  370. background: url('http://dmsphoto.66km.com.cn/thFiles/5F251610-E452-47FE-8EE5-3C3AC74E081F.png') no-repeat;
  371. background-size: 100%;
  372. }
  373. .searchInputBox{
  374. width: 702rpx;display: flex;
  375. height: 80rpx;
  376. background: #FFFFFF;
  377. border-radius: 16rpx;
  378. }
  379. .simg{
  380. width: 34rpx;height: 34rpx;margin-top: 23rpx;margin-left:30rpx;
  381. }
  382. .stimg{
  383. width: 44rpx;height: 44rpx;
  384. }
  385. .searchBox{
  386. display: flex;padding: 20rpx 24rpx;
  387. justify-content: space-between;
  388. padding-right: 0rpx;
  389. }
  390. .st{
  391. text-align: center;padding-left: 20rpx;padding-right: 24rpx;
  392. }
  393. .ssinput{
  394. font-size: 28rpx;font-weight: 400;padding-left: 24rpx;line-height: 80rpx;height: 80rpx;
  395. width: 500rpx;
  396. }
  397. .ip{
  398. color: #999999;
  399. }
  400. .shitu{
  401. font-weight: 400;
  402. color: #FFFFFF;font-size: 22rpx;
  403. }
  404. .historybox{
  405. padding: 0 18rpx; margin-top: -30px;
  406. }
  407. .history{
  408. background: #FFFFFF;
  409. border-radius: 16rpx;
  410. padding: 20rpx;padding-bottom: 0;
  411. }
  412. .jiantouimg{
  413. width: 26rpx;height: 26rpx;margin-top: 7rpx;
  414. }
  415. .historyTop{
  416. display: flex;justify-content: space-between;
  417. padding-bottom: 20rpx;
  418. }
  419. .historyTitle{
  420. font-weight: 500;font-size: 28rpx;
  421. color: #1A1A1A;line-height: 40rpx;
  422. }
  423. .historylinecarImg{
  424. width: 54rpx;
  425. height: 54rpx;
  426. }
  427. .historylinecar{
  428. font-weight: 400;font-size: 26rpx;
  429. color: #1A1A1A;
  430. line-height: 36rpx;width: 590rpx;
  431. }
  432. .historyLine{
  433. display: flex;
  434. padding: 15rpx 0;border-top: 1rpx solid #EEEEEE;
  435. }
  436. .indexnav{
  437. height: 44px;
  438. line-height: 44px;
  439. text-align: center;
  440. font-size: 36rpx;
  441. color: #FFFFFF;
  442. }
  443. .historyLogoBox{
  444. display: flex;align-items: center;
  445. padding-right:24rpx ;
  446. }
  447. .topFlineImg{
  448. width: 64rpx;height: 64rpx;
  449. }
  450. .topFlex{
  451. display: flex;
  452. justify-content: space-around;
  453. text-align: center;
  454. padding: 10rpx 0;
  455. }
  456. .topFlineTxt{
  457. font-size: 24rpx;
  458. color: #FFFFFF;
  459. }
  460. .vinms{
  461. width: 38rpx;
  462. height: 26rpx;
  463. background: linear-gradient(224deg, #FFDA28 0%, #FFBF35 100%);
  464. border-radius: 4rpx;
  465. text-align: center;
  466. line-height: 26rpx;
  467. font-weight: 600;
  468. color: #FFFFFF;
  469. font-size: 18rpx;
  470. margin-top: 2rpx;
  471. }
  472. .historyLineVin{
  473. display: flex;
  474. }
  475. .vinNum{
  476. font-weight: 400;font-size: 22rpx;/* padding-left: 10rpx; */
  477. color: #999999;line-height: 30rpx;
  478. }
  479. </style>