index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  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. },
  116. wy(){
  117. uni.chooseImage({
  118. count: 6, //默认9
  119. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  120. sourceType: ['album'], //从相册选择
  121. success: function (res) {
  122. console.log(JSON.stringify(res.tempFilePaths));
  123. }
  124. });
  125. },
  126. uniLogin(){
  127. var that=this;
  128. uni.login({
  129. provider: 'weixin',
  130. success: function (loginRes) {
  131. console.log(loginRes);
  132. that.getWxOpenID(loginRes)
  133. }
  134. });
  135. },
  136. getWxOpenID(e){
  137. var that=this;
  138. this.$http2('sys/getWxOpenID', {
  139. code:e.code,
  140. },'GET').then(res => {
  141. this.openId=res.data.openId;
  142. uni.setStorage({
  143. key: 'wxdata',
  144. data: res.data,
  145. success: function () {
  146. that.queryHistory()
  147. }
  148. });
  149. })
  150. },
  151. queryHistory(){
  152. this.$http2('queryHistory', {
  153. },'POST').then(res => {
  154. this.historyList=res.data
  155. var bb= this.iStatusBarHeight + 44 + 'px';
  156. var cc='520rpx'
  157. if(this.historyList.length==0){
  158. cc= '240rpx'
  159. }else
  160. if(this.historyList.length==1){
  161. cc= '352rpx'
  162. }else
  163. if(this.historyList.length==2){
  164. cc= '418rpx'
  165. }
  166. this.aaa= `calc(100vh - ${bb} - ${cc})`
  167. })
  168. },
  169. gocarDetail(e){
  170. uni.navigateTo({
  171. url:'/pages/index/byItem?nLevelID='+e.nLevelID+'&logo='+e.logo+'&value='+e.title+'&id='+e.groupID+'&isVin='+e.ifVin+'&vin='+e.vin
  172. })
  173. },
  174. gobyItem(e){
  175. var nLevelID=e.nLevelIDs.split(',')[0]
  176. uni.navigateTo({
  177. url:'/pages/index/byItem?nLevelID='+nLevelID+'&logo='+e.carModelInfo.logo+'&value='+e.title+'&id='+e.ids+'&isVin=1&vin='+this.vinNum
  178. })
  179. },
  180. gohistory(){
  181. uni.navigateTo({
  182. url:'/pages/index/history'
  183. })
  184. },
  185. goSearch(){
  186. uni.navigateTo({
  187. url:'/pages/index/search'
  188. })
  189. },
  190. stBtn(){
  191. var that = this;
  192. console.log("识图识图识图识图")
  193. uni.authorize({
  194. scope: 'scope.camera',
  195. success() {
  196. console.log("chengg");
  197. uni.chooseImage({
  198. sourceType: ['album','camera'],
  199. count:1,
  200. success: (chooseImageRes) => {
  201. //console.log(chooseImageRes)
  202. const tempFilePaths = chooseImageRes.tempFilePaths;
  203. this.fileURl=tempFilePaths[0]
  204. uni.showLoading({ title: '加载中'});
  205. uni.uploadFile({
  206. url: that.$baseURL+'scanner?action=/vinByOpenApi/scanner', //仅为示例,非真实的接口地址
  207. filePath: tempFilePaths[0],
  208. name: 'photo',
  209. /* formData: {
  210. 'user': 'test'
  211. }, */
  212. success: (uploadFileRes) => {
  213. var data=JSON.parse(uploadFileRes.data);
  214. uni.hideLoading();
  215. if(data.code == 0){
  216. console.log(data.data)
  217. that.vinNum=data.data;
  218. that.queryCarModelGroupByVinAggregation()
  219. }else{
  220. uni.showToast({
  221. title: data.msg,
  222. duration: 3000,
  223. icon:'none',
  224. });
  225. }
  226. //console.log(JSON.parse(uploadFileRes.data).data );
  227. },fail(err) {
  228. uni.hideLoading();
  229. console.log(err)
  230. uni.showToast({
  231. title: '拉取失败',
  232. icon:'none',
  233. duration: 3000,
  234. });
  235. },
  236. complete(obj){
  237. uni.hideLoading();
  238. if(obj.statusCode!=200){
  239. uni.showToast({
  240. title: 'vin扫描失败,请重试',
  241. icon:'none',
  242. duration: 3000,
  243. });
  244. console.log("vin扫描失败,请重试")
  245. }
  246. }
  247. });
  248. },fail(err){
  249. console.log("上传失败")
  250. console.log(err)
  251. }
  252. });
  253. },fail(err) {
  254. uni.showToast({
  255. title: '授权失败',
  256. icon:'none',
  257. duration: 3000,
  258. });
  259. console.log("授权失败")
  260. uni.showModal({
  261. title: '是否重新授权识图功能',
  262. success(res) {
  263. if (res.confirm) {
  264. uni.openSetting({
  265. success() {
  266. console.log('开启权限成功');
  267. },
  268. fail() {
  269. console.log('开启权限失败');
  270. }
  271. });
  272. } else if (res.cancel) {
  273. console.log('拒绝开启开启权限');
  274. }
  275. }
  276. });
  277. }
  278. })
  279. },
  280. queryCarModelGroupByVinAggregation(){
  281. this.$http('matchingByOpen/queryCarModelGroupByVinAggregation', {
  282. vin: this.vinNum,type:2
  283. }, 'POST').then(res => {
  284. if(res.code!=1){
  285. this.moreVinList=res.data;
  286. if(this.moreVinList.length>1){
  287. this.ckCarShow=true;
  288. }else{
  289. this.gobyItem(this.moreVinList[0])
  290. }
  291. }
  292. else {
  293. uni.showToast({
  294. title: res.msg,
  295. duration: 3000,
  296. icon:'none',
  297. });
  298. }
  299. })
  300. },
  301. ckcarClose(){
  302. this.ckCarShow=false;
  303. }
  304. },
  305. onShareAppMessage(){
  306. }
  307. }
  308. </script>
  309. <style scoped>
  310. .aaaaa{
  311. width: 500rpx;
  312. background-color: #1A1A1A;
  313. }
  314. .ckcarJtimg{
  315. width: 26rpx;height: 26rpx;margin-top: 4rpx;
  316. }
  317. .ckcarlineBox{
  318. padding:24rpx ;
  319. border-bottom: 1px solid #EEEEEE;
  320. }
  321. .ckcarLeft{
  322. font-weight: 400;line-height: 36rpx;
  323. color: #1A1A1A;font-size: 26rpx;
  324. }
  325. .ckcarBox{
  326. width: 100vw;height: 100vh;
  327. background:rgba(0, 0, 0, 0.4) ;
  328. position: fixed;top: 0;left: 0;
  329. }
  330. .ckcar{
  331. width: 750rpx;
  332. height: 772rpx;
  333. background: #FFFFFF;
  334. border-radius: 24rpx 24rpx 0rpx 0rpx;
  335. position: absolute;
  336. left: 0;
  337. bottom: 0;
  338. }
  339. .ckcarClose{
  340. width: 30rpx;height: 30rpx;
  341. }
  342. .ckcarTitle{
  343. font-weight: 500;font-size: 28rpx;
  344. color: #1A1A1A;
  345. line-height: 40rpx;
  346. }
  347. .ckcarTop{
  348. padding: 40rpx 26rpx 20rpx 24rpx;
  349. }
  350. .content{
  351. min-height: 100vh;background: #F4F5F7;
  352. }
  353. .top{
  354. width: 100%;height: 480rpx;
  355. background: url('http://dmsphoto.66km.com.cn/thFiles/5F251610-E452-47FE-8EE5-3C3AC74E081F.png') no-repeat;
  356. background-size: 100% 100%;
  357. }
  358. .topNavBox{
  359. background: #D53533;
  360. width: 750rpx;
  361. position: fixed;
  362. top: 0;
  363. left: 0;
  364. z-index: 111;
  365. background: url('http://dmsphoto.66km.com.cn/thFiles/5F251610-E452-47FE-8EE5-3C3AC74E081F.png') no-repeat;
  366. background-size: 100%;
  367. }
  368. .searchInputBox{
  369. width: 702rpx;display: flex;
  370. height: 80rpx;
  371. background: #FFFFFF;
  372. border-radius: 16rpx;
  373. }
  374. .simg{
  375. width: 34rpx;height: 34rpx;margin-top: 23rpx;margin-left:30rpx;
  376. }
  377. .stimg{
  378. width: 44rpx;height: 44rpx;
  379. }
  380. .searchBox{
  381. display: flex;padding: 20rpx 24rpx;
  382. justify-content: space-between;
  383. padding-right: 0rpx;
  384. }
  385. .st{
  386. text-align: center;padding-left: 20rpx;padding-right: 24rpx;
  387. }
  388. .ssinput{
  389. font-size: 28rpx;font-weight: 400;padding-left: 24rpx;line-height: 80rpx;height: 80rpx;
  390. width: 500rpx;
  391. }
  392. .ip{
  393. color: #999999;
  394. }
  395. .shitu{
  396. font-weight: 400;
  397. color: #FFFFFF;font-size: 22rpx;
  398. }
  399. .historybox{
  400. padding: 0 18rpx; margin-top: -30px;
  401. }
  402. .history{
  403. background: #FFFFFF;
  404. border-radius: 16rpx;
  405. padding: 20rpx;padding-bottom: 0;
  406. }
  407. .jiantouimg{
  408. width: 26rpx;height: 26rpx;margin-top: 7rpx;
  409. }
  410. .historyTop{
  411. display: flex;justify-content: space-between;
  412. padding-bottom: 30rpx;
  413. }
  414. .historyTitle{
  415. font-weight: 500;font-size: 28rpx;
  416. color: #1A1A1A;line-height: 40rpx;
  417. }
  418. .historylinecarImg{
  419. width: 54rpx;
  420. height: 54rpx;
  421. }
  422. .historylinecar{
  423. font-weight: 400;font-size: 26rpx;
  424. color: #1A1A1A;
  425. line-height: 36rpx;width: 590rpx;
  426. }
  427. .historyLine{
  428. display: flex;
  429. padding: 15rpx 0;border-top: 1rpx solid #EEEEEE;
  430. }
  431. .indexnav{
  432. height: 44px;
  433. line-height: 44px;
  434. text-align: center;
  435. font-size: 36rpx;
  436. color: #FFFFFF;
  437. }
  438. .historyLogoBox{
  439. display: flex;align-items: center;
  440. padding-right:24rpx ;
  441. }
  442. .topFlineImg{
  443. width: 64rpx;height: 64rpx;
  444. }
  445. .topFlex{
  446. display: flex;
  447. justify-content: space-around;
  448. text-align: center;
  449. }
  450. .topFlineTxt{
  451. font-size: 24rpx;
  452. color: #FFFFFF;
  453. }
  454. .vinms{
  455. width: 38rpx;
  456. height: 26rpx;
  457. background: linear-gradient(224deg, #FFDA28 0%, #FFBF35 100%);
  458. border-radius: 4rpx;
  459. text-align: center;
  460. line-height: 26rpx;
  461. font-weight: 600;
  462. color: #FFFFFF;
  463. font-size: 18rpx;
  464. margin-top: 2rpx;
  465. }
  466. .historyLineVin{
  467. display: flex;
  468. }
  469. .vinNum{
  470. font-weight: 400;font-size: 22rpx;/* padding-left: 10rpx; */
  471. color: #999999;line-height: 30rpx;
  472. }
  473. </style>