index.vue 11 KB

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