addCarCK.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <view class="box">
  3. <view class="title">选择车型</view>
  4. <view class="cont">
  5. <view class="line" @click="goCarModel">
  6. <view class="lineTxt">手动选择车型</view>
  7. <view class="lineRgiht">
  8. <view class="lineRtxt">请选择</view>
  9. <image src="../../static/img2/jt1.png" mode="" class="jtIcon"></image>
  10. </view>
  11. </view>
  12. <view class="line" @click="scVinIMg">
  13. <view class="lineTxt">扫描VIN码</view>
  14. <view class="lineRgiht">
  15. <image src="../../static/img2/sm.png" mode="" class="smIcon"></image>
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. components: {
  24. },
  25. data() {
  26. return {
  27. }
  28. },
  29. onLoad(opt) {
  30. },
  31. onShow() {
  32. },
  33. methods: {
  34. goCarModel(){
  35. uni.redirectTo({
  36. url:'../user/addCar/carModel'
  37. })
  38. },
  39. scVinIMg(){
  40. /* this.vin="LSVAF25E6FN098639"
  41. this.queryCarModelGroupByVin()
  42. return false */
  43. var that = this;
  44. uni.chooseImage({
  45. sourceType: ['album','camera'],
  46. count:1,
  47. success: (chooseImageRes) => {
  48. const tempFilePaths = chooseImageRes.tempFilePaths;
  49. that.file=tempFilePaths[0]
  50. that.vinScanner()
  51. /* uni.uploadFile({
  52. url: that.$request.baseUrl+'accompany/SuperCheckSheet/uploadFile', //仅为示例,非真实的接口地址
  53. filePath: tempFilePaths[0],
  54. name: 'file',
  55. formData: {
  56. 'user': 'test'
  57. },
  58. success: (uploadFileRes) => {
  59. console.log(JSON.parse(uploadFileRes.data).data );
  60. //that.imgArr=that.imgArr.concat(JSON.parse(uploadFileRes.data).data) ;
  61. that.vinImg=JSON.parse(uploadFileRes.data).data[0];
  62. }
  63. }); */
  64. // that.$http('accompany/SuperCheckSheet/uploadFile', tempFilePaths[0], 'POST').then(res => {
  65. //})
  66. }
  67. });
  68. },
  69. vinScanner(){
  70. uni.showLoading({
  71. title:'正在识别中'
  72. });
  73. /*
  74. this.$http('miniAppMyBMemberCar/vinScanner', {
  75. photo:this.file,
  76. },'POST').then(res => {
  77. uni.hideLoading();
  78. //this.carGroupList=res.data.carGroupList
  79. }) */
  80. var that=this;
  81. //console.log(that.file)
  82. uni.uploadFile({
  83. url: that.$request.baseUrl+'miniAppMyBMemberCar/vinScanner',
  84. filePath: that.file,
  85. name: 'photo',
  86. formData: {
  87. 'user': 'test'
  88. },
  89. success: (uploadFileRes) => {
  90. uni.hideLoading();
  91. console.log(JSON.parse(uploadFileRes.data) );
  92. if(JSON.parse(uploadFileRes.data).code==0){
  93. that.vin = JSON.parse(uploadFileRes.data).data;
  94. that.queryCarModelGroupByVin()
  95. }else{
  96. uni.showToast({
  97. title: JSON.parse(uploadFileRes.data).msg,
  98. icon: 'none',
  99. duration: 2000,
  100. });
  101. }
  102. }
  103. });
  104. },
  105. queryCarModelGroupByVin(){
  106. console.log(this.vin)
  107. uni.showLoading({ });
  108. this.$http('miniAppMyBMemberCar/queryCarModelGroupByVin', {
  109. vin:this.vin,
  110. },'GET').then(res => {
  111. uni.hideLoading();
  112. if(res.code!=0){
  113. uni.showToast({
  114. title: res.msg,
  115. icon: 'none',
  116. duration: 2000,
  117. });
  118. }else{
  119. /* this.vinboxtwoShow=true
  120. this.vinSbList=res.data;
  121. this.vincarModelInfo=this.vinSbList[0] */
  122. var vinSbList=res.data
  123. /* uni.redirectTo({
  124. url:'../user/addCar/carModel'
  125. }) */
  126. var vin=this.vin
  127. uni.setStorage({
  128. key: 'carModelInfo',
  129. data: vinSbList[0],
  130. success: function () {
  131. uni.redirectTo({
  132. url:'../user/addCar/addCar?vin='+vin
  133. })
  134. }
  135. });
  136. }
  137. })
  138. },
  139. },
  140. }
  141. </script>
  142. <style scoped>
  143. .box {
  144. min-height: 100vh;
  145. background: #F4F5F7;
  146. }
  147. .title{
  148. font-weight: 400;
  149. font-size: 22rpx;
  150. color: #000000;
  151. padding-top: 40rpx;
  152. padding-left: 24rpx;
  153. padding-bottom: 28rpx;
  154. }
  155. .cont{
  156. padding: 0 24rpx;
  157. }
  158. .line{
  159. background: #FFFFFF;
  160. border-radius: 10rpx;
  161. padding: 30rpx;
  162. line-height: 40rpx;
  163. margin-bottom: 20rpx;
  164. display: flex;justify-content: space-between;
  165. }
  166. .lineTxt{
  167. font-weight: 500;
  168. font-size: 28rpx;
  169. color: #000000;
  170. line-height: 40rpx;
  171. }
  172. .lineRtxt{
  173. font-weight: 400;line-height: 40rpx;
  174. font-size: 22rpx;
  175. color: #646464;
  176. padding-right: 10rpx;
  177. }
  178. .jtIcon{
  179. width: 10rpx;height: 20rpx;margin-top: 10rpx;
  180. }
  181. .smIcon{
  182. width: 36rpx;height: 36rpx;margin-top: 2rpx;
  183. }
  184. .lineRgiht{
  185. display: flex;
  186. }
  187. </style>